changeset 8419:11bada5f81a6

refactored MethodSubstitution and MacroSubstitution into top level classes
author Doug Simon <doug.simon@oracle.com>
date Thu, 21 Mar 2013 11:59:40 +0100
parents ba659864f935
children 5d3fa6f949fb
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/AESCryptSubstitutions.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CipherBlockChainingSubstitutions.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassSubstitutions.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectSubstitutions.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemSubstitutions.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ThreadSubstitutions.java graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/MethodSubstitutionTest.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ClassSubstitution.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DoubleSubstitutions.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/FloatSubstitutions.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/IntegerSubstitutions.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/LongSubstitutions.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MacroSubstitution.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MathSubstitutionsX86.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MethodSubstitution.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeClassSubstitutions.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsInstaller.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/UnsafeSubstitutions.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/UnsignedMathSubstitutions.java
diffstat 19 files changed, 137 insertions(+), 98 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/AESCryptSubstitutions.java	Thu Mar 21 11:09:19 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/AESCryptSubstitutions.java	Thu Mar 21 11:59:40 2013 +0100
@@ -35,7 +35,6 @@
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.replacements.*;
-import com.oracle.graal.replacements.ClassSubstitution.*;
 import com.oracle.graal.word.*;
 
 /**
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CipherBlockChainingSubstitutions.java	Thu Mar 21 11:09:19 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CipherBlockChainingSubstitutions.java	Thu Mar 21 11:59:40 2013 +0100
@@ -35,7 +35,6 @@
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.replacements.*;
-import com.oracle.graal.replacements.ClassSubstitution.*;
 import com.oracle.graal.replacements.Snippet.*;
 import com.oracle.graal.word.*;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassSubstitutions.java	Thu Mar 21 11:09:19 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassSubstitutions.java	Thu Mar 21 11:59:40 2013 +0100
@@ -29,7 +29,6 @@
 
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.replacements.*;
-import com.oracle.graal.replacements.ClassSubstitution.*;
 import com.oracle.graal.word.*;
 
 /**
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectSubstitutions.java	Thu Mar 21 11:09:19 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectSubstitutions.java	Thu Mar 21 11:59:40 2013 +0100
@@ -27,7 +27,6 @@
 
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.replacements.*;
-import com.oracle.graal.replacements.ClassSubstitution.*;
 import com.oracle.graal.word.*;
 
 /**
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemSubstitutions.java	Thu Mar 21 11:09:19 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemSubstitutions.java	Thu Mar 21 11:59:40 2013 +0100
@@ -30,7 +30,6 @@
 import com.oracle.graal.graph.Node.NodeIntrinsic;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.replacements.*;
-import com.oracle.graal.replacements.ClassSubstitution.*;
 
 /**
  * Substitutions for {@link java.lang.System} methods.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ThreadSubstitutions.java	Thu Mar 21 11:09:19 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ThreadSubstitutions.java	Thu Mar 21 11:59:40 2013 +0100
@@ -26,7 +26,6 @@
 
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.replacements.*;
-import com.oracle.graal.replacements.ClassSubstitution.*;
 import com.oracle.graal.word.*;
 
 /**
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/MethodSubstitutionTest.java	Thu Mar 21 11:09:19 2013 +0100
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/MethodSubstitutionTest.java	Thu Mar 21 11:59:40 2013 +0100
@@ -38,7 +38,6 @@
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.common.*;
-import com.oracle.graal.replacements.ClassSubstitution.*;
 import com.oracle.graal.replacements.nodes.*;
 
 /**
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ClassSubstitution.java	Thu Mar 21 11:09:19 2013 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ClassSubstitution.java	Thu Mar 21 11:59:40 2013 +0100
@@ -24,10 +24,6 @@
 
 import java.lang.annotation.*;
 
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.replacements.nodes.*;
-
 /**
  * Denotes a class that substitutes methods of another specified class. The substitute methods are
  * exactly those annotated by {@link MethodSubstitution}.
@@ -60,77 +56,4 @@
      * Substitutions for such classes are omitted if the original classes cannot be found.
      */
     boolean optional() default false;
-
-    /**
-     * Denotes a substitute method. A substitute method can call the original/substituted method by
-     * making a recursive call to itself.
-     */
-    @Retention(RetentionPolicy.RUNTIME)
-    @Target(ElementType.METHOD)
-    public @interface MethodSubstitution {
-
-        /**
-         * Gets the name of the original method.
-         * <p>
-         * If the default value is specified for this element, then the name of the original method
-         * is same as the substitute method.
-         */
-        String value() default "";
-
-        /**
-         * Determines if the original method is static.
-         */
-        boolean isStatic() default true;
-
-        /**
-         * Gets the {@linkplain MetaUtil#signatureToMethodDescriptor signature} of the original
-         * method.
-         * <p>
-         * If the default value is specified for this element, then the signature of the original
-         * method is the same as the substitute method.
-         */
-        String signature() default "";
-    }
-
-    /**
-     * Denotes a macro substitute method. This replaces a method invocation with an instance of the
-     * specified node class.
-     * 
-     * A macro substitution can be combined with a normal substitution, so that the macro node can
-     * be replaced with the actual substitution code during lowering.
-     */
-    @Retention(RetentionPolicy.RUNTIME)
-    @Target(ElementType.METHOD)
-    public @interface MacroSubstitution {
-
-        /**
-         * Gets the name of the substituted method.
-         * <p>
-         * If the default value is specified for this element, then the name of the substituted
-         * method is same as the substitute method.
-         */
-        String value() default "";
-
-        /**
-         * Determines if the substituted method is static.
-         */
-        boolean isStatic() default true;
-
-        /**
-         * Gets the {@linkplain MetaUtil#signatureToMethodDescriptor signature} of the substituted
-         * method.
-         * <p>
-         * If the default value is specified for this element, then the signature of the substituted
-         * method is the same as the substitute method.
-         */
-        String signature() default "";
-
-        /**
-         * The node class with which the method invocation should be replaced. It needs to be a
-         * subclass of {@link FixedWithNextNode}, and it is expected to provide a public constructor
-         * that takes an InvokeNode as a parameter. For most cases this class should subclass
-         * {@link MacroNode} and use its constructor.
-         */
-        Class<? extends FixedWithNextNode> macro();
-    }
 }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DoubleSubstitutions.java	Thu Mar 21 11:09:19 2013 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DoubleSubstitutions.java	Thu Mar 21 11:59:40 2013 +0100
@@ -23,7 +23,6 @@
 package com.oracle.graal.replacements;
 
 import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.replacements.ClassSubstitution.*;
 
 /**
  * Substitutions for {@link java.lang.Double} methods.
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/FloatSubstitutions.java	Thu Mar 21 11:09:19 2013 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/FloatSubstitutions.java	Thu Mar 21 11:59:40 2013 +0100
@@ -23,7 +23,6 @@
 package com.oracle.graal.replacements;
 
 import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.replacements.ClassSubstitution.*;
 
 /**
  * Substitutions for {@link java.lang.Float} methods.
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/IntegerSubstitutions.java	Thu Mar 21 11:09:19 2013 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/IntegerSubstitutions.java	Thu Mar 21 11:59:40 2013 +0100
@@ -22,7 +22,6 @@
  */
 package com.oracle.graal.replacements;
 
-import com.oracle.graal.replacements.ClassSubstitution.*;
 import com.oracle.graal.replacements.nodes.*;
 
 @ClassSubstitution(Integer.class)
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/LongSubstitutions.java	Thu Mar 21 11:09:19 2013 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/LongSubstitutions.java	Thu Mar 21 11:59:40 2013 +0100
@@ -22,7 +22,6 @@
  */
 package com.oracle.graal.replacements;
 
-import com.oracle.graal.replacements.ClassSubstitution.*;
 import com.oracle.graal.replacements.nodes.*;
 
 @ClassSubstitution(Long.class)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MacroSubstitution.java	Thu Mar 21 11:59:40 2013 +0100
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013, 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.replacements;
+
+import java.lang.annotation.*;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.replacements.nodes.*;
+
+/**
+ * Denotes a macro substitute method. This replaces a method invocation with an instance of the
+ * specified node class.
+ * 
+ * A macro substitution can be combined with a normal substitution, so that the macro node can be
+ * replaced with the actual substitution code during lowering.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface MacroSubstitution {
+
+    /**
+     * Gets the name of the substituted method.
+     * <p>
+     * If the default value is specified for this element, then the name of the substituted method
+     * is same as the substitute method.
+     */
+    String value() default "";
+
+    /**
+     * Determines if the substituted method is static.
+     */
+    boolean isStatic() default true;
+
+    /**
+     * Gets the {@linkplain MetaUtil#signatureToMethodDescriptor signature} of the substituted
+     * method.
+     * <p>
+     * If the default value is specified for this element, then the signature of the substituted
+     * method is the same as the substitute method.
+     */
+    String signature() default "";
+
+    /**
+     * The node class with which the method invocation should be replaced. It needs to be a subclass
+     * of {@link FixedWithNextNode}, and it is expected to provide a public constructor that takes
+     * an InvokeNode as a parameter. For most cases this class should subclass {@link MacroNode} and
+     * use its constructor.
+     */
+    Class<? extends FixedWithNextNode> macro();
+}
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MathSubstitutionsX86.java	Thu Mar 21 11:09:19 2013 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MathSubstitutionsX86.java	Thu Mar 21 11:59:40 2013 +0100
@@ -26,7 +26,6 @@
 import com.oracle.graal.graph.Node.ConstantNodeParameter;
 import com.oracle.graal.graph.Node.NodeIntrinsic;
 import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.replacements.ClassSubstitution.*;
 import com.oracle.graal.replacements.nodes.*;
 import com.oracle.graal.replacements.nodes.MathIntrinsicNode.*;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MethodSubstitution.java	Thu Mar 21 11:59:40 2013 +0100
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2013, 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.replacements;
+
+import java.lang.annotation.*;
+
+import com.oracle.graal.api.meta.*;
+
+/**
+ * Denotes a substitute method. A substitute method can call the original/substituted method by
+ * making a recursive call to itself.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface MethodSubstitution {
+
+    /**
+     * Gets the name of the original method.
+     * <p>
+     * If the default value is specified for this element, then the name of the original method is
+     * same as the substitute method.
+     */
+    String value() default "";
+
+    /**
+     * Determines if the original method is static.
+     */
+    boolean isStatic() default true;
+
+    /**
+     * Gets the {@linkplain MetaUtil#signatureToMethodDescriptor signature} of the original method.
+     * <p>
+     * If the default value is specified for this element, then the signature of the original method
+     * is the same as the substitute method.
+     */
+    String signature() default "";
+}
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeClassSubstitutions.java	Thu Mar 21 11:09:19 2013 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeClassSubstitutions.java	Thu Mar 21 11:59:40 2013 +0100
@@ -25,7 +25,6 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.replacements.ClassSubstitution.*;
 
 /**
  * Substitutions for improving the performance of some critical methods in {@link NodeClass}
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsInstaller.java	Thu Mar 21 11:09:19 2013 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsInstaller.java	Thu Mar 21 11:59:40 2013 +0100
@@ -41,8 +41,8 @@
 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind;
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.common.*;
-import com.oracle.graal.replacements.ClassSubstitution.*;
-import com.oracle.graal.replacements.Snippet.*;
+import com.oracle.graal.replacements.Snippet.DefaultSnippetInliningPolicy;
+import com.oracle.graal.replacements.Snippet.SnippetInliningPolicy;
 import com.oracle.graal.word.phases.*;
 
 /**
@@ -212,10 +212,13 @@
         new NodeIntrinsificationPhase(runtime, pool).apply(graph);
         assert SnippetTemplate.hasConstantParameter(method) || NodeIntrinsificationVerificationPhase.verify(graph);
 
-        new SnippetFrameStateCleanupPhase().apply(graph);
-        new DeadCodeEliminationPhase().apply(graph);
-
-        new InsertStateAfterPlaceholderPhase().apply(graph);
+        if (substitute == null) {
+            new SnippetFrameStateCleanupPhase().apply(graph);
+            new DeadCodeEliminationPhase().apply(graph);
+            new InsertStateAfterPlaceholderPhase().apply(graph);
+        } else {
+            new DeadCodeEliminationPhase().apply(graph);
+        }
     }
 
     public StructuredGraph makeGraph(final ResolvedJavaMethod method, final SnippetInliningPolicy policy) {
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/UnsafeSubstitutions.java	Thu Mar 21 11:09:19 2013 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/UnsafeSubstitutions.java	Thu Mar 21 11:59:40 2013 +0100
@@ -26,7 +26,6 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
-import com.oracle.graal.replacements.ClassSubstitution.*;
 import com.oracle.graal.replacements.nodes.*;
 
 /**
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/UnsignedMathSubstitutions.java	Thu Mar 21 11:09:19 2013 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/UnsignedMathSubstitutions.java	Thu Mar 21 11:59:40 2013 +0100
@@ -28,7 +28,6 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.replacements.ClassSubstitution.*;
 
 /**
  * Substitutions for {@link UnsignedMath}.