changeset 22221:2bf50a49e392

allow PE to create InvokeNodes instead of InvokeWithExceptionNodes
author Doug Simon <doug.simon@oracle.com>
date Mon, 13 Jul 2015 17:43:09 +0200
parents 2ffa690969d8
children a3a14b57321e
files graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/InlineInvokePlugin.java graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java
diffstat 3 files changed, 30 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/InlineInvokePlugin.java	Mon Jul 13 17:40:57 2015 +0200
+++ b/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/InlineInvokePlugin.java	Mon Jul 13 17:43:09 2015 +0200
@@ -39,8 +39,17 @@
      */
     public static class InlineInfo {
 
-        /** Marker return value to use when the call site must not be inlined. */
-        public static final InlineInfo DO_NOT_INLINE = new InlineInfo(null, false);
+        /**
+         * Denotes a call site that must not be inlined and should be implemented by a node that
+         * does not speculate on the call not raising an exception.
+         */
+        public static final InlineInfo DO_NOT_INLINE_WITH_EXCEPTION = new InlineInfo(null, false);
+
+        /**
+         * Denotes a call site must not be inlined and can be implemented by a node that speculates
+         * the call will not throw an exception.
+         */
+        public static final InlineInfo DO_NOT_INLINE_NO_EXCEPTION = new InlineInfo(null, false);
 
         private final ResolvedJavaMethod methodToInline;
         private final boolean isIntrinsic;
@@ -75,8 +84,8 @@
      * method than the one specified here as the parameter, which allows method substitutions.
      * <p>
      * Non-null return value with a null {@link InlineInfo#getMethodToInline method}, e.g.,
-     * {@link InlineInfo#DO_NOT_INLINE}: The method is not inlined, and other plugins with a lower
-     * priority cannot overwrite this decision.
+     * {@link InlineInfo#DO_NOT_INLINE_WITH_EXCEPTION}: The method is not inlined, and other plugins
+     * with a lower priority cannot overwrite this decision.
      * <p>
      * Null return value: This plugin made no decision, other plugins with a lower priority are
      * asked.
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java	Mon Jul 13 17:40:57 2015 +0200
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java	Mon Jul 13 17:43:09 2015 +0200
@@ -1325,7 +1325,7 @@
         // be conservative if information was not recorded (could result in endless
         // recompiles otherwise)
         Invoke invoke;
-        if (graphBuilderConfig.omitAllExceptionEdges() ||
+        if (lastInlineInfo == InlineInfo.DO_NOT_INLINE_NO_EXCEPTION || graphBuilderConfig.omitAllExceptionEdges() ||
                         (!StressInvokeWithExceptionNode.getValue() && optimisticOpts.useExceptionProbability() && profilingInfo != null && profilingInfo.getExceptionSeen(bci()) == TriState.FALSE)) {
             invoke = createInvoke(callTarget, resultType);
         } else {
@@ -1426,6 +1426,8 @@
         return false;
     }
 
+    InlineInfo lastInlineInfo;
+
     private boolean tryInline(ValueNode[] args, ResolvedJavaMethod targetMethod, JavaType returnType) {
         boolean canBeInlined = forceInliningEverything || parsingIntrinsic() || targetMethod.canBeInlined();
         if (!canBeInlined) {
@@ -1437,13 +1439,13 @@
         }
 
         for (InlineInvokePlugin plugin : graphBuilderConfig.getPlugins().getInlineInvokePlugins()) {
-            InlineInfo inlineInfo = plugin.shouldInlineInvoke(this, targetMethod, args, returnType);
-            if (inlineInfo != null) {
-                if (inlineInfo.getMethodToInline() == null) {
+            lastInlineInfo = plugin.shouldInlineInvoke(this, targetMethod, args, returnType);
+            if (lastInlineInfo != null) {
+                if (lastInlineInfo.getMethodToInline() == null) {
                     /* Do not inline, and do not ask the remaining plugins. */
                     return false;
                 } else {
-                    return inline(targetMethod, inlineInfo.getMethodToInline(), inlineInfo.isIntrinsic(), args);
+                    return inline(targetMethod, lastInlineInfo.getMethodToInline(), lastInlineInfo.isIntrinsic(), args);
                 }
             }
         }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Mon Jul 13 17:40:57 2015 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Mon Jul 13 17:43:09 2015 +0200
@@ -174,11 +174,12 @@
 
         @Override
         public InlineInfo shouldInlineInvoke(GraphBuilderContext builder, ResolvedJavaMethod original, ValueNode[] arguments, JavaType returnType) {
-            if (original.getAnnotation(TruffleBoundary.class) != null) {
-                return InlineInfo.DO_NOT_INLINE;
+            TruffleBoundary truffleBoundary = original.getAnnotation(TruffleBoundary.class);
+            if (truffleBoundary != null) {
+                return truffleBoundary.throwsControlFlowException() ? InlineInfo.DO_NOT_INLINE_WITH_EXCEPTION : InlineInfo.DO_NOT_INLINE_NO_EXCEPTION;
             }
             if (replacements.hasSubstitution(original, builder.bci())) {
-                return InlineInfo.DO_NOT_INLINE;
+                return InlineInfo.DO_NOT_INLINE_NO_EXCEPTION;
             }
             assert !builder.parsingIntrinsic();
 
@@ -243,17 +244,18 @@
         @Override
         public InlineInfo shouldInlineInvoke(GraphBuilderContext builder, ResolvedJavaMethod original, ValueNode[] arguments, JavaType returnType) {
             if (invocationPlugins.lookupInvocation(original) != null || loopExplosionPlugin.shouldExplodeLoops(original)) {
-                return InlineInfo.DO_NOT_INLINE;
+                return InlineInfo.DO_NOT_INLINE_NO_EXCEPTION;
             }
-            if (original.getAnnotation(TruffleBoundary.class) != null) {
-                return InlineInfo.DO_NOT_INLINE;
+            TruffleBoundary truffleBoundary = original.getAnnotation(TruffleBoundary.class);
+            if (truffleBoundary != null) {
+                return truffleBoundary.throwsControlFlowException() ? InlineInfo.DO_NOT_INLINE_WITH_EXCEPTION : InlineInfo.DO_NOT_INLINE_NO_EXCEPTION;
             }
             if (replacements.hasSubstitution(original, builder.bci())) {
-                return InlineInfo.DO_NOT_INLINE;
+                return InlineInfo.DO_NOT_INLINE_NO_EXCEPTION;
             }
 
             if (original.equals(callSiteProxyMethod) || original.equals(callDirectMethod)) {
-                return InlineInfo.DO_NOT_INLINE;
+                return InlineInfo.DO_NOT_INLINE_NO_EXCEPTION;
             }
             if (hasMethodHandleArgument(arguments)) {
                 /*