changeset 4677:74c0b866fe8d

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 23 Feb 2012 12:06:39 +0100
parents 03ea39a3cf68 (current diff) e1c053324210 (diff)
children a03f3fd16b22
files src/cpu/x86/vm/sharedRuntime_x86_64.cpp
diffstat 4 files changed, 37 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Wed Feb 22 21:24:08 2012 +0100
+++ b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Thu Feb 23 12:06:39 2012 +0100
@@ -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 21:24:08 2012 +0100
+++ b/src/share/vm/c1/c1_Runtime1.cpp	Thu Feb 23 12:06:39 2012 +0100
@@ -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/deoptimization.cpp	Wed Feb 22 21:24:08 2012 +0100
+++ b/src/share/vm/runtime/deoptimization.cpp	Thu Feb 23 12:06:39 2012 +0100
@@ -162,8 +162,10 @@
   // handler. Note this fact before we start generating temporary frames
   // that can confuse an asynchronous stack walker. This counter is
   // decremented at the end of unpack_frames().
+  if (TraceDeoptimization) {
+    tty->print("Deoptimization "); 
+  }
   thread->inc_in_deopt_handler();
-
   return fetch_unroll_info_helper(thread);
 JRT_END
 
@@ -176,10 +178,6 @@
   // the vframeArray is created.
   //
 
-  if (PrintDeoptimizationDetails) {
-    tty->print_cr("fetching unroll info");
-  }
-
   // Allocate our special deoptimization ResourceMark
   DeoptResourceMark* dmark = new DeoptResourceMark(thread);
   assert(thread->deopt_mark() == NULL, "Pending deopt!");
@@ -212,11 +210,13 @@
   chunk->push(compiledVFrame::cast(vf));
 
   // TODO(tw): Fix this hack after introducing GRAAL macro.
-//#ifdef COMPILER2
+#if defined(COMPILER2) || defined(GRAAL)
   // Reallocate the non-escaping objects and restore their fields. Then
   // relock objects if synchronization on them was eliminated.
-//  if (DoEscapeAnalysis) {
-//    if (EliminateAllocations) {
+#ifdef COMPILER2
+  if (DoEscapeAnalysis) {
+    if (EliminateAllocations) {
+#endif // COMPILER2
       assert (chunk->at(0)->scope() != NULL,"expect only compiled java frames");
       GrowableArray<ScopeValue*>* objects = chunk->at(0)->scope()->objects();
 
@@ -254,14 +254,16 @@
           tty->print_cr("REALLOC OBJECTS in thread " INTPTR_FORMAT, thread);
           print_objects(objects);
         }
-#endif
+#endif // !PRODUCT
       }
       if (save_oop_result) {
         // Restore result.
         deoptee.set_saved_oop_result(&map, return_value());
       }
-//    }
-//    if (EliminateLocks) {
+#ifdef COMPILER2
+    }
+    if (EliminateLocks) {
+#endif // COMPILER2
 #ifndef PRODUCT
       bool first = true;
 #endif
@@ -285,12 +287,15 @@
               }
             }
           }
-#endif
+#endif // !PRODUCT
         }
       }
-//    }
-//  }
-//#endif // COMPILER2
+#ifdef COMPILER2
+    }
+  }
+#endif // COMPILER2
+#endif // COMPILER2 || GRAAL
+
   // Ensure that no safepoint is taken after pointers have been stored
   // in fields of rematerialized objects.  If a safepoint occurs from here on
   // out the java state residing in the vframeArray will be missed.
@@ -1264,7 +1269,7 @@
     ScopeDesc*      trap_scope  = cvf->scope();
     
     if (TraceDeoptimization) {
-      tty->print_cr("Deoptimization: bci=%d pc=%d, relative_pc=%d, method=%s", trap_scope->bci(), fr.pc(), fr.pc() - nm->code_begin(), trap_scope->method()->name()->as_C_string());
+      tty->print_cr("  bci=%d pc=%d, relative_pc=%d, method=%s", trap_scope->bci(), fr.pc(), fr.pc() - nm->code_begin(), trap_scope->method()->name()->as_C_string());
       if (thread->graal_deopt_info() != NULL) {
         oop deopt_info = thread->graal_deopt_info();
         if (java_lang_String::is_instance(deopt_info)) {
@@ -1698,7 +1703,9 @@
 }
 
 Deoptimization::UnrollBlock* Deoptimization::uncommon_trap(JavaThread* thread, jint trap_request) {
-
+  if (TraceDeoptimization) {
+    tty->print("Uncommon trap "); 
+  }
   // Still in Java no safepoints
   {
     // This enters VM and may safepoint
--- a/src/share/vm/runtime/sharedRuntime.cpp	Wed Feb 22 21:24:08 2012 +0100
+++ b/src/share/vm/runtime/sharedRuntime.cpp	Thu Feb 23 12:06:39 2012 +0100
@@ -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, "");