changeset 9821:32d8115dade8

Merge.
author Doug Simon <doug.simon@oracle.com>
date Sun, 26 May 2013 00:01:38 +0200
parents 1b60f639ac4b (diff) a9517aa587c7 (current diff)
children e210293dca77
files graal/com.oracle.graal.lir.sparc/.settings/org.eclipse.jdt.core.prefs
diffstat 9 files changed, 46 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaAccessProvider.java	Sat May 25 17:24:37 2013 -0400
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaAccessProvider.java	Sun May 26 00:01:38 2013 +0200
@@ -107,4 +107,9 @@
      * Returning any empty array denotes that the call does not kill any memory locations.
      */
     LocationIdentity[] getKilledLocationIdentities(ForeignCallDescriptor descriptor);
+
+    /**
+     * Determines if deoptimization can occur during a given foreign call.
+     */
+    boolean canDeoptimize(ForeignCallDescriptor descriptor);
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Sat May 25 17:24:37 2013 -0400
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Sun May 26 00:01:38 2013 +0200
@@ -411,6 +411,7 @@
     public long arithmeticSinAddress;
     public long arithmeticCosAddress;
     public long arithmeticTanAddress;
+    public long loadAndClearExceptionAddress;
 
     public int deoptReasonNone;
     public int deoptReasonNullCheck;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Sat May 25 17:24:37 2013 -0400
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Sun May 26 00:01:38 2013 +0200
@@ -97,6 +97,7 @@
     public static final ForeignCallDescriptor OSR_MIGRATION_END = new ForeignCallDescriptor("OSR_migration_end", void.class, long.class);
     public static final ForeignCallDescriptor IDENTITY_HASHCODE = new ForeignCallDescriptor("identity_hashcode", int.class, Object.class);
     public static final ForeignCallDescriptor VERIFY_OOP = new ForeignCallDescriptor("verify_oop", Object.class, Object.class);
+    public static final ForeignCallDescriptor LOAD_AND_CLEAR_EXCEPTION = new ForeignCallDescriptor("load_and_clear_exception", Object.class, Word.class);
 
     public final HotSpotVMConfig config;
 
@@ -213,7 +214,7 @@
     protected HotSpotForeignCallLinkage registerForeignCall(ForeignCallDescriptor descriptor, long address, CallingConvention.Type ccType, RegisterEffect effect, Transition transition,
                     boolean reexecutable, LocationIdentity... killedLocations) {
         Class<?> resultType = descriptor.getResultType();
-        assert resultType.isPrimitive() || Word.class.isAssignableFrom(resultType) : "foreign calls must return objects in thread local storage: " + descriptor;
+        assert transition == LEAF || resultType.isPrimitive() || Word.class.isAssignableFrom(resultType) : "non-leaf foreign calls must return objects in thread local storage: " + descriptor;
         return register(HotSpotForeignCallLinkage.create(descriptor, address, effect, ccType, transition, reexecutable, killedLocations));
     }
 
@@ -263,6 +264,7 @@
         registerForeignCall(ARITHMETIC_SIN, c.arithmeticSinAddress, NativeCall, DESTROYS_REGISTERS, LEAF, REEXECUTABLE, NO_LOCATIONS);
         registerForeignCall(ARITHMETIC_COS, c.arithmeticCosAddress, NativeCall, DESTROYS_REGISTERS, LEAF, REEXECUTABLE, NO_LOCATIONS);
         registerForeignCall(ARITHMETIC_TAN, c.arithmeticTanAddress, NativeCall, DESTROYS_REGISTERS, LEAF, REEXECUTABLE, NO_LOCATIONS);
+        registerForeignCall(LOAD_AND_CLEAR_EXCEPTION, c.loadAndClearExceptionAddress, NativeCall, DESTROYS_REGISTERS, LEAF, NOT_REEXECUTABLE, ANY_LOCATION);
 
         registerForeignCall(EXCEPTION_HANDLER_FOR_PC, c.exceptionHandlerForPcAddress, NativeCall, DESTROYS_REGISTERS, NOT_LEAF, REEXECUTABLE, ANY_LOCATION);
         registerForeignCall(EXCEPTION_HANDLER_FOR_RETURN_ADDRESS, c.exceptionHandlerForReturnAddressAddress, NativeCall, DESTROYS_REGISTERS, NOT_LEAF, REEXECUTABLE, ANY_LOCATION);
@@ -996,6 +998,10 @@
         return foreignCalls.get(descriptor).isReexecutable();
     }
 
+    public boolean canDeoptimize(ForeignCallDescriptor descriptor) {
+        return !foreignCalls.get(descriptor).isLeaf();
+    }
+
     public LocationIdentity[] getKilledLocationIdentities(ForeignCallDescriptor descriptor) {
         return foreignCalls.get(descriptor).getKilledLocations();
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/LoadExceptionObjectSnippets.java	Sat May 25 17:24:37 2013 -0400
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/LoadExceptionObjectSnippets.java	Sun May 26 00:01:38 2013 +0200
@@ -22,11 +22,15 @@
  */
 package com.oracle.graal.hotspot.replacements;
 
+import static com.oracle.graal.hotspot.meta.HotSpotRuntime.*;
 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
 import static com.oracle.graal.nodes.extended.UnsafeCastNode.*;
 import static com.oracle.graal.replacements.SnippetTemplate.*;
 
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
@@ -34,6 +38,7 @@
 import com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates;
 import com.oracle.graal.replacements.SnippetTemplate.Arguments;
 import com.oracle.graal.replacements.SnippetTemplate.SnippetInfo;
+import com.oracle.graal.replacements.nodes.*;
 import com.oracle.graal.word.*;
 
 /**
@@ -41,6 +46,11 @@
  */
 public class LoadExceptionObjectSnippets implements Snippets {
 
+    /**
+     * Alternative way to implement exception object loading.
+     */
+    private static final boolean USE_C_RUNTIME = Boolean.getBoolean("graal.loadExceptionObject.useCRuntime");
+
     @Snippet
     public static Object loadException() {
         Word thread = thread();
@@ -59,8 +69,18 @@
         }
 
         public void lower(LoadExceptionObjectNode loadExceptionObject) {
-            Arguments args = new Arguments(loadException);
-            template(args).instantiate(runtime, loadExceptionObject, DEFAULT_REPLACER, args);
+            if (USE_C_RUNTIME) {
+                StructuredGraph graph = loadExceptionObject.graph();
+                HotSpotRuntime hsRuntime = (HotSpotRuntime) runtime;
+                ReadRegisterNode thread = graph.add(new ReadRegisterNode(hsRuntime.threadRegister(), true, false));
+                graph.addBeforeFixed(loadExceptionObject, thread);
+                ForeignCallNode loadExceptionC = graph.add(new ForeignCallNode(runtime, LOAD_AND_CLEAR_EXCEPTION, thread));
+                loadExceptionC.setStateAfter(loadExceptionObject.stateAfter());
+                graph.replaceFixedWithFixed(loadExceptionObject, loadExceptionC);
+            } else {
+                Arguments args = new Arguments(loadException);
+                template(args).instantiate(runtime, loadExceptionObject, DEFAULT_REPLACER, args);
+            }
         }
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ForeignCallNode.java	Sat May 25 17:24:37 2013 -0400
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ForeignCallNode.java	Sun May 26 00:01:38 2013 +0200
@@ -121,7 +121,7 @@
 
     @Override
     public boolean canDeoptimize() {
-        return true;
+        return runtime.canDeoptimize(descriptor);
     }
 
     @Override
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/CompiledExceptionHandlerTest.java	Sat May 25 17:24:37 2013 -0400
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/CompiledExceptionHandlerTest.java	Sun May 26 00:01:38 2013 +0200
@@ -72,7 +72,7 @@
             try {
                 raiseException(message);
             } catch (Exception e) {
-                return message;
+                return message + e.getMessage();
             }
         }
         return null;
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Sat May 25 17:24:37 2013 -0400
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Sun May 26 00:01:38 2013 +0200
@@ -795,6 +795,7 @@
   set_address("logObjectAddress", GraalRuntime::log_object);
   set_address("logPrintfAddress", GraalRuntime::log_printf);
   set_address("vmErrorAddress", GraalRuntime::vm_error);
+  set_address("loadAndClearExceptionAddress", GraalRuntime::load_and_clear_exception);
   set_address("writeBarrierPreAddress", GraalRuntime::write_barrier_pre);
   set_address("writeBarrierPostAddress", GraalRuntime::write_barrier_post);
   set_address("javaTimeMillisAddress", CAST_FROM_FN_PTR(address, os::javaTimeMillis));
--- a/src/share/vm/graal/graalRuntime.cpp	Sat May 25 17:24:37 2013 -0400
+++ b/src/share/vm/graal/graalRuntime.cpp	Sun May 26 00:01:38 2013 +0200
@@ -380,6 +380,13 @@
   report_vm_error(__FILE__, __LINE__, error_msg, detail_msg);
 JRT_END
 
+JRT_LEAF(oop, GraalRuntime::load_and_clear_exception(JavaThread* thread))
+  oop exception = thread->exception_oop();
+  assert(exception != NULL, "npe");
+  thread->set_exception_oop(NULL);
+  thread->set_exception_pc(0);
+  return exception;
+JRT_END
 
 JRT_LEAF(void, GraalRuntime::log_printf(JavaThread* thread, oop format, jlong v1, jlong v2, jlong v3))
   ResourceMark rm;
--- a/src/share/vm/graal/graalRuntime.hpp	Sat May 25 17:24:37 2013 -0400
+++ b/src/share/vm/graal/graalRuntime.hpp	Sun May 26 00:01:38 2013 +0200
@@ -42,6 +42,7 @@
   static void create_null_exception(JavaThread* thread);
   static void create_out_of_bounds_exception(JavaThread* thread, jint index);
   static void vm_error(JavaThread* thread, oop where, oop format, jlong value);
+  static oop load_and_clear_exception(JavaThread* thread);
   static void log_printf(JavaThread* thread, oop format, jlong v1, jlong v2, jlong v3);
   static void log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline);
   // Note: Must be kept in sync with constants in com.oracle.graal.replacements.Log