author | jiangli |
Tue, 09 Apr 2013 17:17:41 -0400 | |
changeset 17000 | 11bf92e571a2 |
child 24442 | 4d4ae31dea26 |
permissions | -rw-r--r-- |
17000
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
1 |
/* |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
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 |
#ifndef SHARE_VM_OOPS_METHODCOUNTERS_HPP |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
26 |
#define SHARE_VM_OOPS_METHODCOUNTERS_HPP |
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" |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
29 |
#include "interpreter/invocationCounter.hpp" |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
30 |
|
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
31 |
class MethodCounters: public MetaspaceObj { |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
32 |
friend class VMStructs; |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
33 |
private: |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
34 |
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
|
35 |
u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
36 |
u2 _number_of_breakpoints; // fullspeed debugging support |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
37 |
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
|
38 |
InvocationCounter _backedge_counter; // Incremented before each backedge taken - used to trigger frequencey-based optimizations |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
39 |
|
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
40 |
#ifdef TIERED |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
41 |
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
|
42 |
jlong _prev_time; // Previous time the rate was acquired |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
43 |
#endif |
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 |
MethodCounters() : _interpreter_invocation_count(0), |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
46 |
_interpreter_throwout_count(0), |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
47 |
_number_of_breakpoints(0) |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
48 |
#ifdef TIERED |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
49 |
, _rate(0), |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
50 |
_prev_time(0) |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
51 |
#endif |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
52 |
{ |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
53 |
invocation_counter()->init(); |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
54 |
backedge_counter()->init(); |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
55 |
} |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
56 |
|
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
57 |
public: |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
58 |
static MethodCounters* allocate(ClassLoaderData* loader_data, TRAPS); |
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 |
void deallocate_contents(ClassLoaderData* loader_data) {} |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
61 |
DEBUG_ONLY(bool on_stack() { return false; }) // for template |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
62 |
|
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
63 |
static int size() { return sizeof(MethodCounters) / wordSize; } |
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 |
bool is_klass() const { return false; } |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
66 |
|
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
67 |
void clear_counters(); |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
68 |
|
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
69 |
int interpreter_invocation_count() { |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
70 |
return _interpreter_invocation_count; |
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 |
void set_interpreter_invocation_count(int count) { |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
73 |
_interpreter_invocation_count = count; |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
74 |
} |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
75 |
int increment_interpreter_invocation_count() { |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
76 |
return ++_interpreter_invocation_count; |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
77 |
} |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
78 |
|
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
79 |
void interpreter_throwout_increment() { |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
80 |
if (_interpreter_throwout_count < 65534) { |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
81 |
_interpreter_throwout_count++; |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
82 |
} |
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 |
int interpreter_throwout_count() const { |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
85 |
return _interpreter_throwout_count; |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
86 |
} |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
87 |
void set_interpreter_throwout_count(int count) { |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
88 |
_interpreter_throwout_count = count; |
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 |
|
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
91 |
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
|
92 |
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
|
93 |
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
|
94 |
void clear_number_of_breakpoints() { _number_of_breakpoints = 0; } |
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 |
#ifdef TIERED |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
97 |
jlong prev_time() const { return _prev_time; } |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
98 |
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
|
99 |
float rate() const { return _rate; } |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
100 |
void set_rate(float rate) { _rate = rate; } |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
101 |
#endif |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
102 |
|
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
103 |
// invocation counter |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
104 |
InvocationCounter* invocation_counter() { return &_invocation_counter; } |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
105 |
InvocationCounter* backedge_counter() { return &_backedge_counter; } |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
106 |
|
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
107 |
static ByteSize interpreter_invocation_counter_offset() { |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
108 |
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
|
109 |
} |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
110 |
|
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
111 |
static ByteSize invocation_counter_offset() { |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
112 |
return byte_offset_of(MethodCounters, _invocation_counter); |
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 |
static ByteSize backedge_counter_offset() { |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
116 |
return byte_offset_of(MethodCounters, _backedge_counter); |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
117 |
} |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
118 |
|
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
119 |
static int interpreter_invocation_counter_offset_in_bytes() { |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
120 |
return offset_of(MethodCounters, _interpreter_invocation_count); |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
121 |
} |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
122 |
|
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
123 |
}; |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff
changeset
|
124 |
#endif //SHARE_VM_OOPS_METHODCOUNTERS_HPP |