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 DepChange;
31 class DirectiveSet;
32 class DebugInformationRecorder;
33 class JvmtiThreadState;
34
35 // nmethods (native methods) are the compiled code versions of Java methods.
36 //
37 // An nmethod contains:
38 // - header (the nmethod structure)
39 // [Relocation]
40 // - relocation information
41 // - constant part (doubles, longs and floats used in nmethod)
42 // - oop table
43 // [Code]
44 // - code body
45 // - exception handler
46 // - stub code
47 // [Debugging information]
48 // - oop array
176 nmethod* oops_do_try_add_to_list_as_weak_done();
177
178 // Attempt X|WD -> N|SR transition. Returns the current link.
179 oops_do_mark_link* oops_do_try_add_strong_request(oops_do_mark_link* next);
180 // Attempt X|WD -> X|SD transition. Returns true if successful.
181 bool oops_do_try_claim_weak_done_as_strong_done(oops_do_mark_link* next);
182
183 // Do the N|SD -> X|SD transition.
184 void oops_do_add_to_list_as_strong_done();
185
186 // Sets this nmethod as strongly claimed (as part of N|SD -> X|SD and N|SR -> X|SD
187 // transitions).
188 void oops_do_set_strong_done(nmethod* old_head);
189
190 static nmethod* volatile _oops_do_mark_nmethods;
191 oops_do_mark_link* volatile _oops_do_mark_link;
192
193 // offsets for entry points
194 address _entry_point; // entry point with class check
195 address _verified_entry_point; // entry point without class check
196 address _osr_entry_point; // entry point for on stack replacement
197
198 // Offsets for different nmethod parts
199 int _exception_offset;
200 // Offset of the unwind handler if it exists
201 int _unwind_handler_offset;
202
203 int _consts_offset;
204 int _stub_offset;
205 int _oops_offset; // offset to where embedded oop table begins (inside data)
206 int _metadata_offset; // embedded meta data table
207 int _scopes_data_offset;
208 int _scopes_pcs_offset;
209 int _dependencies_offset;
210 int _native_invokers_offset;
211 int _handler_table_offset;
212 int _nul_chk_table_offset;
213 #if INCLUDE_JVMCI
214 int _speculations_offset;
215 int _jvmci_data_offset;
432 int speculations_size () const { return speculations_end () - speculations_begin (); }
433 int jvmci_data_size () const { return jvmci_data_end () - jvmci_data_begin (); }
434 #endif
435
436 int oops_count() const { assert(oops_size() % oopSize == 0, ""); return (oops_size() / oopSize) + 1; }
437 int metadata_count() const { assert(metadata_size() % wordSize == 0, ""); return (metadata_size() / wordSize) + 1; }
438
439 int total_size () const;
440
441 void dec_hotness_counter() { _hotness_counter--; }
442 void set_hotness_counter(int val) { _hotness_counter = val; }
443 int hotness_counter() const { return _hotness_counter; }
444
445 // Containment
446 bool oops_contains (oop* addr) const { return oops_begin () <= addr && addr < oops_end (); }
447 bool metadata_contains (Metadata** addr) const { return metadata_begin () <= addr && addr < metadata_end (); }
448 bool scopes_data_contains (address addr) const { return scopes_data_begin () <= addr && addr < scopes_data_end (); }
449 bool scopes_pcs_contains (PcDesc* addr) const { return scopes_pcs_begin () <= addr && addr < scopes_pcs_end (); }
450
451 // entry points
452 address entry_point() const { return _entry_point; } // normal entry point
453 address verified_entry_point() const { return _verified_entry_point; } // if klass is correct
454
455 // flag accessing and manipulation
456 bool is_not_installed() const { return _state == not_installed; }
457 bool is_in_use() const { return _state <= in_use; }
458 bool is_alive() const { return _state < unloaded; }
459 bool is_not_entrant() const { return _state == not_entrant; }
460 bool is_zombie() const { return _state == zombie; }
461 bool is_unloaded() const { return _state == unloaded; }
462
463 void clear_unloading_state();
464 virtual bool is_unloading();
465 virtual void do_unloading(bool unloading_occurred);
466
467 #if INCLUDE_RTM_OPT
468 // rtm state accessing and manipulating
469 RTMState rtm_state() const { return _rtm_state; }
470 void set_rtm_state(RTMState state) { _rtm_state = state; }
471 #endif
472
473 bool make_in_use() {
|
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 DepChange;
32 class DirectiveSet;
33 class DebugInformationRecorder;
34 class JvmtiThreadState;
35
36 // nmethods (native methods) are the compiled code versions of Java methods.
37 //
38 // An nmethod contains:
39 // - header (the nmethod structure)
40 // [Relocation]
41 // - relocation information
42 // - constant part (doubles, longs and floats used in nmethod)
43 // - oop table
44 // [Code]
45 // - code body
46 // - exception handler
47 // - stub code
48 // [Debugging information]
49 // - oop array
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 _inline_entry_point; // inline type entry point (unpack all inline type args) with class check
198 address _verified_inline_entry_point; // inline type entry point (unpack all inline type args) without class check
199 address _verified_inline_ro_entry_point; // inline type entry point (unpack receiver only) without class check
200 address _osr_entry_point; // entry point for on stack replacement
201
202 // Offsets for different nmethod parts
203 int _exception_offset;
204 // Offset of the unwind handler if it exists
205 int _unwind_handler_offset;
206
207 int _consts_offset;
208 int _stub_offset;
209 int _oops_offset; // offset to where embedded oop table begins (inside data)
210 int _metadata_offset; // embedded meta data table
211 int _scopes_data_offset;
212 int _scopes_pcs_offset;
213 int _dependencies_offset;
214 int _native_invokers_offset;
215 int _handler_table_offset;
216 int _nul_chk_table_offset;
217 #if INCLUDE_JVMCI
218 int _speculations_offset;
219 int _jvmci_data_offset;
436 int speculations_size () const { return speculations_end () - speculations_begin (); }
437 int jvmci_data_size () const { return jvmci_data_end () - jvmci_data_begin (); }
438 #endif
439
440 int oops_count() const { assert(oops_size() % oopSize == 0, ""); return (oops_size() / oopSize) + 1; }
441 int metadata_count() const { assert(metadata_size() % wordSize == 0, ""); return (metadata_size() / wordSize) + 1; }
442
443 int total_size () const;
444
445 void dec_hotness_counter() { _hotness_counter--; }
446 void set_hotness_counter(int val) { _hotness_counter = val; }
447 int hotness_counter() const { return _hotness_counter; }
448
449 // Containment
450 bool oops_contains (oop* addr) const { return oops_begin () <= addr && addr < oops_end (); }
451 bool metadata_contains (Metadata** addr) const { return metadata_begin () <= addr && addr < metadata_end (); }
452 bool scopes_data_contains (address addr) const { return scopes_data_begin () <= addr && addr < scopes_data_end (); }
453 bool scopes_pcs_contains (PcDesc* addr) const { return scopes_pcs_begin () <= addr && addr < scopes_pcs_end (); }
454
455 // entry points
456 address entry_point() const { return _entry_point; } // normal entry point
457 address verified_entry_point() const { return _verified_entry_point; } // normal entry point without class check
458 address inline_entry_point() const { return _inline_entry_point; } // inline type entry point (unpack all inline type args)
459 address verified_inline_entry_point() const { return _verified_inline_entry_point; } // inline type entry point (unpack all inline type args) without class check
460 address verified_inline_ro_entry_point() const { return _verified_inline_ro_entry_point; } // inline type entry point (only unpack receiver) without class check
461
462 // flag accessing and manipulation
463 bool is_not_installed() const { return _state == not_installed; }
464 bool is_in_use() const { return _state <= in_use; }
465 bool is_alive() const { return _state < unloaded; }
466 bool is_not_entrant() const { return _state == not_entrant; }
467 bool is_zombie() const { return _state == zombie; }
468 bool is_unloaded() const { return _state == unloaded; }
469
470 void clear_unloading_state();
471 virtual bool is_unloading();
472 virtual void do_unloading(bool unloading_occurred);
473
474 #if INCLUDE_RTM_OPT
475 // rtm state accessing and manipulating
476 RTMState rtm_state() const { return _rtm_state; }
477 void set_rtm_state(RTMState state) { _rtm_state = state; }
478 #endif
479
480 bool make_in_use() {
|