114 // location in frame (offset for sp) that deopt can store the original 115 // pc during a deopt. 116 int _orig_pc_offset; 117 118 int _compile_id; // which compilation made this nmethod 119 int _comp_level; // compilation level 120 121 // protected by CodeCache_lock 122 bool _has_flushed_dependencies; // Used for maintenance of dependencies (CodeCache_lock) 123 124 // used by jvmti to track if an unload event has been posted for this nmethod. 125 bool _unload_reported; 126 127 // Protected by Patching_lock 128 volatile signed char _state; // {not_installed, in_use, not_entrant, zombie, unloaded} 129 130 #ifdef ASSERT 131 bool _oops_are_stale; // indicates that it's no longer safe to access oops section 132 #endif 133 134 jbyte _scavenge_root_state; 135 136 #if INCLUDE_RTM_OPT 137 // RTM state at compile time. Used during deoptimization to decide 138 // whether to restart collecting RTM locking abort statistic again. 139 RTMState _rtm_state; 140 #endif 141 142 // Nmethod Flushing lock. If non-zero, then the nmethod is not removed 143 // and is not made into a zombie. However, once the nmethod is made into 144 // a zombie, it will be locked one final time if CompiledMethodUnload 145 // event processing needs to be done. 146 volatile jint _lock_count; 147 148 // not_entrant method removal. Each mark_sweep pass will update 149 // this mark to current sweep invocation count if it is seen on the 150 // stack. An not_entrant method can be removed when there are no 151 // more activations, i.e., when the _stack_traversal_mark is less than 152 // current sweep traversal index. 153 volatile long _stack_traversal_mark; 154 155 // The _hotness_counter indicates the hotness of a method. The higher 393 // Note: index 0 is reserved for null. 394 Metadata* metadata_at(int index) const { return index == 0 ? NULL: *metadata_addr_at(index); } 395 Metadata** metadata_addr_at(int index) const { // for GC 396 // relocation indexes are biased by 1 (because 0 is reserved) 397 assert(index > 0 && index <= metadata_count(), "must be a valid non-zero index"); 398 return &metadata_begin()[index - 1]; 399 } 400 401 void copy_values(GrowableArray<jobject>* oops); 402 void copy_values(GrowableArray<Metadata*>* metadata); 403 404 // Relocation support 405 private: 406 void fix_oop_relocations(address begin, address end, bool initialize_immediates); 407 inline void initialize_immediate_oop(oop* dest, jobject handle); 408 409 public: 410 void fix_oop_relocations(address begin, address end) { fix_oop_relocations(begin, end, false); } 411 void fix_oop_relocations() { fix_oop_relocations(NULL, NULL, false); } 412 413 // Scavengable oop support 414 bool on_scavenge_root_list() const { return (_scavenge_root_state & 1) != 0; } 415 protected: 416 enum { sl_on_list = 0x01, sl_marked = 0x10 }; 417 void set_on_scavenge_root_list() { _scavenge_root_state = sl_on_list; } 418 void clear_on_scavenge_root_list() { _scavenge_root_state = 0; } 419 // assertion-checking and pruning logic uses the bits of _scavenge_root_state 420 #ifndef PRODUCT 421 void set_scavenge_root_marked() { _scavenge_root_state |= sl_marked; } 422 void clear_scavenge_root_marked() { _scavenge_root_state &= ~sl_marked; } 423 bool scavenge_root_not_marked() { return (_scavenge_root_state &~ sl_on_list) == 0; } 424 // N.B. there is no positive marked query, and we only use the not_marked query for asserts. 425 #endif //PRODUCT 426 nmethod* scavenge_root_link() const { return _scavenge_root_link; } 427 void set_scavenge_root_link(nmethod *n) { _scavenge_root_link = n; } 428 429 public: 430 431 // Sweeper support 432 long stack_traversal_mark() { return _stack_traversal_mark; } 433 void set_stack_traversal_mark(long l) { _stack_traversal_mark = l; } 434 435 // implicit exceptions support 436 address continuation_for_implicit_exception(address pc); 437 438 // On-stack replacement support 439 int osr_entry_bci() const { assert(is_osr_method(), "wrong kind of nmethod"); return _entry_bci; } 440 address osr_entry() const { assert(is_osr_method(), "wrong kind of nmethod"); return _osr_entry_point; } 441 void invalidate_osr_method(); 442 nmethod* osr_link() const { return _osr_link; } 443 void set_osr_link(nmethod *n) { _osr_link = n; } 444 445 // Verify calls to dead methods have been cleaned. 446 void verify_clean_inline_caches(); 447 448 // unlink and deallocate this nmethod 449 // Only NMethodSweeper class is expected to use this. NMethodSweeper is not 450 // expected to use any other private methods/data in this class. 487 // Gets the SpeculationLog object associated with this nmethod 488 // which may be NULL if this nmethod was not compiled by JVMCI 489 // or the weak reference has been cleared. 490 oop speculation_log(); 491 492 private: 493 // Deletes the weak reference (if any) to the InstalledCode object 494 // associated with this nmethod. 495 void clear_jvmci_installed_code(); 496 497 // Deletes the weak reference (if any) to the SpeculationLog object 498 // associated with this nmethod. 499 void clear_speculation_log(); 500 501 public: 502 #endif 503 504 public: 505 void oops_do(OopClosure* f) { oops_do(f, false); } 506 void oops_do(OopClosure* f, bool allow_zombie); 507 bool detect_scavenge_root_oops(); 508 void verify_scavenge_root_oops() PRODUCT_RETURN; 509 510 bool test_set_oops_do_mark(); 511 static void oops_do_marking_prologue(); 512 static void oops_do_marking_epilogue(); 513 static bool oops_do_marking_is_active() { return _oops_do_mark_nmethods != NULL; } 514 bool test_oops_do_mark() { return _oops_do_mark_link != NULL; } 515 516 private: 517 ScopeDesc* scope_desc_in(address begin, address end); 518 519 address* orig_pc_addr(const frame* fr); 520 521 public: 522 // copying of debugging information 523 void copy_scopes_pcs(PcDesc* pcs, int count); 524 void copy_scopes_data(address buffer, int size); 525 526 // Accessor/mutator for the original pc of a frame before a frame was deopted. 527 address get_original_pc(const frame* fr) { return *orig_pc_addr(fr); } 528 void set_original_pc(const frame* fr, address pc) { *orig_pc_addr(fr) = pc; } | 114 // location in frame (offset for sp) that deopt can store the original 115 // pc during a deopt. 116 int _orig_pc_offset; 117 118 int _compile_id; // which compilation made this nmethod 119 int _comp_level; // compilation level 120 121 // protected by CodeCache_lock 122 bool _has_flushed_dependencies; // Used for maintenance of dependencies (CodeCache_lock) 123 124 // used by jvmti to track if an unload event has been posted for this nmethod. 125 bool _unload_reported; 126 127 // Protected by Patching_lock 128 volatile signed char _state; // {not_installed, in_use, not_entrant, zombie, unloaded} 129 130 #ifdef ASSERT 131 bool _oops_are_stale; // indicates that it's no longer safe to access oops section 132 #endif 133 134 #if INCLUDE_RTM_OPT 135 // RTM state at compile time. Used during deoptimization to decide 136 // whether to restart collecting RTM locking abort statistic again. 137 RTMState _rtm_state; 138 #endif 139 140 // Nmethod Flushing lock. If non-zero, then the nmethod is not removed 141 // and is not made into a zombie. However, once the nmethod is made into 142 // a zombie, it will be locked one final time if CompiledMethodUnload 143 // event processing needs to be done. 144 volatile jint _lock_count; 145 146 // not_entrant method removal. Each mark_sweep pass will update 147 // this mark to current sweep invocation count if it is seen on the 148 // stack. An not_entrant method can be removed when there are no 149 // more activations, i.e., when the _stack_traversal_mark is less than 150 // current sweep traversal index. 151 volatile long _stack_traversal_mark; 152 153 // The _hotness_counter indicates the hotness of a method. The higher 391 // Note: index 0 is reserved for null. 392 Metadata* metadata_at(int index) const { return index == 0 ? NULL: *metadata_addr_at(index); } 393 Metadata** metadata_addr_at(int index) const { // for GC 394 // relocation indexes are biased by 1 (because 0 is reserved) 395 assert(index > 0 && index <= metadata_count(), "must be a valid non-zero index"); 396 return &metadata_begin()[index - 1]; 397 } 398 399 void copy_values(GrowableArray<jobject>* oops); 400 void copy_values(GrowableArray<Metadata*>* metadata); 401 402 // Relocation support 403 private: 404 void fix_oop_relocations(address begin, address end, bool initialize_immediates); 405 inline void initialize_immediate_oop(oop* dest, jobject handle); 406 407 public: 408 void fix_oop_relocations(address begin, address end) { fix_oop_relocations(begin, end, false); } 409 void fix_oop_relocations() { fix_oop_relocations(NULL, NULL, false); } 410 411 // Sweeper support 412 long stack_traversal_mark() { return _stack_traversal_mark; } 413 void set_stack_traversal_mark(long l) { _stack_traversal_mark = l; } 414 415 // implicit exceptions support 416 address continuation_for_implicit_exception(address pc); 417 418 // On-stack replacement support 419 int osr_entry_bci() const { assert(is_osr_method(), "wrong kind of nmethod"); return _entry_bci; } 420 address osr_entry() const { assert(is_osr_method(), "wrong kind of nmethod"); return _osr_entry_point; } 421 void invalidate_osr_method(); 422 nmethod* osr_link() const { return _osr_link; } 423 void set_osr_link(nmethod *n) { _osr_link = n; } 424 425 // Verify calls to dead methods have been cleaned. 426 void verify_clean_inline_caches(); 427 428 // unlink and deallocate this nmethod 429 // Only NMethodSweeper class is expected to use this. NMethodSweeper is not 430 // expected to use any other private methods/data in this class. 467 // Gets the SpeculationLog object associated with this nmethod 468 // which may be NULL if this nmethod was not compiled by JVMCI 469 // or the weak reference has been cleared. 470 oop speculation_log(); 471 472 private: 473 // Deletes the weak reference (if any) to the InstalledCode object 474 // associated with this nmethod. 475 void clear_jvmci_installed_code(); 476 477 // Deletes the weak reference (if any) to the SpeculationLog object 478 // associated with this nmethod. 479 void clear_speculation_log(); 480 481 public: 482 #endif 483 484 public: 485 void oops_do(OopClosure* f) { oops_do(f, false); } 486 void oops_do(OopClosure* f, bool allow_zombie); 487 488 bool test_set_oops_do_mark(); 489 static void oops_do_marking_prologue(); 490 static void oops_do_marking_epilogue(); 491 static bool oops_do_marking_is_active() { return _oops_do_mark_nmethods != NULL; } 492 bool test_oops_do_mark() { return _oops_do_mark_link != NULL; } 493 494 private: 495 ScopeDesc* scope_desc_in(address begin, address end); 496 497 address* orig_pc_addr(const frame* fr); 498 499 public: 500 // copying of debugging information 501 void copy_scopes_pcs(PcDesc* pcs, int count); 502 void copy_scopes_data(address buffer, int size); 503 504 // Accessor/mutator for the original pc of a frame before a frame was deopted. 505 address get_original_pc(const frame* fr) { return *orig_pc_addr(fr); } 506 void set_original_pc(const frame* fr, address pc) { *orig_pc_addr(fr) = pc; } |