src/hotspot/share/oops/methodCounters.hpp
author ccheung
Wed, 02 Oct 2019 16:55:08 -0700
changeset 58447 319173c62caa
parent 53244 9807daeb47c4
permissions -rw-r--r--
8231606: _method_ordering is not set during CDS dynamic dump time Summary: Add the missing DynamicDumpSharedSpaces check in sort_methods(); replace the (DumpSharedSpaces || DynamicDumpSharedSpaces) with the Arguments::is_dumping_archive() function call. Reviewed-by: iklam, coleenp, jiangli
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
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53002
diff changeset
     2
 * Copyright (c) 2013, 2019, 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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53002
diff changeset
    25
#ifndef SHARE_OOPS_METHODCOUNTERS_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53002
diff changeset
    26
#define SHARE_OOPS_METHODCOUNTERS_HPP
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    27
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    28
#include "oops/metadata.hpp"
50589
e5d741569070 8184349: There should be some verification that EnableJVMCI is disabled if a GC not supporting JVMCI is selected
kvn
parents: 47799
diff changeset
    29
#include "compiler/compilerDefinitions.hpp"
28650
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    30
#include "compiler/compilerOracle.hpp"
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    31
#include "interpreter/invocationCounter.hpp"
28650
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    32
#include "runtime/arguments.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46619
diff changeset
    33
#include "utilities/align.hpp"
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    34
44630
54aa492f2b19 8176887: AOT: SIGSEGV in AOTCodeHeap::next when using specific configuration
iveresov
parents: 44524
diff changeset
    35
class MethodCounters : public Metadata {
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    36
 friend class VMStructs;
35123
b0b89d83bcf5 8134994: use separate VMStructs databases for SA and JVMCI
twisti
parents: 33163
diff changeset
    37
 friend class JVMCIVMStructs;
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    38
 private:
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46727
diff changeset
    39
  // If you add a new field that points to any metaspace object, you
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46727
diff changeset
    40
  // must add this field to MethodCounters::metaspace_pointers_do().
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 40333
diff changeset
    41
#if INCLUDE_AOT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 40333
diff changeset
    42
  Method*           _method;                     // Back link to Method
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 40333
diff changeset
    43
#endif
47799
1772ebf07d1f 8152470: Add COMPILER2_OR_JVMCI definition
jcm
parents: 47216
diff changeset
    44
#if COMPILER2_OR_JVMCI
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    45
  int               _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered)
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    46
  u2                _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
37272
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
    47
#endif
38059
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 37272
diff changeset
    48
#if INCLUDE_JVMTI
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    49
  u2                _number_of_breakpoints;      // fullspeed debugging support
38059
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 37272
diff changeset
    50
#endif
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    51
  InvocationCounter _invocation_counter;         // Incremented before each activation of the method - used to trigger frequency-based optimizations
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    52
  InvocationCounter _backedge_counter;           // Incremented before each backedge taken - used to trigger frequencey-based optimizations
24442
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
    53
  // NMethod age is a counter for warm methods detection in the code cache sweeper.
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
    54
  // The counter is reset by the sweeper and is decremented by some of the compiled
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
    55
  // code. The counter values are interpreted as follows:
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
    56
  // 1. (HotMethodDetection..INT_MAX] - initial value, no counters inserted
33163
9e128b399e48 8078554: Compiler: implement ranges (optionally constraints) for those flags that have them missing
zmajo
parents: 28650
diff changeset
    57
  // 2. [1..HotMethodDetectionLimit)  - the method is warm, the counter is used
24442
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
    58
  //                                    to figure out which methods can be flushed.
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
    59
  // 3. (INT_MIN..0]                  - method is hot and will deopt and get
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
    60
  //                                    recompiled without the counters
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
    61
  int               _nmethod_age;
28650
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    62
  int               _interpreter_invocation_limit;        // per-method InterpreterInvocationLimit
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    63
  int               _interpreter_backward_branch_limit;   // per-method InterpreterBackwardBranchLimit
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    64
  int               _interpreter_profile_limit;           // per-method InterpreterProfileLimit
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    65
  int               _invoke_mask;                         // per-method Tier0InvokeNotifyFreqLog
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    66
  int               _backedge_mask;                       // per-method Tier0BackedgeNotifyFreqLog
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    67
#ifdef TIERED
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    68
  float             _rate;                        // Events (invocation and backedge counter increments) per millisecond
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    69
  jlong             _prev_time;                   // Previous time the rate was acquired
26586
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    70
  u1                _highest_comp_level;          // Highest compile level this method has ever seen.
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    71
  u1                _highest_osr_comp_level;      // Same for OSR level
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    72
#endif
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    73
46727
6e4a84748e2c 8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents: 46625
diff changeset
    74
  MethodCounters(const methodHandle& mh) :
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 40333
diff changeset
    75
#if INCLUDE_AOT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 40333
diff changeset
    76
                                    _method(mh()),
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 40333
diff changeset
    77
#endif
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 40333
diff changeset
    78
                                    _nmethod_age(INT_MAX)
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    79
#ifdef TIERED
28650
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    80
                                 , _rate(0),
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    81
                                   _prev_time(0),
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    82
                                   _highest_comp_level(0),
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    83
                                   _highest_osr_comp_level(0)
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    84
#endif
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    85
  {
37272
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
    86
    set_interpreter_invocation_count(0);
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
    87
    set_interpreter_throwout_count(0);
38059
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 37272
diff changeset
    88
    JVMTI_ONLY(clear_number_of_breakpoints());
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    89
    invocation_counter()->init();
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    90
    backedge_counter()->init();
24442
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
    91
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
    92
    if (StressCodeAging) {
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
    93
      set_nmethod_age(HotMethodDetectionLimit);
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
    94
    }
28650
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    95
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    96
    // Set per-method thresholds.
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    97
    double scale = 1.0;
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    98
    CompilerOracle::has_option_value(mh, "CompileThresholdScaling", scale);
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    99
50589
e5d741569070 8184349: There should be some verification that EnableJVMCI is disabled if a GC not supporting JVMCI is selected
kvn
parents: 47799
diff changeset
   100
    int compile_threshold = CompilerConfig::scaled_compile_threshold(CompileThreshold, scale);
28650
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   101
    _interpreter_invocation_limit = compile_threshold << InvocationCounter::count_shift;
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   102
    if (ProfileInterpreter) {
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   103
      // If interpreter profiling is enabled, the backward branch limit
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   104
      // is compared against the method data counter rather than an invocation
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   105
      // counter, therefore no shifting of bits is required.
53002
9d60798b21af 8211034: OnStackReplacePercentage option checking has bugs
jcm
parents: 50589
diff changeset
   106
      _interpreter_backward_branch_limit = (int)((int64_t)compile_threshold * (OnStackReplacePercentage - InterpreterProfilePercentage) / 100);
28650
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   107
    } else {
53002
9d60798b21af 8211034: OnStackReplacePercentage option checking has bugs
jcm
parents: 50589
diff changeset
   108
      _interpreter_backward_branch_limit = (int)(((int64_t)compile_threshold * OnStackReplacePercentage / 100) << InvocationCounter::count_shift);
28650
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   109
    }
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   110
    _interpreter_profile_limit = ((compile_threshold * InterpreterProfilePercentage) / 100) << InvocationCounter::count_shift;
50589
e5d741569070 8184349: There should be some verification that EnableJVMCI is disabled if a GC not supporting JVMCI is selected
kvn
parents: 47799
diff changeset
   111
    _invoke_mask = right_n_bits(CompilerConfig::scaled_freq_log(Tier0InvokeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
e5d741569070 8184349: There should be some verification that EnableJVMCI is disabled if a GC not supporting JVMCI is selected
kvn
parents: 47799
diff changeset
   112
    _backedge_mask = right_n_bits(CompilerConfig::scaled_freq_log(Tier0BackedgeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   113
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   114
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   115
 public:
44630
54aa492f2b19 8176887: AOT: SIGSEGV in AOTCodeHeap::next when using specific configuration
iveresov
parents: 44524
diff changeset
   116
  virtual bool is_methodCounters() const volatile { return true; }
54aa492f2b19 8176887: AOT: SIGSEGV in AOTCodeHeap::next when using specific configuration
iveresov
parents: 44524
diff changeset
   117
46727
6e4a84748e2c 8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents: 46625
diff changeset
   118
  static MethodCounters* allocate(const methodHandle& mh, TRAPS);
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   119
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   120
  void deallocate_contents(ClassLoaderData* loader_data) {}
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   121
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 40333
diff changeset
   122
  AOT_ONLY(Method* method() const { return _method; })
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 40333
diff changeset
   123
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46727
diff changeset
   124
  static int method_counters_size() {
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46618
diff changeset
   125
    return align_up((int)sizeof(MethodCounters), wordSize) / wordSize;
44524
b0d3e8ba6f27 8170812: Metaspace corruption caused by incorrect memory size for MethodCounters
aph
parents: 42650
diff changeset
   126
  }
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46727
diff changeset
   127
  virtual int size() const {
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46727
diff changeset
   128
    return method_counters_size();
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46727
diff changeset
   129
  }
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46727
diff changeset
   130
  void metaspace_pointers_do(MetaspaceClosure* it);
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46727
diff changeset
   131
  MetaspaceObj::Type type() const { return MethodCountersType; }
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   132
  void clear_counters();
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   133
47799
1772ebf07d1f 8152470: Add COMPILER2_OR_JVMCI definition
jcm
parents: 47216
diff changeset
   134
#if COMPILER2_OR_JVMCI
37272
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   135
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   136
  int interpreter_invocation_count() {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   137
    return _interpreter_invocation_count;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   138
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   139
  void set_interpreter_invocation_count(int count) {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   140
    _interpreter_invocation_count = count;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   141
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   142
  int increment_interpreter_invocation_count() {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   143
    return ++_interpreter_invocation_count;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   144
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   145
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   146
  void interpreter_throwout_increment() {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   147
    if (_interpreter_throwout_count < 65534) {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   148
      _interpreter_throwout_count++;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   149
    }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   150
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   151
  int  interpreter_throwout_count() const {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   152
    return _interpreter_throwout_count;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   153
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   154
  void set_interpreter_throwout_count(int count) {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   155
    _interpreter_throwout_count = count;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   156
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   157
47799
1772ebf07d1f 8152470: Add COMPILER2_OR_JVMCI definition
jcm
parents: 47216
diff changeset
   158
#else // COMPILER2_OR_JVMCI
37272
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   159
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   160
  int interpreter_invocation_count() {
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   161
    return 0;
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   162
  }
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   163
  void set_interpreter_invocation_count(int count) {
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   164
    assert(count == 0, "count must be 0");
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   165
  }
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   166
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   167
  int  interpreter_throwout_count() const {
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   168
    return 0;
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   169
  }
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   170
  void set_interpreter_throwout_count(int count) {
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   171
    assert(count == 0, "count must be 0");
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   172
  }
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   173
47799
1772ebf07d1f 8152470: Add COMPILER2_OR_JVMCI definition
jcm
parents: 47216
diff changeset
   174
#endif // COMPILER2_OR_JVMCI
37272
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   175
38059
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 37272
diff changeset
   176
#if INCLUDE_JVMTI
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   177
  u2   number_of_breakpoints() const   { return _number_of_breakpoints; }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   178
  void incr_number_of_breakpoints()    { ++_number_of_breakpoints; }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   179
  void decr_number_of_breakpoints()    { --_number_of_breakpoints; }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   180
  void clear_number_of_breakpoints()   { _number_of_breakpoints = 0; }
38059
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 37272
diff changeset
   181
#endif
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   182
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   183
#ifdef TIERED
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   184
  jlong prev_time() const                        { return _prev_time; }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   185
  void set_prev_time(jlong time)                 { _prev_time = time; }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   186
  float rate() const                             { return _rate; }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   187
  void set_rate(float rate)                      { _rate = rate; }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   188
#endif
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   189
26586
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
   190
  int highest_comp_level() const;
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
   191
  void set_highest_comp_level(int level);
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
   192
  int highest_osr_comp_level() const;
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
   193
  void set_highest_osr_comp_level(int level);
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
   194
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   195
  // invocation counter
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   196
  InvocationCounter* invocation_counter() { return &_invocation_counter; }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   197
  InvocationCounter* backedge_counter()   { return &_backedge_counter; }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   198
24442
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   199
  int nmethod_age() {
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   200
    return _nmethod_age;
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   201
  }
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   202
  void set_nmethod_age(int age) {
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   203
    _nmethod_age = age;
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   204
  }
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   205
  void reset_nmethod_age() {
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   206
    set_nmethod_age(HotMethodDetectionLimit);
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   207
  }
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   208
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   209
  static bool is_nmethod_hot(int age)       { return age <= 0; }
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   210
  static bool is_nmethod_warm(int age)      { return age < HotMethodDetectionLimit; }
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   211
  static bool is_nmethod_age_unset(int age) { return age > HotMethodDetectionLimit; }
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   212
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   213
  static ByteSize nmethod_age_offset() {
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   214
    return byte_offset_of(MethodCounters, _nmethod_age);
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   215
  }
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17000
diff changeset
   216
47799
1772ebf07d1f 8152470: Add COMPILER2_OR_JVMCI definition
jcm
parents: 47216
diff changeset
   217
#if COMPILER2_OR_JVMCI
37272
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   218
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   219
  static ByteSize interpreter_invocation_counter_offset() {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   220
    return byte_offset_of(MethodCounters, _interpreter_invocation_count);
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   221
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   222
37272
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   223
  static int interpreter_invocation_counter_offset_in_bytes() {
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   224
    return offset_of(MethodCounters, _interpreter_invocation_count);
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   225
  }
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   226
47799
1772ebf07d1f 8152470: Add COMPILER2_OR_JVMCI definition
jcm
parents: 47216
diff changeset
   227
#else // COMPILER2_OR_JVMCI
37272
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   228
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   229
  static ByteSize interpreter_invocation_counter_offset() {
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   230
    ShouldNotReachHere();
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   231
    return in_ByteSize(0);
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   232
  }
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   233
47799
1772ebf07d1f 8152470: Add COMPILER2_OR_JVMCI definition
jcm
parents: 47216
diff changeset
   234
#endif // COMPILER2_OR_JVMCI
37272
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 35123
diff changeset
   235
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   236
  static ByteSize invocation_counter_offset()    {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   237
    return byte_offset_of(MethodCounters, _invocation_counter);
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   238
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   239
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   240
  static ByteSize backedge_counter_offset()      {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   241
    return byte_offset_of(MethodCounters, _backedge_counter);
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   242
  }
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   243
28650
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   244
  static ByteSize interpreter_invocation_limit_offset() {
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   245
    return byte_offset_of(MethodCounters, _interpreter_invocation_limit);
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   246
  }
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   247
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   248
  static ByteSize interpreter_backward_branch_limit_offset() {
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   249
    return byte_offset_of(MethodCounters, _interpreter_backward_branch_limit);
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   250
  }
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   251
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   252
  static ByteSize interpreter_profile_limit_offset() {
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   253
    return byte_offset_of(MethodCounters, _interpreter_profile_limit);
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   254
  }
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   255
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   256
  static ByteSize invoke_mask_offset() {
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   257
    return byte_offset_of(MethodCounters, _invoke_mask);
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   258
  }
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   259
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   260
  static ByteSize backedge_mask_offset() {
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   261
    return byte_offset_of(MethodCounters, _backedge_mask);
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
   262
  }
44630
54aa492f2b19 8176887: AOT: SIGSEGV in AOTCodeHeap::next when using specific configuration
iveresov
parents: 44524
diff changeset
   263
54aa492f2b19 8176887: AOT: SIGSEGV in AOTCodeHeap::next when using specific configuration
iveresov
parents: 44524
diff changeset
   264
  virtual const char* internal_name() const { return "{method counters}"; }
54aa492f2b19 8176887: AOT: SIGSEGV in AOTCodeHeap::next when using specific configuration
iveresov
parents: 44524
diff changeset
   265
  virtual void print_value_on(outputStream* st) const;
54aa492f2b19 8176887: AOT: SIGSEGV in AOTCodeHeap::next when using specific configuration
iveresov
parents: 44524
diff changeset
   266
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
   267
};
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53002
diff changeset
   268
#endif // SHARE_OOPS_METHODCOUNTERS_HPP