changeset 9519:af0b79174c3d

exposed whether ASSERT is defined to Java code and use it to enable checks in ExceptionHandlerStub
author Doug Simon <doug.simon@oracle.com>
date Thu, 02 May 2013 17:17:11 +0200
parents f491f51e96b5
children 3bb1834202f7
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java src/share/vm/graal/graalCompilerToVM.cpp
diffstat 3 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Thu May 02 17:16:00 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Thu May 02 17:17:11 2013 +0200
@@ -33,6 +33,7 @@
     }
 
     // os information, register layout, code generation, ...
+    public boolean cAssertions;
     public boolean windowsOs;
     public int codeEntryAlignment;
     public boolean verifyOops;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java	Thu May 02 17:16:00 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java	Thu May 02 17:17:11 2013 +0200
@@ -22,6 +22,7 @@
  */
 package com.oracle.graal.hotspot.stubs;
 
+import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 import static com.oracle.graal.hotspot.nodes.PatchReturnAddressNode.*;
 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
 
@@ -64,7 +65,7 @@
 
     @Snippet
     private static void exceptionHandler(Object exception, Word exceptionPc) {
-        checkNoExceptionInThread();
+        checkNoExceptionInThread(exception, exceptionPc);
         writeExceptionOop(thread(), exception);
         writeExceptionPc(thread(), exceptionPc);
         if (logging()) {
@@ -84,13 +85,15 @@
         patchReturnAddress(handlerPc);
     }
 
-    private static void checkNoExceptionInThread() {
+    private static void checkNoExceptionInThread(Object exception, Word exceptionPc) {
         if (assertionsEnabled()) {
-            if (readExceptionOop(thread()) != null) {
-                fatal("exception oop must be null, not %p", Word.fromObject(readExceptionOop(thread())).rawValue());
+            Object currentException = readExceptionOop(thread());
+            if (currentException != null && currentException != exception) {
+                fatal("exception oop must be null or %p, not %p", Word.fromObject(exception).rawValue(), Word.fromObject(currentException).rawValue());
             }
-            if (readExceptionPc(thread()).notEqual(Word.zero())) {
-                fatal("exception pc must be zero, not %p", readExceptionPc(thread()).rawValue());
+            Word currentExceptionPc = readExceptionPc(thread());
+            if (currentExceptionPc.notEqual(Word.zero()) && currentExceptionPc.notEqual(exceptionPc)) {
+                fatal("exception pc must be zero or %p, not %p", exceptionPc.rawValue(), currentExceptionPc.rawValue());
             }
         }
     }
@@ -105,7 +108,7 @@
     private static boolean assertionsEnabled() {
         boolean enabled = false;
         assert enabled = true;
-        return enabled;
+        return enabled || graalRuntime().getConfig().cAssertions;
     }
 
     public static final Descriptor EXCEPTION_HANDLER_FOR_PC = descriptorFor(ExceptionHandlerStub.class, "exceptionHandlerForPc", false);
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Thu May 02 17:16:00 2013 +0200
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Thu May 02 17:17:11 2013 +0200
@@ -634,6 +634,7 @@
 #else
   set_boolean("windowsOs", false);
 #endif
+  set_boolean("cAssertions", DEBUG_ONLY(true) NOT_DEBUG(false));
   set_boolean("verifyOops", VerifyOops);
   set_boolean("ciTime", CITime);
   set_boolean("compileTheWorld", CompileTheWorld);