6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
authornever
Tue, 19 Oct 2010 16:14:34 -0700
changeset 7106 867c9d296c6b
parent 7103 4a46a9508d91
child 7107 db4e07fb94ed
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places Reviewed-by: kvn, twisti
hotspot/src/share/vm/c1/c1_Runtime1.cpp
hotspot/src/share/vm/includeDB_features
hotspot/src/share/vm/includeDB_jvmti
hotspot/src/share/vm/prims/jvmtiEnv.cpp
hotspot/src/share/vm/prims/jvmtiEnvBase.cpp
hotspot/src/share/vm/prims/jvmtiImpl.cpp
hotspot/src/share/vm/runtime/deoptimization.cpp
hotspot/src/share/vm/runtime/deoptimization.hpp
hotspot/src/share/vm/runtime/safepoint.cpp
hotspot/src/share/vm/runtime/vm_operations.cpp
hotspot/src/share/vm/runtime/vm_operations.hpp
--- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp	Mon Oct 18 15:43:29 2010 -0700
+++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp	Tue Oct 19 16:14:34 2010 -0700
@@ -107,7 +107,6 @@
     RegisterMap reg_map(thread, false);
     frame runtime_frame = thread->last_frame();
     frame caller_frame = runtime_frame.sender(&reg_map);
-    // bypass VM_DeoptimizeFrame and deoptimize the frame directly
     Deoptimization::deoptimize_frame(thread, caller_frame.id());
     assert(caller_is_deopted(), "Must be deoptimized");
   }
@@ -368,8 +367,7 @@
     if (osr_nm != NULL) {
       RegisterMap map(thread, false);
       frame fr =  thread->last_frame().sender(&map);
-      VM_DeoptimizeFrame deopt(thread, fr.id());
-      VMThread::execute(&deopt);
+      Deoptimization::deoptimize_frame(thread, fr.id());
     }
   JRT_BLOCK_END
   return NULL;
@@ -441,8 +439,8 @@
     // We don't really want to deoptimize the nmethod itself since we
     // can actually continue in the exception handler ourselves but I
     // don't see an easy way to have the desired effect.
-    VM_DeoptimizeFrame deopt(thread, caller_frame.id());
-    VMThread::execute(&deopt);
+    Deoptimization::deoptimize_frame(thread, caller_frame.id());
+    assert(caller_is_deopted(), "Must be deoptimized");
 
     return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
   }
@@ -835,8 +833,7 @@
       nm->make_not_entrant();
     }
 
-    VM_DeoptimizeFrame deopt(thread, caller_frame.id());
-    VMThread::execute(&deopt);
+    Deoptimization::deoptimize_frame(thread, caller_frame.id());
 
     // Return to the now deoptimized frame.
   }
--- a/hotspot/src/share/vm/includeDB_features	Mon Oct 18 15:43:29 2010 -0700
+++ b/hotspot/src/share/vm/includeDB_features	Tue Oct 19 16:14:34 2010 -0700
@@ -154,6 +154,7 @@
 jvmtiExtensions.hpp                     jvmti.h
 jvmtiExtensions.hpp                     jvmtiEnv.hpp
 
+jvmtiImpl.cpp                           deoptimization.hpp
 jvmtiImpl.cpp                           exceptions.hpp
 jvmtiImpl.cpp                           handles.hpp
 jvmtiImpl.cpp                           handles.inline.hpp
--- a/hotspot/src/share/vm/includeDB_jvmti	Mon Oct 18 15:43:29 2010 -0700
+++ b/hotspot/src/share/vm/includeDB_jvmti	Tue Oct 19 16:14:34 2010 -0700
@@ -87,6 +87,7 @@
 jvmtiEnv.hpp                            jvmtiEnvBase.hpp
 
 jvmtiEnvBase.cpp                        biasedLocking.hpp
+jvmtiEnvBase.cpp                        deoptimization.hpp
 jvmtiEnvBase.cpp                        interfaceSupport.hpp
 jvmtiEnvBase.cpp                        jfieldIDWorkaround.hpp
 jvmtiEnvBase.cpp                        jvmtiEnv.hpp
--- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Mon Oct 18 15:43:29 2010 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Tue Oct 19 16:14:34 2010 -0700
@@ -1407,8 +1407,7 @@
     // If any of the top 2 frames is a compiled one, need to deoptimize it
     for (int i = 0; i < 2; i++) {
       if (!is_interpreted[i]) {
-        VM_DeoptimizeFrame op(java_thread, frame_sp[i]);
-        VMThread::execute(&op);
+        Deoptimization::deoptimize_frame(java_thread, frame_sp[i]);
       }
     }
 
--- a/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp	Mon Oct 18 15:43:29 2010 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp	Tue Oct 19 16:14:34 2010 -0700
@@ -1322,8 +1322,7 @@
     if (!vf->fr().can_be_deoptimized()) {
       return JVMTI_ERROR_OPAQUE_FRAME;
     }
-    VM_DeoptimizeFrame deopt(java_thread, jvf->fr().id());
-    VMThread::execute(&deopt);
+    Deoptimization::deoptimize_frame(java_thread, jvf->fr().id());
   }
 
   // Get information about method return type
--- a/hotspot/src/share/vm/prims/jvmtiImpl.cpp	Mon Oct 18 15:43:29 2010 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiImpl.cpp	Tue Oct 19 16:14:34 2010 -0700
@@ -799,8 +799,7 @@
 
       // Schedule deoptimization so that eventually the local
       // update will be written to an interpreter frame.
-      VM_DeoptimizeFrame deopt(_jvf->thread(), _jvf->fr().id());
-      VMThread::execute(&deopt);
+      Deoptimization::deoptimize_frame(_jvf->thread(), _jvf->fr().id());
 
       // Now store a new value for the local which will be applied
       // once deoptimization occurs. Note however that while this
--- a/hotspot/src/share/vm/runtime/deoptimization.cpp	Mon Oct 18 15:43:29 2010 -0700
+++ b/hotspot/src/share/vm/runtime/deoptimization.cpp	Tue Oct 19 16:14:34 2010 -0700
@@ -1065,7 +1065,9 @@
 }
 
 
-void Deoptimization::deoptimize_frame(JavaThread* thread, intptr_t* id) {
+void Deoptimization::deoptimize_frame_internal(JavaThread* thread, intptr_t* id) {
+  assert(thread == Thread::current() || SafepointSynchronize::is_at_safepoint(),
+         "can only deoptimize other thread at a safepoint");
   // Compute frame and register map based on thread and sp.
   RegisterMap reg_map(thread, UseBiasedLocking);
   frame fr = thread->last_frame();
@@ -1076,6 +1078,16 @@
 }
 
 
+void Deoptimization::deoptimize_frame(JavaThread* thread, intptr_t* id) {
+  if (thread == Thread::current()) {
+    Deoptimization::deoptimize_frame_internal(thread, id);
+  } else {
+    VM_DeoptimizeFrame deopt(thread, id);
+    VMThread::execute(&deopt);
+  }
+}
+
+
 // JVMTI PopFrame support
 JRT_LEAF(void, Deoptimization::popframe_preserve_args(JavaThread* thread, int bytes_to_save, void* start_address))
 {
--- a/hotspot/src/share/vm/runtime/deoptimization.hpp	Mon Oct 18 15:43:29 2010 -0700
+++ b/hotspot/src/share/vm/runtime/deoptimization.hpp	Tue Oct 19 16:14:34 2010 -0700
@@ -216,6 +216,10 @@
   // Only called from VMDeoptimizeFrame
   // @argument thread.     Thread where stub_frame resides.
   // @argument id.         id of frame that should be deoptimized.
+  static void deoptimize_frame_internal(JavaThread* thread, intptr_t* id);
+
+  // If thread is not the current thread then execute
+  // VM_DeoptimizeFrame otherwise deoptimize directly.
   static void deoptimize_frame(JavaThread* thread, intptr_t* id);
 
   // Statistics
--- a/hotspot/src/share/vm/runtime/safepoint.cpp	Mon Oct 18 15:43:29 2010 -0700
+++ b/hotspot/src/share/vm/runtime/safepoint.cpp	Tue Oct 19 16:14:34 2010 -0700
@@ -940,8 +940,7 @@
     // as otherwise we may never deliver it.
     if (thread()->has_async_condition()) {
       ThreadInVMfromJavaNoAsyncException __tiv(thread());
-      VM_DeoptimizeFrame deopt(thread(), caller_fr.id());
-      VMThread::execute(&deopt);
+      Deoptimization::deoptimize_frame(thread(), caller_fr.id());
     }
 
     // If an exception has been installed we must check for a pending deoptimization
--- a/hotspot/src/share/vm/runtime/vm_operations.cpp	Mon Oct 18 15:43:29 2010 -0700
+++ b/hotspot/src/share/vm/runtime/vm_operations.cpp	Tue Oct 19 16:14:34 2010 -0700
@@ -100,7 +100,7 @@
 
 
 void VM_DeoptimizeFrame::doit() {
-  Deoptimization::deoptimize_frame(_thread, _id);
+  Deoptimization::deoptimize_frame_internal(_thread, _id);
 }
 
 
--- a/hotspot/src/share/vm/runtime/vm_operations.hpp	Mon Oct 18 15:43:29 2010 -0700
+++ b/hotspot/src/share/vm/runtime/vm_operations.hpp	Tue Oct 19 16:14:34 2010 -0700
@@ -231,12 +231,18 @@
   bool allow_nested_vm_operations() const        { return true; }
 };
 
+
+// Deopt helper that can deoptimize frames in threads other than the
+// current thread.  Only used through Deoptimization::deoptimize_frame.
 class VM_DeoptimizeFrame: public VM_Operation {
+  friend class Deoptimization;
+
  private:
   JavaThread* _thread;
   intptr_t*   _id;
+  VM_DeoptimizeFrame(JavaThread* thread, intptr_t* id);
+
  public:
-  VM_DeoptimizeFrame(JavaThread* thread, intptr_t* id);
   VMOp_Type type() const                         { return VMOp_DeoptimizeFrame; }
   void doit();
   bool allow_nested_vm_operations() const        { return true;  }