@@ -178,16 +178,9 @@ int BarrierSetNMethod::nmethod_stub_entry_barrier(address* return_address_ptr) {
178
178
nmethod* nm = cb->as_nmethod ();
179
179
BarrierSetNMethod* bs_nm = BarrierSet::barrier_set ()->barrier_set_nmethod ();
180
180
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.
184
- if (!bs_nm->is_armed (nm)) {
185
- return 0 ;
186
- }
187
-
188
- assert (!nm->is_osr_method (), " Should not reach here" );
189
181
// Called upon first entry after being armed
190
182
bool may_enter = bs_nm->nmethod_entry_barrier (nm);
183
+ assert (!nm->is_osr_method () || may_enter, " OSR nmethods should always be entrant after migration" );
191
184
192
185
// In case a concurrent thread disarmed the nmethod, we need to ensure the new instructions
193
186
// are made visible, by using a cross modify fence. Note that this is synchronous cross modifying
@@ -197,11 +190,11 @@ int BarrierSetNMethod::nmethod_stub_entry_barrier(address* return_address_ptr) {
197
190
// it can be made conditional on the nmethod_patching_type.
198
191
OrderAccess::cross_modify_fence ();
199
192
200
- // Diagnostic option to force deoptimization 1 in 3 times. It is otherwise
193
+ // Diagnostic option to force deoptimization 1 in 10 times. It is otherwise
201
194
// a very rare event.
202
- if (DeoptimizeNMethodBarriersALot) {
195
+ if (DeoptimizeNMethodBarriersALot && !nm-> is_osr_method () ) {
203
196
static volatile uint32_t counter=0 ;
204
- if (Atomic::add (&counter, 1u ) % 3 == 0 ) {
197
+ if (Atomic::add (&counter, 1u ) % 10 == 0 ) {
205
198
may_enter = false ;
206
199
}
207
200
}
@@ -214,15 +207,6 @@ int BarrierSetNMethod::nmethod_stub_entry_barrier(address* return_address_ptr) {
214
207
}
215
208
216
209
bool BarrierSetNMethod::nmethod_osr_entry_barrier (nmethod* nm) {
217
- // This check depends on the invariant that all nmethods that are deoptimized / made not entrant
218
- // are NOT disarmed.
219
- // This invariant is important because a method can be deoptimized after the method have been
220
- // resolved / looked up by OSR by another thread. By not deoptimizing them we guarantee that
221
- // a deoptimized method will always hit the barrier and come to the same conclusion - deoptimize
222
- if (!is_armed (nm)) {
223
- return true ;
224
- }
225
-
226
210
assert (nm->is_osr_method (), " Should not reach here" );
227
211
log_trace (nmethod, barrier)(" Running osr nmethod entry barrier: " PTR_FORMAT, p2i (nm));
228
212
bool result = nmethod_entry_barrier (nm);
0 commit comments