< 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

 666   int skipped_instructions_size () const { return _skipped_instructions_size; }
 667   int total_size() const;
 668 
 669   // Containment
 670   bool consts_contains         (address addr) const { return consts_begin       () <= addr && addr < consts_end       (); }
 671   // Returns true if a given address is in the 'insts' section. The method
 672   // insts_contains_inclusive() is end-inclusive.
 673   bool insts_contains          (address addr) const { return insts_begin        () <= addr && addr < insts_end        (); }
 674   bool insts_contains_inclusive(address addr) const { return insts_begin        () <= addr && addr <= insts_end       (); }
 675   bool stub_contains           (address addr) const { return stub_begin         () <= addr && addr < stub_end         (); }
 676   bool oops_contains           (oop*    addr) const { return oops_begin         () <= addr && addr < oops_end         (); }
 677   bool metadata_contains       (Metadata** addr) const { return metadata_begin  () <= addr && addr < metadata_end     (); }
 678   bool scopes_data_contains    (address addr) const { return scopes_data_begin  () <= addr && addr < scopes_data_end  (); }
 679   bool scopes_pcs_contains     (PcDesc* addr) const { return scopes_pcs_begin   () <= addr && addr < scopes_pcs_end   (); }
 680   bool handler_table_contains  (address addr) const { return handler_table_begin() <= addr && addr < handler_table_end(); }
 681   bool nul_chk_table_contains  (address addr) const { return nul_chk_table_begin() <= addr && addr < nul_chk_table_end(); }
 682 
 683   // entry points
 684   address entry_point() const          { return code_begin() + _entry_offset;          } // normal entry point
 685   address verified_entry_point() const { return code_begin() + _verified_entry_offset; } // if klass is correct



 686 
 687   enum : signed char { not_installed = -1, // in construction, only the owner doing the construction is
 688                                            // allowed to advance state
 689                        in_use        = 0,  // executable nmethod
 690                        not_entrant   = 1   // marked for deoptimization but activations may still exist
 691   };
 692 
 693   // flag accessing and manipulation
 694   bool is_not_installed() const        { return _state == not_installed; }
 695   bool is_in_use() const               { return _state <= in_use; }
 696   bool is_not_entrant() const          { return _state == not_entrant; }
 697   int  get_state() const               { return _state; }
 698 
 699   void clear_unloading_state();
 700   // Heuristically deduce an nmethod isn't worth keeping around
 701   bool is_cold();
 702   bool is_unloading();
 703   void do_unloading(bool unloading_occurred);
 704 
 705   bool make_in_use() {

 735   template<typename T>
 736   T* gc_data() const                              { return reinterpret_cast<T*>(_gc_data); }
 737   template<typename T>
 738   void set_gc_data(T* gc_data)                    { _gc_data = reinterpret_cast<void*>(gc_data); }
 739 
 740   bool  has_unsafe_access() const                 { return _has_unsafe_access; }
 741   void  set_has_unsafe_access(bool z)             { _has_unsafe_access = z; }
 742 
 743   bool  has_monitors() const                      { return _has_monitors; }
 744   void  set_has_monitors(bool z)                  { _has_monitors = z; }
 745 
 746   bool  has_scoped_access() const                 { return _has_scoped_access; }
 747   void  set_has_scoped_access(bool z)             { _has_scoped_access = z; }
 748 
 749   bool  has_method_handle_invokes() const         { return _has_method_handle_invokes; }
 750   void  set_has_method_handle_invokes(bool z)     { _has_method_handle_invokes = z; }
 751 
 752   bool  has_wide_vectors() const                  { return _has_wide_vectors; }
 753   void  set_has_wide_vectors(bool z)              { _has_wide_vectors = z; }
 754 










 755   bool  has_flushed_dependencies() const          { return _has_flushed_dependencies; }
 756   void  set_has_flushed_dependencies(bool z)      {
 757     assert(!has_flushed_dependencies(), "should only happen once");
 758     _has_flushed_dependencies = z;
 759   }
 760 
 761   bool  is_unlinked() const                       { return _is_unlinked; }
 762   void  set_is_unlinked()                         {
 763      assert(!_is_unlinked, "already unlinked");
 764       _is_unlinked = true;
 765   }
 766 
 767   int   comp_level() const                        { return _comp_level; }
 768 
 769   // Support for oops in scopes and relocs:
 770   // Note: index 0 is reserved for null.
 771   oop   oop_at(int index) const;
 772   oop   oop_at_phantom(int index) const; // phantom reference
 773   oop*  oop_addr_at(int index) const {  // for GC
 774     // 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

 671   int skipped_instructions_size () const { return _skipped_instructions_size; }
 672   int total_size() const;
 673 
 674   // Containment
 675   bool consts_contains         (address addr) const { return consts_begin       () <= addr && addr < consts_end       (); }
 676   // Returns true if a given address is in the 'insts' section. The method
 677   // insts_contains_inclusive() is end-inclusive.
 678   bool insts_contains          (address addr) const { return insts_begin        () <= addr && addr < insts_end        (); }
 679   bool insts_contains_inclusive(address addr) const { return insts_begin        () <= addr && addr <= insts_end       (); }
 680   bool stub_contains           (address addr) const { return stub_begin         () <= addr && addr < stub_end         (); }
 681   bool oops_contains           (oop*    addr) const { return oops_begin         () <= addr && addr < oops_end         (); }
 682   bool metadata_contains       (Metadata** addr) const { return metadata_begin  () <= addr && addr < metadata_end     (); }
 683   bool scopes_data_contains    (address addr) const { return scopes_data_begin  () <= addr && addr < scopes_data_end  (); }
 684   bool scopes_pcs_contains     (PcDesc* addr) const { return scopes_pcs_begin   () <= addr && addr < scopes_pcs_end   (); }
 685   bool handler_table_contains  (address addr) const { return handler_table_begin() <= addr && addr < handler_table_end(); }
 686   bool nul_chk_table_contains  (address addr) const { return nul_chk_table_begin() <= addr && addr < nul_chk_table_end(); }
 687 
 688   // entry points
 689   address entry_point() const          { return code_begin() + _entry_offset;          } // normal entry point
 690   address verified_entry_point() const { return code_begin() + _verified_entry_offset; } // if klass is correct
 691   address inline_entry_point() const              { return _inline_entry_point; }             // inline type entry point (unpack all inline type args)
 692   address verified_inline_entry_point() const     { return _verified_inline_entry_point; }    // inline type entry point (unpack all inline type args) without class check
 693   address verified_inline_ro_entry_point() const  { return _verified_inline_ro_entry_point; } // inline type entry point (only unpack receiver) without class check
 694 
 695   enum : signed char { not_installed = -1, // in construction, only the owner doing the construction is
 696                                            // allowed to advance state
 697                        in_use        = 0,  // executable nmethod
 698                        not_entrant   = 1   // marked for deoptimization but activations may still exist
 699   };
 700 
 701   // flag accessing and manipulation
 702   bool is_not_installed() const        { return _state == not_installed; }
 703   bool is_in_use() const               { return _state <= in_use; }
 704   bool is_not_entrant() const          { return _state == not_entrant; }
 705   int  get_state() const               { return _state; }
 706 
 707   void clear_unloading_state();
 708   // Heuristically deduce an nmethod isn't worth keeping around
 709   bool is_cold();
 710   bool is_unloading();
 711   void do_unloading(bool unloading_occurred);
 712 
 713   bool make_in_use() {

 743   template<typename T>
 744   T* gc_data() const                              { return reinterpret_cast<T*>(_gc_data); }
 745   template<typename T>
 746   void set_gc_data(T* gc_data)                    { _gc_data = reinterpret_cast<void*>(gc_data); }
 747 
 748   bool  has_unsafe_access() const                 { return _has_unsafe_access; }
 749   void  set_has_unsafe_access(bool z)             { _has_unsafe_access = z; }
 750 
 751   bool  has_monitors() const                      { return _has_monitors; }
 752   void  set_has_monitors(bool z)                  { _has_monitors = z; }
 753 
 754   bool  has_scoped_access() const                 { return _has_scoped_access; }
 755   void  set_has_scoped_access(bool z)             { _has_scoped_access = z; }
 756 
 757   bool  has_method_handle_invokes() const         { return _has_method_handle_invokes; }
 758   void  set_has_method_handle_invokes(bool z)     { _has_method_handle_invokes = z; }
 759 
 760   bool  has_wide_vectors() const                  { return _has_wide_vectors; }
 761   void  set_has_wide_vectors(bool z)              { _has_wide_vectors = z; }
 762 
 763   bool  needs_stack_repair() const {
 764     if (is_compiled_by_c1()) {
 765       return method()->c1_needs_stack_repair();
 766     } else if (is_compiled_by_c2()) {
 767       return method()->c2_needs_stack_repair();
 768     } else {
 769       return false;
 770     }
 771   }
 772 
 773   bool  has_flushed_dependencies() const          { return _has_flushed_dependencies; }
 774   void  set_has_flushed_dependencies(bool z)      {
 775     assert(!has_flushed_dependencies(), "should only happen once");
 776     _has_flushed_dependencies = z;
 777   }
 778 
 779   bool  is_unlinked() const                       { return _is_unlinked; }
 780   void  set_is_unlinked()                         {
 781      assert(!_is_unlinked, "already unlinked");
 782       _is_unlinked = true;
 783   }
 784 
 785   int   comp_level() const                        { return _comp_level; }
 786 
 787   // Support for oops in scopes and relocs:
 788   // Note: index 0 is reserved for null.
 789   oop   oop_at(int index) const;
 790   oop   oop_at_phantom(int index) const; // phantom reference
 791   oop*  oop_addr_at(int index) const {  // for GC
 792     // relocation indexes are biased by 1 (because 0 is reserved)
< prev index next >