File tree Expand file tree Collapse file tree 4 files changed +28
-8
lines changed Expand file tree Collapse file tree 4 files changed +28
-8
lines changed Original file line number Diff line number Diff line change @@ -844,10 +844,8 @@ void nmethod::run_nmethod_entry_barrier() {
844844 // By calling this nmethod entry barrier, it plays along and acts
845845 // like any other nmethod found on the stack of a thread (fewer surprises).
846846 nmethod* nm = this ;
847- if (bs_nm->is_armed (nm)) {
848- bool alive = bs_nm->nmethod_entry_barrier (nm);
849- assert (alive, " should be alive" );
850- }
847+ bool alive = bs_nm->nmethod_entry_barrier (nm);
848+ assert (alive, " should be alive" );
851849 }
852850}
853851
Original file line number Diff line number Diff line change @@ -100,6 +100,12 @@ bool BarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) {
100100 virtual void do_oop (narrowOop* p) { ShouldNotReachHere (); }
101101 };
102102
103+ if (!is_armed (nm)) {
104+ // Some other thread got here first and healed the oops
105+ // and disarmed the nmethod. No need to continue.
106+ return true ;
107+ }
108+
103109 // If the nmethod is the only thing pointing to the oops, and we are using a
104110 // SATB GC, then it is important that this code marks them live.
105111 // Also, with concurrent GC, it is possible that frames in continuation stack
@@ -172,6 +178,9 @@ int BarrierSetNMethod::nmethod_stub_entry_barrier(address* return_address_ptr) {
172178 nmethod* nm = cb->as_nmethod ();
173179 BarrierSetNMethod* bs_nm = BarrierSet::barrier_set ()->barrier_set_nmethod ();
174180
181+ // Check for disarmed method here to avoid going into DeoptimizeNMethodBarriersALot code
182+ // too often. nmethod_entry_barrier checks for disarmed status itself,
183+ // but we have no visibility into whether the barrier acted or not.
175184 if (!bs_nm->is_armed (nm)) {
176185 return 0 ;
177186 }
Original file line number Diff line number Diff line change 3232#include " runtime/threadWXSetters.inline.hpp"
3333
3434bool XBarrierSetNMethod::nmethod_entry_barrier (nmethod* nm) {
35+ if (!is_armed (nm)) {
36+ // Some other thread got here first and healed the oops
37+ // and disarmed the nmethod. No need to continue.
38+ return true ;
39+ }
40+
3541 XLocker<XReentrantLock> locker (XNMethod::lock_for_nmethod (nm));
3642 log_trace (nmethod, barrier)(" Entered critical zone for %p" , nm);
3743
3844 if (!is_armed (nm)) {
39- // Some other thread got here first and healed the oops
40- // and disarmed the nmethod .
45+ // Some other thread managed to complete while we were
46+ // waiting for lock. No need to continue .
4147 return true ;
4248 }
4349
Original file line number Diff line number Diff line change 3737#include " runtime/threadWXSetters.inline.hpp"
3838
3939bool ZBarrierSetNMethod::nmethod_entry_barrier (nmethod* nm) {
40+ if (!is_armed (nm)) {
41+ log_develop_trace (gc, nmethod)(" nmethod: " PTR_FORMAT " visited by entry (disarmed before lock)" , p2i (nm));
42+ // Some other thread got here first and healed the oops
43+ // and disarmed the nmethod. No need to continue.
44+ return true ;
45+ }
46+
4047 ZLocker<ZReentrantLock> locker (ZNMethod::lock_for_nmethod (nm));
4148 log_trace (nmethod, barrier)(" Entered critical zone for %p" , nm);
4249
4350 log_develop_trace (gc, nmethod)(" nmethod: " PTR_FORMAT " visited by entry (try)" , p2i (nm));
4451
4552 if (!is_armed (nm)) {
4653 log_develop_trace (gc, nmethod)(" nmethod: " PTR_FORMAT " visited by entry (disarmed)" , p2i (nm));
47- // Some other thread got here first and healed the oops
48- // and disarmed the nmethod .
54+ // Some other thread managed to complete while we were
55+ // waiting for lock. No need to continue .
4956 return true ;
5057 }
5158
You can’t perform that action at this time.
0 commit comments