hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodCounters.java
author cjplummer
Wed, 30 Mar 2016 09:52:02 -0700
changeset 37272 c427db4ea8c4
parent 35217 ce4b5303a813
child 40333 0dc2e9be4855
permissions -rw-r--r--
8148639: Some MethodCounter fields can be excluded when not including C2 Summary: Removed _interpreter_invocation_count and _interpreter_throwout_count fields for C1 Reviewed-by: kvn, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
     1
/*
37272
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35217
diff changeset
     2
 * Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved.
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
     4
 *
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
     7
 * published by the Free Software Foundation.
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
     8
 *
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    13
 * accompanied this code).
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    14
 *
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    18
 *
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    21
 * questions.
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    22
 *
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    23
 */
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    24
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    25
package sun.jvm.hotspot.oops;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    26
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    27
import java.io.*;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    28
import java.util.*;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    29
import sun.jvm.hotspot.debugger.*;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    30
import sun.jvm.hotspot.runtime.*;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    31
import sun.jvm.hotspot.types.*;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    32
import sun.jvm.hotspot.utilities.*;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    33
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    34
public class MethodCounters extends Metadata {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    35
  public MethodCounters(Address addr) {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    36
    super(addr);
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    37
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    38
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    39
  static {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    40
    VM.registerVMInitializedObserver(new Observer() {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    41
        public void update(Observable o, Object data) {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    42
          initialize(VM.getVM().getTypeDataBase());
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    43
        }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    44
      });
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    45
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    46
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    47
  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    48
    Type type      = db.lookupType("MethodCounters");
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    49
37272
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35217
diff changeset
    50
    if (VM.getVM().isServerCompiler()) {
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35217
diff changeset
    51
      interpreterInvocationCountField = new CIntField(type.getCIntegerField("_interpreter_invocation_count"), 0);
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35217
diff changeset
    52
      interpreterThrowoutCountField = new CIntField(type.getCIntegerField("_interpreter_throwout_count"), 0);
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35217
diff changeset
    53
    }
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    54
    if (!VM.getVM().isCore()) {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    55
      invocationCounter        = new CIntField(type.getCIntegerField("_invocation_counter"), 0);
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    56
      backedgeCounter          = new CIntField(type.getCIntegerField("_backedge_counter"), 0);
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    57
    }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    58
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    59
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    60
  private static CIntField interpreterInvocationCountField;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    61
  private static CIntField interpreterThrowoutCountField;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    62
  private static CIntField invocationCounter;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    63
  private static CIntField backedgeCounter;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    64
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    65
  public int interpreterInvocationCount() {
37272
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35217
diff changeset
    66
      if (interpreterInvocationCountField != null) {
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35217
diff changeset
    67
        return (int) interpreterInvocationCountField.getValue(this);
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35217
diff changeset
    68
      } else {
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35217
diff changeset
    69
        return 0;
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35217
diff changeset
    70
      }
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    71
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    72
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    73
  public int interpreterThrowoutCount() {
37272
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35217
diff changeset
    74
      if (interpreterThrowoutCountField != null) {
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35217
diff changeset
    75
        return (int) interpreterThrowoutCountField.getValue(this);
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35217
diff changeset
    76
      } else {
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35217
diff changeset
    77
        return 0;
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35217
diff changeset
    78
      }
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    79
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    80
  public long getInvocationCounter() {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    81
    if (Assert.ASSERTS_ENABLED) {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    82
      Assert.that(!VM.getVM().isCore(), "must not be used in core build");
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    83
    }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    84
    return invocationCounter.getValue(this);
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    85
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    86
  public long getBackedgeCounter() {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    87
    if (Assert.ASSERTS_ENABLED) {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    88
      Assert.that(!VM.getVM().isCore(), "must not be used in core build");
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    89
    }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    90
    return backedgeCounter.getValue(this);
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    91
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    92
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    93
  public void printValueOn(PrintStream tty) {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    94
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    95
}
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    96