# HG changeset patch # User Christian Wimmer # Date 1443218842 25200 # Node ID 89520cbb9633cd7e72597fc18c9b2084288cabc6 # Parent a610e5da2e28727dd715991879d2863ef70a3d22# Parent 78293834a24b68afd15d5526394b87eadc70177a Merge diff -r a610e5da2e28 -r 89520cbb9633 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java Thu Sep 24 14:24:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java Fri Sep 25 15:07:22 2015 -0700 @@ -124,7 +124,7 @@ registerStableOptionPlugins(invocationPlugins, snippetReflection); registerAESPlugins(invocationPlugins, config); registerCRC32Plugins(invocationPlugins, config); - StandardGraphBuilderPlugins.registerInvocationPlugins(metaAccess, invocationPlugins); + StandardGraphBuilderPlugins.registerInvocationPlugins(metaAccess, invocationPlugins, true); return plugins; } diff -r a610e5da2e28 -r 89520cbb9633 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhase.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhase.java Thu Sep 24 14:24:07 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhase.java Fri Sep 25 15:07:22 2015 -0700 @@ -90,17 +90,13 @@ } }; - @SuppressWarnings("all") - private static boolean assertionsEnabled() { - boolean enabled = false; - assert enabled = true; - return enabled; + /** Lazy initialization to create pattern only when assertions are enabled. */ + static class NamePatternHolder { + static final Pattern NAME_PATTERN = Pattern.compile("[A-Z][A-Za-z0-9]+"); } - private static final Pattern NAME_PATTERN = assertionsEnabled() ? Pattern.compile("[A-Z][A-Za-z0-9]+") : null; - private static boolean checkName(String name) { - assert name == null || NAME_PATTERN.matcher(name).matches() : "illegal phase name: " + name; + assert name == null || NamePatternHolder.NAME_PATTERN.matcher(name).matches() : "illegal phase name: " + name; return true; } diff -r a610e5da2e28 -r 89520cbb9633 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/BasePhase.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/BasePhase.java Thu Sep 24 14:24:07 2015 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/BasePhase.java Fri Sep 25 15:07:22 2015 -0700 @@ -67,17 +67,13 @@ */ private final DebugMemUseTracker memUseTracker; - @SuppressWarnings("all") - private static boolean assertionsEnabled() { - boolean enabled = false; - assert enabled = true; - return enabled; + /** Lazy initialization to create pattern only when assertions are enabled. */ + static class NamePatternHolder { + static final Pattern NAME_PATTERN = Pattern.compile("[A-Z][A-Za-z0-9]+"); } - private static final Pattern NAME_PATTERN = assertionsEnabled() ? Pattern.compile("[A-Z][A-Za-z0-9]+") : null; - private static boolean checkName(String name) { - assert NAME_PATTERN.matcher(name).matches() : "illegal phase name: " + name; + assert NamePatternHolder.NAME_PATTERN.matcher(name).matches() : "illegal phase name: " + name; return true; } diff -r a610e5da2e28 -r 89520cbb9633 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java Thu Sep 24 14:24:07 2015 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java Fri Sep 25 15:07:22 2015 -0700 @@ -118,10 +118,10 @@ } // @formatter:on - public static void registerInvocationPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins) { + public static void registerInvocationPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins, boolean allowDeoptimization) { registerObjectPlugins(plugins); registerClassPlugins(plugins); - registerMathPlugins(plugins); + registerMathPlugins(plugins, allowDeoptimization); registerUnsignedMathPlugins(plugins); registerCharacterPlugins(plugins); registerShortPlugins(plugins); @@ -332,28 +332,30 @@ }); } - private static void registerMathPlugins(InvocationPlugins plugins) { + private static void registerMathPlugins(InvocationPlugins plugins, boolean allowDeoptimization) { Registration r = new Registration(plugins, Math.class); - for (JavaKind kind : new JavaKind[]{JavaKind.Int, JavaKind.Long}) { - Class type = kind.toJavaClass(); - r.register2("addExact", type, type, new InvocationPlugin() { - public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) { - b.addPush(kind, new IntegerAddExactNode(x, y)); - return true; - } - }); - r.register2("subtractExact", type, type, new InvocationPlugin() { - public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) { - b.addPush(kind, new IntegerSubExactNode(x, y)); - return true; - } - }); - r.register2("multiplyExact", type, type, new InvocationPlugin() { - public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) { - b.addPush(kind, new IntegerMulExactNode(x, y)); - return true; - } - }); + if (allowDeoptimization) { + for (JavaKind kind : new JavaKind[]{JavaKind.Int, JavaKind.Long}) { + Class type = kind.toJavaClass(); + r.register2("addExact", type, type, new InvocationPlugin() { + public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) { + b.addPush(kind, new IntegerAddExactNode(x, y)); + return true; + } + }); + r.register2("subtractExact", type, type, new InvocationPlugin() { + public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) { + b.addPush(kind, new IntegerSubExactNode(x, y)); + return true; + } + }); + r.register2("multiplyExact", type, type, new InvocationPlugin() { + public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) { + b.addPush(kind, new IntegerMulExactNode(x, y)); + return true; + } + }); + } } r.register1("abs", Float.TYPE, new InvocationPlugin() { public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { diff -r a610e5da2e28 -r 89520cbb9633 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java Thu Sep 24 14:24:07 2015 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java Fri Sep 25 15:07:22 2015 -0700 @@ -26,6 +26,7 @@ import static com.oracle.graal.truffle.TruffleCompilerOptions.TruffleBackgroundCompilation; import static com.oracle.graal.truffle.TruffleCompilerOptions.TruffleCallTargetProfiling; import static com.oracle.graal.truffle.TruffleCompilerOptions.TruffleCompilationExceptionsAreFatal; +import static com.oracle.graal.truffle.TruffleCompilerOptions.TruffleCompilationExceptionsArePrinted; import static com.oracle.graal.truffle.TruffleCompilerOptions.TruffleCompilationExceptionsAreThrown; import static com.oracle.graal.truffle.TruffleCompilerOptions.TruffleReturnTypeSpeculation; @@ -385,9 +386,11 @@ if (TruffleCompilationExceptionsAreThrown.getValue()) { throw new OptimizationFailedException(t, this); } - if (TruffleCompilationExceptionsAreFatal.getValue()) { + if (TruffleCompilationExceptionsArePrinted.getValue() || TruffleCompilationExceptionsAreFatal.getValue()) { printException(t); - System.exit(-1); + if (TruffleCompilationExceptionsAreFatal.getValue()) { + System.exit(-1); + } } } } diff -r a610e5da2e28 -r 89520cbb9633 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java Thu Sep 24 14:24:07 2015 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java Fri Sep 25 15:07:22 2015 -0700 @@ -147,6 +147,9 @@ @Option(help = "Treat compilation exceptions as fatal exceptions that will exit the application", type = OptionType.Debug) public static final OptionValue TruffleCompilationExceptionsAreFatal = new OptionValue<>(false); + @Option(help = "Prints the exception stack trace for compilation exceptions", type = OptionType.Debug) + public static final OptionValue TruffleCompilationExceptionsArePrinted = new OptionValue<>(false); + @Option(help = "Treat compilation exceptions as thrown runtime exceptions", type = OptionType.Debug) public static final OptionValue TruffleCompilationExceptionsAreThrown = new OptionValue<>(false);