diff src/share/vm/runtime/sharedRuntime.cpp @ 7154:5d0bb7d52783

changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
author Doug Simon <doug.simon@oracle.com>
date Wed, 12 Dec 2012 21:36:40 +0100
parents 1baf7f1e3f23
children 291ffc492eb6
line wrap: on
line diff
--- a/src/share/vm/runtime/sharedRuntime.cpp	Wed Dec 12 15:46:11 2012 +0100
+++ b/src/share/vm/runtime/sharedRuntime.cpp	Wed Dec 12 21:36:40 2012 +0100
@@ -630,24 +630,25 @@
   ResourceMark rm;
 
 #ifdef GRAAL
-  // lookup exception handler for this pc
-  int catch_pco = ret_pc - nm->code_begin();
-  ExceptionHandlerTable table(nm);
-  HandlerTableEntry *t = table.entry_for(catch_pco, -1, 0);
-  if (t != NULL) {
-    return nm->code_begin() + t->pco();
-  } else {
-    // there is no exception handler for this pc => deoptimize
-    nm->make_not_entrant();
-    JavaThread* thread = JavaThread::current();
-    RegisterMap reg_map(thread);
-    frame runtime_frame = thread->last_frame();
-    frame caller_frame = runtime_frame.sender(&reg_map);
-    Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_not_compiled_exception_handler);
-    return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
+  if (nm->is_compiled_by_graal()) {
+    // lookup exception handler for this pc
+    int catch_pco = ret_pc - nm->code_begin();
+    ExceptionHandlerTable table(nm);
+    HandlerTableEntry *t = table.entry_for(catch_pco, -1, 0);
+    if (t != NULL) {
+      return nm->code_begin() + t->pco();
+    } else {
+      // there is no exception handler for this pc => deoptimize
+      nm->make_not_entrant();
+      JavaThread* thread = JavaThread::current();
+      RegisterMap reg_map(thread);
+      frame runtime_frame = thread->last_frame();
+      frame caller_frame = runtime_frame.sender(&reg_map);
+      Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_not_compiled_exception_handler);
+      return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
+    }
   }
-
-#else
+#endif
 
   ScopeDesc* sd = nm->scope_desc_at(ret_pc);
   // determine handler bci, if any
@@ -728,7 +729,6 @@
   }
 
   return nm->code_begin() + t->pco();
-#endif
 }
 
 JRT_ENTRY(void, SharedRuntime::throw_AbstractMethodError(JavaThread* thread))
@@ -871,9 +871,13 @@
           _implicit_null_throws++;
 #endif
 #ifdef GRAAL
-          target_pc = deoptimize_for_implicit_exception(thread, pc, nm, Deoptimization::Reason_null_check);
-#else
+          if (nm->is_compiled_by_graal()) {
+            target_pc = deoptimize_for_implicit_exception(thread, pc, nm, Deoptimization::Reason_null_check);
+          } else {
+#endif
           target_pc = nm->continuation_for_implicit_exception(pc);
+#ifdef GRAAL
+          }
 #endif
           // If there's an unexpected fault, target_pc might be NULL,
           // in which case we want to fall through into the normal
@@ -891,12 +895,16 @@
         _implicit_div0_throws++;
 #endif
 #ifdef GRAAL
-        if (TraceSignals) {
-          tty->print_cr("Graal implicit div0");
+        if (nm->is_compiled_by_graal()) {
+          if (TraceSignals) {
+            tty->print_cr("Graal implicit div0");
+          }
+          target_pc = deoptimize_for_implicit_exception(thread, pc, nm, Deoptimization::Reason_div0_check);
+        } else {
+#endif
+        target_pc = nm->continuation_for_implicit_exception(pc);
+#ifdef GRAAL
         }
-        target_pc = deoptimize_for_implicit_exception(thread, pc, nm, Deoptimization::Reason_div0_check);
-#else
-        target_pc = nm->continuation_for_implicit_exception(pc);
 #endif
         // If there's an unexpected fault, target_pc might be NULL,
         // in which case we want to fall through into the normal