< prev index next >

src/hotspot/share/code/nmethod.hpp

Print this page

  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_CODE_NMETHOD_HPP
  26 #define SHARE_CODE_NMETHOD_HPP
  27 
  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;

 196   };
 197 
 198   // nmethod's read-only data
 199   address _immutable_data;
 200 
 201   PcDescContainer* _pc_desc_container;
 202   ExceptionCache* volatile _exception_cache;
 203 
 204   void* _gc_data;
 205 
 206   struct oops_do_mark_link; // Opaque data type.
 207   static nmethod*    volatile _oops_do_mark_nmethods;
 208   oops_do_mark_link* volatile _oops_do_mark_link;
 209 
 210   CompiledICData* _compiled_ic_data;
 211 
 212   // offsets for entry points
 213   address  _osr_entry_point;       // entry point for on stack replacement
 214   uint16_t _entry_offset;          // entry point with class check
 215   uint16_t _verified_entry_offset; // entry point without class check




 216   int      _entry_bci;             // != InvocationEntryBci if this nmethod is an on-stack replacement method
 217   int      _immutable_data_size;
 218 
 219   // _consts_offset == _content_offset because SECT_CONSTS is first in code buffer
 220 
 221   int _skipped_instructions_size;
 222 
 223   int _stub_offset;
 224 
 225   // Offsets for different stubs section parts
 226   int _exception_offset;
 227   // All deoptee's will resume execution at this location described by
 228   // this offset.
 229   int _deopt_handler_offset;
 230   // All deoptee's at a MethodHandle call site will resume execution
 231   // at this location described by this offset.
 232   int _deopt_mh_handler_offset;
 233   // Offset (from insts_end) of the unwind handler if it exists
 234   int16_t  _unwind_handler_offset;
 235   // Number of arguments passed on the stack

 588   int skipped_instructions_size () const { return _skipped_instructions_size; }
 589   int total_size() const;
 590 
 591   // Containment
 592   bool consts_contains         (address addr) const { return consts_begin       () <= addr && addr < consts_end       (); }
 593   // Returns true if a given address is in the 'insts' section. The method
 594   // insts_contains_inclusive() is end-inclusive.
 595   bool insts_contains          (address addr) const { return insts_begin        () <= addr && addr < insts_end        (); }
 596   bool insts_contains_inclusive(address addr) const { return insts_begin        () <= addr && addr <= insts_end       (); }
 597   bool stub_contains           (address addr) const { return stub_begin         () <= addr && addr < stub_end         (); }
 598   bool oops_contains           (oop*    addr) const { return oops_begin         () <= addr && addr < oops_end         (); }
 599   bool metadata_contains       (Metadata** addr) const { return metadata_begin  () <= addr && addr < metadata_end     (); }
 600   bool scopes_data_contains    (address addr) const { return scopes_data_begin  () <= addr && addr < scopes_data_end  (); }
 601   bool scopes_pcs_contains     (PcDesc* addr) const { return scopes_pcs_begin   () <= addr && addr < scopes_pcs_end   (); }
 602   bool handler_table_contains  (address addr) const { return handler_table_begin() <= addr && addr < handler_table_end(); }
 603   bool nul_chk_table_contains  (address addr) const { return nul_chk_table_begin() <= addr && addr < nul_chk_table_end(); }
 604 
 605   // entry points
 606   address entry_point() const          { return code_begin() + _entry_offset;          } // normal entry point
 607   address verified_entry_point() const { return code_begin() + _verified_entry_offset; } // if klass is correct



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

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










 677   bool  has_flushed_dependencies() const          { return _has_flushed_dependencies; }
 678   void  set_has_flushed_dependencies(bool z)      {
 679     assert(!has_flushed_dependencies(), "should only happen once");
 680     _has_flushed_dependencies = z;
 681   }
 682 
 683   bool  is_unlinked() const                       { return _is_unlinked; }
 684   void  set_is_unlinked()                         {
 685      assert(!_is_unlinked, "already unlinked");
 686       _is_unlinked = true;
 687   }
 688 
 689   int   comp_level() const                        { return _comp_level; }
 690 
 691   // Support for oops in scopes and relocs:
 692   // Note: index 0 is reserved for null.
 693   oop   oop_at(int index) const;
 694   oop   oop_at_phantom(int index) const; // phantom reference
 695   oop*  oop_addr_at(int index) const {  // for GC
 696     // relocation indexes are biased by 1 (because 0 is reserved)

  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_CODE_NMETHOD_HPP
  26 #define SHARE_CODE_NMETHOD_HPP
  27 
  28 #include "code/codeBlob.hpp"
  29 #include "code/pcDesc.hpp"
  30 #include "compiler/compilerDefinitions.hpp"
  31 #include "oops/metadata.hpp"
  32 #include "oops/method.hpp"
  33 
  34 class AbstractCompiler;
  35 class CompiledDirectCall;
  36 class CompiledIC;
  37 class CompiledICData;
  38 class CompileTask;
  39 class DepChange;
  40 class Dependencies;
  41 class DirectiveSet;
  42 class DebugInformationRecorder;
  43 class ExceptionHandlerTable;
  44 class ImplicitExceptionTable;
  45 class JvmtiThreadState;
  46 class MetadataClosure;
  47 class NativeCallWrapper;
  48 class OopIterateClosure;
  49 class ScopeDesc;
  50 class xmlStream;

 197   };
 198 
 199   // nmethod's read-only data
 200   address _immutable_data;
 201 
 202   PcDescContainer* _pc_desc_container;
 203   ExceptionCache* volatile _exception_cache;
 204 
 205   void* _gc_data;
 206 
 207   struct oops_do_mark_link; // Opaque data type.
 208   static nmethod*    volatile _oops_do_mark_nmethods;
 209   oops_do_mark_link* volatile _oops_do_mark_link;
 210 
 211   CompiledICData* _compiled_ic_data;
 212 
 213   // offsets for entry points
 214   address  _osr_entry_point;       // entry point for on stack replacement
 215   uint16_t _entry_offset;          // entry point with class check
 216   uint16_t _verified_entry_offset; // entry point without class check
 217   // TODO: can these be uint16_t, seem rely on -1 CodeOffset, can change later...
 218   address _inline_entry_point;              // inline type entry point (unpack all inline type args) with class check
 219   address _verified_inline_entry_point;     // inline type entry point (unpack all inline type args) without class check
 220   address _verified_inline_ro_entry_point;  // inline type entry point (unpack receiver only) without class check
 221   int      _entry_bci;             // != InvocationEntryBci if this nmethod is an on-stack replacement method
 222   int      _immutable_data_size;
 223 
 224   // _consts_offset == _content_offset because SECT_CONSTS is first in code buffer
 225 
 226   int _skipped_instructions_size;
 227 
 228   int _stub_offset;
 229 
 230   // Offsets for different stubs section parts
 231   int _exception_offset;
 232   // All deoptee's will resume execution at this location described by
 233   // this offset.
 234   int _deopt_handler_offset;
 235   // All deoptee's at a MethodHandle call site will resume execution
 236   // at this location described by this offset.
 237   int _deopt_mh_handler_offset;
 238   // Offset (from insts_end) of the unwind handler if it exists
 239   int16_t  _unwind_handler_offset;
 240   // Number of arguments passed on the stack

 593   int skipped_instructions_size () const { return _skipped_instructions_size; }
 594   int total_size() const;
 595 
 596   // Containment
 597   bool consts_contains         (address addr) const { return consts_begin       () <= addr && addr < consts_end       (); }
 598   // Returns true if a given address is in the 'insts' section. The method
 599   // insts_contains_inclusive() is end-inclusive.
 600   bool insts_contains          (address addr) const { return insts_begin        () <= addr && addr < insts_end        (); }
 601   bool insts_contains_inclusive(address addr) const { return insts_begin        () <= addr && addr <= insts_end       (); }
 602   bool stub_contains           (address addr) const { return stub_begin         () <= addr && addr < stub_end         (); }
 603   bool oops_contains           (oop*    addr) const { return oops_begin         () <= addr && addr < oops_end         (); }
 604   bool metadata_contains       (Metadata** addr) const { return metadata_begin  () <= addr && addr < metadata_end     (); }
 605   bool scopes_data_contains    (address addr) const { return scopes_data_begin  () <= addr && addr < scopes_data_end  (); }
 606   bool scopes_pcs_contains     (PcDesc* addr) const { return scopes_pcs_begin   () <= addr && addr < scopes_pcs_end   (); }
 607   bool handler_table_contains  (address addr) const { return handler_table_begin() <= addr && addr < handler_table_end(); }
 608   bool nul_chk_table_contains  (address addr) const { return nul_chk_table_begin() <= addr && addr < nul_chk_table_end(); }
 609 
 610   // entry points
 611   address entry_point() const          { return code_begin() + _entry_offset;          } // normal entry point
 612   address verified_entry_point() const { return code_begin() + _verified_entry_offset; } // if klass is correct
 613   address inline_entry_point() const              { return _inline_entry_point; }             // inline type entry point (unpack all inline type args)
 614   address verified_inline_entry_point() const     { return _verified_inline_entry_point; }    // inline type entry point (unpack all inline type args) without class check
 615   address verified_inline_ro_entry_point() const  { return _verified_inline_ro_entry_point; } // inline type entry point (only unpack receiver) without class check
 616 
 617   enum : signed char { not_installed = -1, // in construction, only the owner doing the construction is
 618                                            // allowed to advance state
 619                        in_use        = 0,  // executable nmethod
 620                        not_entrant   = 1   // marked for deoptimization but activations may still exist
 621   };
 622 
 623   // flag accessing and manipulation
 624   bool is_not_installed() const        { return _state == not_installed; }
 625   bool is_in_use() const               { return _state <= in_use; }
 626   bool is_not_entrant() const          { return _state == not_entrant; }
 627   int  get_state() const               { return _state; }
 628 
 629   void clear_unloading_state();
 630   // Heuristically deduce an nmethod isn't worth keeping around
 631   bool is_cold();
 632   bool is_unloading();
 633   void do_unloading(bool unloading_occurred);
 634 
 635   bool make_in_use() {

 665   template<typename T>
 666   T* gc_data() const                              { return reinterpret_cast<T*>(_gc_data); }
 667   template<typename T>
 668   void set_gc_data(T* gc_data)                    { _gc_data = reinterpret_cast<void*>(gc_data); }
 669 
 670   bool  has_unsafe_access() const                 { return _has_unsafe_access; }
 671   void  set_has_unsafe_access(bool z)             { _has_unsafe_access = z; }
 672 
 673   bool  has_monitors() const                      { return _has_monitors; }
 674   void  set_has_monitors(bool z)                  { _has_monitors = z; }
 675 
 676   bool  has_scoped_access() const                 { return _has_scoped_access; }
 677   void  set_has_scoped_access(bool z)             { _has_scoped_access = z; }
 678 
 679   bool  has_method_handle_invokes() const         { return _has_method_handle_invokes; }
 680   void  set_has_method_handle_invokes(bool z)     { _has_method_handle_invokes = z; }
 681 
 682   bool  has_wide_vectors() const                  { return _has_wide_vectors; }
 683   void  set_has_wide_vectors(bool z)              { _has_wide_vectors = z; }
 684 
 685   bool  needs_stack_repair() const {
 686     if (is_compiled_by_c1()) {
 687       return method()->c1_needs_stack_repair();
 688     } else if (is_compiled_by_c2()) {
 689       return method()->c2_needs_stack_repair();
 690     } else {
 691       return false;
 692     }
 693   }
 694 
 695   bool  has_flushed_dependencies() const          { return _has_flushed_dependencies; }
 696   void  set_has_flushed_dependencies(bool z)      {
 697     assert(!has_flushed_dependencies(), "should only happen once");
 698     _has_flushed_dependencies = z;
 699   }
 700 
 701   bool  is_unlinked() const                       { return _is_unlinked; }
 702   void  set_is_unlinked()                         {
 703      assert(!_is_unlinked, "already unlinked");
 704       _is_unlinked = true;
 705   }
 706 
 707   int   comp_level() const                        { return _comp_level; }
 708 
 709   // Support for oops in scopes and relocs:
 710   // Note: index 0 is reserved for null.
 711   oop   oop_at(int index) const;
 712   oop   oop_at_phantom(int index) const; // phantom reference
 713   oop*  oop_addr_at(int index) const {  // for GC
 714     // relocation indexes are biased by 1 (because 0 is reserved)
< prev index next >