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_CI_CIMETHOD_HPP
26 #define SHARE_VM_CI_CIMETHOD_HPP
27
28 #include "ci/ciFlags.hpp"
29 #include "ci/ciInstanceKlass.hpp"
30 #include "ci/ciObject.hpp"
31 #include "ci/ciSignature.hpp"
32 #include "compiler/methodLiveness.hpp"
33 #include "prims/methodHandles.hpp"
34 #include "utilities/bitMap.hpp"
35
36 class ciMethodBlocks;
37 class MethodLiveness;
38 class BitMap;
39 class Arena;
40 class BCEscapeAnalyzer;
41
42
43 // ciMethod
44 //
45 // This class represents a Method* in the HotSpot virtual
46 // machine.
47 class ciMethod : public ciMetadata {
48 friend class CompileBroker;
49 CI_PACKAGE_ACCESS
50 friend class ciEnv;
51 friend class ciExceptionHandlerStream;
52 friend class ciBytecodeStream;
53 friend class ciMethodHandle;
54 friend class ciReplay;
55
56 private:
57 // General method information.
58 ciFlags _flags;
59 ciSymbol* _name;
60 ciInstanceKlass* _holder;
61 ciSignature* _signature;
62 ciMethodData* _method_data;
63 ciMethodBlocks* _method_blocks;
64
65 // Code attributes.
66 int _code_size;
67 int _max_stack;
68 int _max_locals;
69 vmIntrinsics::ID _intrinsic_id;
70 int _handler_count;
71 int _nmethod_age;
72 int _interpreter_invocation_count;
73 int _interpreter_throwout_count;
74 int _instructions_size;
78 bool _balanced_monitors;
79 bool _is_c1_compilable;
80 bool _is_c2_compilable;
81 bool _can_be_statically_bound;
82 bool _has_injected_profile;
83
84 // Lazy fields, filled in on demand
85 address _code;
86 ciExceptionHandler** _exception_handlers;
87
88 // Optional liveness analyzer.
89 MethodLiveness* _liveness;
90 #if defined(COMPILER2) || defined(SHARK)
91 ciTypeFlow* _flow;
92 BCEscapeAnalyzer* _bcea;
93 #endif
94
95 ciMethod(methodHandle h_m, ciInstanceKlass* holder);
96 ciMethod(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature, ciInstanceKlass* accessor);
97
98 Method* get_Method() const {
99 Method* m = (Method*)_metadata;
100 assert(m != NULL, "illegal use of unloaded method");
101 return m;
102 }
103
104 oop loader() const { return _holder->loader(); }
105
106 const char* type_string() { return "ciMethod"; }
107
108 void print_impl(outputStream* st);
109
110 void load_code();
111
112 void check_is_loaded() const { assert(is_loaded(), "not loaded"); }
113
114 bool ensure_method_data(methodHandle h_m);
115
116 void code_at_put(int bci, Bytecodes::Code code) {
117 Bytecodes::check(code);
118 assert(0 <= bci && bci < code_size(), "valid bci");
119 address bcp = _code + bci;
120 *bcp = code;
121 }
122
123 // Check bytecode and profile data collected are compatible
141 check_is_loaded();
142 return _signature->size() + (_flags.is_static() ? 0 : 1);
143 }
144 // Report the number of elements on stack when invoking this method.
145 // This is different than the regular arg_size because invokedynamic
146 // has an implicit receiver.
147 int invoke_arg_size(Bytecodes::Code code) const {
148 if (is_loaded()) {
149 return arg_size();
150 } else {
151 int arg_size = _signature->size();
152 // Add a receiver argument, maybe:
153 if (code != Bytecodes::_invokestatic &&
154 code != Bytecodes::_invokedynamic) {
155 arg_size++;
156 }
157 return arg_size;
158 }
159 }
160
161
162 // Method code and related information.
163 address code() { if (_code == NULL) load_code(); return _code; }
164 int code_size() const { check_is_loaded(); return _code_size; }
165 int max_stack() const { check_is_loaded(); return _max_stack; }
166 int max_locals() const { check_is_loaded(); return _max_locals; }
167 vmIntrinsics::ID intrinsic_id() const { check_is_loaded(); return _intrinsic_id; }
168 bool has_exception_handlers() const { check_is_loaded(); return _handler_count > 0; }
169 int exception_table_length() const { check_is_loaded(); return _handler_count; }
170 int interpreter_invocation_count() const { check_is_loaded(); return _interpreter_invocation_count; }
171 int interpreter_throwout_count() const { check_is_loaded(); return _interpreter_throwout_count; }
172 int size_of_parameters() const { check_is_loaded(); return _size_of_parameters; }
173 int nmethod_age() const { check_is_loaded(); return _nmethod_age; }
174
175 // Should the method be compiled with an age counter?
176 bool profile_aging() const;
177
178 // Code size for inlining decisions.
179 int code_size_for_inlining();
180
322 bool is_accessor () const;
323 bool is_initializer () const;
324 bool can_be_statically_bound() const { return _can_be_statically_bound; }
325 bool is_boxing_method() const;
326 bool is_unboxing_method() const;
327
328 // Replay data methods
329 void dump_name_as_ascii(outputStream* st);
330 void dump_replay_data(outputStream* st);
331
332 // Print the bytecodes of this method.
333 void print_codes_on(outputStream* st);
334 void print_codes() {
335 print_codes_on(tty);
336 }
337 void print_codes_on(int from, int to, outputStream* st);
338
339 // Print the name of this method in various incarnations.
340 void print_name(outputStream* st = tty);
341 void print_short_name(outputStream* st = tty);
342 };
343
344 #endif // SHARE_VM_CI_CIMETHOD_HPP
|
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_CI_CIMETHOD_HPP
26 #define SHARE_VM_CI_CIMETHOD_HPP
27
28 #include "ci/ciFlags.hpp"
29 #include "ci/ciInstanceKlass.hpp"
30 #include "ci/ciObject.hpp"
31 #include "ci/ciSignature.hpp"
32 #include "compiler/methodLiveness.hpp"
33 #include "prims/methodHandles.hpp"
34 #include "utilities/bitMap.hpp"
35 #include "trace/tracing.hpp"
36
37 class ciMethodBlocks;
38 class MethodLiveness;
39 class BitMap;
40 class Arena;
41 class BCEscapeAnalyzer;
42 class InlineTree;
43
44 // ciMethod
45 //
46 // This class represents a Method* in the HotSpot virtual
47 // machine.
48 class ciMethod : public ciMetadata {
49 friend class CompileBroker;
50 CI_PACKAGE_ACCESS
51 friend class ciEnv;
52 friend class ciExceptionHandlerStream;
53 friend class ciBytecodeStream;
54 friend class ciMethodHandle;
55 friend class ciReplay;
56 friend class InlineTree;
57
58 private:
59 // General method information.
60 ciFlags _flags;
61 ciSymbol* _name;
62 ciInstanceKlass* _holder;
63 ciSignature* _signature;
64 ciMethodData* _method_data;
65 ciMethodBlocks* _method_blocks;
66
67 // Code attributes.
68 int _code_size;
69 int _max_stack;
70 int _max_locals;
71 vmIntrinsics::ID _intrinsic_id;
72 int _handler_count;
73 int _nmethod_age;
74 int _interpreter_invocation_count;
75 int _interpreter_throwout_count;
76 int _instructions_size;
80 bool _balanced_monitors;
81 bool _is_c1_compilable;
82 bool _is_c2_compilable;
83 bool _can_be_statically_bound;
84 bool _has_injected_profile;
85
86 // Lazy fields, filled in on demand
87 address _code;
88 ciExceptionHandler** _exception_handlers;
89
90 // Optional liveness analyzer.
91 MethodLiveness* _liveness;
92 #if defined(COMPILER2) || defined(SHARK)
93 ciTypeFlow* _flow;
94 BCEscapeAnalyzer* _bcea;
95 #endif
96
97 ciMethod(methodHandle h_m, ciInstanceKlass* holder);
98 ciMethod(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature, ciInstanceKlass* accessor);
99
100 oop loader() const { return _holder->loader(); }
101
102 const char* type_string() { return "ciMethod"; }
103
104 void print_impl(outputStream* st);
105
106 void load_code();
107
108 void check_is_loaded() const { assert(is_loaded(), "not loaded"); }
109
110 bool ensure_method_data(methodHandle h_m);
111
112 void code_at_put(int bci, Bytecodes::Code code) {
113 Bytecodes::check(code);
114 assert(0 <= bci && bci < code_size(), "valid bci");
115 address bcp = _code + bci;
116 *bcp = code;
117 }
118
119 // Check bytecode and profile data collected are compatible
137 check_is_loaded();
138 return _signature->size() + (_flags.is_static() ? 0 : 1);
139 }
140 // Report the number of elements on stack when invoking this method.
141 // This is different than the regular arg_size because invokedynamic
142 // has an implicit receiver.
143 int invoke_arg_size(Bytecodes::Code code) const {
144 if (is_loaded()) {
145 return arg_size();
146 } else {
147 int arg_size = _signature->size();
148 // Add a receiver argument, maybe:
149 if (code != Bytecodes::_invokestatic &&
150 code != Bytecodes::_invokedynamic) {
151 arg_size++;
152 }
153 return arg_size;
154 }
155 }
156
157 Method* get_Method() const {
158 Method* m = (Method*)_metadata;
159 assert(m != NULL, "illegal use of unloaded method");
160 return m;
161 }
162
163 // Method code and related information.
164 address code() { if (_code == NULL) load_code(); return _code; }
165 int code_size() const { check_is_loaded(); return _code_size; }
166 int max_stack() const { check_is_loaded(); return _max_stack; }
167 int max_locals() const { check_is_loaded(); return _max_locals; }
168 vmIntrinsics::ID intrinsic_id() const { check_is_loaded(); return _intrinsic_id; }
169 bool has_exception_handlers() const { check_is_loaded(); return _handler_count > 0; }
170 int exception_table_length() const { check_is_loaded(); return _handler_count; }
171 int interpreter_invocation_count() const { check_is_loaded(); return _interpreter_invocation_count; }
172 int interpreter_throwout_count() const { check_is_loaded(); return _interpreter_throwout_count; }
173 int size_of_parameters() const { check_is_loaded(); return _size_of_parameters; }
174 int nmethod_age() const { check_is_loaded(); return _nmethod_age; }
175
176 // Should the method be compiled with an age counter?
177 bool profile_aging() const;
178
179 // Code size for inlining decisions.
180 int code_size_for_inlining();
181
323 bool is_accessor () const;
324 bool is_initializer () const;
325 bool can_be_statically_bound() const { return _can_be_statically_bound; }
326 bool is_boxing_method() const;
327 bool is_unboxing_method() const;
328
329 // Replay data methods
330 void dump_name_as_ascii(outputStream* st);
331 void dump_replay_data(outputStream* st);
332
333 // Print the bytecodes of this method.
334 void print_codes_on(outputStream* st);
335 void print_codes() {
336 print_codes_on(tty);
337 }
338 void print_codes_on(int from, int to, outputStream* st);
339
340 // Print the name of this method in various incarnations.
341 void print_name(outputStream* st = tty);
342 void print_short_name(outputStream* st = tty);
343
344 #if INCLUDE_TRACE
345 TraceStructCiMethod to_trace_struct() const;
346 #endif
347 };
348
349 #endif // SHARE_VM_CI_CIMETHOD_HPP
|