# HG changeset patch # User Doug Simon # Date 1367507831 -7200 # Node ID af0b79174c3dc44c1812ae68df0fddc70730835d # Parent f491f51e96b598a1191f4e85147c8c5ecd176ac7 exposed whether ASSERT is defined to Java code and use it to enable checks in ExceptionHandlerStub diff -r f491f51e96b5 -r af0b79174c3d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java --- 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; diff -r f491f51e96b5 -r af0b79174c3d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java --- 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); diff -r f491f51e96b5 -r af0b79174c3d src/share/vm/graal/graalCompilerToVM.cpp --- 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);