changeset 20901:c4691265275a

made ReplacementContext and IntrinsicContext top level classes
author Doug Simon <doug.simon@oracle.com>
date Fri, 10 Apr 2015 13:21:33 +0200
parents dc41766b35e1
children 7cc48e7e6bfe
files graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java graal/com.oracle.graal.java/src/com/oracle/graal/java/HIRFrameStateBuilder.java graal/com.oracle.graal.java/src/com/oracle/graal/java/IntrinsicContext.java graal/com.oracle.graal.java/src/com/oracle/graal/java/ReplacementContext.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java
diffstat 9 files changed, 207 insertions(+), 161 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java	Fri Apr 10 13:10:56 2015 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java	Fri Apr 10 13:21:33 2015 +0200
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.hotspot.test;
 
-import static com.oracle.graal.java.AbstractBytecodeParser.IntrinsicContext.*;
+import static com.oracle.graal.java.IntrinsicContext.*;
 
 import java.io.*;
 import java.lang.reflect.*;
@@ -39,7 +39,6 @@
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.bridge.CompilerToVM.CodeInstallResult;
 import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.java.AbstractBytecodeParser.IntrinsicContext;
 import com.oracle.graal.java.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.StructuredGraph.*;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java	Fri Apr 10 13:10:56 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java	Fri Apr 10 13:21:33 2015 +0200
@@ -32,7 +32,6 @@
 import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.java.AbstractBytecodeParser.ReplacementContext;
 import com.oracle.graal.java.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java	Fri Apr 10 13:10:56 2015 +0200
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java	Fri Apr 10 13:21:33 2015 +0200
@@ -20,30 +20,24 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
 package com.oracle.graal.java;
 
 import static com.oracle.graal.api.code.TypeCheckHints.*;
 import static com.oracle.graal.api.meta.DeoptimizationReason.*;
 import static com.oracle.graal.bytecode.Bytecodes.*;
 import static com.oracle.graal.java.AbstractBytecodeParser.Options.*;
-import static com.oracle.graal.java.HIRFrameStateBuilder.*;
 
 import java.util.*;
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.bytecode.*;
 import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.compiler.common.calc.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graphbuilderconf.*;
-import com.oracle.graal.graphbuilderconf.GraphBuilderContext.Replacement;
 import com.oracle.graal.java.BciBlockMapping.BciBlock;
-import com.oracle.graal.java.GraphBuilderPhase.Instance.BytecodeParser;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.options.*;
 import com.oracle.graal.phases.*;
@@ -83,153 +77,6 @@
     }
 
     /**
-     * Information about a substitute method being parsed in lieu of an original method. This can
-     * happen when a call to a {@link MethodSubstitution} is encountered or the root of compilation
-     * is a {@link MethodSubstitution} or a snippet.
-     */
-    public static class ReplacementContext implements Replacement {
-        /**
-         * The method being replaced.
-         */
-        final ResolvedJavaMethod method;
-
-        /**
-         * The replacement method.
-         */
-        final ResolvedJavaMethod replacement;
-
-        public ReplacementContext(ResolvedJavaMethod method, ResolvedJavaMethod substitute) {
-            this.method = method;
-            this.replacement = substitute;
-        }
-
-        public ResolvedJavaMethod getOriginalMethod() {
-            return method;
-        }
-
-        public ResolvedJavaMethod getReplacementMethod() {
-            return replacement;
-        }
-
-        public boolean isIntrinsic() {
-            return false;
-        }
-
-        /**
-         * Determines if a call within the compilation scope of a replacement represents a call to
-         * the original method.
-         */
-        public boolean isCallToOriginal(ResolvedJavaMethod targetMethod) {
-            return method.equals(targetMethod) || replacement.equals(targetMethod);
-        }
-
-        IntrinsicContext asIntrinsic() {
-            return null;
-        }
-
-        @Override
-        public String toString() {
-            return "Replacement{original: " + method.format("%H.%n(%p)") + ", replacement: " + replacement.format("%H.%n(%p)") + "}";
-        }
-    }
-
-    /**
-     * Context for a replacement being inlined as a compiler intrinsic. Deoptimization within a
-     * compiler intrinsic must replay the intrinsified call. This context object retains the
-     * information required to build a frame state denoting the JVM state just before the
-     * intrinsified call.
-     */
-    public static class IntrinsicContext extends ReplacementContext {
-
-        /**
-         * BCI denoting an intrinsic is being parsed for inlining after the caller has been parsed.
-         */
-        public static final int POST_PARSE_INLINE_BCI = -1;
-
-        /**
-         * BCI denoting an intrinsic is the compilation root.
-         */
-        public static final int ROOT_COMPILATION_BCI = -2;
-
-        /**
-         * The arguments to the intrinsic.
-         */
-        ValueNode[] args;
-
-        /**
-         * The BCI of the intrinsified invocation, {@link #POST_PARSE_INLINE_BCI} or
-         * {@link #ROOT_COMPILATION_BCI}.
-         */
-        final int bci;
-
-        private FrameState stateBeforeCache;
-
-        public IntrinsicContext(ResolvedJavaMethod method, ResolvedJavaMethod substitute, ValueNode[] args, int bci) {
-            super(method, substitute);
-            assert bci != POST_PARSE_INLINE_BCI || args == null;
-            this.args = args;
-            this.bci = bci;
-            assert !isCompilationRoot() || method.hasBytecodes() : "Cannot intrinsic for native or abstract method " + method.format("%H.%n(%p)");
-        }
-
-        @Override
-        public boolean isIntrinsic() {
-            return true;
-        }
-
-        public boolean isPostParseInlined() {
-            return bci == POST_PARSE_INLINE_BCI;
-        }
-
-        public boolean isCompilationRoot() {
-            return bci == ROOT_COMPILATION_BCI;
-        }
-
-        public FrameState getInvokeStateBefore(StructuredGraph graph, BytecodeParser parent) {
-            if (isCompilationRoot()) {
-                int maxLocals = method.getMaxLocals();
-                // The 'args' were initialized based on the intrinsic method but a
-                // frame state's 'locals' needs to have the same length as the frame
-                // state method's 'max_locals'.
-                ValueNode[] locals = maxLocals == args.length ? args : Arrays.copyOf(args, maxLocals);
-                ValueNode[] stack = EMPTY_ARRAY;
-                int stackSize = 0;
-                ValueNode[] locks = EMPTY_ARRAY;
-                List<MonitorIdNode> monitorIds = Collections.emptyList();
-                return graph.add(new FrameState(null, method, 0, locals, stack, stackSize, locks, monitorIds, false, false));
-            } else if (isPostParseInlined()) {
-                return graph.add(new FrameState(BytecodeFrame.BEFORE_BCI));
-            } else {
-                assert !parent.parsingReplacement() || parent.replacementContext instanceof IntrinsicContext;
-                if (stateBeforeCache == null) {
-                    assert stateBeforeCache == null;
-
-                    // Find the non-intrinsic ancestor calling the intrinsified method
-                    BytecodeParser ancestor = parent;
-                    while (ancestor.parsingReplacement()) {
-                        assert ancestor.replacementContext instanceof IntrinsicContext;
-                        ancestor = ancestor.getParent();
-                    }
-                    FrameState stateDuring = ancestor.getFrameState().create(ancestor.bci(), ancestor.getParent(), true);
-                    stateBeforeCache = stateDuring.duplicateModifiedBeforeCall(bci, Kind.Void, args);
-                }
-                return stateBeforeCache;
-            }
-        }
-
-        @Override
-        IntrinsicContext asIntrinsic() {
-            return this;
-        }
-
-        @Override
-        public String toString() {
-            return "Intrinsic{original: " + method.format("%H.%n(%p)") + ", replacement: " + replacement.format("%H.%n(%p)") + ", bci: " + bci +
-                            (args == null ? "" : ", args: " + Arrays.toString(args)) + (stateBeforeCache == null ? "" : ", stateBefore: " + stateBeforeCache) + "}";
-        }
-    }
-
-    /**
      * The minimum value to which {@link Options#TraceBytecodeParserLevel} must be set to trace the
      * bytecode instructions as they are parsed.
      */
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Fri Apr 10 13:10:56 2015 +0200
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Fri Apr 10 13:21:33 2015 +0200
@@ -50,7 +50,6 @@
 import com.oracle.graal.graphbuilderconf.*;
 import com.oracle.graal.graphbuilderconf.InlineInvokePlugin.InlineInfo;
 import com.oracle.graal.graphbuilderconf.InvocationPlugins.InvocationPluginReceiver;
-import com.oracle.graal.java.AbstractBytecodeParser.ReplacementContext;
 import com.oracle.graal.java.BciBlockMapping.BciBlock;
 import com.oracle.graal.java.BciBlockMapping.ExceptionDispatchBlock;
 import com.oracle.graal.nodeinfo.*;
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/HIRFrameStateBuilder.java	Fri Apr 10 13:10:56 2015 +0200
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/HIRFrameStateBuilder.java	Fri Apr 10 13:21:33 2015 +0200
@@ -32,7 +32,6 @@
 import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graphbuilderconf.*;
-import com.oracle.graal.java.AbstractBytecodeParser.IntrinsicContext;
 import com.oracle.graal.java.BciBlockMapping.BciBlock;
 import com.oracle.graal.java.GraphBuilderPhase.Instance.BytecodeParser;
 import com.oracle.graal.nodeinfo.*;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/IntrinsicContext.java	Fri Apr 10 13:21:33 2015 +0200
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.java;
+
+import static com.oracle.graal.java.HIRFrameStateBuilder.*;
+
+import java.util.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.java.GraphBuilderPhase.Instance.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.java.*;
+
+/**
+ * Context for a replacement being inlined as a compiler intrinsic. Deoptimization within a compiler
+ * intrinsic must replay the intrinsified call. This context object retains the information required
+ * to build a frame state denoting the JVM state just before the intrinsified call.
+ */
+public class IntrinsicContext extends ReplacementContext {
+
+    /**
+     * BCI denoting an intrinsic is being parsed for inlining after the caller has been parsed.
+     */
+    public static final int POST_PARSE_INLINE_BCI = -1;
+
+    /**
+     * BCI denoting an intrinsic is the compilation root.
+     */
+    public static final int ROOT_COMPILATION_BCI = -2;
+
+    /**
+     * The arguments to the intrinsic.
+     */
+    ValueNode[] args;
+
+    /**
+     * The BCI of the intrinsified invocation, {@link #POST_PARSE_INLINE_BCI} or
+     * {@link #ROOT_COMPILATION_BCI}.
+     */
+    final int bci;
+
+    private FrameState stateBeforeCache;
+
+    public IntrinsicContext(ResolvedJavaMethod method, ResolvedJavaMethod substitute, ValueNode[] args, int bci) {
+        super(method, substitute);
+        assert bci != POST_PARSE_INLINE_BCI || args == null;
+        this.args = args;
+        this.bci = bci;
+        assert !isCompilationRoot() || method.hasBytecodes() : "Cannot intrinsic for native or abstract method " + method.format("%H.%n(%p)");
+    }
+
+    @Override
+    public boolean isIntrinsic() {
+        return true;
+    }
+
+    public boolean isPostParseInlined() {
+        return bci == POST_PARSE_INLINE_BCI;
+    }
+
+    public boolean isCompilationRoot() {
+        return bci == ROOT_COMPILATION_BCI;
+    }
+
+    public FrameState getInvokeStateBefore(StructuredGraph graph, BytecodeParser parent) {
+        if (isCompilationRoot()) {
+            int maxLocals = method.getMaxLocals();
+            // The 'args' were initialized based on the intrinsic method but a
+            // frame state's 'locals' needs to have the same length as the frame
+            // state method's 'max_locals'.
+            ValueNode[] locals = maxLocals == args.length ? args : Arrays.copyOf(args, maxLocals);
+            ValueNode[] stack = EMPTY_ARRAY;
+            int stackSize = 0;
+            ValueNode[] locks = EMPTY_ARRAY;
+            List<MonitorIdNode> monitorIds = Collections.emptyList();
+            return graph.add(new FrameState(null, method, 0, locals, stack, stackSize, locks, monitorIds, false, false));
+        } else if (isPostParseInlined()) {
+            return graph.add(new FrameState(BytecodeFrame.BEFORE_BCI));
+        } else {
+            assert !parent.parsingReplacement() || parent.replacementContext instanceof IntrinsicContext;
+            if (stateBeforeCache == null) {
+                assert stateBeforeCache == null;
+
+                // Find the non-intrinsic ancestor calling the intrinsified method
+                BytecodeParser ancestor = parent;
+                while (ancestor.parsingReplacement()) {
+                    assert ancestor.replacementContext instanceof IntrinsicContext;
+                    ancestor = ancestor.getParent();
+                }
+                FrameState stateDuring = ancestor.getFrameState().create(ancestor.bci(), ancestor.getParent(), true);
+                stateBeforeCache = stateDuring.duplicateModifiedBeforeCall(bci, Kind.Void, args);
+            }
+            return stateBeforeCache;
+        }
+    }
+
+    @Override
+    IntrinsicContext asIntrinsic() {
+        return this;
+    }
+
+    @Override
+    public String toString() {
+        return "Intrinsic{original: " + method.format("%H.%n(%p)") + ", replacement: " + replacement.format("%H.%n(%p)") + ", bci: " + bci + (args == null ? "" : ", args: " + Arrays.toString(args)) +
+                        (stateBeforeCache == null ? "" : ", stateBefore: " + stateBeforeCache) + "}";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/ReplacementContext.java	Fri Apr 10 13:21:33 2015 +0200
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.java;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.graphbuilderconf.GraphBuilderContext.Replacement;
+
+/**
+ * Information about a substitute method being parsed in lieu of an original method. This can happen
+ * when a call to a {@link MethodSubstitution} is encountered or the root of compilation is a
+ * {@link MethodSubstitution} or a snippet.
+ */
+public class ReplacementContext implements Replacement {
+    /**
+     * The method being replaced.
+     */
+    final ResolvedJavaMethod method;
+
+    /**
+     * The replacement method.
+     */
+    final ResolvedJavaMethod replacement;
+
+    public ReplacementContext(ResolvedJavaMethod method, ResolvedJavaMethod substitute) {
+        this.method = method;
+        this.replacement = substitute;
+    }
+
+    public ResolvedJavaMethod getOriginalMethod() {
+        return method;
+    }
+
+    public ResolvedJavaMethod getReplacementMethod() {
+        return replacement;
+    }
+
+    public boolean isIntrinsic() {
+        return false;
+    }
+
+    /**
+     * Determines if a call within the compilation scope of a replacement represents a call to the
+     * original method.
+     */
+    public boolean isCallToOriginal(ResolvedJavaMethod targetMethod) {
+        return method.equals(targetMethod) || replacement.equals(targetMethod);
+    }
+
+    IntrinsicContext asIntrinsic() {
+        return null;
+    }
+
+    @Override
+    public String toString() {
+        return "Replacement{original: " + method.format("%H.%n(%p)") + ", replacement: " + replacement.format("%H.%n(%p)") + "}";
+    }
+}
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java	Fri Apr 10 13:10:56 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java	Fri Apr 10 13:21:33 2015 +0200
@@ -30,7 +30,6 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graphbuilderconf.*;
 import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins;
-import com.oracle.graal.java.AbstractBytecodeParser.IntrinsicContext;
 import com.oracle.graal.java.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.CallTargetNode.InvokeKind;
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Fri Apr 10 13:10:56 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Fri Apr 10 13:21:33 2015 +0200
@@ -47,8 +47,6 @@
 import com.oracle.graal.graphbuilderconf.*;
 import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins;
 import com.oracle.graal.graphbuilderconf.GraphBuilderContext.Replacement;
-import com.oracle.graal.java.AbstractBytecodeParser.IntrinsicContext;
-import com.oracle.graal.java.AbstractBytecodeParser.ReplacementContext;
 import com.oracle.graal.java.*;
 import com.oracle.graal.java.GraphBuilderPhase.Instance;
 import com.oracle.graal.nodes.*;