< prev index next >

src/hotspot/share/code/nmethod.hpp

Print this page

  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 

 243 #endif
 244 
 245   // Offset in immutable data section
 246   // _dependencies_offset == 0
 247   uint16_t _nul_chk_table_offset;
 248   uint16_t _handler_table_offset; // This table could be big in C1 code
 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   // Local state used to keep track of whether unloading is happening or not
 264   volatile uint8_t _is_unloading_state;
 265 
 266   // Protected by NMethodState_lock
 267   volatile signed char _state;         // {not_installed, in_use, not_entrant}
 268 
 269   // set during construction
 270   uint8_t _has_unsafe_access:1,        // May fault due to unsafe access.
 271           _has_method_handle_invokes:1,// Has this method MethodHandle invokes?
 272           _has_wide_vectors:1,         // Preserve wide vectors at safepoints
 273           _has_monitors:1,             // Fastpath monitor detection for continuations
 274           _has_scoped_access:1,        // used by for shared scope closure (scopedMemoryAccess.cpp)
 275           _has_flushed_dependencies:1, // Used for maintenance of dependencies (under CodeCache_lock)
 276           _is_unlinked:1,              // mark during class unloading
 277           _load_reported:1;            // used by jvmti to track if an event has been posted for this nmethod


 278 
 279   enum DeoptimizationStatus : u1 {
 280     not_marked,
 281     deoptimize,
 282     deoptimize_noupdate,
 283     deoptimize_done
 284   };
 285 
 286   volatile DeoptimizationStatus _deoptimization_status; // Used for stack deoptimization
 287 
 288   DeoptimizationStatus deoptimization_status() const {
 289     return Atomic::load(&_deoptimization_status);
 290   }
 291 
 292   // Initialize fields to their default values
 293   void init_defaults(CodeBuffer *code_buffer, CodeOffsets* offsets);
 294 
 295   // Post initialization
 296   void post_init();
 297 

 311   // For normal JIT compiled code
 312   nmethod(Method* method,
 313           CompilerType type,
 314           int nmethod_size,
 315           int immutable_data_size,
 316           int mutable_data_size,
 317           int compile_id,
 318           int entry_bci,
 319           address immutable_data,
 320           CodeOffsets* offsets,
 321           int orig_pc_offset,
 322           DebugInformationRecorder *recorder,
 323           Dependencies* dependencies,
 324           CodeBuffer *code_buffer,
 325           int frame_size,
 326           OopMapSet* oop_maps,
 327           ExceptionHandlerTable* handler_table,
 328           ImplicitExceptionTable* nul_chk_table,
 329           AbstractCompiler* compiler,
 330           CompLevel comp_level

 331 #if INCLUDE_JVMCI
 332           , char* speculations = nullptr,
 333           int speculations_len = 0,
 334           JVMCINMethodData* jvmci_data = nullptr
 335 #endif
 336           );
 337 
 338   // helper methods
 339   void* operator new(size_t size, int nmethod_size, int comp_level) throw();
 340 
 341   // For method handle intrinsics: Try MethodNonProfiled, MethodProfiled and NonNMethod.
 342   // Attention: Only allow NonNMethod space for special nmethods which don't need to be
 343   // findable by nmethod iterators! In particular, they must not contain oops!
 344   void* operator new(size_t size, int nmethod_size, bool allow_NonNMethod_space) throw();
 345 
 346   const char* reloc_string_for(u_char* begin, u_char* end);
 347 
 348   bool try_transition(signed char new_state);
 349 
 350   // Returns true if this thread changed the state of the nmethod or

 453   // Attempt Unclaimed -> N|WR transition. Returns true if successful.
 454   bool oops_do_try_claim_weak_request();
 455 
 456   // Attempt Unclaimed -> N|SD transition. Returns the current link.
 457   oops_do_mark_link* oops_do_try_claim_strong_done();
 458   // Attempt N|WR -> X|WD transition. Returns nullptr if successful, X otherwise.
 459   nmethod* oops_do_try_add_to_list_as_weak_done();
 460 
 461   // Attempt X|WD -> N|SR transition. Returns the current link.
 462   oops_do_mark_link* oops_do_try_add_strong_request(oops_do_mark_link* next);
 463   // Attempt X|WD -> X|SD transition. Returns true if successful.
 464   bool oops_do_try_claim_weak_done_as_strong_done(oops_do_mark_link* next);
 465 
 466   // Do the N|SD -> X|SD transition.
 467   void oops_do_add_to_list_as_strong_done();
 468 
 469   // Sets this nmethod as strongly claimed (as part of N|SD -> X|SD and N|SR -> X|SD
 470   // transitions).
 471   void oops_do_set_strong_done(nmethod* old_head);
 472 


















 473 public:


















 474   // create nmethod with entry_bci
 475   static nmethod* new_nmethod(const methodHandle& method,
 476                               int compile_id,
 477                               int entry_bci,
 478                               CodeOffsets* offsets,
 479                               int orig_pc_offset,
 480                               DebugInformationRecorder* recorder,
 481                               Dependencies* dependencies,
 482                               CodeBuffer *code_buffer,
 483                               int frame_size,
 484                               OopMapSet* oop_maps,
 485                               ExceptionHandlerTable* handler_table,
 486                               ImplicitExceptionTable* nul_chk_table,
 487                               AbstractCompiler* compiler,
 488                               CompLevel comp_level

 489 #if INCLUDE_JVMCI
 490                               , char* speculations = nullptr,
 491                               int speculations_len = 0,
 492                               JVMCINMethodData* jvmci_data = nullptr
 493 #endif
 494   );
 495 
 496   static nmethod* new_native_nmethod(const methodHandle& method,
 497                                      int compile_id,
 498                                      CodeBuffer *code_buffer,
 499                                      int vep_offset,
 500                                      int frame_complete,
 501                                      int frame_size,
 502                                      ByteSize receiver_sp_offset,
 503                                      ByteSize basic_lock_sp_offset,
 504                                      OopMapSet* oop_maps,
 505                                      int exception_handler = -1);
 506 
 507   Method* method       () const { return _method; }

 508   bool is_native_method() const { return _method != nullptr && _method->is_native(); }
 509   bool is_java_method  () const { return _method != nullptr && !_method->is_native(); }
 510   bool is_osr_method   () const { return _entry_bci != InvocationEntryBci; }
 511 
 512   // Compiler task identification.  Note that all OSR methods
 513   // are numbered in an independent sequence if CICountOSR is true,
 514   // and native method wrappers are also numbered independently if
 515   // CICountNative is true.
 516   int compile_id() const { return _compile_id; }
 517   const char* compile_kind() const;
 518 
 519   inline bool  is_compiled_by_c1   () const { return _compiler_type == compiler_c1; }
 520   inline bool  is_compiled_by_c2   () const { return _compiler_type == compiler_c2; }
 521   inline bool  is_compiled_by_jvmci() const { return _compiler_type == compiler_jvmci; }
 522   CompilerType compiler_type       () const { return _compiler_type; }
 523   const char*  compiler_name       () const;
 524 
 525   // boundaries for different parts
 526   address consts_begin          () const { return           content_begin(); }
 527   address consts_end            () const { return           code_begin()   ; }
 528   address insts_begin           () const { return           code_begin()   ; }
 529   address insts_end             () const { return           header_begin() + _stub_offset             ; }
 530   address stub_begin            () const { return           header_begin() + _stub_offset             ; }
 531   address stub_end              () const { return           code_end()     ; }
 532   address exception_begin       () const { return           header_begin() + _exception_offset        ; }
 533   address deopt_handler_begin   () const { return           header_begin() + _deopt_handler_offset    ; }
 534   address deopt_mh_handler_begin() const { return           header_begin() + _deopt_mh_handler_offset ; }
 535   address unwind_handler_begin  () const { return _unwind_handler_offset != -1 ? (insts_end() - _unwind_handler_offset) : nullptr; }
 536   oop*    oops_begin            () const { return (oop*)    data_begin(); }
 537   oop*    oops_end              () const { return (oop*)    data_end(); }
 538 
 539   // mutable data
 540   Metadata** metadata_begin     () const { return (Metadata**) (mutable_data_begin() + _relocation_size); }
 541 #if INCLUDE_JVMCI
 542   Metadata** metadata_end       () const { return (Metadata**) (mutable_data_begin() + _relocation_size + _metadata_size); }
 543   address jvmci_data_begin      () const { return               mutable_data_begin() + _relocation_size + _metadata_size; }
 544   address jvmci_data_end        () const { return               mutable_data_end(); }
 545 #else
 546   Metadata** metadata_end       () const { return (Metadata**)  mutable_data_end(); }
 547 #endif
 548 
 549   // immutable data

 550   address immutable_data_begin  () const { return           _immutable_data; }
 551   address immutable_data_end    () const { return           _immutable_data + _immutable_data_size ; }
 552   address dependencies_begin    () const { return           _immutable_data; }
 553   address dependencies_end      () const { return           _immutable_data + _nul_chk_table_offset; }
 554   address nul_chk_table_begin   () const { return           _immutable_data + _nul_chk_table_offset; }
 555   address nul_chk_table_end     () const { return           _immutable_data + _handler_table_offset; }
 556   address handler_table_begin   () const { return           _immutable_data + _handler_table_offset; }
 557   address handler_table_end     () const { return           _immutable_data + _scopes_pcs_offset   ; }
 558   PcDesc* scopes_pcs_begin      () const { return (PcDesc*)(_immutable_data + _scopes_pcs_offset)  ; }
 559   PcDesc* scopes_pcs_end        () const { return (PcDesc*)(_immutable_data + _scopes_data_offset) ; }
 560   address scopes_data_begin     () const { return           _immutable_data + _scopes_data_offset  ; }
 561 
 562 #if INCLUDE_JVMCI
 563   address scopes_data_end       () const { return           _immutable_data + _speculations_offset ; }
 564   address speculations_begin    () const { return           _immutable_data + _speculations_offset ; }
 565   address speculations_end      () const { return            immutable_data_end(); }
 566 #else
 567   address scopes_data_end       () const { return            immutable_data_end(); }
 568 #endif
 569 

 609   address verified_entry_point() const { return code_begin() + _verified_entry_offset; } // if klass is correct
 610 
 611   enum : signed char { not_installed = -1, // in construction, only the owner doing the construction is
 612                                            // allowed to advance state
 613                        in_use        = 0,  // executable nmethod
 614                        not_entrant   = 1   // marked for deoptimization but activations may still exist
 615   };
 616 
 617   // flag accessing and manipulation
 618   bool is_not_installed() const        { return _state == not_installed; }
 619   bool is_in_use() const               { return _state <= in_use; }
 620   bool is_not_entrant() const          { return _state == not_entrant; }
 621   int  get_state() const               { return _state; }
 622 
 623   void clear_unloading_state();
 624   // Heuristically deduce an nmethod isn't worth keeping around
 625   bool is_cold();
 626   bool is_unloading();
 627   void do_unloading(bool unloading_occurred);
 628 



 629   bool make_in_use() {
 630     return try_transition(in_use);
 631   }
 632   // Make the nmethod non entrant. The nmethod will continue to be
 633   // alive.  It is used when an uncommon trap happens.  Returns true
 634   // if this thread changed the state of the nmethod or false if
 635   // another thread performed the transition.
 636   bool  make_not_entrant(const char* reason);
 637   bool  make_not_used()    { return make_not_entrant("not used"); }
 638 
 639   bool  is_marked_for_deoptimization() const { return deoptimization_status() != not_marked; }
 640   bool  has_been_deoptimized() const { return deoptimization_status() == deoptimize_done; }
 641   void  set_deoptimized_done();
 642 
 643   bool update_recompile_counts() const {
 644     // Update recompile counts when either the update is explicitly requested (deoptimize)
 645     // or the nmethod is not marked for deoptimization at all (not_marked).
 646     // The latter happens during uncommon traps when deoptimized nmethod is made not entrant.
 647     DeoptimizationStatus status = deoptimization_status();
 648     return status != deoptimize_noupdate && status != deoptimize_done;
 649   }
 650 
 651   // tells whether frames described by this nmethod can be deoptimized
 652   // note: native wrappers cannot be deoptimized.
 653   bool can_be_deoptimized() const { return is_java_method(); }
 654 
 655   bool has_dependencies()                         { return dependencies_size() != 0; }
 656   void print_dependencies_on(outputStream* out) PRODUCT_RETURN;

 659   template<typename T>
 660   T* gc_data() const                              { return reinterpret_cast<T*>(_gc_data); }
 661   template<typename T>
 662   void set_gc_data(T* gc_data)                    { _gc_data = reinterpret_cast<void*>(gc_data); }
 663 
 664   bool  has_unsafe_access() const                 { return _has_unsafe_access; }
 665   void  set_has_unsafe_access(bool z)             { _has_unsafe_access = z; }
 666 
 667   bool  has_monitors() const                      { return _has_monitors; }
 668   void  set_has_monitors(bool z)                  { _has_monitors = z; }
 669 
 670   bool  has_scoped_access() const                 { return _has_scoped_access; }
 671   void  set_has_scoped_access(bool z)             { _has_scoped_access = z; }
 672 
 673   bool  has_method_handle_invokes() const         { return _has_method_handle_invokes; }
 674   void  set_has_method_handle_invokes(bool z)     { _has_method_handle_invokes = z; }
 675 
 676   bool  has_wide_vectors() const                  { return _has_wide_vectors; }
 677   void  set_has_wide_vectors(bool z)              { _has_wide_vectors = z; }
 678 






 679   bool  has_flushed_dependencies() const          { return _has_flushed_dependencies; }
 680   void  set_has_flushed_dependencies(bool z)      {
 681     assert(!has_flushed_dependencies(), "should only happen once");
 682     _has_flushed_dependencies = z;
 683   }
 684 
 685   bool  is_unlinked() const                       { return _is_unlinked; }
 686   void  set_is_unlinked()                         {
 687      assert(!_is_unlinked, "already unlinked");
 688       _is_unlinked = true;
 689   }
 690 
 691   int   comp_level() const                        { return _comp_level; }
 692 
 693   // Support for oops in scopes and relocs:
 694   // Note: index 0 is reserved for null.
 695   oop   oop_at(int index) const;
 696   oop   oop_at_phantom(int index) const; // phantom reference
 697   oop*  oop_addr_at(int index) const {  // for GC
 698     // relocation indexes are biased by 1 (because 0 is reserved)
 699     assert(index > 0 && index <= oops_count(), "must be a valid non-zero index");
 700     return &oops_begin()[index - 1];
 701   }
 702 
 703   // Support for meta data in scopes and relocs:
 704   // Note: index 0 is reserved for null.
 705   Metadata*   metadata_at(int index) const      { return index == 0 ? nullptr: *metadata_addr_at(index); }
 706   Metadata**  metadata_addr_at(int index) const {  // for GC
 707     // relocation indexes are biased by 1 (because 0 is reserved)
 708     assert(index > 0 && index <= metadata_count(), "must be a valid non-zero index");
 709     return &metadata_begin()[index - 1];
 710   }
 711 

 712   void copy_values(GrowableArray<jobject>* oops);
 713   void copy_values(GrowableArray<Metadata*>* metadata);
 714   void copy_values(GrowableArray<address>* metadata) {} // Nothing to do
 715 
 716   // Relocation support
 717 private:
 718   void fix_oop_relocations(address begin, address end, bool initialize_immediates);
 719   inline void initialize_immediate_oop(oop* dest, jobject handle);
 720 
 721 protected:
 722   address oops_reloc_begin() const;
 723 
 724 public:
 725   void fix_oop_relocations(address begin, address end) { fix_oop_relocations(begin, end, false); }
 726   void fix_oop_relocations()                           { fix_oop_relocations(nullptr, nullptr, false); }
 727 


 728   bool is_at_poll_return(address pc);
 729   bool is_at_poll_or_poll_return(address pc);
 730 
 731 protected:
 732   // Exception cache support
 733   // Note: _exception_cache may be read and cleaned concurrently.
 734   ExceptionCache* exception_cache() const         { return _exception_cache; }
 735   ExceptionCache* exception_cache_acquire() const;
 736 
 737 public:
 738   address handler_for_exception_and_pc(Handle exception, address pc);
 739   void add_handler_for_exception_and_pc(Handle exception, address pc, address handler);
 740   void clean_exception_cache();
 741 
 742   void add_exception_cache_entry(ExceptionCache* new_entry);
 743   ExceptionCache* exception_cache_entry_for_exception(Handle exception);
 744 
 745 
 746   // MethodHandle
 747   bool is_method_handle_return(address return_pc);

 878   // used by jvmti to track if the load events has been reported
 879   bool  load_reported() const                     { return _load_reported; }
 880   void  set_load_reported()                       { _load_reported = true; }
 881 
 882  public:
 883   // ScopeDesc retrieval operation
 884   PcDesc* pc_desc_at(address pc)   { return find_pc_desc(pc, false); }
 885   // pc_desc_near returns the first PcDesc at or after the given pc.
 886   PcDesc* pc_desc_near(address pc) { return find_pc_desc(pc, true); }
 887 
 888   // ScopeDesc for an instruction
 889   ScopeDesc* scope_desc_at(address pc);
 890   ScopeDesc* scope_desc_near(address pc);
 891 
 892   // copying of debugging information
 893   void copy_scopes_pcs(PcDesc* pcs, int count);
 894   void copy_scopes_data(address buffer, int size);
 895 
 896   int orig_pc_offset() { return _orig_pc_offset; }
 897 







 898   // Post successful compilation
 899   void post_compiled_method(CompileTask* task);
 900 
 901   // jvmti support:
 902   void post_compiled_method_load_event(JvmtiThreadState* state = nullptr);
 903 
 904   // verify operations
 905   void verify();
 906   void verify_scopes();
 907   void verify_interrupt_point(address interrupt_point, bool is_inline_cache);
 908 
 909   // Disassemble this nmethod with additional debug information, e.g. information about blocks.
 910   void decode2(outputStream* st) const;
 911   void print_constant_pool(outputStream* st);
 912 
 913   // Avoid hiding of parent's 'decode(outputStream*)' method.
 914   void decode(outputStream* st) const { decode2(st); } // just delegate here.
 915 
 916   // printing support
 917   void print_on_impl(outputStream* st) const;
 918   void print_code();
 919   void print_value_on_impl(outputStream* st) const;
 920 
 921 #if defined(SUPPORT_DATA_STRUCTS)
 922   // print output in opt build for disassembler library
 923   void print_relocations()                        PRODUCT_RETURN;
 924   void print_pcs_on(outputStream* st);
 925   void print_scopes() { print_scopes_on(tty); }
 926   void print_scopes_on(outputStream* st)          PRODUCT_RETURN;
 927   void print_handler_table();
 928   void print_nul_chk_table();
 929   void print_recorded_oop(int log_n, int index);
 930   void print_recorded_oops();
 931   void print_recorded_metadata();
 932 
 933   void print_oops(outputStream* st);     // oops from the underlying CodeBlob.
 934   void print_metadata(outputStream* st); // metadata in metadata pool.
 935 #else
 936   void print_pcs_on(outputStream* st) { return; }
 937 #endif
 938 
 939   void print_calls(outputStream* st)              PRODUCT_RETURN;
 940   static void print_statistics()                  PRODUCT_RETURN;
 941 
 942   void maybe_print_nmethod(const DirectiveSet* directive);
 943   void print_nmethod(bool print_code);

 971   ByteSize native_receiver_sp_offset() {
 972     assert(is_native_method(), "sanity");
 973     return _native_receiver_sp_offset;
 974   }
 975   ByteSize native_basic_lock_sp_offset() {
 976     assert(is_native_method(), "sanity");
 977     return _native_basic_lock_sp_offset;
 978   }
 979 
 980   // support for code generation
 981   static ByteSize osr_entry_point_offset() { return byte_offset_of(nmethod, _osr_entry_point); }
 982   static ByteSize state_offset()           { return byte_offset_of(nmethod, _state); }
 983 
 984   void metadata_do(MetadataClosure* f);
 985 
 986   address call_instruction_address(address pc) const;
 987 
 988   void make_deoptimized();
 989   void finalize_relocations();
 990 


 991   class Vptr : public CodeBlob::Vptr {
 992     void print_on(const CodeBlob* instance, outputStream* st) const override {
 993       ttyLocker ttyl;
 994       instance->as_nmethod()->print_on_impl(st);
 995     }
 996     void print_value_on(const CodeBlob* instance, outputStream* st) const override {
 997       instance->as_nmethod()->print_value_on_impl(st);
 998     }
 999   };
1000 
1001   static const Vptr _vpntr;
1002 };
1003 
1004 #endif // SHARE_CODE_NMETHOD_HPP

  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 AOTCodeReader;
  49 class AOTCodeEntry;
  50 class ScopeDesc;
  51 class xmlStream;
  52 
  53 // This class is used internally by nmethods, to cache
  54 // exception/pc/handler information.
  55 
  56 class ExceptionCache : public CHeapObj<mtCode> {
  57   friend class VMStructs;
  58  private:
  59   enum { cache_size = 16 };
  60   Klass*   _exception_type;
  61   address  _pc[cache_size];
  62   address  _handler[cache_size];
  63   volatile int _count;
  64   ExceptionCache* volatile _next;
  65   ExceptionCache* _purge_list_next;
  66 
  67   inline address pc_at(int index);
  68   void set_pc_at(int index, address a)      { assert(index >= 0 && index < cache_size,""); _pc[index] = a; }
  69 

 160 
 161 #if INCLUDE_JVMCI
 162 class FailedSpeculation;
 163 class JVMCINMethodData;
 164 #endif
 165 
 166 class nmethod : public CodeBlob {
 167   friend class VMStructs;
 168   friend class JVMCIVMStructs;
 169   friend class CodeCache;  // scavengable oops
 170   friend class JVMCINMethodData;
 171   friend class DeoptimizationScope;
 172 
 173  private:
 174 
 175   // Used to track in which deoptimize handshake this method will be deoptimized.
 176   uint64_t  _deoptimization_generation;
 177 
 178   uint64_t  _gc_epoch;
 179 
 180   // Profiling counter used to figure out the hottest nmethods to record into CDS
 181   volatile uint64_t _method_profiling_count;
 182 
 183   Method*   _method;
 184 
 185   // To reduce header size union fields which usages do not overlap.
 186   union {
 187     // To support simple linked-list chaining of nmethods:
 188     nmethod*  _osr_link; // from InstanceKlass::osr_nmethods_head
 189     struct {
 190       // These are used for compiled synchronized native methods to
 191       // locate the owner and stack slot for the BasicLock. They are
 192       // needed because there is no debug information for compiled native
 193       // wrappers and the oop maps are insufficient to allow
 194       // frame::retrieve_receiver() to work. Currently they are expected
 195       // to be byte offsets from the Java stack pointer for maximum code
 196       // sharing between platforms. JVMTI's GetLocalInstance() uses these
 197       // offsets to find the receiver for non-static native wrapper frames.
 198       ByteSize _native_receiver_sp_offset;
 199       ByteSize _native_basic_lock_sp_offset;
 200     };
 201   };
 202 

 248 #endif
 249 
 250   // Offset in immutable data section
 251   // _dependencies_offset == 0
 252   uint16_t _nul_chk_table_offset;
 253   uint16_t _handler_table_offset; // This table could be big in C1 code
 254   int      _scopes_pcs_offset;
 255   int      _scopes_data_offset;
 256 #if INCLUDE_JVMCI
 257   int      _speculations_offset;
 258 #endif
 259 
 260   // location in frame (offset for sp) that deopt can store the original
 261   // pc during a deopt.
 262   int _orig_pc_offset;
 263 
 264   int          _compile_id;            // which compilation made this nmethod
 265   CompLevel    _comp_level;            // compilation level (s1)
 266   CompilerType _compiler_type;         // which compiler made this nmethod (u1)
 267 
 268   AOTCodeEntry* _aot_code_entry;
 269 
 270   bool _used; // has this nmethod ever been invoked?
 271 
 272   // Local state used to keep track of whether unloading is happening or not
 273   volatile uint8_t _is_unloading_state;
 274 
 275   // Protected by NMethodState_lock
 276   volatile signed char _state;         // {not_installed, in_use, not_entrant}
 277 
 278   // set during construction
 279   uint8_t _has_unsafe_access:1,        // May fault due to unsafe access.
 280           _has_method_handle_invokes:1,// Has this method MethodHandle invokes?
 281           _has_wide_vectors:1,         // Preserve wide vectors at safepoints
 282           _has_monitors:1,             // Fastpath monitor detection for continuations
 283           _has_scoped_access:1,        // used by for shared scope closure (scopedMemoryAccess.cpp)
 284           _has_flushed_dependencies:1, // Used for maintenance of dependencies (under CodeCache_lock)
 285           _is_unlinked:1,              // mark during class unloading
 286           _load_reported:1,            // used by jvmti to track if an event has been posted for this nmethod
 287           _preloaded:1,
 288           _has_clinit_barriers:1;
 289 
 290   enum DeoptimizationStatus : u1 {
 291     not_marked,
 292     deoptimize,
 293     deoptimize_noupdate,
 294     deoptimize_done
 295   };
 296 
 297   volatile DeoptimizationStatus _deoptimization_status; // Used for stack deoptimization
 298 
 299   DeoptimizationStatus deoptimization_status() const {
 300     return Atomic::load(&_deoptimization_status);
 301   }
 302 
 303   // Initialize fields to their default values
 304   void init_defaults(CodeBuffer *code_buffer, CodeOffsets* offsets);
 305 
 306   // Post initialization
 307   void post_init();
 308 

 322   // For normal JIT compiled code
 323   nmethod(Method* method,
 324           CompilerType type,
 325           int nmethod_size,
 326           int immutable_data_size,
 327           int mutable_data_size,
 328           int compile_id,
 329           int entry_bci,
 330           address immutable_data,
 331           CodeOffsets* offsets,
 332           int orig_pc_offset,
 333           DebugInformationRecorder *recorder,
 334           Dependencies* dependencies,
 335           CodeBuffer *code_buffer,
 336           int frame_size,
 337           OopMapSet* oop_maps,
 338           ExceptionHandlerTable* handler_table,
 339           ImplicitExceptionTable* nul_chk_table,
 340           AbstractCompiler* compiler,
 341           CompLevel comp_level
 342           , AOTCodeEntry* aot_code_entry
 343 #if INCLUDE_JVMCI
 344           , char* speculations = nullptr,
 345           int speculations_len = 0,
 346           JVMCINMethodData* jvmci_data = nullptr
 347 #endif
 348           );
 349 
 350   // helper methods
 351   void* operator new(size_t size, int nmethod_size, int comp_level) throw();
 352 
 353   // For method handle intrinsics: Try MethodNonProfiled, MethodProfiled and NonNMethod.
 354   // Attention: Only allow NonNMethod space for special nmethods which don't need to be
 355   // findable by nmethod iterators! In particular, they must not contain oops!
 356   void* operator new(size_t size, int nmethod_size, bool allow_NonNMethod_space) throw();
 357 
 358   const char* reloc_string_for(u_char* begin, u_char* end);
 359 
 360   bool try_transition(signed char new_state);
 361 
 362   // Returns true if this thread changed the state of the nmethod or

 465   // Attempt Unclaimed -> N|WR transition. Returns true if successful.
 466   bool oops_do_try_claim_weak_request();
 467 
 468   // Attempt Unclaimed -> N|SD transition. Returns the current link.
 469   oops_do_mark_link* oops_do_try_claim_strong_done();
 470   // Attempt N|WR -> X|WD transition. Returns nullptr if successful, X otherwise.
 471   nmethod* oops_do_try_add_to_list_as_weak_done();
 472 
 473   // Attempt X|WD -> N|SR transition. Returns the current link.
 474   oops_do_mark_link* oops_do_try_add_strong_request(oops_do_mark_link* next);
 475   // Attempt X|WD -> X|SD transition. Returns true if successful.
 476   bool oops_do_try_claim_weak_done_as_strong_done(oops_do_mark_link* next);
 477 
 478   // Do the N|SD -> X|SD transition.
 479   void oops_do_add_to_list_as_strong_done();
 480 
 481   // Sets this nmethod as strongly claimed (as part of N|SD -> X|SD and N|SR -> X|SD
 482   // transitions).
 483   void oops_do_set_strong_done(nmethod* old_head);
 484 
 485   void record_nmethod_dependency();
 486 
 487   void restore_from_archive(nmethod* archived_nm,
 488                             const methodHandle& method,
 489                             int compile_id,
 490                             address reloc_data,
 491                             GrowableArray<Handle>& oop_list,
 492                             GrowableArray<Metadata*>& metadata_list,
 493                             ImmutableOopMapSet* oop_maps,
 494                             address immutable_data,
 495                             GrowableArray<Handle>& reloc_imm_oop_list,
 496                             GrowableArray<Metadata*>& reloc_imm_metadata_list,
 497 #ifndef PRODUCT
 498                             AsmRemarks& asm_remarks,
 499                             DbgStrings& dbg_strings,
 500 #endif /* PRODUCT */
 501                             AOTCodeReader* aot_code_reader);
 502 
 503 public:
 504   // create nmethod using archived nmethod from AOT code cache
 505   static nmethod* new_nmethod(nmethod* archived_nm,
 506                               const methodHandle& method,
 507                               AbstractCompiler* compiler,
 508                               int compile_id,
 509                               address reloc_data,
 510                               GrowableArray<Handle>& oop_list,
 511                               GrowableArray<Metadata*>& metadata_list,
 512                               ImmutableOopMapSet* oop_maps,
 513                               address immutable_data,
 514                               GrowableArray<Handle>& reloc_imm_oop_list,
 515                               GrowableArray<Metadata*>& reloc_imm_metadata_list,
 516 #ifndef PRODUCT
 517                               AsmRemarks& asm_remarks,
 518                               DbgStrings& dbg_strings,
 519 #endif /* PRODUCT */
 520                               AOTCodeReader* aot_code_reader);
 521 
 522   // create nmethod with entry_bci
 523   static nmethod* new_nmethod(const methodHandle& method,
 524                               int compile_id,
 525                               int entry_bci,
 526                               CodeOffsets* offsets,
 527                               int orig_pc_offset,
 528                               DebugInformationRecorder* recorder,
 529                               Dependencies* dependencies,
 530                               CodeBuffer *code_buffer,
 531                               int frame_size,
 532                               OopMapSet* oop_maps,
 533                               ExceptionHandlerTable* handler_table,
 534                               ImplicitExceptionTable* nul_chk_table,
 535                               AbstractCompiler* compiler,
 536                               CompLevel comp_level
 537                               , AOTCodeEntry* aot_code_entry
 538 #if INCLUDE_JVMCI
 539                               , char* speculations = nullptr,
 540                               int speculations_len = 0,
 541                               JVMCINMethodData* jvmci_data = nullptr
 542 #endif
 543   );
 544 
 545   static nmethod* new_native_nmethod(const methodHandle& method,
 546                                      int compile_id,
 547                                      CodeBuffer *code_buffer,
 548                                      int vep_offset,
 549                                      int frame_complete,
 550                                      int frame_size,
 551                                      ByteSize receiver_sp_offset,
 552                                      ByteSize basic_lock_sp_offset,
 553                                      OopMapSet* oop_maps,
 554                                      int exception_handler = -1);
 555 
 556   Method* method       () const { return _method; }
 557   uint16_t entry_bci   () const { return _entry_bci; }
 558   bool is_native_method() const { return _method != nullptr && _method->is_native(); }
 559   bool is_java_method  () const { return _method != nullptr && !_method->is_native(); }
 560   bool is_osr_method   () const { return _entry_bci != InvocationEntryBci; }
 561 
 562   // Compiler task identification.  Note that all OSR methods
 563   // are numbered in an independent sequence if CICountOSR is true,
 564   // and native method wrappers are also numbered independently if
 565   // CICountNative is true.
 566   int compile_id() const { return _compile_id; }
 567   const char* compile_kind() const;
 568 
 569   inline bool  is_compiled_by_c1   () const { return _compiler_type == compiler_c1; }
 570   inline bool  is_compiled_by_c2   () const { return _compiler_type == compiler_c2; }
 571   inline bool  is_compiled_by_jvmci() const { return _compiler_type == compiler_jvmci; }
 572   CompilerType compiler_type       () const { return _compiler_type; }
 573   const char*  compiler_name       () const;
 574 
 575   // boundaries for different parts
 576   address consts_begin          () const { return           content_begin(); }
 577   address consts_end            () const { return           code_begin()   ; }
 578   address insts_begin           () const { return           code_begin()   ; }
 579   address insts_end             () const { return           header_begin() + _stub_offset             ; }
 580   address stub_begin            () const { return           header_begin() + _stub_offset             ; }
 581   address stub_end              () const { return           code_end()     ; }
 582   address exception_begin       () const { return           header_begin() + _exception_offset        ; }
 583   address deopt_handler_begin   () const { return           header_begin() + _deopt_handler_offset    ; }
 584   address deopt_mh_handler_begin() const { return _deopt_mh_handler_offset != -1 ? (header_begin() + _deopt_mh_handler_offset) : nullptr; }
 585   address unwind_handler_begin  () const { return _unwind_handler_offset != -1 ? (insts_end() - _unwind_handler_offset) : nullptr; }
 586   oop*    oops_begin            () const { return (oop*)    data_begin(); }
 587   oop*    oops_end              () const { return (oop*)    data_end(); }
 588 
 589   // mutable data
 590   Metadata** metadata_begin     () const { return (Metadata**) (mutable_data_begin() + _relocation_size); }
 591 #if INCLUDE_JVMCI
 592   Metadata** metadata_end       () const { return (Metadata**) (mutable_data_begin() + _relocation_size + _metadata_size); }
 593   address jvmci_data_begin      () const { return               mutable_data_begin() + _relocation_size + _metadata_size; }
 594   address jvmci_data_end        () const { return               mutable_data_end(); }
 595 #else
 596   Metadata** metadata_end       () const { return (Metadata**)  mutable_data_end(); }
 597 #endif
 598 
 599   // immutable data
 600   void set_immutable_data(address data) { _immutable_data = data; }
 601   address immutable_data_begin  () const { return           _immutable_data; }
 602   address immutable_data_end    () const { return           _immutable_data + _immutable_data_size ; }
 603   address dependencies_begin    () const { return           _immutable_data; }
 604   address dependencies_end      () const { return           _immutable_data + _nul_chk_table_offset; }
 605   address nul_chk_table_begin   () const { return           _immutable_data + _nul_chk_table_offset; }
 606   address nul_chk_table_end     () const { return           _immutable_data + _handler_table_offset; }
 607   address handler_table_begin   () const { return           _immutable_data + _handler_table_offset; }
 608   address handler_table_end     () const { return           _immutable_data + _scopes_pcs_offset   ; }
 609   PcDesc* scopes_pcs_begin      () const { return (PcDesc*)(_immutable_data + _scopes_pcs_offset)  ; }
 610   PcDesc* scopes_pcs_end        () const { return (PcDesc*)(_immutable_data + _scopes_data_offset) ; }
 611   address scopes_data_begin     () const { return           _immutable_data + _scopes_data_offset  ; }
 612 
 613 #if INCLUDE_JVMCI
 614   address scopes_data_end       () const { return           _immutable_data + _speculations_offset ; }
 615   address speculations_begin    () const { return           _immutable_data + _speculations_offset ; }
 616   address speculations_end      () const { return            immutable_data_end(); }
 617 #else
 618   address scopes_data_end       () const { return            immutable_data_end(); }
 619 #endif
 620 

 660   address verified_entry_point() const { return code_begin() + _verified_entry_offset; } // if klass is correct
 661 
 662   enum : signed char { not_installed = -1, // in construction, only the owner doing the construction is
 663                                            // allowed to advance state
 664                        in_use        = 0,  // executable nmethod
 665                        not_entrant   = 1   // marked for deoptimization but activations may still exist
 666   };
 667 
 668   // flag accessing and manipulation
 669   bool is_not_installed() const        { return _state == not_installed; }
 670   bool is_in_use() const               { return _state <= in_use; }
 671   bool is_not_entrant() const          { return _state == not_entrant; }
 672   int  get_state() const               { return _state; }
 673 
 674   void clear_unloading_state();
 675   // Heuristically deduce an nmethod isn't worth keeping around
 676   bool is_cold();
 677   bool is_unloading();
 678   void do_unloading(bool unloading_occurred);
 679 
 680   void inc_method_profiling_count();
 681   uint64_t method_profiling_count();
 682 
 683   bool make_in_use() {
 684     return try_transition(in_use);
 685   }
 686   // Make the nmethod non entrant. The nmethod will continue to be
 687   // alive.  It is used when an uncommon trap happens.  Returns true
 688   // if this thread changed the state of the nmethod or false if
 689   // another thread performed the transition.
 690   bool  make_not_entrant(const char* reason, bool make_not_entrant = true);
 691   bool  make_not_used()    { return make_not_entrant("not used"); }
 692 
 693   bool  is_marked_for_deoptimization() const { return deoptimization_status() != not_marked; }
 694   bool  has_been_deoptimized() const { return deoptimization_status() == deoptimize_done; }
 695   void  set_deoptimized_done();
 696 
 697   bool update_recompile_counts() const {
 698     // Update recompile counts when either the update is explicitly requested (deoptimize)
 699     // or the nmethod is not marked for deoptimization at all (not_marked).
 700     // The latter happens during uncommon traps when deoptimized nmethod is made not entrant.
 701     DeoptimizationStatus status = deoptimization_status();
 702     return status != deoptimize_noupdate && status != deoptimize_done;
 703   }
 704 
 705   // tells whether frames described by this nmethod can be deoptimized
 706   // note: native wrappers cannot be deoptimized.
 707   bool can_be_deoptimized() const { return is_java_method(); }
 708 
 709   bool has_dependencies()                         { return dependencies_size() != 0; }
 710   void print_dependencies_on(outputStream* out) PRODUCT_RETURN;

 713   template<typename T>
 714   T* gc_data() const                              { return reinterpret_cast<T*>(_gc_data); }
 715   template<typename T>
 716   void set_gc_data(T* gc_data)                    { _gc_data = reinterpret_cast<void*>(gc_data); }
 717 
 718   bool  has_unsafe_access() const                 { return _has_unsafe_access; }
 719   void  set_has_unsafe_access(bool z)             { _has_unsafe_access = z; }
 720 
 721   bool  has_monitors() const                      { return _has_monitors; }
 722   void  set_has_monitors(bool z)                  { _has_monitors = z; }
 723 
 724   bool  has_scoped_access() const                 { return _has_scoped_access; }
 725   void  set_has_scoped_access(bool z)             { _has_scoped_access = z; }
 726 
 727   bool  has_method_handle_invokes() const         { return _has_method_handle_invokes; }
 728   void  set_has_method_handle_invokes(bool z)     { _has_method_handle_invokes = z; }
 729 
 730   bool  has_wide_vectors() const                  { return _has_wide_vectors; }
 731   void  set_has_wide_vectors(bool z)              { _has_wide_vectors = z; }
 732 
 733   bool  has_clinit_barriers() const               { return _has_clinit_barriers; }
 734   void  set_has_clinit_barriers(bool z)           { _has_clinit_barriers = z; }
 735 
 736   bool  preloaded() const                         { return _preloaded; }
 737   void  set_preloaded(bool z)                     { _preloaded = z; }
 738 
 739   bool  has_flushed_dependencies() const          { return _has_flushed_dependencies; }
 740   void  set_has_flushed_dependencies(bool z)      {
 741     assert(!has_flushed_dependencies(), "should only happen once");
 742     _has_flushed_dependencies = z;
 743   }
 744 
 745   bool  is_unlinked() const                       { return _is_unlinked; }
 746   void  set_is_unlinked()                         {
 747      assert(!_is_unlinked, "already unlinked");
 748       _is_unlinked = true;
 749   }
 750 
 751   int   comp_level() const                        { return _comp_level; }
 752 
 753   // Support for oops in scopes and relocs:
 754   // Note: index 0 is reserved for null.
 755   oop   oop_at(int index) const;
 756   oop   oop_at_phantom(int index) const; // phantom reference
 757   oop*  oop_addr_at(int index) const {  // for GC
 758     // relocation indexes are biased by 1 (because 0 is reserved)
 759     assert(index > 0 && index <= oops_count(), "must be a valid non-zero index");
 760     return &oops_begin()[index - 1];
 761   }
 762 
 763   // Support for meta data in scopes and relocs:
 764   // Note: index 0 is reserved for null.
 765   Metadata*   metadata_at(int index) const      { return index == 0 ? nullptr: *metadata_addr_at(index); }
 766   Metadata**  metadata_addr_at(int index) const {  // for GC
 767     // relocation indexes are biased by 1 (because 0 is reserved)
 768     assert(index > 0 && index <= metadata_count(), "must be a valid non-zero index");
 769     return &metadata_begin()[index - 1];
 770   }
 771 
 772   void copy_values(GrowableArray<Handle>* array);
 773   void copy_values(GrowableArray<jobject>* oops);
 774   void copy_values(GrowableArray<Metadata*>* metadata);
 775   void copy_values(GrowableArray<address>* metadata) {} // Nothing to do
 776 
 777   // Relocation support
 778 private:
 779   void fix_oop_relocations(address begin, address end, bool initialize_immediates);
 780   inline void initialize_immediate_oop(oop* dest, jobject handle);
 781 
 782 protected:
 783   address oops_reloc_begin() const;
 784 
 785 public:
 786   void fix_oop_relocations(address begin, address end) { fix_oop_relocations(begin, end, false); }
 787   void fix_oop_relocations()                           { fix_oop_relocations(nullptr, nullptr, false); }
 788 
 789   void create_reloc_immediates_list(JavaThread* thread, GrowableArray<Handle>& oop_list, GrowableArray<Metadata*>& metadata_list);
 790 
 791   bool is_at_poll_return(address pc);
 792   bool is_at_poll_or_poll_return(address pc);
 793 
 794 protected:
 795   // Exception cache support
 796   // Note: _exception_cache may be read and cleaned concurrently.
 797   ExceptionCache* exception_cache() const         { return _exception_cache; }
 798   ExceptionCache* exception_cache_acquire() const;
 799 
 800 public:
 801   address handler_for_exception_and_pc(Handle exception, address pc);
 802   void add_handler_for_exception_and_pc(Handle exception, address pc, address handler);
 803   void clean_exception_cache();
 804 
 805   void add_exception_cache_entry(ExceptionCache* new_entry);
 806   ExceptionCache* exception_cache_entry_for_exception(Handle exception);
 807 
 808 
 809   // MethodHandle
 810   bool is_method_handle_return(address return_pc);

 941   // used by jvmti to track if the load events has been reported
 942   bool  load_reported() const                     { return _load_reported; }
 943   void  set_load_reported()                       { _load_reported = true; }
 944 
 945  public:
 946   // ScopeDesc retrieval operation
 947   PcDesc* pc_desc_at(address pc)   { return find_pc_desc(pc, false); }
 948   // pc_desc_near returns the first PcDesc at or after the given pc.
 949   PcDesc* pc_desc_near(address pc) { return find_pc_desc(pc, true); }
 950 
 951   // ScopeDesc for an instruction
 952   ScopeDesc* scope_desc_at(address pc);
 953   ScopeDesc* scope_desc_near(address pc);
 954 
 955   // copying of debugging information
 956   void copy_scopes_pcs(PcDesc* pcs, int count);
 957   void copy_scopes_data(address buffer, int size);
 958 
 959   int orig_pc_offset() { return _orig_pc_offset; }
 960 
 961   AOTCodeEntry* aot_code_entry() const { return _aot_code_entry; }
 962   bool is_aot() const { return aot_code_entry() != nullptr; }
 963   void set_aot_code_entry(AOTCodeEntry* entry) { _aot_code_entry = entry; }
 964 
 965   bool     used() const { return _used; }
 966   void set_used()       { _used = true; }
 967 
 968   // Post successful compilation
 969   void post_compiled_method(CompileTask* task);
 970 
 971   // jvmti support:
 972   void post_compiled_method_load_event(JvmtiThreadState* state = nullptr);
 973 
 974   // verify operations
 975   void verify();
 976   void verify_scopes();
 977   void verify_interrupt_point(address interrupt_point, bool is_inline_cache);
 978 
 979   // Disassemble this nmethod with additional debug information, e.g. information about blocks.
 980   void decode2(outputStream* st) const;
 981   void print_constant_pool(outputStream* st);
 982 
 983   // Avoid hiding of parent's 'decode(outputStream*)' method.
 984   void decode(outputStream* st) const { decode2(st); } // just delegate here.
 985 
 986   // printing support
 987   void print_on_impl(outputStream* st) const;
 988   void print_code();
 989   void print_value_on_impl(outputStream* st) const;
 990 
 991 #if defined(SUPPORT_DATA_STRUCTS)
 992   // print output in opt build for disassembler library
 993   void print_relocations_on(outputStream* st)     PRODUCT_RETURN;
 994   void print_pcs_on(outputStream* st);
 995   void print_scopes() { print_scopes_on(tty); }
 996   void print_scopes_on(outputStream* st)          PRODUCT_RETURN;
 997   void print_handler_table();
 998   void print_nul_chk_table();
 999   void print_recorded_oop(int log_n, int index);
1000   void print_recorded_oops();
1001   void print_recorded_metadata();
1002 
1003   void print_oops(outputStream* st);     // oops from the underlying CodeBlob.
1004   void print_metadata(outputStream* st); // metadata in metadata pool.
1005 #else
1006   void print_pcs_on(outputStream* st) { return; }
1007 #endif
1008 
1009   void print_calls(outputStream* st)              PRODUCT_RETURN;
1010   static void print_statistics()                  PRODUCT_RETURN;
1011 
1012   void maybe_print_nmethod(const DirectiveSet* directive);
1013   void print_nmethod(bool print_code);

1041   ByteSize native_receiver_sp_offset() {
1042     assert(is_native_method(), "sanity");
1043     return _native_receiver_sp_offset;
1044   }
1045   ByteSize native_basic_lock_sp_offset() {
1046     assert(is_native_method(), "sanity");
1047     return _native_basic_lock_sp_offset;
1048   }
1049 
1050   // support for code generation
1051   static ByteSize osr_entry_point_offset() { return byte_offset_of(nmethod, _osr_entry_point); }
1052   static ByteSize state_offset()           { return byte_offset_of(nmethod, _state); }
1053 
1054   void metadata_do(MetadataClosure* f);
1055 
1056   address call_instruction_address(address pc) const;
1057 
1058   void make_deoptimized();
1059   void finalize_relocations();
1060 
1061   void prepare_for_archiving();
1062 
1063   class Vptr : public CodeBlob::Vptr {
1064     void print_on(const CodeBlob* instance, outputStream* st) const override {
1065       ttyLocker ttyl;
1066       instance->as_nmethod()->print_on_impl(st);
1067     }
1068     void print_value_on(const CodeBlob* instance, outputStream* st) const override {
1069       instance->as_nmethod()->print_value_on_impl(st);
1070     }
1071   };
1072 
1073   static const Vptr _vpntr;
1074 };
1075 
1076 #endif // SHARE_CODE_NMETHOD_HPP
< prev index next >