# HG changeset patch # User Doug Simon # Date 1363863580 -3600 # Node ID 11bada5f81a6594b845c3fcd973ed0553fc6ff69 # Parent ba659864f9353bd2c9b4ab196703c83a609d3c24 refactored MethodSubstitution and MacroSubstitution into top level classes diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/AESCryptSubstitutions.java --- 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.*; /** diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CipherBlockChainingSubstitutions.java --- 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.*; diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassSubstitutions.java --- 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.*; /** diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectSubstitutions.java --- 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.*; /** diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemSubstitutions.java --- 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. diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ThreadSubstitutions.java --- 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.*; /** diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/MethodSubstitutionTest.java --- 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.*; /** diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ClassSubstitution.java --- 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. - *

- * 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. - *

- * 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. - *

- * 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. - *

- * 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 macro(); - } } diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DoubleSubstitutions.java --- 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. diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/FloatSubstitutions.java --- 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. diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/IntegerSubstitutions.java --- 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) diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/LongSubstitutions.java --- 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) diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MacroSubstitution.java --- /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. + *

+ * 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. + *

+ * 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 macro(); +} diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MathSubstitutionsX86.java --- 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.*; diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MethodSubstitution.java --- /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. + *

+ * 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. + *

+ * 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 ""; +} diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeClassSubstitutions.java --- 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} diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsInstaller.java --- 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) { diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/UnsafeSubstitutions.java --- 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.*; /** diff -r ba659864f935 -r 11bada5f81a6 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/UnsignedMathSubstitutions.java --- 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}.