changeset 19847:e17f04731c61

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sat, 14 Mar 2015 02:04:40 +0100
parents 7fdfb533dc7a (current diff) a9fbe23a602b (diff)
children e532af44f9f9
files graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java
diffstat 9 files changed, 42 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java	Sat Mar 14 01:57:26 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java	Sat Mar 14 02:04:40 2015 +0100
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.hotspot.test;
 
+import static com.oracle.graal.nodes.spi.Replacements.*;
+
 import java.io.*;
 import java.lang.reflect.*;
 import java.security.*;
@@ -58,6 +60,8 @@
 
     @Test
     public void testEncryptSubstitution() throws Exception {
+        Assume.assumeTrue(SELF_RECURSIVE_INTRINSICS_ENABLED);
+
         byte[] seed = {0x4, 0x7, 0x1, 0x1};
         SecureRandom random = new SecureRandom(seed);
         KeyGenerator aesKeyGen = KeyGenerator.getInstance("AES");
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInlineInvokePlugin.java	Sat Mar 14 01:57:26 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInlineInvokePlugin.java	Sat Mar 14 02:04:40 2015 +0100
@@ -48,20 +48,22 @@
     public InlineInfo getInlineInfo(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args, JavaType returnType) {
         ResolvedJavaMethod subst = replacements.getMethodSubstitutionMethod(method);
         if (subst != null) {
-            // Forced inlining of intrinsics
-            return new InlineInfo(subst, true);
+            if (b.parsingReplacement() || InlineDuringParsing.getValue()) {
+                // Forced inlining of intrinsics
+                return new InlineInfo(subst, true, true);
+            }
         }
         if (b.parsingReplacement()) {
             assert nodeIntrinsification.getIntrinsic(method) == null && method.getAnnotation(Word.Operation.class) == null && method.getAnnotation(HotSpotOperation.class) == null &&
                             !nodeIntrinsification.isFoldable(method) : format("%s should have been handled by %s", method.format("%H.%n(%p)"), DefaultGenericInvocationPlugin.class.getName());
 
             // Force inlining when parsing replacements
-            return new InlineInfo(method, true);
+            return new InlineInfo(method, true, true);
         } else {
             assert nodeIntrinsification.getIntrinsic(method) == null : String.format("@%s method %s must only be called from within a replacement%n%s", NodeIntrinsic.class.getSimpleName(),
                             method.format("%h.%n"), b);
             if (InlineDuringParsing.getValue() && method.hasBytecodes() && method.getCode().length <= TrivialInliningSize.getValue() && b.getDepth() < InlineDuringParsingMaxDepth.getValue()) {
-                return new InlineInfo(method, false);
+                return new InlineInfo(method, false, false);
             }
         }
         return null;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotSubstitutions.java	Sat Mar 14 01:57:26 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotSubstitutions.java	Sat Mar 14 02:04:40 2015 +0100
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.hotspot.replacements;
 
+import static com.oracle.graal.nodes.spi.Replacements.*;
+
 import java.lang.reflect.*;
 import java.util.zip.*;
 
@@ -62,7 +64,9 @@
         replacements.registerSubstitutions(CRC32.class, CRC32Substitutions.class);
         replacements.registerSubstitutions(Reflection.class, ReflectionSubstitutions.class);
         replacements.registerSubstitutions(CompilerToVMImpl.class, CompilerToVMImplSubstitutions.class);
-        replacements.registerSubstitutions(new NamedType("com.sun.crypto.provider.AESCrypt"), AESCryptSubstitutions.class);
-        replacements.registerSubstitutions(new NamedType("com.sun.crypto.provider.CipherBlockChaining"), CipherBlockChainingSubstitutions.class);
+        if (SELF_RECURSIVE_INTRINSICS_ENABLED) {
+            replacements.registerSubstitutions(new NamedType("com.sun.crypto.provider.AESCrypt"), AESCryptSubstitutions.class);
+            replacements.registerSubstitutions(new NamedType("com.sun.crypto.provider.CipherBlockChaining"), CipherBlockChainingSubstitutions.class);
+        }
     }
 }
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java	Sat Mar 14 01:57:26 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java	Sat Mar 14 02:04:40 2015 +0100
@@ -698,7 +698,7 @@
     }
 
     private void maybeEagerlyResolve(int cpi, int bytecode) {
-        if (graphBuilderConfig.eagerResolving() || parsingReplacement()) {
+        if (graphBuilderConfig.eagerResolving() || replacementContext instanceof IntrinsicContext) {
             constantPool.loadReferencedType(cpi, bytecode);
         }
     }
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderContext.java	Sat Mar 14 01:57:26 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderContext.java	Sat Mar 14 02:04:40 2015 +0100
@@ -36,7 +36,9 @@
 
     /**
      * Information about a snippet or method substitution currently being processed by the graph
-     * builder.
+     * builder. When in the scope of a replacement, the graph builder does not check the value kinds
+     * flowing through the JVM state since replacements can employ non-Java kinds to represent
+     * values such as raw machine words and pointers.
      */
     public interface Replacement {
 
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Sat Mar 14 01:57:26 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Sat Mar 14 02:04:40 2015 +0100
@@ -1219,8 +1219,9 @@
                         return false;
                     }
                 } else {
-                    if (context == null && !inlinedMethod.equals(targetMethod)) {
-                        if (inlineInfo.adoptBeforeCallFrameState) {
+                    if (context == null && inlineInfo.isReplacement) {
+                        assert !inlinedMethod.equals(targetMethod);
+                        if (inlineInfo.isIntrinsic) {
                             context = new IntrinsicContext(targetMethod, inlinedMethod, args, bci);
                         } else {
                             context = new ReplacementContext(targetMethod, inlinedMethod);
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPlugin.java	Sat Mar 14 01:57:26 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPlugin.java	Sat Mar 14 02:04:40 2015 +0100
@@ -75,22 +75,29 @@
         public static class InlineInfo {
 
             /**
-             * The method to be inlined. If this is not equal to the {@code method} argument passed
-             * to {@link InlineInvokePlugin#getClass()}, the graph builder context interprets it as
-             * a {@linkplain GraphBuilderContext.Replacement replacement}.
+             * The method to be inlined.
              */
             public final ResolvedJavaMethod methodToInline;
 
             /**
+             * Specifies if {@link #methodToInline} is to be considered a
+             * {@linkplain GraphBuilderContext.Replacement replacement} for the {@code method}
+             * passed to {@link InlineInvokePlugin#getInlineInfo}.
+             */
+            public final boolean isReplacement;
+
+            /**
              * Specifies if {@link #methodToInline} is an intrinsic for the original method. If so,
              * any {@link StateSplit} node created in the (recursive) inlining scope will be given a
              * frame state that restarts the interpreter just before the intrinsified invocation.
              */
-            public final boolean adoptBeforeCallFrameState;
+            public final boolean isIntrinsic;
 
-            public InlineInfo(ResolvedJavaMethod methodToInline, boolean adoptBeforeCallFrameState) {
+            public InlineInfo(ResolvedJavaMethod methodToInline, boolean isReplacement, boolean isIntrinsic) {
                 this.methodToInline = methodToInline;
-                this.adoptBeforeCallFrameState = adoptBeforeCallFrameState;
+                this.isIntrinsic = isIntrinsic;
+                this.isReplacement = isReplacement;
+                assert !isIntrinsic || isReplacement : "cannot be an intrinsic without also being a replacement";
             }
         }
 
@@ -211,7 +218,7 @@
             if (ALLOW_INVOCATION_PLUGIN_TO_DO_INLINING) {
                 ResolvedJavaMethod subst = plugin.getSubstitute();
                 if (subst != null) {
-                    return ((BytecodeParser) b).inline(null, targetMethod, new InlineInfo(subst, false), args);
+                    return ((BytecodeParser) b).inline(null, targetMethod, new InlineInfo(subst, true, false), args);
                 }
             }
             if (args.length == 0) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java	Sat Mar 14 01:57:26 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java	Sat Mar 14 02:04:40 2015 +0100
@@ -33,6 +33,8 @@
  * Interface for managing replacements.
  */
 public interface Replacements {
+    // Disabled until bug in support for this is fixed.
+    boolean SELF_RECURSIVE_INTRINSICS_ENABLED = false;
 
     /**
      * Gets the snippet graph derived from a given method.
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Sat Mar 14 01:57:26 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Sat Mar 14 02:04:40 2015 +0100
@@ -204,6 +204,7 @@
             if (replacements != null && (replacements.getMethodSubstitutionMethod(original) != null || replacements.getMacroSubstitution(original) != null)) {
                 return null;
             }
+            assert !builder.parsingReplacement();
             if (original.equals(callSiteProxyMethod)) {
                 ValueNode arg1 = arguments[0];
                 if (!arg1.isConstant()) {
@@ -221,10 +222,10 @@
                 if (decision != null && decision.isInline()) {
                     inlining.push(decision);
                     builder.getAssumptions().record(new AssumptionValidAssumption((OptimizedAssumption) decision.getTarget().getNodeRewritingAssumption()));
-                    return new InlineInfo(callInlinedMethod, false);
+                    return new InlineInfo(callInlinedMethod, false, false);
                 }
             }
-            return new InlineInfo(original, false);
+            return new InlineInfo(original, false, false);
         }
 
         public void postInline(ResolvedJavaMethod inlinedTargetMethod) {