29 #include "ci/ciInstanceKlass.hpp"
30 #include "ci/ciObject.hpp"
31 #include "ci/ciSignature.hpp"
32 #include "classfile/vmIntrinsics.hpp"
33 #include "compiler/methodLiveness.hpp"
34 #include "oops/method.hpp"
35 #include "runtime/handles.hpp"
36 #include "utilities/bitMap.hpp"
37 #include "utilities/vmEnums.hpp"
38
39 class ciMethodBlocks;
40 class MethodLiveness;
41 class Arena;
42 class BCEscapeAnalyzer;
43 class InlineTree;
44 class xmlStream;
45
46 // Whether profiling found an oop to be always, never or sometimes
47 // null
48 enum ProfilePtrKind {
49 ProfileAlwaysNull,
50 ProfileNeverNull,
51 ProfileMaybeNull
52 };
53
54 // ciMethod
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:
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;
252 // dead when those paths merge. Since the interpreter's viewpoint is
253 // used when gc'ing an interpreter frame we need to use its viewpoint
254 // during OSR when loading the locals.
255
256 ResourceBitMap live_local_oops_at_bci(int bci);
257
258 bool needs_clinit_barrier() const;
259
260 #ifdef COMPILER1
261 const BitMap& bci_block_start();
262 #endif
263
264 ciTypeFlow* get_flow_analysis();
265 ciTypeFlow* get_osr_flow_analysis(int osr_bci); // alternate entry point
266 ciCallProfile call_profile_at_bci(int bci);
267
268 // Does type profiling provide any useful information at this point?
269 bool argument_profiled_type(int bci, int i, ciKlass*& type, ProfilePtrKind& ptr_kind);
270 bool parameter_profiled_type(int i, ciKlass*& type, ProfilePtrKind& ptr_kind);
271 bool return_profiled_type(int bci, ciKlass*& type, ProfilePtrKind& ptr_kind);
272
273 ciField* get_field_at_bci( int bci, bool &will_link);
274 ciMethod* get_method_at_bci(int bci, bool &will_link, ciSignature* *declared_signature);
275 ciMethod* get_method_at_bci(int bci) {
276 bool ignored_will_link;
277 ciSignature* ignored_declared_signature;
278 return get_method_at_bci(bci, ignored_will_link, &ignored_declared_signature);
279 }
280
281 ciKlass* get_declared_method_holder_at_bci(int bci);
282
283 ciSignature* get_declared_signature_at_bci(int bci) {
284 bool ignored_will_link;
285 ciSignature* declared_signature;
286 get_method_at_bci(bci, ignored_will_link, &declared_signature);
287 assert(declared_signature != nullptr, "cannot be null");
288 return declared_signature;
289 }
290
291 // Given a certain calling environment, find the monomorphic target
292 // for the call. Return null if the call is not monomorphic in
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(); }
338 bool is_static () const { return flags().is_static(); }
339 bool is_final () const { return flags().is_final(); }
340 bool is_synchronized() const { return flags().is_synchronized(); }
341 bool is_native () const { return flags().is_native(); }
342 bool is_interface () const { return flags().is_interface(); }
343 bool is_abstract () const { return flags().is_abstract(); }
344
345 // Other flags
346 bool is_final_method() const { return is_final() || holder()->is_final(); }
347 bool is_default_method() const { return !is_abstract() && !is_private() &&
348 holder()->is_interface(); }
349 bool is_overpass () const { check_is_loaded(); return _is_overpass; }
350 bool has_loops () const;
351 bool has_jsrs () const;
352 bool is_getter () const;
353 bool is_setter () const;
354 bool is_accessor () const;
355 bool is_empty () const;
356 bool can_be_statically_bound() const { return _can_be_statically_bound; }
357 bool has_reserved_stack_access() const { return _has_reserved_stack_access; }
358 bool is_boxing_method() const;
359 bool is_unboxing_method() const;
360 bool is_vector_method() const;
361 bool is_object_initializer() const;
362 bool is_scoped() const;
363
364 bool can_be_statically_bound(ciInstanceKlass* context) const;
365
366 bool can_omit_stack_trace() const;
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
|
29 #include "ci/ciInstanceKlass.hpp"
30 #include "ci/ciObject.hpp"
31 #include "ci/ciSignature.hpp"
32 #include "classfile/vmIntrinsics.hpp"
33 #include "compiler/methodLiveness.hpp"
34 #include "oops/method.hpp"
35 #include "runtime/handles.hpp"
36 #include "utilities/bitMap.hpp"
37 #include "utilities/vmEnums.hpp"
38
39 class ciMethodBlocks;
40 class MethodLiveness;
41 class Arena;
42 class BCEscapeAnalyzer;
43 class InlineTree;
44 class xmlStream;
45
46 // Whether profiling found an oop to be always, never or sometimes
47 // null
48 enum ProfilePtrKind {
49 ProfileUnknownNull,
50 ProfileAlwaysNull,
51 ProfileNeverNull,
52 ProfileMaybeNull
53 };
54
55 // ciMethod
56 //
57 // This class represents a Method* in the HotSpot virtual
58 // machine.
59 class ciMethod : public ciMetadata {
60 friend class CompileBroker;
61 CI_PACKAGE_ACCESS
62 friend class ciEnv;
63 friend class ciExceptionHandlerStream;
64 friend class ciBytecodeStream;
65 friend class ciMethodHandle;
66 friend class ciReplay;
67 friend class InlineTree;
68
69 private:
182
183 // Method code and related information.
184 address code() { if (_code == nullptr) load_code(); return _code; }
185 int code_size() const { check_is_loaded(); return _code_size; }
186 int max_stack() const { check_is_loaded(); return _max_stack; }
187 int max_locals() const { check_is_loaded(); return _max_locals; }
188 vmIntrinsicID intrinsic_id() const { check_is_loaded(); return _intrinsic_id; }
189 bool has_exception_handlers() const { check_is_loaded(); return _handler_count > 0; }
190 int exception_table_length() const { check_is_loaded(); return _handler_count; }
191 int interpreter_invocation_count() const { check_is_loaded(); return _interpreter_invocation_count; }
192 int interpreter_throwout_count() const { check_is_loaded(); return _interpreter_throwout_count; }
193 int size_of_parameters() const { check_is_loaded(); return _size_of_parameters; }
194
195 // Code size for inlining decisions.
196 int code_size_for_inlining();
197
198 bool caller_sensitive() const { return get_Method()->caller_sensitive(); }
199 bool force_inline() const { return get_Method()->force_inline(); }
200 bool dont_inline() const { return get_Method()->dont_inline(); }
201 bool intrinsic_candidate() const { return get_Method()->intrinsic_candidate(); }
202 bool is_class_initializer() const { return get_Method()->is_class_initializer(); }
203 bool changes_current_thread() const { return get_Method()->changes_current_thread(); }
204 bool deprecated() const { return is_loaded() && get_Method()->deprecated(); }
205
206 bool check_intrinsic_candidate() const {
207 if (intrinsic_id() == vmIntrinsics::_blackhole) {
208 // This is the intrinsic without an associated method, so no intrinsic_candidate
209 // flag is set. The intrinsic is still correct.
210 return true;
211 }
212 return (CheckIntrinsics ? intrinsic_candidate() : true);
213 }
214
215 int highest_osr_comp_level();
216
217 Bytecodes::Code java_code_at_bci(int bci) {
218 address bcp = code() + bci;
219 return Bytecodes::java_code_at(nullptr, bcp);
220 }
221 Bytecodes::Code raw_code_at_bci(int bci) {
222 address bcp = code() + bci;
253 // dead when those paths merge. Since the interpreter's viewpoint is
254 // used when gc'ing an interpreter frame we need to use its viewpoint
255 // during OSR when loading the locals.
256
257 ResourceBitMap live_local_oops_at_bci(int bci);
258
259 bool needs_clinit_barrier() const;
260
261 #ifdef COMPILER1
262 const BitMap& bci_block_start();
263 #endif
264
265 ciTypeFlow* get_flow_analysis();
266 ciTypeFlow* get_osr_flow_analysis(int osr_bci); // alternate entry point
267 ciCallProfile call_profile_at_bci(int bci);
268
269 // Does type profiling provide any useful information at this point?
270 bool argument_profiled_type(int bci, int i, ciKlass*& type, ProfilePtrKind& ptr_kind);
271 bool parameter_profiled_type(int i, ciKlass*& type, ProfilePtrKind& ptr_kind);
272 bool return_profiled_type(int bci, ciKlass*& type, ProfilePtrKind& ptr_kind);
273 bool array_access_profiled_type(int bci, ciKlass*& array_type, ciKlass*& element_type, ProfilePtrKind& element_ptr, bool &flat_array, bool &null_free);
274 bool acmp_profiled_type(int bci, ciKlass*& left_type, ciKlass*& right_type,
275 ProfilePtrKind& left_ptr, ProfilePtrKind& right_ptr,
276 bool &left_inline_type, bool &right_inline_type);
277 ciField* get_field_at_bci( int bci, bool &will_link);
278 ciMethod* get_method_at_bci(int bci, bool &will_link, ciSignature* *declared_signature);
279 ciMethod* get_method_at_bci(int bci) {
280 bool ignored_will_link;
281 ciSignature* ignored_declared_signature;
282 return get_method_at_bci(bci, ignored_will_link, &ignored_declared_signature);
283 }
284
285 ciKlass* get_declared_method_holder_at_bci(int bci);
286
287 ciSignature* get_declared_signature_at_bci(int bci) {
288 bool ignored_will_link;
289 ciSignature* declared_signature;
290 get_method_at_bci(bci, ignored_will_link, &declared_signature);
291 assert(declared_signature != nullptr, "cannot be null");
292 return declared_signature;
293 }
294
295 // Given a certain calling environment, find the monomorphic target
296 // for the call. Return null if the call is not monomorphic in
328 bool is_ignored_by_security_stack_walk() const;
329
330 // JSR 292 support
331 bool is_method_handle_intrinsic() const;
332 bool is_compiled_lambda_form() const;
333 bool has_member_arg() const;
334
335 // What kind of ciObject is this?
336 bool is_method() const { return true; }
337
338 // Java access flags
339 bool is_public () const { return flags().is_public(); }
340 bool is_private () const { return flags().is_private(); }
341 bool is_protected () const { return flags().is_protected(); }
342 bool is_static () const { return flags().is_static(); }
343 bool is_final () const { return flags().is_final(); }
344 bool is_synchronized() const { return flags().is_synchronized(); }
345 bool is_native () const { return flags().is_native(); }
346 bool is_interface () const { return flags().is_interface(); }
347 bool is_abstract () const { return flags().is_abstract(); }
348 bool has_vararg () const { return flags().has_vararg(); }
349
350 // Other flags
351 bool is_final_method() const { return is_final() || holder()->is_final(); }
352 bool is_default_method() const { return !is_abstract() && !is_private() &&
353 holder()->is_interface(); }
354 bool is_overpass () const { check_is_loaded(); return _is_overpass; }
355 bool has_loops () const;
356 bool has_jsrs () const;
357 bool is_getter () const;
358 bool is_setter () const;
359 bool is_accessor () const;
360 bool is_empty () const;
361 bool can_be_statically_bound() const { return _can_be_statically_bound; }
362 bool has_reserved_stack_access() const { return _has_reserved_stack_access; }
363 bool is_boxing_method() const;
364 bool is_unboxing_method() const;
365 bool is_object_constructor() const;
366 bool is_vector_method() const;
367 bool is_scoped() const;
368
369 bool can_be_statically_bound(ciInstanceKlass* context) const;
370
371 bool can_omit_stack_trace() const;
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
393 // Support for the inline type calling convention
394 bool is_scalarized_arg(int idx) const;
395 bool has_scalarized_args() const;
396 const GrowableArray<SigEntry>* get_sig_cc() const;
397 };
398
399 #endif // SHARE_CI_CIMETHOD_HPP
|