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 CompileTask;
31 class DepChange;
32 class DirectiveSet;
33 class DebugInformationRecorder;
34 class JvmtiThreadState;
35 class OopIterateClosure;
36
37 // nmethods (native methods) are the compiled code versions of Java methods.
38 //
39 // An nmethod contains:
40 // - header (the nmethod structure)
41 // [Relocation]
42 // - relocation information
43 // - constant part (doubles, longs and floats used in nmethod)
44 // - oop table
45 // [Code]
46 // - code body
47 // - exception handler
48 // - stub code
177 nmethod* oops_do_try_add_to_list_as_weak_done();
178
179 // Attempt X|WD -> N|SR transition. Returns the current link.
180 oops_do_mark_link* oops_do_try_add_strong_request(oops_do_mark_link* next);
181 // Attempt X|WD -> X|SD transition. Returns true if successful.
182 bool oops_do_try_claim_weak_done_as_strong_done(oops_do_mark_link* next);
183
184 // Do the N|SD -> X|SD transition.
185 void oops_do_add_to_list_as_strong_done();
186
187 // Sets this nmethod as strongly claimed (as part of N|SD -> X|SD and N|SR -> X|SD
188 // transitions).
189 void oops_do_set_strong_done(nmethod* old_head);
190
191 static nmethod* volatile _oops_do_mark_nmethods;
192 oops_do_mark_link* volatile _oops_do_mark_link;
193
194 // offsets for entry points
195 address _entry_point; // entry point with class check
196 address _verified_entry_point; // entry point without class check
197 address _osr_entry_point; // entry point for on stack replacement
198
199 bool _is_unlinked;
200
201 // Shared fields for all nmethod's
202 int _entry_bci; // != InvocationEntryBci if this nmethod is an on-stack replacement method
203
204 // Offsets for different nmethod parts
205 int _exception_offset;
206 // Offset of the unwind handler if it exists
207 int _unwind_handler_offset;
208
209 int _consts_offset;
210 int _stub_offset;
211 int _oops_offset; // offset to where embedded oop table begins (inside data)
212 int _metadata_offset; // embedded meta data table
213 int _scopes_data_offset;
214 int _scopes_pcs_offset;
215 int _dependencies_offset;
216 int _handler_table_offset;
410 int oops_size () const { return int((address) oops_end () - (address) oops_begin ()); }
411 int metadata_size () const { return int((address) metadata_end () - (address) metadata_begin ()); }
412 int dependencies_size () const { return int( dependencies_end () - dependencies_begin ()); }
413 #if INCLUDE_JVMCI
414 int speculations_size () const { return int( speculations_end () - speculations_begin ()); }
415 int jvmci_data_size () const { return int( jvmci_data_end () - jvmci_data_begin ()); }
416 #endif
417
418 int oops_count() const { assert(oops_size() % oopSize == 0, ""); return (oops_size() / oopSize) + 1; }
419 int metadata_count() const { assert(metadata_size() % wordSize == 0, ""); return (metadata_size() / wordSize) + 1; }
420
421 int total_size () const;
422
423 // Containment
424 bool oops_contains (oop* addr) const { return oops_begin () <= addr && addr < oops_end (); }
425 bool metadata_contains (Metadata** addr) const { return metadata_begin () <= addr && addr < metadata_end (); }
426 bool scopes_data_contains (address addr) const { return scopes_data_begin () <= addr && addr < scopes_data_end (); }
427 bool scopes_pcs_contains (PcDesc* addr) const { return scopes_pcs_begin () <= addr && addr < scopes_pcs_end (); }
428
429 // entry points
430 address entry_point() const { return _entry_point; } // normal entry point
431 address verified_entry_point() const { return _verified_entry_point; } // if klass is correct
432
433 // flag accessing and manipulation
434 bool is_not_installed() const { return _state == not_installed; }
435 bool is_in_use() const { return _state <= in_use; }
436 bool is_not_entrant() const { return _state == not_entrant; }
437
438 void clear_unloading_state();
439 // Heuristically deduce an nmethod isn't worth keeping around
440 bool is_cold();
441 virtual bool is_unloading();
442 virtual void do_unloading(bool unloading_occurred);
443
444 bool is_unlinked() const { return _is_unlinked; }
445 void set_is_unlinked() { assert(!_is_unlinked, "already unlinked"); _is_unlinked = true; }
446
447 #if INCLUDE_RTM_OPT
448 // rtm state accessing and manipulating
449 RTMState rtm_state() const { return _rtm_state; }
450 void set_rtm_state(RTMState state) { _rtm_state = state; }
451 #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 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
49 // - stub code
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 _inline_entry_point; // inline type entry point (unpack all inline type args) with class check
199 address _verified_inline_entry_point; // inline type entry point (unpack all inline type args) without class check
200 address _verified_inline_ro_entry_point; // inline type entry point (unpack receiver only) without class check
201 address _osr_entry_point; // entry point for on stack replacement
202
203 bool _is_unlinked;
204
205 // Shared fields for all nmethod's
206 int _entry_bci; // != InvocationEntryBci if this nmethod is an on-stack replacement method
207
208 // Offsets for different nmethod parts
209 int _exception_offset;
210 // Offset of the unwind handler if it exists
211 int _unwind_handler_offset;
212
213 int _consts_offset;
214 int _stub_offset;
215 int _oops_offset; // offset to where embedded oop table begins (inside data)
216 int _metadata_offset; // embedded meta data table
217 int _scopes_data_offset;
218 int _scopes_pcs_offset;
219 int _dependencies_offset;
220 int _handler_table_offset;
414 int oops_size () const { return int((address) oops_end () - (address) oops_begin ()); }
415 int metadata_size () const { return int((address) metadata_end () - (address) metadata_begin ()); }
416 int dependencies_size () const { return int( dependencies_end () - dependencies_begin ()); }
417 #if INCLUDE_JVMCI
418 int speculations_size () const { return int( speculations_end () - speculations_begin ()); }
419 int jvmci_data_size () const { return int( jvmci_data_end () - jvmci_data_begin ()); }
420 #endif
421
422 int oops_count() const { assert(oops_size() % oopSize == 0, ""); return (oops_size() / oopSize) + 1; }
423 int metadata_count() const { assert(metadata_size() % wordSize == 0, ""); return (metadata_size() / wordSize) + 1; }
424
425 int total_size () const;
426
427 // Containment
428 bool oops_contains (oop* addr) const { return oops_begin () <= addr && addr < oops_end (); }
429 bool metadata_contains (Metadata** addr) const { return metadata_begin () <= addr && addr < metadata_end (); }
430 bool scopes_data_contains (address addr) const { return scopes_data_begin () <= addr && addr < scopes_data_end (); }
431 bool scopes_pcs_contains (PcDesc* addr) const { return scopes_pcs_begin () <= addr && addr < scopes_pcs_end (); }
432
433 // entry points
434 address entry_point() const { return _entry_point; } // normal entry point
435 address verified_entry_point() const { return _verified_entry_point; } // normal entry point without class check
436 address inline_entry_point() const { return _inline_entry_point; } // inline type entry point (unpack all inline type args)
437 address verified_inline_entry_point() const { return _verified_inline_entry_point; } // inline type entry point (unpack all inline type args) without class check
438 address verified_inline_ro_entry_point() const { return _verified_inline_ro_entry_point; } // inline type entry point (only unpack receiver) without class check
439
440 // flag accessing and manipulation
441 bool is_not_installed() const { return _state == not_installed; }
442 bool is_in_use() const { return _state <= in_use; }
443 bool is_not_entrant() const { return _state == not_entrant; }
444
445 void clear_unloading_state();
446 // Heuristically deduce an nmethod isn't worth keeping around
447 bool is_cold();
448 virtual bool is_unloading();
449 virtual void do_unloading(bool unloading_occurred);
450
451 bool is_unlinked() const { return _is_unlinked; }
452 void set_is_unlinked() { assert(!_is_unlinked, "already unlinked"); _is_unlinked = true; }
453
454 #if INCLUDE_RTM_OPT
455 // rtm state accessing and manipulating
456 RTMState rtm_state() const { return _rtm_state; }
457 void set_rtm_state(RTMState state) { _rtm_state = state; }
458 #endif
|