< prev index next >

src/hotspot/share/code/nmethod.hpp

Print this page

190   static nmethod* volatile _oops_do_mark_nmethods;
191   oops_do_mark_link* volatile _oops_do_mark_link;
192 
193   // offsets for entry points
194   address _entry_point;                      // entry point with class check
195   address _verified_entry_point;             // entry point without class check
196   address _osr_entry_point;                  // entry point for on stack replacement
197 
198   // Offsets for different nmethod parts
199   int  _exception_offset;
200   // Offset of the unwind handler if it exists
201   int _unwind_handler_offset;
202 
203   int _consts_offset;
204   int _stub_offset;
205   int _oops_offset;                       // offset to where embedded oop table begins (inside data)
206   int _metadata_offset;                   // embedded meta data table
207   int _scopes_data_offset;
208   int _scopes_pcs_offset;
209   int _dependencies_offset;
210   int _native_invokers_offset;
211   int _handler_table_offset;
212   int _nul_chk_table_offset;
213 #if INCLUDE_JVMCI
214   int _speculations_offset;
215   int _jvmci_data_offset;
216 #endif
217   int _nmethod_end_offset;
218 
219   int code_offset() const { return (address) code_begin() - header_begin(); }
220 
221   // location in frame (offset for sp) that deopt can store the original
222   // pc during a deopt.
223   int _orig_pc_offset;
224 
225   int _compile_id;                           // which compilation made this nmethod
226   int _comp_level;                           // compilation level
227 
228   // protected by CodeCache_lock
229   bool _has_flushed_dependencies;            // Used for maintenance of dependencies (CodeCache_lock)
230 

292           ByteSize basic_lock_owner_sp_offset, /* synchronized natives only */
293           ByteSize basic_lock_sp_offset,       /* synchronized natives only */
294           OopMapSet* oop_maps);
295 
296   // Creation support
297   nmethod(Method* method,
298           CompilerType type,
299           int nmethod_size,
300           int compile_id,
301           int entry_bci,
302           CodeOffsets* offsets,
303           int orig_pc_offset,
304           DebugInformationRecorder *recorder,
305           Dependencies* dependencies,
306           CodeBuffer *code_buffer,
307           int frame_size,
308           OopMapSet* oop_maps,
309           ExceptionHandlerTable* handler_table,
310           ImplicitExceptionTable* nul_chk_table,
311           AbstractCompiler* compiler,
312           int comp_level,
313           const GrowableArrayView<RuntimeStub*>& native_invokers
314 #if INCLUDE_JVMCI
315           , char* speculations,
316           int speculations_len,
317           int jvmci_data_size
318 #endif
319           );
320 
321   // helper methods
322   void* operator new(size_t size, int nmethod_size, int comp_level) throw();
323 
324   const char* reloc_string_for(u_char* begin, u_char* end);
325 
326   bool try_transition(int new_state);
327 
328   // Returns true if this thread changed the state of the nmethod or
329   // false if another thread performed the transition.
330   bool make_not_entrant_or_zombie(int state);
331   bool make_entrant() { Unimplemented(); return false; }
332   void inc_decompile_count();
333 

341   int content_offset() const                  { return content_begin() - header_begin(); }
342   int data_offset() const                     { return _data_offset; }
343 
344   address header_end() const                  { return (address)    header_begin() + header_size(); }
345 
346  public:
347   // create nmethod with entry_bci
348   static nmethod* new_nmethod(const methodHandle& method,
349                               int compile_id,
350                               int entry_bci,
351                               CodeOffsets* offsets,
352                               int orig_pc_offset,
353                               DebugInformationRecorder* recorder,
354                               Dependencies* dependencies,
355                               CodeBuffer *code_buffer,
356                               int frame_size,
357                               OopMapSet* oop_maps,
358                               ExceptionHandlerTable* handler_table,
359                               ImplicitExceptionTable* nul_chk_table,
360                               AbstractCompiler* compiler,
361                               int comp_level,
362                               const GrowableArrayView<RuntimeStub*>& native_invokers = GrowableArrayView<RuntimeStub*>::EMPTY
363 #if INCLUDE_JVMCI
364                               , char* speculations = NULL,
365                               int speculations_len = 0,
366                               int nmethod_mirror_index = -1,
367                               const char* nmethod_mirror_name = NULL,
368                               FailedSpeculation** failed_speculations = NULL
369 #endif
370   );
371 
372   // Only used for unit tests.
373   nmethod()
374     : CompiledMethod(),
375       _is_unloading_state(0),
376       _native_receiver_sp_offset(in_ByteSize(-1)),
377       _native_basic_lock_sp_offset(in_ByteSize(-1)) {}
378 
379 
380   static nmethod* new_native_nmethod(const methodHandle& method,
381                                      int compile_id,
382                                      CodeBuffer *code_buffer,

391   bool is_nmethod() const                         { return true; }
392   bool is_osr_method() const                      { return _entry_bci != InvocationEntryBci; }
393 
394   // boundaries for different parts
395   address consts_begin          () const          { return           header_begin() + _consts_offset        ; }
396   address consts_end            () const          { return           code_begin()                           ; }
397   address stub_begin            () const          { return           header_begin() + _stub_offset          ; }
398   address stub_end              () const          { return           header_begin() + _oops_offset          ; }
399   address exception_begin       () const          { return           header_begin() + _exception_offset     ; }
400   address unwind_handler_begin  () const          { return _unwind_handler_offset != -1 ? (header_begin() + _unwind_handler_offset) : NULL; }
401   oop*    oops_begin            () const          { return (oop*)   (header_begin() + _oops_offset)         ; }
402   oop*    oops_end              () const          { return (oop*)   (header_begin() + _metadata_offset)     ; }
403 
404   Metadata** metadata_begin   () const            { return (Metadata**)  (header_begin() + _metadata_offset)     ; }
405   Metadata** metadata_end     () const            { return (Metadata**)  _scopes_data_begin; }
406 
407   address scopes_data_end       () const          { return           header_begin() + _scopes_pcs_offset    ; }
408   PcDesc* scopes_pcs_begin      () const          { return (PcDesc*)(header_begin() + _scopes_pcs_offset   ); }
409   PcDesc* scopes_pcs_end        () const          { return (PcDesc*)(header_begin() + _dependencies_offset) ; }
410   address dependencies_begin    () const          { return           header_begin() + _dependencies_offset  ; }
411   address dependencies_end      () const          { return           header_begin() + _native_invokers_offset ; }
412   RuntimeStub** native_invokers_begin() const     { return (RuntimeStub**)(header_begin() + _native_invokers_offset) ; }
413   RuntimeStub** native_invokers_end  () const     { return (RuntimeStub**)(header_begin() + _handler_table_offset); }
414   address handler_table_begin   () const          { return           header_begin() + _handler_table_offset ; }
415   address handler_table_end     () const          { return           header_begin() + _nul_chk_table_offset ; }
416   address nul_chk_table_begin   () const          { return           header_begin() + _nul_chk_table_offset ; }
417 #if INCLUDE_JVMCI
418   address nul_chk_table_end     () const          { return           header_begin() + _speculations_offset  ; }
419   address speculations_begin    () const          { return           header_begin() + _speculations_offset  ; }
420   address speculations_end      () const          { return           header_begin() + _jvmci_data_offset   ; }
421   address jvmci_data_begin      () const          { return           header_begin() + _jvmci_data_offset    ; }
422   address jvmci_data_end        () const          { return           header_begin() + _nmethod_end_offset   ; }
423 #else
424   address nul_chk_table_end     () const          { return           header_begin() + _nmethod_end_offset   ; }
425 #endif
426 
427   // Sizes
428   int oops_size         () const                  { return (address)  oops_end         () - (address)  oops_begin         (); }
429   int metadata_size     () const                  { return (address)  metadata_end     () - (address)  metadata_begin     (); }
430   int dependencies_size () const                  { return            dependencies_end () -            dependencies_begin (); }
431 #if INCLUDE_JVMCI
432   int speculations_size () const                  { return            speculations_end () -            speculations_begin (); }
433   int jvmci_data_size   () const                  { return            jvmci_data_end   () -            jvmci_data_begin   (); }

509   oop   oop_at_phantom(int index) const; // phantom reference
510   oop*  oop_addr_at(int index) const {  // for GC
511     // relocation indexes are biased by 1 (because 0 is reserved)
512     assert(index > 0 && index <= oops_count(), "must be a valid non-zero index");
513     assert(!_oops_are_stale, "oops are stale");
514     return &oops_begin()[index - 1];
515   }
516 
517   // Support for meta data in scopes and relocs:
518   // Note: index 0 is reserved for null.
519   Metadata*     metadata_at(int index) const      { return index == 0 ? NULL: *metadata_addr_at(index); }
520   Metadata**  metadata_addr_at(int index) const {  // for GC
521     // relocation indexes are biased by 1 (because 0 is reserved)
522     assert(index > 0 && index <= metadata_count(), "must be a valid non-zero index");
523     return &metadata_begin()[index - 1];
524   }
525 
526   void copy_values(GrowableArray<jobject>* oops);
527   void copy_values(GrowableArray<Metadata*>* metadata);
528 
529   void free_native_invokers();
530 
531   // Relocation support
532 private:
533   void fix_oop_relocations(address begin, address end, bool initialize_immediates);
534   inline void initialize_immediate_oop(oop* dest, jobject handle);
535 
536 public:
537   void fix_oop_relocations(address begin, address end) { fix_oop_relocations(begin, end, false); }
538   void fix_oop_relocations()                           { fix_oop_relocations(NULL, NULL, false); }
539 
540   // Sweeper support
541   long  stack_traversal_mark()                    { return _stack_traversal_mark; }
542   void  set_stack_traversal_mark(long l)          { _stack_traversal_mark = l; }
543 
544   // On-stack replacement support
545   int   osr_entry_bci() const                     { assert(is_osr_method(), "wrong kind of nmethod"); return _entry_bci; }
546   address  osr_entry() const                      { assert(is_osr_method(), "wrong kind of nmethod"); return _osr_entry_point; }
547   void  invalidate_osr_method();
548   nmethod* osr_link() const                       { return _osr_link; }
549   void     set_osr_link(nmethod *n)               { _osr_link = n; }
550 

647   // Disassemble this nmethod with additional debug information, e.g. information about blocks.
648   void decode2(outputStream* st) const;
649   void print_constant_pool(outputStream* st);
650 
651   // Avoid hiding of parent's 'decode(outputStream*)' method.
652   void decode(outputStream* st) const { decode2(st); } // just delegate here.
653 
654   // printing support
655   void print()                          const;
656   void print(outputStream* st)          const;
657   void print_code();
658 
659 #if defined(SUPPORT_DATA_STRUCTS)
660   // print output in opt build for disassembler library
661   void print_relocations()                        PRODUCT_RETURN;
662   void print_pcs() { print_pcs_on(tty); }
663   void print_pcs_on(outputStream* st);
664   void print_scopes() { print_scopes_on(tty); }
665   void print_scopes_on(outputStream* st)          PRODUCT_RETURN;
666   void print_value_on(outputStream* st) const;
667   void print_native_invokers();
668   void print_handler_table();
669   void print_nul_chk_table();
670   void print_recorded_oop(int log_n, int index);
671   void print_recorded_oops();
672   void print_recorded_metadata();
673 
674   void print_oops(outputStream* st);     // oops from the underlying CodeBlob.
675   void print_metadata(outputStream* st); // metadata in metadata pool.
676 #else
677   // void print_pcs()                             PRODUCT_RETURN;
678   void print_pcs()                                { return; }
679 #endif
680 
681   void print_calls(outputStream* st)              PRODUCT_RETURN;
682   static void print_statistics()                  PRODUCT_RETURN;
683 
684   void maybe_print_nmethod(DirectiveSet* directive);
685   void print_nmethod(bool print_code);
686 
687   // need to re-define this from CodeBlob else the overload hides it

190   static nmethod* volatile _oops_do_mark_nmethods;
191   oops_do_mark_link* volatile _oops_do_mark_link;
192 
193   // offsets for entry points
194   address _entry_point;                      // entry point with class check
195   address _verified_entry_point;             // entry point without class check
196   address _osr_entry_point;                  // entry point for on stack replacement
197 
198   // Offsets for different nmethod parts
199   int  _exception_offset;
200   // Offset of the unwind handler if it exists
201   int _unwind_handler_offset;
202 
203   int _consts_offset;
204   int _stub_offset;
205   int _oops_offset;                       // offset to where embedded oop table begins (inside data)
206   int _metadata_offset;                   // embedded meta data table
207   int _scopes_data_offset;
208   int _scopes_pcs_offset;
209   int _dependencies_offset;

210   int _handler_table_offset;
211   int _nul_chk_table_offset;
212 #if INCLUDE_JVMCI
213   int _speculations_offset;
214   int _jvmci_data_offset;
215 #endif
216   int _nmethod_end_offset;
217 
218   int code_offset() const { return (address) code_begin() - header_begin(); }
219 
220   // location in frame (offset for sp) that deopt can store the original
221   // pc during a deopt.
222   int _orig_pc_offset;
223 
224   int _compile_id;                           // which compilation made this nmethod
225   int _comp_level;                           // compilation level
226 
227   // protected by CodeCache_lock
228   bool _has_flushed_dependencies;            // Used for maintenance of dependencies (CodeCache_lock)
229 

291           ByteSize basic_lock_owner_sp_offset, /* synchronized natives only */
292           ByteSize basic_lock_sp_offset,       /* synchronized natives only */
293           OopMapSet* oop_maps);
294 
295   // Creation support
296   nmethod(Method* method,
297           CompilerType type,
298           int nmethod_size,
299           int compile_id,
300           int entry_bci,
301           CodeOffsets* offsets,
302           int orig_pc_offset,
303           DebugInformationRecorder *recorder,
304           Dependencies* dependencies,
305           CodeBuffer *code_buffer,
306           int frame_size,
307           OopMapSet* oop_maps,
308           ExceptionHandlerTable* handler_table,
309           ImplicitExceptionTable* nul_chk_table,
310           AbstractCompiler* compiler,
311           int comp_level

312 #if INCLUDE_JVMCI
313           , char* speculations,
314           int speculations_len,
315           int jvmci_data_size
316 #endif
317           );
318 
319   // helper methods
320   void* operator new(size_t size, int nmethod_size, int comp_level) throw();
321 
322   const char* reloc_string_for(u_char* begin, u_char* end);
323 
324   bool try_transition(int new_state);
325 
326   // Returns true if this thread changed the state of the nmethod or
327   // false if another thread performed the transition.
328   bool make_not_entrant_or_zombie(int state);
329   bool make_entrant() { Unimplemented(); return false; }
330   void inc_decompile_count();
331 

339   int content_offset() const                  { return content_begin() - header_begin(); }
340   int data_offset() const                     { return _data_offset; }
341 
342   address header_end() const                  { return (address)    header_begin() + header_size(); }
343 
344  public:
345   // create nmethod with entry_bci
346   static nmethod* new_nmethod(const methodHandle& method,
347                               int compile_id,
348                               int entry_bci,
349                               CodeOffsets* offsets,
350                               int orig_pc_offset,
351                               DebugInformationRecorder* recorder,
352                               Dependencies* dependencies,
353                               CodeBuffer *code_buffer,
354                               int frame_size,
355                               OopMapSet* oop_maps,
356                               ExceptionHandlerTable* handler_table,
357                               ImplicitExceptionTable* nul_chk_table,
358                               AbstractCompiler* compiler,
359                               int comp_level

360 #if INCLUDE_JVMCI
361                               , char* speculations = NULL,
362                               int speculations_len = 0,
363                               int nmethod_mirror_index = -1,
364                               const char* nmethod_mirror_name = NULL,
365                               FailedSpeculation** failed_speculations = NULL
366 #endif
367   );
368 
369   // Only used for unit tests.
370   nmethod()
371     : CompiledMethod(),
372       _is_unloading_state(0),
373       _native_receiver_sp_offset(in_ByteSize(-1)),
374       _native_basic_lock_sp_offset(in_ByteSize(-1)) {}
375 
376 
377   static nmethod* new_native_nmethod(const methodHandle& method,
378                                      int compile_id,
379                                      CodeBuffer *code_buffer,

388   bool is_nmethod() const                         { return true; }
389   bool is_osr_method() const                      { return _entry_bci != InvocationEntryBci; }
390 
391   // boundaries for different parts
392   address consts_begin          () const          { return           header_begin() + _consts_offset        ; }
393   address consts_end            () const          { return           code_begin()                           ; }
394   address stub_begin            () const          { return           header_begin() + _stub_offset          ; }
395   address stub_end              () const          { return           header_begin() + _oops_offset          ; }
396   address exception_begin       () const          { return           header_begin() + _exception_offset     ; }
397   address unwind_handler_begin  () const          { return _unwind_handler_offset != -1 ? (header_begin() + _unwind_handler_offset) : NULL; }
398   oop*    oops_begin            () const          { return (oop*)   (header_begin() + _oops_offset)         ; }
399   oop*    oops_end              () const          { return (oop*)   (header_begin() + _metadata_offset)     ; }
400 
401   Metadata** metadata_begin   () const            { return (Metadata**)  (header_begin() + _metadata_offset)     ; }
402   Metadata** metadata_end     () const            { return (Metadata**)  _scopes_data_begin; }
403 
404   address scopes_data_end       () const          { return           header_begin() + _scopes_pcs_offset    ; }
405   PcDesc* scopes_pcs_begin      () const          { return (PcDesc*)(header_begin() + _scopes_pcs_offset   ); }
406   PcDesc* scopes_pcs_end        () const          { return (PcDesc*)(header_begin() + _dependencies_offset) ; }
407   address dependencies_begin    () const          { return           header_begin() + _dependencies_offset  ; }
408   address dependencies_end      () const          { return           header_begin() + _handler_table_offset ; }


409   address handler_table_begin   () const          { return           header_begin() + _handler_table_offset ; }
410   address handler_table_end     () const          { return           header_begin() + _nul_chk_table_offset ; }
411   address nul_chk_table_begin   () const          { return           header_begin() + _nul_chk_table_offset ; }
412 #if INCLUDE_JVMCI
413   address nul_chk_table_end     () const          { return           header_begin() + _speculations_offset  ; }
414   address speculations_begin    () const          { return           header_begin() + _speculations_offset  ; }
415   address speculations_end      () const          { return           header_begin() + _jvmci_data_offset   ; }
416   address jvmci_data_begin      () const          { return           header_begin() + _jvmci_data_offset    ; }
417   address jvmci_data_end        () const          { return           header_begin() + _nmethod_end_offset   ; }
418 #else
419   address nul_chk_table_end     () const          { return           header_begin() + _nmethod_end_offset   ; }
420 #endif
421 
422   // Sizes
423   int oops_size         () const                  { return (address)  oops_end         () - (address)  oops_begin         (); }
424   int metadata_size     () const                  { return (address)  metadata_end     () - (address)  metadata_begin     (); }
425   int dependencies_size () const                  { return            dependencies_end () -            dependencies_begin (); }
426 #if INCLUDE_JVMCI
427   int speculations_size () const                  { return            speculations_end () -            speculations_begin (); }
428   int jvmci_data_size   () const                  { return            jvmci_data_end   () -            jvmci_data_begin   (); }

504   oop   oop_at_phantom(int index) const; // phantom reference
505   oop*  oop_addr_at(int index) const {  // for GC
506     // relocation indexes are biased by 1 (because 0 is reserved)
507     assert(index > 0 && index <= oops_count(), "must be a valid non-zero index");
508     assert(!_oops_are_stale, "oops are stale");
509     return &oops_begin()[index - 1];
510   }
511 
512   // Support for meta data in scopes and relocs:
513   // Note: index 0 is reserved for null.
514   Metadata*     metadata_at(int index) const      { return index == 0 ? NULL: *metadata_addr_at(index); }
515   Metadata**  metadata_addr_at(int index) const {  // for GC
516     // relocation indexes are biased by 1 (because 0 is reserved)
517     assert(index > 0 && index <= metadata_count(), "must be a valid non-zero index");
518     return &metadata_begin()[index - 1];
519   }
520 
521   void copy_values(GrowableArray<jobject>* oops);
522   void copy_values(GrowableArray<Metadata*>* metadata);
523 


524   // Relocation support
525 private:
526   void fix_oop_relocations(address begin, address end, bool initialize_immediates);
527   inline void initialize_immediate_oop(oop* dest, jobject handle);
528 
529 public:
530   void fix_oop_relocations(address begin, address end) { fix_oop_relocations(begin, end, false); }
531   void fix_oop_relocations()                           { fix_oop_relocations(NULL, NULL, false); }
532 
533   // Sweeper support
534   long  stack_traversal_mark()                    { return _stack_traversal_mark; }
535   void  set_stack_traversal_mark(long l)          { _stack_traversal_mark = l; }
536 
537   // On-stack replacement support
538   int   osr_entry_bci() const                     { assert(is_osr_method(), "wrong kind of nmethod"); return _entry_bci; }
539   address  osr_entry() const                      { assert(is_osr_method(), "wrong kind of nmethod"); return _osr_entry_point; }
540   void  invalidate_osr_method();
541   nmethod* osr_link() const                       { return _osr_link; }
542   void     set_osr_link(nmethod *n)               { _osr_link = n; }
543 

640   // Disassemble this nmethod with additional debug information, e.g. information about blocks.
641   void decode2(outputStream* st) const;
642   void print_constant_pool(outputStream* st);
643 
644   // Avoid hiding of parent's 'decode(outputStream*)' method.
645   void decode(outputStream* st) const { decode2(st); } // just delegate here.
646 
647   // printing support
648   void print()                          const;
649   void print(outputStream* st)          const;
650   void print_code();
651 
652 #if defined(SUPPORT_DATA_STRUCTS)
653   // print output in opt build for disassembler library
654   void print_relocations()                        PRODUCT_RETURN;
655   void print_pcs() { print_pcs_on(tty); }
656   void print_pcs_on(outputStream* st);
657   void print_scopes() { print_scopes_on(tty); }
658   void print_scopes_on(outputStream* st)          PRODUCT_RETURN;
659   void print_value_on(outputStream* st) const;

660   void print_handler_table();
661   void print_nul_chk_table();
662   void print_recorded_oop(int log_n, int index);
663   void print_recorded_oops();
664   void print_recorded_metadata();
665 
666   void print_oops(outputStream* st);     // oops from the underlying CodeBlob.
667   void print_metadata(outputStream* st); // metadata in metadata pool.
668 #else
669   // void print_pcs()                             PRODUCT_RETURN;
670   void print_pcs()                                { return; }
671 #endif
672 
673   void print_calls(outputStream* st)              PRODUCT_RETURN;
674   static void print_statistics()                  PRODUCT_RETURN;
675 
676   void maybe_print_nmethod(DirectiveSet* directive);
677   void print_nmethod(bool print_code);
678 
679   // need to re-define this from CodeBlob else the overload hides it
< prev index next >