changeset 4673:8021e46f4a99

another fix for resolving the issue with biased monitor and deoptimization
author Christian Haeubl <christian.haeubl@oracle.com>
date Wed, 22 Feb 2012 16:53:23 -0800
parents 7167f487cc31
children e1c053324210
files src/cpu/x86/vm/sharedRuntime_x86_64.cpp src/share/vm/c1/c1_Runtime1.cpp src/share/vm/runtime/sharedRuntime.cpp
diffstat 3 files changed, 13 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Wed Feb 22 17:27:11 2012 +0100
+++ b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Wed Feb 22 16:53:23 2012 -0800
@@ -2703,17 +2703,12 @@
   }
 #endif // ASSERT
   
-  __ movl(c_rarg1, (int32_t)(Deoptimization::make_trap_request(Deoptimization::Reason_unreached, Deoptimization::Action_none)));
   __ mov(c_rarg0, r15_thread);
-  __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::uncommon_trap)));
-  oop_maps->add_gc_map( __ pc()-start, map->deep_copy());
-
-  //__ reset_last_Java_frame(false, false);
-  //__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::fetch_unroll_info)));
+  __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::fetch_unroll_info)));
 
   // Need to have an oopmap that tells fetch_unroll_info where to
   // find any register it might need.
-//  oop_maps->add_gc_map(__ pc() - start, map);
+  oop_maps->add_gc_map(__ pc() - start, map);
 
   __ reset_last_Java_frame(false, false);
 
--- a/src/share/vm/c1/c1_Runtime1.cpp	Wed Feb 22 17:27:11 2012 +0100
+++ b/src/share/vm/c1/c1_Runtime1.cpp	Wed Feb 22 16:53:23 2012 -0800
@@ -558,7 +558,7 @@
     thread->set_exception_pc(pc);
 
     // the exception cache is used only by non-implicit exceptions
-    if (continuation != NULL) {
+    if (continuation != NULL && !SharedRuntime::deopt_blob()->contains(continuation)) {
       nm->add_handler_for_exception_and_pc(exception, pc, continuation);
     }
   }
@@ -595,7 +595,6 @@
     continuation = exception_handler_for_pc_helper(thread, exception, pc, nm);
   }
   // Back in JAVA, use no oops DON'T safepoint
-
   // Now check to see if the nmethod we were called from is now deoptimized.
   // If so we must return to the deopt blob and deoptimize the nmethod
   if (nm != NULL && caller_is_deopted()) {
--- a/src/share/vm/runtime/sharedRuntime.cpp	Wed Feb 22 17:27:11 2012 +0100
+++ b/src/share/vm/runtime/sharedRuntime.cpp	Wed Feb 22 16:53:23 2012 -0800
@@ -716,9 +716,16 @@
   if (t == NULL && nm->is_compiled_by_c1()) {
 #ifdef GRAAL
     nm->make_not_entrant();
-    JavaThread::current()->set_exception_pc(ret_pc);
-    JavaThread::current()->set_exception_oop(exception());
-    JavaThread::current()->clear_pending_exception();
+    JavaThread* thread = JavaThread::current();
+    // save the exception for deoptimization
+    thread->set_exception_pc(ret_pc);
+    thread->set_exception_oop(exception());
+    // clear the pending exception and deoptimize the frame
+    thread->clear_pending_exception();    
+    RegisterMap reg_map(thread, false);
+    frame runtime_frame = thread->last_frame();
+    frame caller_frame = runtime_frame.sender(&reg_map);
+    Deoptimization::deoptimize_frame(thread, caller_frame.id());
     return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
 #else
     assert(nm->unwind_handler_begin() != NULL, "");