comparison src/share/vm/oops/methodCounters.hpp @ 10408:836a62f43af9

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Wed, 19 Jun 2013 10:45:56 +0200
parents aeaca88565e6
children 88672775a26c
comparison
equal deleted inserted replaced
10086:e0fb8a213650 10408:836a62f43af9
1 /*
2 * Copyright (c) 2013, 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 "interpreter/invocationCounter.hpp"
30
31 class MethodCounters: public MetaspaceObj {
32 friend class VMStructs;
33 private:
34 int _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered)
35 u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
36 u2 _number_of_breakpoints; // fullspeed debugging support
37 InvocationCounter _invocation_counter; // Incremented before each activation of the method - used to trigger frequency-based optimizations
38 InvocationCounter _backedge_counter; // Incremented before each backedge taken - used to trigger frequencey-based optimizations
39
40 #ifdef GRAAL
41 jlong _graal_invocation_time;
42 int _graal_priority;
43 #endif
44 #ifdef TIERED
45 float _rate; // Events (invocation and backedge counter increments) per millisecond
46 jlong _prev_time; // Previous time the rate was acquired
47 #endif
48
49 MethodCounters() : _interpreter_invocation_count(0),
50 _interpreter_throwout_count(0),
51 _number_of_breakpoints(0)
52 #ifdef TIERED
53 , _rate(0),
54 _prev_time(0)
55 #endif
56 {
57 invocation_counter()->init();
58 backedge_counter()->init();
59 }
60
61 public:
62 static MethodCounters* allocate(ClassLoaderData* loader_data, TRAPS);
63
64 void deallocate_contents(ClassLoaderData* loader_data) {}
65 DEBUG_ONLY(bool on_stack() { return false; }) // for template
66
67 static int size() { return sizeof(MethodCounters) / wordSize; }
68
69 bool is_klass() const { return false; }
70
71 void clear_counters();
72
73 int interpreter_invocation_count() {
74 return _interpreter_invocation_count;
75 }
76 void set_interpreter_invocation_count(int count) {
77 _interpreter_invocation_count = count;
78 }
79 int increment_interpreter_invocation_count() {
80 return ++_interpreter_invocation_count;
81 }
82
83 void interpreter_throwout_increment() {
84 if (_interpreter_throwout_count < 65534) {
85 _interpreter_throwout_count++;
86 }
87 }
88 int interpreter_throwout_count() const {
89 return _interpreter_throwout_count;
90 }
91 void set_interpreter_throwout_count(int count) {
92 _interpreter_throwout_count = count;
93 }
94
95 u2 number_of_breakpoints() const { return _number_of_breakpoints; }
96 void incr_number_of_breakpoints() { ++_number_of_breakpoints; }
97 void decr_number_of_breakpoints() { --_number_of_breakpoints; }
98 void clear_number_of_breakpoints() { _number_of_breakpoints = 0; }
99
100 #ifdef GRAAL
101 void set_graal_invocation_time(jlong time) { _graal_invocation_time = time; }
102 jlong graal_invocation_time() { return _graal_invocation_time; }
103
104 void set_graal_priority(int prio) { _graal_priority = prio; }
105 int graal_priority() { return _graal_priority; }
106 #endif // GRAAL
107
108
109 #ifdef TIERED
110 jlong prev_time() const { return _prev_time; }
111 void set_prev_time(jlong time) { _prev_time = time; }
112 float rate() const { return _rate; }
113 void set_rate(float rate) { _rate = rate; }
114 #endif
115
116 // invocation counter
117 InvocationCounter* invocation_counter() { return &_invocation_counter; }
118 InvocationCounter* backedge_counter() { return &_backedge_counter; }
119
120 static ByteSize interpreter_invocation_counter_offset() {
121 return byte_offset_of(MethodCounters, _interpreter_invocation_count);
122 }
123
124 static ByteSize invocation_counter_offset() {
125 return byte_offset_of(MethodCounters, _invocation_counter);
126 }
127
128 static ByteSize backedge_counter_offset() {
129 return byte_offset_of(MethodCounters, _backedge_counter);
130 }
131
132 static int interpreter_invocation_counter_offset_in_bytes() {
133 return offset_of(MethodCounters, _interpreter_invocation_count);
134 }
135
136 };
137 #endif //SHARE_VM_OOPS_METHODCOUNTERS_HPP