< prev index next >

src/hotspot/share/gc/shared/barrierSetNMethod.cpp

Print this page
*** 176,10 ***
--- 176,11 ---
    assert(cb != nullptr, "invariant");
  
    nmethod* nm = cb->as_nmethod();
    BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
  
+   log_trace(nmethod, barrier)("Running nmethod entry barrier: %d " PTR_FORMAT, nm->compile_id(), p2i(nm));
    // Called upon first entry after being armed
    bool may_enter = bs_nm->nmethod_entry_barrier(nm);
    assert(!nm->is_osr_method() || may_enter, "OSR nmethods should always be entrant after migration");
  
    // In case a concurrent thread disarmed the nmethod, we need to ensure the new instructions

*** 197,19 ***
      if (Atomic::add(&counter, 1u) % 10 == 0) {
        may_enter = false;
      }
    }
  
!   if (!may_enter) {
      log_trace(nmethod, barrier)("Deoptimizing nmethod: " PTR_FORMAT, p2i(nm));
      bs_nm->deoptimize(nm, return_address_ptr);
    }
    return may_enter ? 0 : 1;
  }
  
  bool BarrierSetNMethod::nmethod_osr_entry_barrier(nmethod* nm) {
    assert(nm->is_osr_method(), "Should not reach here");
!   log_trace(nmethod, barrier)("Running osr nmethod entry barrier: " PTR_FORMAT, p2i(nm));
    bool result = nmethod_entry_barrier(nm);
    OrderAccess::cross_modify_fence();
    return result;
  }
--- 198,24 ---
      if (Atomic::add(&counter, 1u) % 10 == 0) {
        may_enter = false;
      }
    }
  
!   if (may_enter) {
+     nm->set_used();
+   } else {
      log_trace(nmethod, barrier)("Deoptimizing nmethod: " PTR_FORMAT, p2i(nm));
      bs_nm->deoptimize(nm, return_address_ptr);
    }
    return may_enter ? 0 : 1;
  }
  
  bool BarrierSetNMethod::nmethod_osr_entry_barrier(nmethod* nm) {
    assert(nm->is_osr_method(), "Should not reach here");
!   log_trace(nmethod, barrier)("Running osr nmethod entry barrier: %d " PTR_FORMAT, nm->compile_id(), p2i(nm));
    bool result = nmethod_entry_barrier(nm);
+   if (result) {
+     nm->set_used();
+   }
    OrderAccess::cross_modify_fence();
    return result;
  }
< prev index next >