changeset 19415:fcb426a54eed

pass required providers through to HotSpotSuitesProvider; remove redundant registration of Graal InlineInvokePlugin
author Doug Simon <doug.simon@oracle.com>
date Mon, 16 Feb 2015 21:02:31 +0100
parents 5b93a11c535c
children d4f37673849d
files graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java
diffstat 3 files changed, 30 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java	Mon Feb 16 20:53:21 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java	Mon Feb 16 21:02:31 2015 +0100
@@ -163,7 +163,7 @@
                 disassembler = createDisassembler(runtime);
             }
             try (InitTimer rt = timer("create Suites provider")) {
-                suites = createSuites(runtime);
+                suites = createSuites(runtime, metaAccess, constantReflection, replacements);
             }
             providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, disassembler, suites, registers, snippetReflection);
         }
@@ -209,8 +209,8 @@
         return new HotSpotMetaAccessProvider(runtime);
     }
 
-    protected HotSpotSuitesProvider createSuites(HotSpotGraalRuntimeProvider runtime) {
-        return new HotSpotSuitesProvider(runtime);
+    protected HotSpotSuitesProvider createSuites(HotSpotGraalRuntimeProvider runtime, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, Replacements replacements) {
+        return new HotSpotSuitesProvider(runtime, metaAccess, constantReflection, replacements);
     }
 
     protected HotSpotSnippetReflectionProvider createSnippetReflection(HotSpotGraalRuntimeProvider runtime) {
@@ -248,15 +248,15 @@
         } else {
             /*
              * System V Application Binary Interface, AMD64 Architecture Processor Supplement
-             * 
+             *
              * Draft Version 0.96
-             * 
+             *
              * http://www.uclibc.org/docs/psABI-x86_64.pdf
-             * 
+             *
              * 3.2.1
-             * 
+             *
              * ...
-             * 
+             *
              * This subsection discusses usage of each register. Registers %rbp, %rbx and %r12
              * through %r15 "belong" to the calling function and the called function is required to
              * preserve their values. In other words, a called function must preserve these
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java	Mon Feb 16 20:53:21 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java	Mon Feb 16 21:02:31 2015 +0100
@@ -64,7 +64,7 @@
         HotSpotSnippetReflectionProvider snippetReflection = new HotSpotSnippetReflectionProvider(runtime);
         HotSpotReplacementsImpl replacements = new HotSpotReplacementsImpl(p, snippetReflection, runtime.getConfig(), target);
         HotSpotDisassemblerProvider disassembler = new HotSpotDisassemblerProvider(runtime);
-        HotSpotSuitesProvider suites = new HotSpotSuitesProvider(runtime);
+        HotSpotSuitesProvider suites = new HotSpotSuitesProvider(runtime, metaAccess, constantReflection, replacements);
         HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, disassembler, suites, registers, snippetReflection);
 
         return new SPARCHotSpotBackend(runtime, providers);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java	Mon Feb 16 20:53:21 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java	Mon Feb 16 21:02:31 2015 +0100
@@ -26,7 +26,6 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.replacements.*;
-import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.hotspot.phases.*;
@@ -72,9 +71,9 @@
 
     }
 
-    public HotSpotSuitesProvider(HotSpotGraalRuntimeProvider runtime) {
+    public HotSpotSuitesProvider(HotSpotGraalRuntimeProvider runtime, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, Replacements replacements) {
         this.runtime = runtime;
-        this.defaultGraphBuilderSuite = createGraphBuilderSuite();
+        this.defaultGraphBuilderSuite = createGraphBuilderSuite(metaAccess, constantReflection, replacements);
         this.defaultSuites = new DerivedOptionValue<>(new SuitesSupplier());
         this.defaultLIRSuites = new DerivedOptionValue<>(new LIRSuitesSupplier());
     }
@@ -106,51 +105,40 @@
         return ret;
     }
 
-    protected PhaseSuite<HighTierContext> createGraphBuilderSuite() {
+    protected PhaseSuite<HighTierContext> createGraphBuilderSuite(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, Replacements replacements) {
         PhaseSuite<HighTierContext> suite = new PhaseSuite<>();
         GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault();
-        config.setInlineInvokePlugin(new InlineInvokePlugin() {
-            public ResolvedJavaMethod getInlinedMethod(GraphBuilderContext builder, ResolvedJavaMethod method, ValueNode[] args, JavaType returnType, int depth) {
-                if (GraalOptions.InlineDuringParsing.getValue() && method.getCode().length <= GraalOptions.TrivialInliningSize.getValue() &&
-                                depth < GraalOptions.InlineDuringParsingMaxDepth.getValue()) {
-                    return method;
+        if (InlineDuringParsing.getValue()) {
+            config.setLoadFieldPlugin(new LoadFieldPlugin() {
+                public boolean apply(GraphBuilderContext builder, ValueNode receiver, ResolvedJavaField field) {
+                    if (receiver.isConstant()) {
+                        JavaConstant asJavaConstant = receiver.asJavaConstant();
+                        return tryConstantFold(builder, metaAccess, constantReflection, field, asJavaConstant);
+                    }
+                    return false;
                 }
-                return null;
-            }
-        });
-        config.setLoadFieldPlugin(new LoadFieldPlugin() {
-            public boolean apply(GraphBuilderContext builder, ValueNode receiver, ResolvedJavaField field) {
-                if (receiver.isConstant()) {
-                    JavaConstant asJavaConstant = receiver.asJavaConstant();
-                    return tryConstantFold(builder, runtime.getHostProviders().getMetaAccess(), runtime.getHostProviders().getConstantReflection(), field, asJavaConstant);
+
+                public boolean apply(GraphBuilderContext builder, ResolvedJavaField staticField) {
+                    return tryConstantFold(builder, metaAccess, constantReflection, staticField, null);
                 }
-                return false;
-            }
-
-            public boolean apply(GraphBuilderContext builder, ResolvedJavaField staticField) {
-                return tryConstantFold(builder, runtime.getHostProviders().getMetaAccess(), runtime.getHostProviders().getConstantReflection(), staticField, null);
-            }
-        });
-        config.setInlineInvokePlugin(new InlineInvokePlugin() {
-            public ResolvedJavaMethod getInlinedMethod(GraphBuilderContext builder, ResolvedJavaMethod method, ValueNode[] args, JavaType returnType, int depth) {
-                if (GraalOptions.InlineDuringParsing.getValue()) {
+            });
+            config.setInlineInvokePlugin(new InlineInvokePlugin() {
+                public ResolvedJavaMethod getInlinedMethod(GraphBuilderContext builder, ResolvedJavaMethod method, ValueNode[] args, JavaType returnType, int depth) {
                     if (builder.parsingReplacement()) {
                         if (method.getAnnotation(MethodSubstitution.class) != null) {
-                            HotSpotProviders providers = runtime.getHostProviders();
-                            Replacements replacements = providers.getReplacements();
                             ResolvedJavaMethod subst = replacements.getMethodSubstitutionMethod(method);
                             if (subst != null) {
                                 return subst;
                             }
                         }
                     }
-                    if (method.hasBytecodes() && method.getCode().length <= GraalOptions.TrivialInliningSize.getValue() && depth < GraalOptions.InlineDuringParsingMaxDepth.getValue()) {
+                    if (method.hasBytecodes() && method.getCode().length <= TrivialInliningSize.getValue() && depth < InlineDuringParsingMaxDepth.getValue()) {
                         return method;
                     }
+                    return null;
                 }
-                return null;
-            }
-        });
+            });
+        }
         suite.appendPhase(new GraphBuilderPhase(config));
         return suite;
     }