< prev index next >

src/hotspot/share/code/nmethod.hpp

Print this page

  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 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/compiledMethod.hpp"

 29 
 30 class CompiledICData;
 31 class CompileTask;
 32 class DepChange;
 33 class DirectiveSet;
 34 class DebugInformationRecorder;
 35 class JvmtiThreadState;
 36 class OopIterateClosure;
 37 
 38 // nmethods (native methods) are the compiled code versions of Java methods.
 39 //
 40 // An nmethod contains:
 41 //  - header                 (the nmethod structure)
 42 //  [Relocation]
 43 //  - relocation information
 44 //  - constant part          (doubles, longs and floats used in nmethod)
 45 //  - oop table
 46 //  [Code]
 47 //  - code body
 48 //  - exception handler

178   nmethod* oops_do_try_add_to_list_as_weak_done();
179 
180   // Attempt X|WD -> N|SR transition. Returns the current link.
181   oops_do_mark_link* oops_do_try_add_strong_request(oops_do_mark_link* next);
182   // Attempt X|WD -> X|SD transition. Returns true if successful.
183   bool oops_do_try_claim_weak_done_as_strong_done(oops_do_mark_link* next);
184 
185   // Do the N|SD -> X|SD transition.
186   void oops_do_add_to_list_as_strong_done();
187 
188   // Sets this nmethod as strongly claimed (as part of N|SD -> X|SD and N|SR -> X|SD
189   // transitions).
190   void oops_do_set_strong_done(nmethod* old_head);
191 
192   static nmethod* volatile _oops_do_mark_nmethods;
193   oops_do_mark_link* volatile _oops_do_mark_link;
194 
195   // offsets for entry points
196   address _entry_point;                      // entry point with class check
197   address _verified_entry_point;             // entry point without class check



198   address _osr_entry_point;                  // entry point for on stack replacement
199 
200   CompiledICData* _compiled_ic_data;
201   bool _is_unlinked;
202 
203   // Shared fields for all nmethod's
204   int _entry_bci;      // != InvocationEntryBci if this nmethod is an on-stack replacement method
205 
206   // Offsets for different nmethod parts
207   int  _exception_offset;
208   // Offset of the unwind handler if it exists
209   int _unwind_handler_offset;
210 
211   int _consts_offset;
212   int _stub_offset;
213   int _oops_offset;                       // offset to where embedded oop table begins (inside data)
214   int _metadata_offset;                   // embedded meta data table
215   int _scopes_data_offset;
216   int _scopes_pcs_offset;
217   int _dependencies_offset;

412   int oops_size         () const                  { return int((address)  oops_end         () - (address)  oops_begin         ()); }
413   int metadata_size     () const                  { return int((address)  metadata_end     () - (address)  metadata_begin     ()); }
414   int dependencies_size () const                  { return int(           dependencies_end () -            dependencies_begin ()); }
415 #if INCLUDE_JVMCI
416   int speculations_size () const                  { return int(           speculations_end () -            speculations_begin ()); }
417   int jvmci_data_size   () const                  { return int(           jvmci_data_end   () -            jvmci_data_begin   ()); }
418 #endif
419 
420   int     oops_count() const { assert(oops_size() % oopSize == 0, "");  return (oops_size() / oopSize) + 1; }
421   int metadata_count() const { assert(metadata_size() % wordSize == 0, ""); return (metadata_size() / wordSize) + 1; }
422 
423   int total_size        () const;
424 
425   // Containment
426   bool oops_contains         (oop*    addr) const { return oops_begin         () <= addr && addr < oops_end         (); }
427   bool metadata_contains     (Metadata** addr) const   { return metadata_begin     () <= addr && addr < metadata_end     (); }
428   bool scopes_data_contains  (address addr) const { return scopes_data_begin  () <= addr && addr < scopes_data_end  (); }
429   bool scopes_pcs_contains   (PcDesc* addr) const { return scopes_pcs_begin   () <= addr && addr < scopes_pcs_end   (); }
430 
431   // entry points
432   address entry_point() const                     { return _entry_point;             } // normal entry point
433   address verified_entry_point() const            { return _verified_entry_point;    } // if klass is correct



434 
435   // flag accessing and manipulation
436   bool  is_not_installed() const                  { return _state == not_installed; }
437   bool  is_in_use() const                         { return _state <= in_use; }
438   bool  is_not_entrant() const                    { return _state == not_entrant; }
439 
440   void clear_unloading_state();
441   // Heuristically deduce an nmethod isn't worth keeping around
442   bool is_cold();
443   virtual bool is_unloading();
444   virtual void do_unloading(bool unloading_occurred);
445 
446   bool is_unlinked() const                        { return _is_unlinked; }
447   void set_is_unlinked()                          { assert(!_is_unlinked, "already unlinked"); _is_unlinked = true; }
448 
449 #if INCLUDE_RTM_OPT
450   // rtm state accessing and manipulating
451   RTMState  rtm_state() const                     { return _rtm_state; }
452   void set_rtm_state(RTMState state)              { _rtm_state = state; }
453 #endif

  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 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/compiledMethod.hpp"
 29 #include "compiler/compilerDefinitions.hpp"
 30 
 31 class CompiledICData;
 32 class CompileTask;
 33 class DepChange;
 34 class DirectiveSet;
 35 class DebugInformationRecorder;
 36 class JvmtiThreadState;
 37 class OopIterateClosure;
 38 
 39 // nmethods (native methods) are the compiled code versions of Java methods.
 40 //
 41 // An nmethod contains:
 42 //  - header                 (the nmethod structure)
 43 //  [Relocation]
 44 //  - relocation information
 45 //  - constant part          (doubles, longs and floats used in nmethod)
 46 //  - oop table
 47 //  [Code]
 48 //  - code body
 49 //  - exception handler

179   nmethod* oops_do_try_add_to_list_as_weak_done();
180 
181   // Attempt X|WD -> N|SR transition. Returns the current link.
182   oops_do_mark_link* oops_do_try_add_strong_request(oops_do_mark_link* next);
183   // Attempt X|WD -> X|SD transition. Returns true if successful.
184   bool oops_do_try_claim_weak_done_as_strong_done(oops_do_mark_link* next);
185 
186   // Do the N|SD -> X|SD transition.
187   void oops_do_add_to_list_as_strong_done();
188 
189   // Sets this nmethod as strongly claimed (as part of N|SD -> X|SD and N|SR -> X|SD
190   // transitions).
191   void oops_do_set_strong_done(nmethod* old_head);
192 
193   static nmethod* volatile _oops_do_mark_nmethods;
194   oops_do_mark_link* volatile _oops_do_mark_link;
195 
196   // offsets for entry points
197   address _entry_point;                      // entry point with class check
198   address _verified_entry_point;             // entry point without class check
199   address _inline_entry_point;               // inline type entry point (unpack all inline type args) with class check
200   address _verified_inline_entry_point;      // inline type entry point (unpack all inline type args) without class check
201   address _verified_inline_ro_entry_point;   // inline type entry point (unpack receiver only) without class check
202   address _osr_entry_point;                  // entry point for on stack replacement
203 
204   CompiledICData* _compiled_ic_data;
205   bool _is_unlinked;
206 
207   // Shared fields for all nmethod's
208   int _entry_bci;      // != InvocationEntryBci if this nmethod is an on-stack replacement method
209 
210   // Offsets for different nmethod parts
211   int  _exception_offset;
212   // Offset of the unwind handler if it exists
213   int _unwind_handler_offset;
214 
215   int _consts_offset;
216   int _stub_offset;
217   int _oops_offset;                       // offset to where embedded oop table begins (inside data)
218   int _metadata_offset;                   // embedded meta data table
219   int _scopes_data_offset;
220   int _scopes_pcs_offset;
221   int _dependencies_offset;

416   int oops_size         () const                  { return int((address)  oops_end         () - (address)  oops_begin         ()); }
417   int metadata_size     () const                  { return int((address)  metadata_end     () - (address)  metadata_begin     ()); }
418   int dependencies_size () const                  { return int(           dependencies_end () -            dependencies_begin ()); }
419 #if INCLUDE_JVMCI
420   int speculations_size () const                  { return int(           speculations_end () -            speculations_begin ()); }
421   int jvmci_data_size   () const                  { return int(           jvmci_data_end   () -            jvmci_data_begin   ()); }
422 #endif
423 
424   int     oops_count() const { assert(oops_size() % oopSize == 0, "");  return (oops_size() / oopSize) + 1; }
425   int metadata_count() const { assert(metadata_size() % wordSize == 0, ""); return (metadata_size() / wordSize) + 1; }
426 
427   int total_size        () const;
428 
429   // Containment
430   bool oops_contains         (oop*    addr) const { return oops_begin         () <= addr && addr < oops_end         (); }
431   bool metadata_contains     (Metadata** addr) const   { return metadata_begin     () <= addr && addr < metadata_end     (); }
432   bool scopes_data_contains  (address addr) const { return scopes_data_begin  () <= addr && addr < scopes_data_end  (); }
433   bool scopes_pcs_contains   (PcDesc* addr) const { return scopes_pcs_begin   () <= addr && addr < scopes_pcs_end   (); }
434 
435   // entry points
436   address entry_point() const                     { return _entry_point;             }        // normal entry point
437   address verified_entry_point() const            { return _verified_entry_point;    }        // normal entry point without class check
438   address inline_entry_point() const              { return _inline_entry_point; }             // inline type entry point (unpack all inline type args)
439   address verified_inline_entry_point() const     { return _verified_inline_entry_point; }    // inline type entry point (unpack all inline type args) without class check
440   address verified_inline_ro_entry_point() const  { return _verified_inline_ro_entry_point; } // inline type entry point (only unpack receiver) without class check
441 
442   // flag accessing and manipulation
443   bool  is_not_installed() const                  { return _state == not_installed; }
444   bool  is_in_use() const                         { return _state <= in_use; }
445   bool  is_not_entrant() const                    { return _state == not_entrant; }
446 
447   void clear_unloading_state();
448   // Heuristically deduce an nmethod isn't worth keeping around
449   bool is_cold();
450   virtual bool is_unloading();
451   virtual void do_unloading(bool unloading_occurred);
452 
453   bool is_unlinked() const                        { return _is_unlinked; }
454   void set_is_unlinked()                          { assert(!_is_unlinked, "already unlinked"); _is_unlinked = true; }
455 
456 #if INCLUDE_RTM_OPT
457   // rtm state accessing and manipulating
458   RTMState  rtm_state() const                     { return _rtm_state; }
459   void set_rtm_state(RTMState state)              { _rtm_state = state; }
460 #endif
< prev index next >