28 #include "code/codeBlob.hpp"
29 #include "code/pcDesc.hpp"
30 #include "oops/metadata.hpp"
31 #include "oops/method.hpp"
32
33 class AbstractCompiler;
34 class CompiledDirectCall;
35 class CompiledIC;
36 class CompiledICData;
37 class CompileTask;
38 class DepChange;
39 class Dependencies;
40 class DirectiveSet;
41 class DebugInformationRecorder;
42 class ExceptionHandlerTable;
43 class ImplicitExceptionTable;
44 class JvmtiThreadState;
45 class MetadataClosure;
46 class NativeCallWrapper;
47 class OopIterateClosure;
48 class ScopeDesc;
49 class xmlStream;
50
51 // This class is used internally by nmethods, to cache
52 // exception/pc/handler information.
53
54 class ExceptionCache : public CHeapObj<mtCode> {
55 friend class VMStructs;
56 private:
57 enum { cache_size = 16 };
58 Klass* _exception_type;
59 address _pc[cache_size];
60 address _handler[cache_size];
61 volatile int _count;
62 ExceptionCache* volatile _next;
63 ExceptionCache* _purge_list_next;
64
65 inline address pc_at(int index);
66 void set_pc_at(int index, address a) { assert(index >= 0 && index < cache_size,""); _pc[index] = a; }
67
158
159 #if INCLUDE_JVMCI
160 class FailedSpeculation;
161 class JVMCINMethodData;
162 #endif
163
164 class nmethod : public CodeBlob {
165 friend class VMStructs;
166 friend class JVMCIVMStructs;
167 friend class CodeCache; // scavengable oops
168 friend class JVMCINMethodData;
169 friend class DeoptimizationScope;
170
171 private:
172
173 // Used to track in which deoptimize handshake this method will be deoptimized.
174 uint64_t _deoptimization_generation;
175
176 uint64_t _gc_epoch;
177
178 Method* _method;
179
180 // To reduce header size union fields which usages do not overlap.
181 union {
182 // To support simple linked-list chaining of nmethods:
183 nmethod* _osr_link; // from InstanceKlass::osr_nmethods_head
184 struct {
185 // These are used for compiled synchronized native methods to
186 // locate the owner and stack slot for the BasicLock. They are
187 // needed because there is no debug information for compiled native
188 // wrappers and the oop maps are insufficient to allow
189 // frame::retrieve_receiver() to work. Currently they are expected
190 // to be byte offsets from the Java stack pointer for maximum code
191 // sharing between platforms. JVMTI's GetLocalInstance() uses these
192 // offsets to find the receiver for non-static native wrapper frames.
193 ByteSize _native_receiver_sp_offset;
194 ByteSize _native_basic_lock_sp_offset;
195 };
196 };
197
249 int _scopes_pcs_offset;
250 int _scopes_data_offset;
251 #if INCLUDE_JVMCI
252 int _speculations_offset;
253 #endif
254
255 // location in frame (offset for sp) that deopt can store the original
256 // pc during a deopt.
257 int _orig_pc_offset;
258
259 int _compile_id; // which compilation made this nmethod
260 CompLevel _comp_level; // compilation level (s1)
261 CompilerType _compiler_type; // which compiler made this nmethod (u1)
262
263 #if INCLUDE_RTM_OPT
264 // RTM state at compile time. Used during deoptimization to decide
265 // whether to restart collecting RTM locking abort statistic again.
266 RTMState _rtm_state;
267 #endif
268
269 // Local state used to keep track of whether unloading is happening or not
270 volatile uint8_t _is_unloading_state;
271
272 // Protected by NMethodState_lock
273 volatile signed char _state; // {not_installed, in_use, not_entrant}
274
275 // set during construction
276 uint8_t _has_unsafe_access:1, // May fault due to unsafe access.
277 _has_method_handle_invokes:1,// Has this method MethodHandle invokes?
278 _has_wide_vectors:1, // Preserve wide vectors at safepoints
279 _has_monitors:1, // Fastpath monitor detection for continuations
280 _has_flushed_dependencies:1, // Used for maintenance of dependencies (under CodeCache_lock)
281 _is_unlinked:1, // mark during class unloading
282 _load_reported:1; // used by jvmti to track if an event has been posted for this nmethod
283
284 enum DeoptimizationStatus : u1 {
285 not_marked,
286 deoptimize,
287 deoptimize_noupdate,
288 deoptimize_done
289 };
290
291 volatile DeoptimizationStatus _deoptimization_status; // Used for stack deoptimization
292
293 DeoptimizationStatus deoptimization_status() const {
294 return Atomic::load(&_deoptimization_status);
295 }
296
297 // Initialize fields to their default values
298 void init_defaults(CodeBuffer *code_buffer, CodeOffsets* offsets);
299
300 // Post initialization
301 void post_init();
302
314
315 // For normal JIT compiled code
316 nmethod(Method* method,
317 CompilerType type,
318 int nmethod_size,
319 int immutable_data_size,
320 int compile_id,
321 int entry_bci,
322 address immutable_data,
323 CodeOffsets* offsets,
324 int orig_pc_offset,
325 DebugInformationRecorder *recorder,
326 Dependencies* dependencies,
327 CodeBuffer *code_buffer,
328 int frame_size,
329 OopMapSet* oop_maps,
330 ExceptionHandlerTable* handler_table,
331 ImplicitExceptionTable* nul_chk_table,
332 AbstractCompiler* compiler,
333 CompLevel comp_level
334 #if INCLUDE_JVMCI
335 , char* speculations = nullptr,
336 int speculations_len = 0,
337 JVMCINMethodData* jvmci_data = nullptr
338 #endif
339 );
340
341 // helper methods
342 void* operator new(size_t size, int nmethod_size, int comp_level) throw();
343
344 // For method handle intrinsics: Try MethodNonProfiled, MethodProfiled and NonNMethod.
345 // Attention: Only allow NonNMethod space for special nmethods which don't need to be
346 // findable by nmethod iterators! In particular, they must not contain oops!
347 void* operator new(size_t size, int nmethod_size, bool allow_NonNMethod_space) throw();
348
349 const char* reloc_string_for(u_char* begin, u_char* end);
350
351 bool try_transition(signed char new_state);
352
353 // Returns true if this thread changed the state of the nmethod or
472 // Sets this nmethod as strongly claimed (as part of N|SD -> X|SD and N|SR -> X|SD
473 // transitions).
474 void oops_do_set_strong_done(nmethod* old_head);
475
476 public:
477 // create nmethod with entry_bci
478 static nmethod* new_nmethod(const methodHandle& method,
479 int compile_id,
480 int entry_bci,
481 CodeOffsets* offsets,
482 int orig_pc_offset,
483 DebugInformationRecorder* recorder,
484 Dependencies* dependencies,
485 CodeBuffer *code_buffer,
486 int frame_size,
487 OopMapSet* oop_maps,
488 ExceptionHandlerTable* handler_table,
489 ImplicitExceptionTable* nul_chk_table,
490 AbstractCompiler* compiler,
491 CompLevel comp_level
492 #if INCLUDE_JVMCI
493 , char* speculations = nullptr,
494 int speculations_len = 0,
495 JVMCINMethodData* jvmci_data = nullptr
496 #endif
497 );
498
499 static nmethod* new_native_nmethod(const methodHandle& method,
500 int compile_id,
501 CodeBuffer *code_buffer,
502 int vep_offset,
503 int frame_complete,
504 int frame_size,
505 ByteSize receiver_sp_offset,
506 ByteSize basic_lock_sp_offset,
507 OopMapSet* oop_maps,
508 int exception_handler = -1);
509
510 Method* method () const { return _method; }
511 bool is_native_method() const { return _method != nullptr && _method->is_native(); }
612 address verified_entry_point() const { return code_begin() + _verified_entry_offset; } // if klass is correct
613
614 enum : signed char { not_installed = -1, // in construction, only the owner doing the construction is
615 // allowed to advance state
616 in_use = 0, // executable nmethod
617 not_entrant = 1 // marked for deoptimization but activations may still exist
618 };
619
620 // flag accessing and manipulation
621 bool is_not_installed() const { return _state == not_installed; }
622 bool is_in_use() const { return _state <= in_use; }
623 bool is_not_entrant() const { return _state == not_entrant; }
624 int get_state() const { return _state; }
625
626 void clear_unloading_state();
627 // Heuristically deduce an nmethod isn't worth keeping around
628 bool is_cold();
629 bool is_unloading();
630 void do_unloading(bool unloading_occurred);
631
632 #if INCLUDE_RTM_OPT
633 // rtm state accessing and manipulating
634 RTMState rtm_state() const { return _rtm_state; }
635 void set_rtm_state(RTMState state) { _rtm_state = state; }
636 #endif
637
638 bool make_in_use() {
639 return try_transition(in_use);
640 }
641 // Make the nmethod non entrant. The nmethod will continue to be
642 // alive. It is used when an uncommon trap happens. Returns true
643 // if this thread changed the state of the nmethod or false if
644 // another thread performed the transition.
645 bool make_not_entrant();
646 bool make_not_used() { return make_not_entrant(); }
647
648 bool is_marked_for_deoptimization() const { return deoptimization_status() != not_marked; }
649 bool has_been_deoptimized() const { return deoptimization_status() == deoptimize_done; }
650 void set_deoptimized_done();
651
652 bool update_recompile_counts() const {
653 // Update recompile counts when either the update is explicitly requested (deoptimize)
654 // or the nmethod is not marked for deoptimization at all (not_marked).
655 // The latter happens during uncommon traps when deoptimized nmethod is made not entrant.
656 DeoptimizationStatus status = deoptimization_status();
657 return status != deoptimize_noupdate && status != deoptimize_done;
658 }
659
660 // tells whether frames described by this nmethod can be deoptimized
661 // note: native wrappers cannot be deoptimized.
662 bool can_be_deoptimized() const { return is_java_method(); }
663
664 bool has_dependencies() { return dependencies_size() != 0; }
665 void print_dependencies_on(outputStream* out) PRODUCT_RETURN;
666 void flush_dependencies();
667
668 template<typename T>
669 T* gc_data() const { return reinterpret_cast<T*>(_gc_data); }
670 template<typename T>
671 void set_gc_data(T* gc_data) { _gc_data = reinterpret_cast<void*>(gc_data); }
672
673 bool has_unsafe_access() const { return _has_unsafe_access; }
674 void set_has_unsafe_access(bool z) { _has_unsafe_access = z; }
675
676 bool has_monitors() const { return _has_monitors; }
677 void set_has_monitors(bool z) { _has_monitors = z; }
678
679 bool has_method_handle_invokes() const { return _has_method_handle_invokes; }
680 void set_has_method_handle_invokes(bool z) { _has_method_handle_invokes = z; }
681
682 bool has_wide_vectors() const { return _has_wide_vectors; }
683 void set_has_wide_vectors(bool z) { _has_wide_vectors = z; }
684
685 bool has_flushed_dependencies() const { return _has_flushed_dependencies; }
686 void set_has_flushed_dependencies(bool z) {
687 assert(!has_flushed_dependencies(), "should only happen once");
688 _has_flushed_dependencies = z;
689 }
690
691 bool is_unlinked() const { return _is_unlinked; }
692 void set_is_unlinked() {
693 assert(!_is_unlinked, "already unlinked");
694 _is_unlinked = true;
695 }
696
697 int comp_level() const { return _comp_level; }
698
699 // Support for oops in scopes and relocs:
700 // Note: index 0 is reserved for null.
701 oop oop_at(int index) const;
702 oop oop_at_phantom(int index) const; // phantom reference
703 oop* oop_addr_at(int index) const { // for GC
704 // relocation indexes are biased by 1 (because 0 is reserved)
883 // used by jvmti to track if the load events has been reported
884 bool load_reported() const { return _load_reported; }
885 void set_load_reported() { _load_reported = true; }
886
887 public:
888 // ScopeDesc retrieval operation
889 PcDesc* pc_desc_at(address pc) { return find_pc_desc(pc, false); }
890 // pc_desc_near returns the first PcDesc at or after the given pc.
891 PcDesc* pc_desc_near(address pc) { return find_pc_desc(pc, true); }
892
893 // ScopeDesc for an instruction
894 ScopeDesc* scope_desc_at(address pc);
895 ScopeDesc* scope_desc_near(address pc);
896
897 // copying of debugging information
898 void copy_scopes_pcs(PcDesc* pcs, int count);
899 void copy_scopes_data(address buffer, int size);
900
901 int orig_pc_offset() { return _orig_pc_offset; }
902
903 // Post successful compilation
904 void post_compiled_method(CompileTask* task);
905
906 // jvmti support:
907 void post_compiled_method_load_event(JvmtiThreadState* state = nullptr);
908
909 // verify operations
910 void verify() override;
911 void verify_scopes();
912 void verify_interrupt_point(address interrupt_point, bool is_inline_cache);
913
914 // Disassemble this nmethod with additional debug information, e.g. information about blocks.
915 void decode2(outputStream* st) const;
916 void print_constant_pool(outputStream* st);
917
918 // Avoid hiding of parent's 'decode(outputStream*)' method.
919 void decode(outputStream* st) const { decode2(st); } // just delegate here.
920
921 // printing support
922 void print() const override;
923 void print(outputStream* st) const;
924 void print_code();
925
926 #if defined(SUPPORT_DATA_STRUCTS)
927 // print output in opt build for disassembler library
928 void print_relocations() PRODUCT_RETURN;
929 void print_pcs_on(outputStream* st);
930 void print_scopes() { print_scopes_on(tty); }
931 void print_scopes_on(outputStream* st) PRODUCT_RETURN;
932 void print_value_on(outputStream* st) const override;
933 void print_handler_table();
934 void print_nul_chk_table();
935 void print_recorded_oop(int log_n, int index);
936 void print_recorded_oops();
937 void print_recorded_metadata();
938
939 void print_oops(outputStream* st); // oops from the underlying CodeBlob.
940 void print_metadata(outputStream* st); // metadata in metadata pool.
941 #else
942 void print_pcs_on(outputStream* st) { return; }
943 #endif
944
945 void print_calls(outputStream* st) PRODUCT_RETURN;
946 static void print_statistics() PRODUCT_RETURN;
947
948 void maybe_print_nmethod(const DirectiveSet* directive);
|
28 #include "code/codeBlob.hpp"
29 #include "code/pcDesc.hpp"
30 #include "oops/metadata.hpp"
31 #include "oops/method.hpp"
32
33 class AbstractCompiler;
34 class CompiledDirectCall;
35 class CompiledIC;
36 class CompiledICData;
37 class CompileTask;
38 class DepChange;
39 class Dependencies;
40 class DirectiveSet;
41 class DebugInformationRecorder;
42 class ExceptionHandlerTable;
43 class ImplicitExceptionTable;
44 class JvmtiThreadState;
45 class MetadataClosure;
46 class NativeCallWrapper;
47 class OopIterateClosure;
48 class SCCEntry;
49 class ScopeDesc;
50 class xmlStream;
51
52 // This class is used internally by nmethods, to cache
53 // exception/pc/handler information.
54
55 class ExceptionCache : public CHeapObj<mtCode> {
56 friend class VMStructs;
57 private:
58 enum { cache_size = 16 };
59 Klass* _exception_type;
60 address _pc[cache_size];
61 address _handler[cache_size];
62 volatile int _count;
63 ExceptionCache* volatile _next;
64 ExceptionCache* _purge_list_next;
65
66 inline address pc_at(int index);
67 void set_pc_at(int index, address a) { assert(index >= 0 && index < cache_size,""); _pc[index] = a; }
68
159
160 #if INCLUDE_JVMCI
161 class FailedSpeculation;
162 class JVMCINMethodData;
163 #endif
164
165 class nmethod : public CodeBlob {
166 friend class VMStructs;
167 friend class JVMCIVMStructs;
168 friend class CodeCache; // scavengable oops
169 friend class JVMCINMethodData;
170 friend class DeoptimizationScope;
171
172 private:
173
174 // Used to track in which deoptimize handshake this method will be deoptimized.
175 uint64_t _deoptimization_generation;
176
177 uint64_t _gc_epoch;
178
179 // Profiling counter used to figure out the hottest nmethods to record into CDS
180 volatile uint64_t _method_profiling_count;
181
182 Method* _method;
183
184 // To reduce header size union fields which usages do not overlap.
185 union {
186 // To support simple linked-list chaining of nmethods:
187 nmethod* _osr_link; // from InstanceKlass::osr_nmethods_head
188 struct {
189 // These are used for compiled synchronized native methods to
190 // locate the owner and stack slot for the BasicLock. They are
191 // needed because there is no debug information for compiled native
192 // wrappers and the oop maps are insufficient to allow
193 // frame::retrieve_receiver() to work. Currently they are expected
194 // to be byte offsets from the Java stack pointer for maximum code
195 // sharing between platforms. JVMTI's GetLocalInstance() uses these
196 // offsets to find the receiver for non-static native wrapper frames.
197 ByteSize _native_receiver_sp_offset;
198 ByteSize _native_basic_lock_sp_offset;
199 };
200 };
201
253 int _scopes_pcs_offset;
254 int _scopes_data_offset;
255 #if INCLUDE_JVMCI
256 int _speculations_offset;
257 #endif
258
259 // location in frame (offset for sp) that deopt can store the original
260 // pc during a deopt.
261 int _orig_pc_offset;
262
263 int _compile_id; // which compilation made this nmethod
264 CompLevel _comp_level; // compilation level (s1)
265 CompilerType _compiler_type; // which compiler made this nmethod (u1)
266
267 #if INCLUDE_RTM_OPT
268 // RTM state at compile time. Used during deoptimization to decide
269 // whether to restart collecting RTM locking abort statistic again.
270 RTMState _rtm_state;
271 #endif
272
273 SCCEntry* _scc_entry;
274
275 bool _used; // has this nmethod ever been invoked?
276
277 // Local state used to keep track of whether unloading is happening or not
278 volatile uint8_t _is_unloading_state;
279
280 // Protected by NMethodState_lock
281 volatile signed char _state; // {not_installed, in_use, not_entrant}
282
283 // set during construction
284 uint8_t _has_unsafe_access:1, // May fault due to unsafe access.
285 _has_method_handle_invokes:1,// Has this method MethodHandle invokes?
286 _has_wide_vectors:1, // Preserve wide vectors at safepoints
287 _has_monitors:1, // Fastpath monitor detection for continuations
288 _has_flushed_dependencies:1, // Used for maintenance of dependencies (under CodeCache_lock)
289 _is_unlinked:1, // mark during class unloading
290 _load_reported:1, // used by jvmti to track if an event has been posted for this nmethod
291 _preloaded:1,
292 _has_clinit_barriers:1;
293
294 enum DeoptimizationStatus : u1 {
295 not_marked,
296 deoptimize,
297 deoptimize_noupdate,
298 deoptimize_done
299 };
300
301 volatile DeoptimizationStatus _deoptimization_status; // Used for stack deoptimization
302
303 DeoptimizationStatus deoptimization_status() const {
304 return Atomic::load(&_deoptimization_status);
305 }
306
307 // Initialize fields to their default values
308 void init_defaults(CodeBuffer *code_buffer, CodeOffsets* offsets);
309
310 // Post initialization
311 void post_init();
312
324
325 // For normal JIT compiled code
326 nmethod(Method* method,
327 CompilerType type,
328 int nmethod_size,
329 int immutable_data_size,
330 int compile_id,
331 int entry_bci,
332 address immutable_data,
333 CodeOffsets* offsets,
334 int orig_pc_offset,
335 DebugInformationRecorder *recorder,
336 Dependencies* dependencies,
337 CodeBuffer *code_buffer,
338 int frame_size,
339 OopMapSet* oop_maps,
340 ExceptionHandlerTable* handler_table,
341 ImplicitExceptionTable* nul_chk_table,
342 AbstractCompiler* compiler,
343 CompLevel comp_level
344 , SCCEntry* scc_entry
345 #if INCLUDE_JVMCI
346 , char* speculations = nullptr,
347 int speculations_len = 0,
348 JVMCINMethodData* jvmci_data = nullptr
349 #endif
350 );
351
352 // helper methods
353 void* operator new(size_t size, int nmethod_size, int comp_level) throw();
354
355 // For method handle intrinsics: Try MethodNonProfiled, MethodProfiled and NonNMethod.
356 // Attention: Only allow NonNMethod space for special nmethods which don't need to be
357 // findable by nmethod iterators! In particular, they must not contain oops!
358 void* operator new(size_t size, int nmethod_size, bool allow_NonNMethod_space) throw();
359
360 const char* reloc_string_for(u_char* begin, u_char* end);
361
362 bool try_transition(signed char new_state);
363
364 // Returns true if this thread changed the state of the nmethod or
483 // Sets this nmethod as strongly claimed (as part of N|SD -> X|SD and N|SR -> X|SD
484 // transitions).
485 void oops_do_set_strong_done(nmethod* old_head);
486
487 public:
488 // create nmethod with entry_bci
489 static nmethod* new_nmethod(const methodHandle& method,
490 int compile_id,
491 int entry_bci,
492 CodeOffsets* offsets,
493 int orig_pc_offset,
494 DebugInformationRecorder* recorder,
495 Dependencies* dependencies,
496 CodeBuffer *code_buffer,
497 int frame_size,
498 OopMapSet* oop_maps,
499 ExceptionHandlerTable* handler_table,
500 ImplicitExceptionTable* nul_chk_table,
501 AbstractCompiler* compiler,
502 CompLevel comp_level
503 , SCCEntry* scc_entry
504 #if INCLUDE_JVMCI
505 , char* speculations = nullptr,
506 int speculations_len = 0,
507 JVMCINMethodData* jvmci_data = nullptr
508 #endif
509 );
510
511 static nmethod* new_native_nmethod(const methodHandle& method,
512 int compile_id,
513 CodeBuffer *code_buffer,
514 int vep_offset,
515 int frame_complete,
516 int frame_size,
517 ByteSize receiver_sp_offset,
518 ByteSize basic_lock_sp_offset,
519 OopMapSet* oop_maps,
520 int exception_handler = -1);
521
522 Method* method () const { return _method; }
523 bool is_native_method() const { return _method != nullptr && _method->is_native(); }
624 address verified_entry_point() const { return code_begin() + _verified_entry_offset; } // if klass is correct
625
626 enum : signed char { not_installed = -1, // in construction, only the owner doing the construction is
627 // allowed to advance state
628 in_use = 0, // executable nmethod
629 not_entrant = 1 // marked for deoptimization but activations may still exist
630 };
631
632 // flag accessing and manipulation
633 bool is_not_installed() const { return _state == not_installed; }
634 bool is_in_use() const { return _state <= in_use; }
635 bool is_not_entrant() const { return _state == not_entrant; }
636 int get_state() const { return _state; }
637
638 void clear_unloading_state();
639 // Heuristically deduce an nmethod isn't worth keeping around
640 bool is_cold();
641 bool is_unloading();
642 void do_unloading(bool unloading_occurred);
643
644 void inc_method_profiling_count();
645 uint64_t method_profiling_count();
646
647 #if INCLUDE_RTM_OPT
648 // rtm state accessing and manipulating
649 RTMState rtm_state() const { return _rtm_state; }
650 void set_rtm_state(RTMState state) { _rtm_state = state; }
651 #endif
652
653 bool make_in_use() {
654 return try_transition(in_use);
655 }
656 // Make the nmethod non entrant. The nmethod will continue to be
657 // alive. It is used when an uncommon trap happens. Returns true
658 // if this thread changed the state of the nmethod or false if
659 // another thread performed the transition.
660 bool make_not_entrant(bool make_not_entrant = true);
661 bool make_not_used() { return make_not_entrant(false); }
662
663 bool is_marked_for_deoptimization() const { return deoptimization_status() != not_marked; }
664 bool has_been_deoptimized() const { return deoptimization_status() == deoptimize_done; }
665 void set_deoptimized_done();
666
667 bool update_recompile_counts() const {
668 // Update recompile counts when either the update is explicitly requested (deoptimize)
669 // or the nmethod is not marked for deoptimization at all (not_marked).
670 // The latter happens during uncommon traps when deoptimized nmethod is made not entrant.
671 DeoptimizationStatus status = deoptimization_status();
672 return status != deoptimize_noupdate && status != deoptimize_done;
673 }
674
675 // tells whether frames described by this nmethod can be deoptimized
676 // note: native wrappers cannot be deoptimized.
677 bool can_be_deoptimized() const { return is_java_method(); }
678
679 bool has_dependencies() { return dependencies_size() != 0; }
680 void print_dependencies_on(outputStream* out) PRODUCT_RETURN;
681 void flush_dependencies();
682
683 template<typename T>
684 T* gc_data() const { return reinterpret_cast<T*>(_gc_data); }
685 template<typename T>
686 void set_gc_data(T* gc_data) { _gc_data = reinterpret_cast<void*>(gc_data); }
687
688 bool has_unsafe_access() const { return _has_unsafe_access; }
689 void set_has_unsafe_access(bool z) { _has_unsafe_access = z; }
690
691 bool has_monitors() const { return _has_monitors; }
692 void set_has_monitors(bool z) { _has_monitors = z; }
693
694 bool has_method_handle_invokes() const { return _has_method_handle_invokes; }
695 void set_has_method_handle_invokes(bool z) { _has_method_handle_invokes = z; }
696
697 bool has_wide_vectors() const { return _has_wide_vectors; }
698 void set_has_wide_vectors(bool z) { _has_wide_vectors = z; }
699
700 bool has_clinit_barriers() const { return _has_clinit_barriers; }
701 void set_has_clinit_barriers(bool z) { _has_clinit_barriers = z; }
702
703 bool preloaded() const { return _preloaded; }
704 void set_preloaded(bool z) { _preloaded = z; }
705
706 bool has_flushed_dependencies() const { return _has_flushed_dependencies; }
707 void set_has_flushed_dependencies(bool z) {
708 assert(!has_flushed_dependencies(), "should only happen once");
709 _has_flushed_dependencies = z;
710 }
711
712 bool is_unlinked() const { return _is_unlinked; }
713 void set_is_unlinked() {
714 assert(!_is_unlinked, "already unlinked");
715 _is_unlinked = true;
716 }
717
718 int comp_level() const { return _comp_level; }
719
720 // Support for oops in scopes and relocs:
721 // Note: index 0 is reserved for null.
722 oop oop_at(int index) const;
723 oop oop_at_phantom(int index) const; // phantom reference
724 oop* oop_addr_at(int index) const { // for GC
725 // relocation indexes are biased by 1 (because 0 is reserved)
904 // used by jvmti to track if the load events has been reported
905 bool load_reported() const { return _load_reported; }
906 void set_load_reported() { _load_reported = true; }
907
908 public:
909 // ScopeDesc retrieval operation
910 PcDesc* pc_desc_at(address pc) { return find_pc_desc(pc, false); }
911 // pc_desc_near returns the first PcDesc at or after the given pc.
912 PcDesc* pc_desc_near(address pc) { return find_pc_desc(pc, true); }
913
914 // ScopeDesc for an instruction
915 ScopeDesc* scope_desc_at(address pc);
916 ScopeDesc* scope_desc_near(address pc);
917
918 // copying of debugging information
919 void copy_scopes_pcs(PcDesc* pcs, int count);
920 void copy_scopes_data(address buffer, int size);
921
922 int orig_pc_offset() { return _orig_pc_offset; }
923
924 SCCEntry* scc_entry() const { return _scc_entry; }
925 bool is_scc() const { return scc_entry() != nullptr; }
926
927 bool used() const { return _used; }
928 void set_used() { _used = true; }
929
930 // Post successful compilation
931 void post_compiled_method(CompileTask* task);
932
933 // jvmti support:
934 void post_compiled_method_load_event(JvmtiThreadState* state = nullptr);
935
936 // verify operations
937 void verify() override;
938 void verify_scopes();
939 void verify_interrupt_point(address interrupt_point, bool is_inline_cache);
940
941 // Disassemble this nmethod with additional debug information, e.g. information about blocks.
942 void decode2(outputStream* st) const;
943 void print_constant_pool(outputStream* st);
944
945 // Avoid hiding of parent's 'decode(outputStream*)' method.
946 void decode(outputStream* st) const { decode2(st); } // just delegate here.
947
948 // printing support
949 void print() const override;
950 void print(outputStream* st) const;
951 void print_code();
952
953 #if defined(SUPPORT_DATA_STRUCTS)
954 // print output in opt build for disassembler library
955 void print_relocations_on(outputStream* st) PRODUCT_RETURN;
956 void print_pcs_on(outputStream* st);
957 void print_scopes() { print_scopes_on(tty); }
958 void print_scopes_on(outputStream* st) PRODUCT_RETURN;
959 void print_value_on(outputStream* st) const override;
960 void print_handler_table();
961 void print_nul_chk_table();
962 void print_recorded_oop(int log_n, int index);
963 void print_recorded_oops();
964 void print_recorded_metadata();
965
966 void print_oops(outputStream* st); // oops from the underlying CodeBlob.
967 void print_metadata(outputStream* st); // metadata in metadata pool.
968 #else
969 void print_pcs_on(outputStream* st) { return; }
970 #endif
971
972 void print_calls(outputStream* st) PRODUCT_RETURN;
973 static void print_statistics() PRODUCT_RETURN;
974
975 void maybe_print_nmethod(const DirectiveSet* directive);
|