< prev index next >

src/hotspot/share/code/nmethod.hpp

Print this page

219   int _speculations_offset;
220   int _jvmci_data_offset;
221 #endif
222   int _nmethod_end_offset;
223 
224   int code_offset() const { return (address) code_begin() - header_begin(); }
225 
226   // location in frame (offset for sp) that deopt can store the original
227   // pc during a deopt.
228   int _orig_pc_offset;
229 
230   int _compile_id;                           // which compilation made this nmethod
231 
232 #if INCLUDE_RTM_OPT
233   // RTM state at compile time. Used during deoptimization to decide
234   // whether to restart collecting RTM locking abort statistic again.
235   RTMState _rtm_state;
236 #endif
237 
238   // These are used for compiled synchronized native methods to
239   // locate the owner and stack slot for the BasicLock. They are
240   // needed because there is no debug information for compiled native
241   // wrappers and the oop maps are insufficient to allow
242   // frame::retrieve_receiver() to work. Currently they are expected
243   // to be byte offsets from the Java stack pointer for maximum code
244   // sharing between platforms. JVMTI's GetLocalInstance() uses these
245   // offsets to find the receiver for non-static native wrapper frames.
246   ByteSize _native_receiver_sp_offset;
247   ByteSize _native_basic_lock_sp_offset;
248 
249   CompLevel _comp_level;               // compilation level
250 
251   // Local state used to keep track of whether unloading is happening or not
252   volatile uint8_t _is_unloading_state;
253 
254   // protected by CodeCache_lock
255   bool _has_flushed_dependencies;      // Used for maintenance of dependencies (CodeCache_lock)
256 
257   // used by jvmti to track if an event has been posted for this nmethod.
258   bool _load_reported;
259 
260   // Protected by CompiledMethod_lock
261   volatile signed char _state;         // {not_installed, in_use, not_used, not_entrant}
262 
263   // For native wrappers
264   nmethod(Method* method,
265           CompilerType type,
266           int nmethod_size,
267           int compile_id,
268           CodeOffsets* offsets,
269           CodeBuffer *code_buffer,
270           int frame_size,
271           ByteSize basic_lock_owner_sp_offset, /* synchronized natives only */
272           ByteSize basic_lock_sp_offset,       /* synchronized natives only */
273           OopMapSet* oop_maps);
274 
275   // Creation support
276   nmethod(Method* method,
277           CompilerType type,
278           int nmethod_size,
279           int compile_id,
280           int entry_bci,
281           CodeOffsets* offsets,
282           int orig_pc_offset,
283           DebugInformationRecorder *recorder,
284           Dependencies* dependencies,
285           CodeBuffer *code_buffer,
286           int frame_size,
287           OopMapSet* oop_maps,
288           ExceptionHandlerTable* handler_table,
289           ImplicitExceptionTable* nul_chk_table,
290           AbstractCompiler* compiler,
291           CompLevel comp_level
292 #if INCLUDE_JVMCI

332                               CodeBuffer *code_buffer,
333                               int frame_size,
334                               OopMapSet* oop_maps,
335                               ExceptionHandlerTable* handler_table,
336                               ImplicitExceptionTable* nul_chk_table,
337                               AbstractCompiler* compiler,
338                               CompLevel comp_level
339 #if INCLUDE_JVMCI
340                               , char* speculations = NULL,
341                               int speculations_len = 0,
342                               int nmethod_mirror_index = -1,
343                               const char* nmethod_mirror_name = NULL,
344                               FailedSpeculation** failed_speculations = NULL
345 #endif
346   );
347 
348   // Only used for unit tests.
349   nmethod()
350     : CompiledMethod(),
351       _native_receiver_sp_offset(in_ByteSize(-1)),
352       _native_basic_lock_sp_offset(in_ByteSize(-1)),
353       _is_unloading_state(0) {}
354 
355 
356   static nmethod* new_native_nmethod(const methodHandle& method,
357                                      int compile_id,
358                                      CodeBuffer *code_buffer,
359                                      int vep_offset,
360                                      int frame_complete,
361                                      int frame_size,
362                                      ByteSize receiver_sp_offset,
363                                      ByteSize basic_lock_sp_offset,
364                                      OopMapSet* oop_maps,
365                                      int exception_handler = -1);
366 
367   // type info
368   bool is_nmethod() const                         { return true; }
369   bool is_osr_method() const                      { return _entry_bci != InvocationEntryBci; }
370 
371   // boundaries for different parts
372   address consts_begin          () const          { return           header_begin() + _consts_offset        ; }
373   address consts_end            () const          { return           code_begin()                           ; }
374   address stub_begin            () const          { return           header_begin() + _stub_offset          ; }
375   address stub_end              () const          { return           header_begin() + _oops_offset          ; }
376   address exception_begin       () const          { return           header_begin() + _exception_offset     ; }
377   address unwind_handler_begin  () const          { return _unwind_handler_offset != -1 ? (header_begin() + _unwind_handler_offset) : NULL; }
378   oop*    oops_begin            () const          { return (oop*)   (header_begin() + _oops_offset)         ; }
379   oop*    oops_end              () const          { return (oop*)   (header_begin() + _metadata_offset)     ; }
380 
381   Metadata** metadata_begin   () const            { return (Metadata**)  (header_begin() + _metadata_offset)     ; }
382   Metadata** metadata_end     () const            { return (Metadata**)  _scopes_data_begin; }
383 

670   virtual int compile_id() const { return _compile_id; }
671   const char* compile_kind() const;
672 
673   // tells if any of this method's dependencies have been invalidated
674   // (this is expensive!)
675   static void check_all_dependencies(DepChange& changes);
676 
677   // tells if this compiled method is dependent on the given changes,
678   // and the changes have invalidated it
679   bool check_dependency_on(DepChange& changes);
680 
681   // Fast breakpoint support. Tells if this compiled method is
682   // dependent on the given method. Returns true if this nmethod
683   // corresponds to the given method as well.
684   virtual bool is_dependent_on_method(Method* dependee);
685 
686   // JVMTI's GetLocalInstance() support
687   ByteSize native_receiver_sp_offset() {
688     return _native_receiver_sp_offset;
689   }
690   ByteSize native_basic_lock_sp_offset() {
691     return _native_basic_lock_sp_offset;
692   }
693 
694   // support for code generation
695   static int verified_entry_point_offset()        { return offset_of(nmethod, _verified_entry_point); }
696   static int osr_entry_point_offset()             { return offset_of(nmethod, _osr_entry_point); }
697   static int state_offset()                       { return offset_of(nmethod, _state); }
698 
699   virtual void metadata_do(MetadataClosure* f);
700 
701   NativeCallWrapper* call_wrapper_at(address call) const;
702   NativeCallWrapper* call_wrapper_before(address return_pc) const;
703   address call_instruction_address(address pc) const;
704 
705   virtual CompiledStaticCall* compiledStaticCall_at(Relocation* call_site) const;
706   virtual CompiledStaticCall* compiledStaticCall_at(address addr) const;
707   virtual CompiledStaticCall* compiledStaticCall_before(address addr) const;
708 
709   virtual void  make_deoptimized();
710   void finalize_relocations();
711 };
712 

219   int _speculations_offset;
220   int _jvmci_data_offset;
221 #endif
222   int _nmethod_end_offset;
223 
224   int code_offset() const { return (address) code_begin() - header_begin(); }
225 
226   // location in frame (offset for sp) that deopt can store the original
227   // pc during a deopt.
228   int _orig_pc_offset;
229 
230   int _compile_id;                           // which compilation made this nmethod
231 
232 #if INCLUDE_RTM_OPT
233   // RTM state at compile time. Used during deoptimization to decide
234   // whether to restart collecting RTM locking abort statistic again.
235   RTMState _rtm_state;
236 #endif
237 
238   // These are used for compiled synchronized native methods to
239   // locate the owner for the lock. They are
240   // needed because there is no debug information for compiled native
241   // wrappers and the oop maps are insufficient to allow
242   // frame::retrieve_receiver() to work. Currently they are expected
243   // to be byte offsets from the Java stack pointer for maximum code
244   // sharing between platforms. JVMTI's GetLocalInstance() uses these
245   // offsets to find the receiver for non-static native wrapper frames.
246   ByteSize _native_receiver_sp_offset;

247 
248   CompLevel _comp_level;               // compilation level
249 
250   // Local state used to keep track of whether unloading is happening or not
251   volatile uint8_t _is_unloading_state;
252 
253   // protected by CodeCache_lock
254   bool _has_flushed_dependencies;      // Used for maintenance of dependencies (CodeCache_lock)
255 
256   // used by jvmti to track if an event has been posted for this nmethod.
257   bool _load_reported;
258 
259   // Protected by CompiledMethod_lock
260   volatile signed char _state;         // {not_installed, in_use, not_used, not_entrant}
261 
262   // For native wrappers
263   nmethod(Method* method,
264           CompilerType type,
265           int nmethod_size,
266           int compile_id,
267           CodeOffsets* offsets,
268           CodeBuffer *code_buffer,
269           int frame_size,
270           ByteSize basic_lock_owner_sp_offset, /* synchronized natives only */

271           OopMapSet* oop_maps);
272 
273   // Creation support
274   nmethod(Method* method,
275           CompilerType type,
276           int nmethod_size,
277           int compile_id,
278           int entry_bci,
279           CodeOffsets* offsets,
280           int orig_pc_offset,
281           DebugInformationRecorder *recorder,
282           Dependencies* dependencies,
283           CodeBuffer *code_buffer,
284           int frame_size,
285           OopMapSet* oop_maps,
286           ExceptionHandlerTable* handler_table,
287           ImplicitExceptionTable* nul_chk_table,
288           AbstractCompiler* compiler,
289           CompLevel comp_level
290 #if INCLUDE_JVMCI

330                               CodeBuffer *code_buffer,
331                               int frame_size,
332                               OopMapSet* oop_maps,
333                               ExceptionHandlerTable* handler_table,
334                               ImplicitExceptionTable* nul_chk_table,
335                               AbstractCompiler* compiler,
336                               CompLevel comp_level
337 #if INCLUDE_JVMCI
338                               , char* speculations = NULL,
339                               int speculations_len = 0,
340                               int nmethod_mirror_index = -1,
341                               const char* nmethod_mirror_name = NULL,
342                               FailedSpeculation** failed_speculations = NULL
343 #endif
344   );
345 
346   // Only used for unit tests.
347   nmethod()
348     : CompiledMethod(),
349       _native_receiver_sp_offset(in_ByteSize(-1)),

350       _is_unloading_state(0) {}
351 
352 
353   static nmethod* new_native_nmethod(const methodHandle& method,
354                                      int compile_id,
355                                      CodeBuffer *code_buffer,
356                                      int vep_offset,
357                                      int frame_complete,
358                                      int frame_size,
359                                      ByteSize receiver_sp_offset,

360                                      OopMapSet* oop_maps,
361                                      int exception_handler = -1);
362 
363   // type info
364   bool is_nmethod() const                         { return true; }
365   bool is_osr_method() const                      { return _entry_bci != InvocationEntryBci; }
366 
367   // boundaries for different parts
368   address consts_begin          () const          { return           header_begin() + _consts_offset        ; }
369   address consts_end            () const          { return           code_begin()                           ; }
370   address stub_begin            () const          { return           header_begin() + _stub_offset          ; }
371   address stub_end              () const          { return           header_begin() + _oops_offset          ; }
372   address exception_begin       () const          { return           header_begin() + _exception_offset     ; }
373   address unwind_handler_begin  () const          { return _unwind_handler_offset != -1 ? (header_begin() + _unwind_handler_offset) : NULL; }
374   oop*    oops_begin            () const          { return (oop*)   (header_begin() + _oops_offset)         ; }
375   oop*    oops_end              () const          { return (oop*)   (header_begin() + _metadata_offset)     ; }
376 
377   Metadata** metadata_begin   () const            { return (Metadata**)  (header_begin() + _metadata_offset)     ; }
378   Metadata** metadata_end     () const            { return (Metadata**)  _scopes_data_begin; }
379 

666   virtual int compile_id() const { return _compile_id; }
667   const char* compile_kind() const;
668 
669   // tells if any of this method's dependencies have been invalidated
670   // (this is expensive!)
671   static void check_all_dependencies(DepChange& changes);
672 
673   // tells if this compiled method is dependent on the given changes,
674   // and the changes have invalidated it
675   bool check_dependency_on(DepChange& changes);
676 
677   // Fast breakpoint support. Tells if this compiled method is
678   // dependent on the given method. Returns true if this nmethod
679   // corresponds to the given method as well.
680   virtual bool is_dependent_on_method(Method* dependee);
681 
682   // JVMTI's GetLocalInstance() support
683   ByteSize native_receiver_sp_offset() {
684     return _native_receiver_sp_offset;
685   }



686 
687   // support for code generation
688   static int verified_entry_point_offset()        { return offset_of(nmethod, _verified_entry_point); }
689   static int osr_entry_point_offset()             { return offset_of(nmethod, _osr_entry_point); }
690   static int state_offset()                       { return offset_of(nmethod, _state); }
691 
692   virtual void metadata_do(MetadataClosure* f);
693 
694   NativeCallWrapper* call_wrapper_at(address call) const;
695   NativeCallWrapper* call_wrapper_before(address return_pc) const;
696   address call_instruction_address(address pc) const;
697 
698   virtual CompiledStaticCall* compiledStaticCall_at(Relocation* call_site) const;
699   virtual CompiledStaticCall* compiledStaticCall_at(address addr) const;
700   virtual CompiledStaticCall* compiledStaticCall_before(address addr) const;
701 
702   virtual void  make_deoptimized();
703   void finalize_relocations();
704 };
705 
< prev index next >