55 //
56 // This class represents a Method* in the HotSpot virtual
57 // machine.
58 class ciMethod : public ciMetadata {
59 friend class CompileBroker;
60 CI_PACKAGE_ACCESS
61 friend class ciEnv;
62 friend class ciExceptionHandlerStream;
63 friend class ciBytecodeStream;
64 friend class ciMethodHandle;
65 friend class ciReplay;
66 friend class InlineTree;
67
68 private:
69 // General method information.
70 ciFlags _flags;
71 ciSymbol* _name;
72 ciInstanceKlass* _holder;
73 ciSignature* _signature;
74 ciMethodData* _method_data;
75 ciMethodBlocks* _method_blocks;
76
77 // Code attributes.
78 int _code_size;
79 int _max_stack;
80 int _max_locals;
81 vmIntrinsicID _intrinsic_id;
82 int _handler_count;
83 int _interpreter_invocation_count;
84 int _interpreter_throwout_count;
85 int _inline_instructions_size;
86 int _size_of_parameters;
87
88 bool _uses_monitors;
89 bool _balanced_monitors;
90 bool _is_c1_compilable;
91 bool _is_c2_compilable;
92 bool _can_be_parsed;
93 bool _can_be_statically_bound;
94 bool _can_omit_stack_trace;
95 bool _has_reserved_stack_access;
96 bool _is_overpass;
97
98 // Lazy fields, filled in on demand
99 address _code;
100 ciExceptionHandler** _exception_handlers;
101
102 // Optional liveness analyzer.
103 MethodLiveness* _liveness;
104 #if defined(COMPILER2)
105 ciTypeFlow* _flow;
106 BCEscapeAnalyzer* _bcea;
107 #endif
108
109 ciMethod(const methodHandle& h_m, ciInstanceKlass* holder);
110 ciMethod(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature, ciInstanceKlass* accessor);
111
112 oop loader() const { return _holder->loader(); }
113
114 const char* type_string() { return "ciMethod"; }
115
116 void print_impl(outputStream* st);
117
118 void load_code();
119
120 bool ensure_method_data(const methodHandle& h_m);
121
122 void code_at_put(int bci, Bytecodes::Code code) {
123 Bytecodes::check(code);
124 assert(0 <= bci && bci < code_size(), "valid bci");
125 address bcp = _code + bci;
126 *bcp = code;
127 }
128
129 // Check bytecode and profile data collected are compatible
130 void assert_virtual_call_type_ok(int bci);
131 void assert_call_type_ok(int bci);
132
133 // Check and update the profile counter in case of overflow
134 static int check_overflow(int c, Bytecodes::Code code);
135
136 public:
137 void check_is_loaded() const { assert(is_loaded(), "not loaded"); }
138
139 // Basic method information.
140 ciFlags flags() const { check_is_loaded(); return _flags; }
177 Method* m = (Method*)_metadata;
178 assert(m != nullptr, "illegal use of unloaded method");
179 return m;
180 }
181
182 // Method code and related information.
183 address code() { if (_code == nullptr) load_code(); return _code; }
184 int code_size() const { check_is_loaded(); return _code_size; }
185 int max_stack() const { check_is_loaded(); return _max_stack; }
186 int max_locals() const { check_is_loaded(); return _max_locals; }
187 vmIntrinsicID intrinsic_id() const { check_is_loaded(); return _intrinsic_id; }
188 bool has_exception_handlers() const { check_is_loaded(); return _handler_count > 0; }
189 int exception_table_length() const { check_is_loaded(); return _handler_count; }
190 int interpreter_invocation_count() const { check_is_loaded(); return _interpreter_invocation_count; }
191 int interpreter_throwout_count() const { check_is_loaded(); return _interpreter_throwout_count; }
192 int size_of_parameters() const { check_is_loaded(); return _size_of_parameters; }
193
194 // Code size for inlining decisions.
195 int code_size_for_inlining();
196
197 bool caller_sensitive() const { return get_Method()->caller_sensitive(); }
198 bool force_inline() const { return get_Method()->force_inline(); }
199 bool dont_inline() const { return get_Method()->dont_inline(); }
200 bool intrinsic_candidate() const { return get_Method()->intrinsic_candidate(); }
201 bool is_static_initializer() const { return get_Method()->is_static_initializer(); }
202 bool changes_current_thread() const { return get_Method()->changes_current_thread(); }
203 bool deprecated() const { return is_loaded() && get_Method()->deprecated(); }
204
205 bool check_intrinsic_candidate() const {
206 if (intrinsic_id() == vmIntrinsics::_blackhole) {
207 // This is the intrinsic without an associated method, so no intrinsic_candidate
208 // flag is set. The intrinsic is still correct.
209 return true;
210 }
211 return (CheckIntrinsics ? intrinsic_candidate() : true);
212 }
213
214 int highest_osr_comp_level();
215
216 Bytecodes::Code java_code_at_bci(int bci) {
217 address bcp = code() + bci;
218 return Bytecodes::java_code_at(nullptr, bcp);
219 }
220 Bytecodes::Code raw_code_at_bci(int bci) {
221 address bcp = code() + bci;
222 return Bytecodes::code_at(nullptr, bcp);
223 }
297 bool check_access = true);
298
299 // Given a known receiver klass, find the target for the call.
300 // Return null if the call has no target or is abstract.
301 ciMethod* resolve_invoke(ciKlass* caller, ciKlass* exact_receiver, bool check_access = true, bool allow_abstract = false);
302
303 // Find the proper vtable index to invoke this method.
304 int resolve_vtable_index(ciKlass* caller, ciKlass* receiver);
305
306 bool has_option(CompileCommandEnum option);
307 bool has_option_value(CompileCommandEnum option, double& value);
308 bool can_be_compiled();
309 bool can_be_parsed() const { return _can_be_parsed; }
310 bool has_compiled_code();
311 void log_nmethod_identity(xmlStream* log);
312 bool is_not_reached(int bci);
313 bool was_executed_more_than(int times);
314 bool has_unloaded_classes_in_signature();
315 bool is_klass_loaded(int refinfo_index, Bytecodes::Code bc, bool must_be_resolved) const;
316 bool check_call(int refinfo_index, bool is_static) const;
317 bool ensure_method_data(); // make sure it exists in the VM also
318 MethodCounters* ensure_method_counters();
319
320 int inline_instructions_size();
321 int scale_count(int count, float prof_factor = 1.); // make MDO count commensurate with IIC
322
323 // Stack walking support
324 bool is_ignored_by_security_stack_walk() const;
325
326 // JSR 292 support
327 bool is_method_handle_intrinsic() const;
328 bool is_compiled_lambda_form() const;
329 bool has_member_arg() const;
330
331 // What kind of ciObject is this?
332 bool is_method() const { return true; }
333
334 // Java access flags
335 bool is_public () const { return flags().is_public(); }
336 bool is_private () const { return flags().is_private(); }
337 bool is_protected () const { return flags().is_protected(); }
367
368 bool equals(const ciMethod* m) const;
369
370 // Replay data methods
371 static void dump_name_as_ascii(outputStream* st, Method* method);
372 void dump_name_as_ascii(outputStream* st);
373 void dump_replay_data(outputStream* st);
374
375 // Print the bytecodes of this method.
376 void print_codes_on(outputStream* st);
377 void print_codes() {
378 print_codes_on(tty);
379 }
380 void print_codes_on(int from, int to, outputStream* st);
381
382 // Print the name of this method in various incarnations.
383 void print_name(outputStream* st = tty);
384 void print_short_name(outputStream* st = tty);
385
386 static bool is_consistent_info(ciMethod* declared_method, ciMethod* resolved_method);
387 };
388
389 #endif // SHARE_CI_CIMETHOD_HPP
|
55 //
56 // This class represents a Method* in the HotSpot virtual
57 // machine.
58 class ciMethod : public ciMetadata {
59 friend class CompileBroker;
60 CI_PACKAGE_ACCESS
61 friend class ciEnv;
62 friend class ciExceptionHandlerStream;
63 friend class ciBytecodeStream;
64 friend class ciMethodHandle;
65 friend class ciReplay;
66 friend class InlineTree;
67
68 private:
69 // General method information.
70 ciFlags _flags;
71 ciSymbol* _name;
72 ciInstanceKlass* _holder;
73 ciSignature* _signature;
74 ciMethodData* _method_data;
75 ciMethodData* _method_data_recorded;
76 ciMethodBlocks* _method_blocks;
77
78 // Code attributes.
79 int _code_size;
80 int _max_stack;
81 int _max_locals;
82 vmIntrinsicID _intrinsic_id;
83 int _handler_count;
84 int _interpreter_invocation_count;
85 int _interpreter_throwout_count;
86 int _inline_instructions_size;
87 int _size_of_parameters;
88
89 bool _uses_monitors;
90 bool _balanced_monitors;
91 bool _is_c1_compilable;
92 bool _is_c2_compilable;
93 bool _can_be_parsed;
94 bool _can_be_statically_bound;
95 bool _can_omit_stack_trace;
96 bool _has_reserved_stack_access;
97 bool _is_overpass;
98
99 GrowableArray<int>* _has_trap_at_bci;
100
101 // Lazy fields, filled in on demand
102 address _code;
103 ciExceptionHandler** _exception_handlers;
104
105 // Optional liveness analyzer.
106 MethodLiveness* _liveness;
107 #if defined(COMPILER2)
108 ciTypeFlow* _flow;
109 BCEscapeAnalyzer* _bcea;
110 #endif
111
112 ciMethod(const methodHandle& h_m, ciInstanceKlass* holder);
113 ciMethod(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature, ciInstanceKlass* accessor);
114
115 oop loader() const { return _holder->loader(); }
116
117 const char* type_string() { return "ciMethod"; }
118
119 void print_impl(outputStream* st);
120
121 void load_code();
122
123 bool ensure_method_data(const methodHandle& h_m, bool training_data_only);
124
125 void code_at_put(int bci, Bytecodes::Code code) {
126 Bytecodes::check(code);
127 assert(0 <= bci && bci < code_size(), "valid bci");
128 address bcp = _code + bci;
129 *bcp = code;
130 }
131
132 // Check bytecode and profile data collected are compatible
133 void assert_virtual_call_type_ok(int bci);
134 void assert_call_type_ok(int bci);
135
136 // Check and update the profile counter in case of overflow
137 static int check_overflow(int c, Bytecodes::Code code);
138
139 public:
140 void check_is_loaded() const { assert(is_loaded(), "not loaded"); }
141
142 // Basic method information.
143 ciFlags flags() const { check_is_loaded(); return _flags; }
180 Method* m = (Method*)_metadata;
181 assert(m != nullptr, "illegal use of unloaded method");
182 return m;
183 }
184
185 // Method code and related information.
186 address code() { if (_code == nullptr) load_code(); return _code; }
187 int code_size() const { check_is_loaded(); return _code_size; }
188 int max_stack() const { check_is_loaded(); return _max_stack; }
189 int max_locals() const { check_is_loaded(); return _max_locals; }
190 vmIntrinsicID intrinsic_id() const { check_is_loaded(); return _intrinsic_id; }
191 bool has_exception_handlers() const { check_is_loaded(); return _handler_count > 0; }
192 int exception_table_length() const { check_is_loaded(); return _handler_count; }
193 int interpreter_invocation_count() const { check_is_loaded(); return _interpreter_invocation_count; }
194 int interpreter_throwout_count() const { check_is_loaded(); return _interpreter_throwout_count; }
195 int size_of_parameters() const { check_is_loaded(); return _size_of_parameters; }
196
197 // Code size for inlining decisions.
198 int code_size_for_inlining();
199
200 bool caller_sensitive() const { return get_Method()->caller_sensitive(); }
201 bool force_inline() const { return get_Method()->force_inline(); }
202 bool dont_inline() const { return get_Method()->dont_inline(); }
203 bool intrinsic_candidate() const { return get_Method()->intrinsic_candidate(); }
204 bool is_static_initializer() const { return get_Method()->is_static_initializer(); }
205 bool changes_current_thread() const { return get_Method()->changes_current_thread(); }
206 bool deprecated() const { return is_loaded() && get_Method()->deprecated(); }
207 bool has_upcall_on_method_entry() const { return get_Method()->has_upcall_on_method_entry(); }
208 bool has_upcall_on_method_exit() const { return get_Method()->has_upcall_on_method_exit(); }
209
210 bool check_intrinsic_candidate() const {
211 if (intrinsic_id() == vmIntrinsics::_blackhole) {
212 // This is the intrinsic without an associated method, so no intrinsic_candidate
213 // flag is set. The intrinsic is still correct.
214 return true;
215 }
216 return (CheckIntrinsics ? intrinsic_candidate() : true);
217 }
218
219 int highest_osr_comp_level();
220
221 Bytecodes::Code java_code_at_bci(int bci) {
222 address bcp = code() + bci;
223 return Bytecodes::java_code_at(nullptr, bcp);
224 }
225 Bytecodes::Code raw_code_at_bci(int bci) {
226 address bcp = code() + bci;
227 return Bytecodes::code_at(nullptr, bcp);
228 }
302 bool check_access = true);
303
304 // Given a known receiver klass, find the target for the call.
305 // Return null if the call has no target or is abstract.
306 ciMethod* resolve_invoke(ciKlass* caller, ciKlass* exact_receiver, bool check_access = true, bool allow_abstract = false);
307
308 // Find the proper vtable index to invoke this method.
309 int resolve_vtable_index(ciKlass* caller, ciKlass* receiver);
310
311 bool has_option(CompileCommandEnum option);
312 bool has_option_value(CompileCommandEnum option, double& value);
313 bool can_be_compiled();
314 bool can_be_parsed() const { return _can_be_parsed; }
315 bool has_compiled_code();
316 void log_nmethod_identity(xmlStream* log);
317 bool is_not_reached(int bci);
318 bool was_executed_more_than(int times);
319 bool has_unloaded_classes_in_signature();
320 bool is_klass_loaded(int refinfo_index, Bytecodes::Code bc, bool must_be_resolved) const;
321 bool check_call(int refinfo_index, bool is_static) const;
322 bool ensure_method_data(bool training_data_only = false); // make sure it exists in the VM also
323 MethodCounters* ensure_method_counters();
324
325 int inline_instructions_size();
326 int scale_count(int count, float prof_factor = 1.); // make MDO count commensurate with IIC
327
328 // Stack walking support
329 bool is_ignored_by_security_stack_walk() const;
330
331 // JSR 292 support
332 bool is_method_handle_intrinsic() const;
333 bool is_compiled_lambda_form() const;
334 bool has_member_arg() const;
335
336 // What kind of ciObject is this?
337 bool is_method() const { return true; }
338
339 // Java access flags
340 bool is_public () const { return flags().is_public(); }
341 bool is_private () const { return flags().is_private(); }
342 bool is_protected () const { return flags().is_protected(); }
372
373 bool equals(const ciMethod* m) const;
374
375 // Replay data methods
376 static void dump_name_as_ascii(outputStream* st, Method* method);
377 void dump_name_as_ascii(outputStream* st);
378 void dump_replay_data(outputStream* st);
379
380 // Print the bytecodes of this method.
381 void print_codes_on(outputStream* st);
382 void print_codes() {
383 print_codes_on(tty);
384 }
385 void print_codes_on(int from, int to, outputStream* st);
386
387 // Print the name of this method in various incarnations.
388 void print_name(outputStream* st = tty);
389 void print_short_name(outputStream* st = tty);
390
391 static bool is_consistent_info(ciMethod* declared_method, ciMethod* resolved_method);
392 bool has_trap_at(int bci) {
393 return _has_trap_at_bci != nullptr &&
394 _has_trap_at_bci->contains(bci);
395 }
396 };
397
398 #endif // SHARE_CI_CIMETHOD_HPP
|