1 /*
2 * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_OOPS_METHODCOUNTERS_HPP
26 #define SHARE_VM_OOPS_METHODCOUNTERS_HPP
27
28 #include "oops/metadata.hpp"
29 #include "compiler/compilerOracle.hpp"
30 #include "interpreter/invocationCounter.hpp"
31 #include "runtime/arguments.hpp"
32 #include "utilities/align.hpp"
33
34 class MethodCounters : public Metadata {
35 friend class VMStructs;
36 friend class JVMCIVMStructs;
37 private:
38 // If you add a new field that points to any metaspace object, you
39 // must add this field to MethodCounters::metaspace_pointers_do().
40 #if INCLUDE_AOT
41 Method* _method; // Back link to Method
42 #endif
43 #if COMPILER2_OR_JVMCI
44 int _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered)
45 u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
46 #endif
47 #if INCLUDE_JVMTI
48 u2 _number_of_breakpoints; // fullspeed debugging support
79 , _rate(0),
80 _prev_time(0),
81 _highest_comp_level(0),
82 _highest_osr_comp_level(0)
83 #endif
84 {
85 set_interpreter_invocation_count(0);
86 set_interpreter_throwout_count(0);
87 JVMTI_ONLY(clear_number_of_breakpoints());
88 invocation_counter()->init();
89 backedge_counter()->init();
90
91 if (StressCodeAging) {
92 set_nmethod_age(HotMethodDetectionLimit);
93 }
94
95 // Set per-method thresholds.
96 double scale = 1.0;
97 CompilerOracle::has_option_value(mh, "CompileThresholdScaling", scale);
98
99 int compile_threshold = Arguments::scaled_compile_threshold(CompileThreshold, scale);
100 _interpreter_invocation_limit = compile_threshold << InvocationCounter::count_shift;
101 if (ProfileInterpreter) {
102 // If interpreter profiling is enabled, the backward branch limit
103 // is compared against the method data counter rather than an invocation
104 // counter, therefore no shifting of bits is required.
105 _interpreter_backward_branch_limit = (compile_threshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100;
106 } else {
107 _interpreter_backward_branch_limit = ((compile_threshold * OnStackReplacePercentage) / 100) << InvocationCounter::count_shift;
108 }
109 _interpreter_profile_limit = ((compile_threshold * InterpreterProfilePercentage) / 100) << InvocationCounter::count_shift;
110 _invoke_mask = right_n_bits(Arguments::scaled_freq_log(Tier0InvokeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
111 _backedge_mask = right_n_bits(Arguments::scaled_freq_log(Tier0BackedgeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
112 }
113
114 public:
115 virtual bool is_methodCounters() const volatile { return true; }
116
117 static MethodCounters* allocate(const methodHandle& mh, TRAPS);
118
119 void deallocate_contents(ClassLoaderData* loader_data) {}
120
121 AOT_ONLY(Method* method() const { return _method; })
122
123 static int method_counters_size() {
124 return align_up((int)sizeof(MethodCounters), wordSize) / wordSize;
125 }
126 virtual int size() const {
127 return method_counters_size();
128 }
129 void metaspace_pointers_do(MetaspaceClosure* it);
130 MetaspaceObj::Type type() const { return MethodCountersType; }
131 void clear_counters();
|
1 /*
2 * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_OOPS_METHODCOUNTERS_HPP
26 #define SHARE_VM_OOPS_METHODCOUNTERS_HPP
27
28 #include "oops/metadata.hpp"
29 #include "compiler/compilerConfig.hpp"
30 #include "compiler/compilerOracle.hpp"
31 #include "interpreter/invocationCounter.hpp"
32 #include "runtime/arguments.hpp"
33 #include "utilities/align.hpp"
34
35 class MethodCounters : public Metadata {
36 friend class VMStructs;
37 friend class JVMCIVMStructs;
38 private:
39 // If you add a new field that points to any metaspace object, you
40 // must add this field to MethodCounters::metaspace_pointers_do().
41 #if INCLUDE_AOT
42 Method* _method; // Back link to Method
43 #endif
44 #if COMPILER2_OR_JVMCI
45 int _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered)
46 u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
47 #endif
48 #if INCLUDE_JVMTI
49 u2 _number_of_breakpoints; // fullspeed debugging support
80 , _rate(0),
81 _prev_time(0),
82 _highest_comp_level(0),
83 _highest_osr_comp_level(0)
84 #endif
85 {
86 set_interpreter_invocation_count(0);
87 set_interpreter_throwout_count(0);
88 JVMTI_ONLY(clear_number_of_breakpoints());
89 invocation_counter()->init();
90 backedge_counter()->init();
91
92 if (StressCodeAging) {
93 set_nmethod_age(HotMethodDetectionLimit);
94 }
95
96 // Set per-method thresholds.
97 double scale = 1.0;
98 CompilerOracle::has_option_value(mh, "CompileThresholdScaling", scale);
99
100 int compile_threshold = CompilerConfig::scaled_compile_threshold(CompileThreshold, scale);
101 _interpreter_invocation_limit = compile_threshold << InvocationCounter::count_shift;
102 if (ProfileInterpreter) {
103 // If interpreter profiling is enabled, the backward branch limit
104 // is compared against the method data counter rather than an invocation
105 // counter, therefore no shifting of bits is required.
106 _interpreter_backward_branch_limit = (compile_threshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100;
107 } else {
108 _interpreter_backward_branch_limit = ((compile_threshold * OnStackReplacePercentage) / 100) << InvocationCounter::count_shift;
109 }
110 _interpreter_profile_limit = ((compile_threshold * InterpreterProfilePercentage) / 100) << InvocationCounter::count_shift;
111 _invoke_mask = right_n_bits(CompilerConfig::scaled_freq_log(Tier0InvokeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
112 _backedge_mask = right_n_bits(CompilerConfig::scaled_freq_log(Tier0BackedgeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
113 }
114
115 public:
116 virtual bool is_methodCounters() const volatile { return true; }
117
118 static MethodCounters* allocate(const methodHandle& mh, TRAPS);
119
120 void deallocate_contents(ClassLoaderData* loader_data) {}
121
122 AOT_ONLY(Method* method() const { return _method; })
123
124 static int method_counters_size() {
125 return align_up((int)sizeof(MethodCounters), wordSize) / wordSize;
126 }
127 virtual int size() const {
128 return method_counters_size();
129 }
130 void metaspace_pointers_do(MetaspaceClosure* it);
131 MetaspaceObj::Type type() const { return MethodCountersType; }
132 void clear_counters();
|