< prev index next >

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

Print this page
*** 181,10 ***
--- 181,11 ---
    if (!bs_nm->is_armed(nm)) {
      return 0;
    }
  
    assert(!nm->is_osr_method(), "Should not reach here");
+   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);
  
    // In case a concurrent thread disarmed the nmethod, we need to ensure the new instructions
    // are made visible, by using a cross modify fence. Note that this is synchronous cross modifying

*** 201,11 ***
      if (Atomic::add(&counter, 1u) % 3 == 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;
  }
--- 202,13 ---
      if (Atomic::add(&counter, 1u) % 3 == 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;
  }

*** 219,10 ***
    if (!is_armed(nm)) {
      return true;
    }
  
    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;
  }
--- 222,13 ---
    if (!is_armed(nm)) {
      return true;
    }
  
    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 >