< prev index next >

src/hotspot/share/code/nmethod.cpp

Print this page
@@ -1968,27 +1968,25 @@
    if (method() != nullptr) {
      method()->method_holder()->remove_osr_nmethod(this);
    }
  }
  
- void nmethod::log_state_change(const char* reason) const {
-   assert(reason != nullptr, "Must provide a reason");
- 
+ void nmethod::log_state_change(InvalidationReason invalidation_reason) const {
    if (LogCompilation) {
      if (xtty != nullptr) {
        ttyLocker ttyl;  // keep the following output all in one block
        xtty->begin_elem("make_not_entrant thread='%zu' reason='%s'",
-                        os::current_thread_id(), reason);
+                        os::current_thread_id(), invalidation_reason_to_string(invalidation_reason));
        log_identity(xtty);
        xtty->stamp();
        xtty->end_elem();
      }
    }
  
    ResourceMark rm;
    stringStream ss(NEW_RESOURCE_ARRAY(char, 256), 256);
-   ss.print("made not entrant: %s", reason);
+   ss.print("made not entrant: %s", invalidation_reason_to_string(invalidation_reason));
  
    CompileTask::print_ul(this, ss.freeze());
    if (PrintCompilation) {
      print_on_with_msg(tty, ss.freeze());
    }

@@ -1999,13 +1997,11 @@
      method()->unlink_code(this);
    }
  }
  
  // Invalidate code
- bool nmethod::make_not_entrant(const char* reason) {
-   assert(reason != nullptr, "Must provide a reason");
- 
+ bool nmethod::make_not_entrant(InvalidationReason invalidation_reason) {
    // This can be called while the system is already at a safepoint which is ok
    NoSafepointVerifier nsv;
  
    if (is_unloading()) {
      // If the nmethod is unloading, then it is already not entrant through

@@ -2059,22 +2055,22 @@
      // Change state
      bool success = try_transition(not_entrant);
      assert(success, "Transition can't fail");
  
      // Log the transition once
-     log_state_change(reason);
+     log_state_change(invalidation_reason);
  
      // Remove nmethod from method.
      unlink_from_method();
  
    } // leave critical region under NMethodState_lock
  
  #if INCLUDE_JVMCI
    // Invalidate can't occur while holding the NMethodState_lock
    JVMCINMethodData* nmethod_data = jvmci_nmethod_data();
    if (nmethod_data != nullptr) {
-     nmethod_data->invalidate_nmethod_mirror(this);
+     nmethod_data->invalidate_nmethod_mirror(this, invalidation_reason);
    }
  #endif
  
  #ifdef ASSERT
    if (is_osr_method() && method() != nullptr) {

@@ -2108,11 +2104,13 @@
  
  #if INCLUDE_JVMCI
    // Clear the link between this nmethod and a HotSpotNmethod mirror
    JVMCINMethodData* nmethod_data = jvmci_nmethod_data();
    if (nmethod_data != nullptr) {
-     nmethod_data->invalidate_nmethod_mirror(this);
+     nmethod_data->invalidate_nmethod_mirror(this, is_cold() ?
+             nmethod::InvalidationReason::UNLOADING_COLD :
+             nmethod::InvalidationReason::UNLOADING);
    }
  #endif
  
    // Post before flushing as jmethodID is being used
    post_compiled_method_unload();
< prev index next >