@@ -172,13 +172,9 @@ int BarrierSetNMethod::nmethod_stub_entry_barrier(address* return_address_ptr) {
172172 nmethod* nm = cb->as_nmethod ();
173173 BarrierSetNMethod* bs_nm = BarrierSet::barrier_set ()->barrier_set_nmethod ();
174174
175- if (!bs_nm->is_armed (nm)) {
176- return 0 ;
177- }
178-
179- assert (!nm->is_osr_method (), " Should not reach here" );
180175 // Called upon first entry after being armed
181176 bool may_enter = bs_nm->nmethod_entry_barrier (nm);
177+ assert (!nm->is_osr_method () || may_enter, " OSR nmethods should always be entrant after migration" );
182178
183179 // In case a concurrent thread disarmed the nmethod, we need to ensure the new instructions
184180 // are made visible, by using a cross modify fence. Note that this is synchronous cross modifying
@@ -188,11 +184,11 @@ int BarrierSetNMethod::nmethod_stub_entry_barrier(address* return_address_ptr) {
188184 // it can be made conditional on the nmethod_patching_type.
189185 OrderAccess::cross_modify_fence ();
190186
191- // Diagnostic option to force deoptimization 1 in 3 times. It is otherwise
187+ // Diagnostic option to force deoptimization 1 in 10 times. It is otherwise
192188 // a very rare event.
193- if (DeoptimizeNMethodBarriersALot) {
189+ if (DeoptimizeNMethodBarriersALot && !nm-> is_osr_method () ) {
194190 static volatile uint32_t counter=0 ;
195- if (Atomic::add (&counter, 1u ) % 3 == 0 ) {
191+ if (Atomic::add (&counter, 1u ) % 10 == 0 ) {
196192 may_enter = false ;
197193 }
198194 }
@@ -205,15 +201,6 @@ int BarrierSetNMethod::nmethod_stub_entry_barrier(address* return_address_ptr) {
205201}
206202
207203bool BarrierSetNMethod::nmethod_osr_entry_barrier (nmethod* nm) {
208- // This check depends on the invariant that all nmethods that are deoptimized / made not entrant
209- // are NOT disarmed.
210- // This invariant is important because a method can be deoptimized after the method have been
211- // resolved / looked up by OSR by another thread. By not deoptimizing them we guarantee that
212- // a deoptimized method will always hit the barrier and come to the same conclusion - deoptimize
213- if (!is_armed (nm)) {
214- return true ;
215- }
216-
217204 assert (nm->is_osr_method (), " Should not reach here" );
218205 log_trace (nmethod, barrier)(" Running osr nmethod entry barrier: " PTR_FORMAT, p2i (nm));
219206 bool result = nmethod_entry_barrier (nm);
0 commit comments