192 |
192 |
193 jbyte _scavenge_root_state; |
193 jbyte _scavenge_root_state; |
194 |
194 |
195 NOT_PRODUCT(bool _has_debug_info; ) |
195 NOT_PRODUCT(bool _has_debug_info; ) |
196 |
196 |
197 // Nmethod Flushing lock (if non-zero, then the nmethod is not removed) |
197 // Nmethod Flushing lock. If non-zero, then the nmethod is not removed |
|
198 // and is not made into a zombie. However, once the nmethod is made into |
|
199 // a zombie, it will be locked one final time if CompiledMethodUnload |
|
200 // event processing needs to be done. |
198 jint _lock_count; |
201 jint _lock_count; |
199 |
202 |
200 // not_entrant method removal. Each mark_sweep pass will update |
203 // not_entrant method removal. Each mark_sweep pass will update |
201 // this mark to current sweep invocation count if it is seen on the |
204 // this mark to current sweep invocation count if it is seen on the |
202 // stack. An not_entrant method can be removed when there is no |
205 // stack. An not_entrant method can be removed when there is no |
520 |
523 |
521 protected: |
524 protected: |
522 void flush(); |
525 void flush(); |
523 |
526 |
524 public: |
527 public: |
525 // If returning true, it is unsafe to remove this nmethod even though it is a zombie |
528 // When true is returned, it is unsafe to remove this nmethod even if |
526 // nmethod, since the VM might have a reference to it. Should only be called from a safepoint. |
529 // it is a zombie, since the VM or the ServiceThread might still be |
|
530 // using it. |
527 bool is_locked_by_vm() const { return _lock_count >0; } |
531 bool is_locked_by_vm() const { return _lock_count >0; } |
528 |
532 |
529 // See comment at definition of _last_seen_on_stack |
533 // See comment at definition of _last_seen_on_stack |
530 void mark_as_seen_on_stack(); |
534 void mark_as_seen_on_stack(); |
531 bool can_not_entrant_be_converted(); |
535 bool can_not_entrant_be_converted(); |
687 static int osr_entry_point_offset() { return offset_of(nmethod, _osr_entry_point); } |
691 static int osr_entry_point_offset() { return offset_of(nmethod, _osr_entry_point); } |
688 static int entry_bci_offset() { return offset_of(nmethod, _entry_bci); } |
692 static int entry_bci_offset() { return offset_of(nmethod, _entry_bci); } |
689 |
693 |
690 }; |
694 }; |
691 |
695 |
692 // Locks an nmethod so its code will not get removed, even if it is a zombie/not_entrant method |
696 // Locks an nmethod so its code will not get removed and it will not |
|
697 // be made into a zombie, even if it is a not_entrant method. After the |
|
698 // nmethod becomes a zombie, if CompiledMethodUnload event processing |
|
699 // needs to be done, then lock_nmethod() is used directly to keep the |
|
700 // generated code from being reused too early. |
693 class nmethodLocker : public StackObj { |
701 class nmethodLocker : public StackObj { |
694 nmethod* _nm; |
702 nmethod* _nm; |
695 |
703 |
696 public: |
704 public: |
697 |
705 |
698 static void lock_nmethod(nmethod* nm); // note: nm can be NULL |
706 // note: nm can be NULL |
|
707 // Only JvmtiDeferredEvent::compiled_method_unload_event() |
|
708 // should pass zombie_ok == true. |
|
709 static void lock_nmethod(nmethod* nm, bool zombie_ok = false); |
699 static void unlock_nmethod(nmethod* nm); // (ditto) |
710 static void unlock_nmethod(nmethod* nm); // (ditto) |
700 |
711 |
701 nmethodLocker(address pc); // derive nm from pc |
712 nmethodLocker(address pc); // derive nm from pc |
702 nmethodLocker(nmethod *nm) { _nm = nm; lock_nmethod(_nm); } |
713 nmethodLocker(nmethod *nm) { _nm = nm; lock_nmethod(_nm); } |
703 nmethodLocker() { _nm = NULL; } |
714 nmethodLocker() { _nm = NULL; } |