# HG changeset patch # User Doug Simon # Date 1426195167 -3600 # Node ID 6a684aeb1590c8e7342066a1bad24bb7c8f14c6c # Parent 3cc8aa066ed37c2acf6a29c3e408aef81f7e9828 NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object diff -r 3cc8aa066ed3 -r 6a684aeb1590 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java Thu Mar 12 22:10:07 2015 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java Thu Mar 12 22:19:27 2015 +0100 @@ -251,7 +251,7 @@ StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO); HighTierContext highContext = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL); MidTierContext midContext = new MidTierContext(getProviders(), getCodeCache().getTarget(), OptimisticOptimizations.ALL, graph.method().getProfilingInfo(), null); - new NodeIntrinsificationPhase(getProviders(), getSnippetReflection()).apply(graph); + new NodeIntrinsificationPhase(getMetaAccess(), getConstantReflection(), getSnippetReflection(), getProviders().getForeignCalls(), getProviders().getStampProvider()).apply(graph); new InliningPhase(new InlineEverythingPolicy(), new CanonicalizerPhase()).apply(graph, highContext); new CanonicalizerPhase().apply(graph, highContext); new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, highContext); diff -r 3cc8aa066ed3 -r 6a684aeb1590 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java Thu Mar 12 22:10:07 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java Thu Mar 12 22:19:27 2015 +0100 @@ -73,7 +73,8 @@ HotSpotReplacementsImpl replacements = (HotSpotReplacementsImpl) providers.getReplacements(); try (InitTimer st = timer("graphBuilderPlugins.initialize")) { - Plugins plugins = HotSpotGraphBuilderPlugins.create(config, providers); + Plugins plugins = HotSpotGraphBuilderPlugins.create(config, providers.getWordTypes(), providers.getMetaAccess(), providers.getConstantReflection(), providers.getSnippetReflection(), + providers.getForeignCalls(), providers.getStampProvider(), replacements, providers.getCodeCache().getTarget().arch); providers.setGraphBuilderPlugins(plugins); GraphBuilderPhase phase = (GraphBuilderPhase) providers.getSuites().getDefaultGraphBuilderSuite().findPhase(GraphBuilderPhase.class).previous(); phase.getGraphBuilderConfig().setPlugins(plugins); diff -r 3cc8aa066ed3 -r 6a684aeb1590 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java Thu Mar 12 22:10:07 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java Thu Mar 12 22:19:27 2015 +0100 @@ -27,6 +27,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.api.replacements.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.nodes.*; @@ -52,29 +53,32 @@ /** * Creates a {@link Plugins} object that should be used when running on HotSpot. + * + * @param constantReflection + * @param snippetReflection + * @param foreignCalls + * @param stampProvider */ - public static Plugins create(HotSpotVMConfig config, HotSpotProviders providers) { + public static Plugins create(HotSpotVMConfig config, HotSpotWordTypes wordTypes, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, + SnippetReflectionProvider snippetReflection, ForeignCallsProvider foreignCalls, StampProvider stampProvider, ReplacementsImpl replacements, Architecture arch) { - MetaAccessProvider metaAccess = providers.getMetaAccess(); - HotSpotWordTypes wordTypes = providers.getWordTypes(); InvocationPlugins invocationPlugins = new HotSpotInvocationPlugins(config, metaAccess); Plugins plugins = new Plugins(invocationPlugins); - NodeIntrinsificationPhase nodeIntrinsification = new NodeIntrinsificationPhase(providers, providers.getSnippetReflection()); - ConstantReflectionProvider constantReflection = providers.getConstantReflection(); - HotSpotWordOperationPlugin wordOperationPlugin = new HotSpotWordOperationPlugin(providers.getSnippetReflection(), wordTypes); + NodeIntrinsificationPhase nodeIntrinsification = new NodeIntrinsificationPhase(metaAccess, constantReflection, snippetReflection, foreignCalls, stampProvider); + HotSpotWordOperationPlugin wordOperationPlugin = new HotSpotWordOperationPlugin(snippetReflection, wordTypes); plugins.setParameterPlugin(new HotSpotParameterPlugin(wordTypes)); plugins.setLoadFieldPlugin(new HotSpotLoadFieldPlugin(metaAccess, constantReflection)); plugins.setLoadIndexedPlugin(new HotSpotLoadIndexedPlugin(wordTypes)); - plugins.setInlineInvokePlugin(new HotSpotInlineInvokePlugin(nodeIntrinsification, (ReplacementsImpl) providers.getReplacements())); + plugins.setInlineInvokePlugin(new HotSpotInlineInvokePlugin(nodeIntrinsification, replacements)); plugins.setGenericInvocationPlugin(new DefaultGenericInvocationPlugin(nodeIntrinsification, wordOperationPlugin)); registerObjectPlugins(invocationPlugins); - registerSystemPlugins(invocationPlugins, providers.getForeignCalls()); + registerSystemPlugins(invocationPlugins, foreignCalls); registerThreadPlugins(invocationPlugins, metaAccess, wordTypes, config); registerStableOptionPlugins(invocationPlugins); - StandardGraphBuilderPlugins.registerInvocationPlugins(providers.getMetaAccess(), providers.getCodeCache().target.arch, invocationPlugins, !config.useHeapProfiler); + StandardGraphBuilderPlugins.registerInvocationPlugins(metaAccess, arch, invocationPlugins, !config.useHeapProfiler); return plugins; } diff -r 3cc8aa066ed3 -r 6a684aeb1590 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java Thu Mar 12 22:10:07 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java Thu Mar 12 22:19:27 2015 +0100 @@ -45,7 +45,6 @@ import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.util.*; import com.oracle.graal.phases.*; -import com.oracle.graal.phases.util.*; /** * Replaces calls to {@link NodeIntrinsic}s with nodes and calls to methods annotated with @@ -53,12 +52,19 @@ */ public class NodeIntrinsificationPhase extends Phase { - private final Providers providers; + private final MetaAccessProvider metaAccess; + private final ConstantReflectionProvider constantReflection; private final SnippetReflectionProvider snippetReflection; + private final ForeignCallsProvider foreignCalls; + private final StampProvider stampProvider; - public NodeIntrinsificationPhase(Providers providers, SnippetReflectionProvider snippetReflection) { - this.providers = providers; + public NodeIntrinsificationPhase(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, SnippetReflectionProvider snippetReflection, ForeignCallsProvider foreignCalls, + StampProvider stampProvider) { + this.metaAccess = metaAccess; + this.constantReflection = constantReflection; this.snippetReflection = snippetReflection; + this.foreignCalls = foreignCalls; + this.stampProvider = stampProvider; } @Override @@ -101,7 +107,7 @@ if (constant != null) { // Replace the invoke with the result of the call - ConstantNode node = ConstantNode.forConstant(constant, providers.getMetaAccess(), methodCallTargetNode.graph()); + ConstantNode node = ConstantNode.forConstant(constant, metaAccess, methodCallTargetNode.graph()); methodCallTargetNode.invoke().intrinsify(node); // Clean up checkcast instructions inserted by javac if the return type is generic. @@ -165,7 +171,7 @@ if (intrinsic.foldable() && areAllConstant(arguments)) { JavaConstant res = tryFold(arguments, parameterTypes, method); if (!res.equals(COULD_NOT_FOLD)) { - return ConstantNode.forConstant(res, providers.getMetaAccess()); + return ConstantNode.forConstant(res, metaAccess); } } @@ -220,12 +226,12 @@ * For intrinsification (but not for folding) if we have a Class object we want * the corresponding ResolvedJavaType. */ - ResolvedJavaType type = folding ? null : providers.getConstantReflection().asJavaType(constant); + ResolvedJavaType type = folding ? null : constantReflection.asJavaType(constant); Object arg; if (type != null) { /* If we found such a type then it's our arg */ arg = type; - parameterTypes[i] = providers.getMetaAccess().lookupJavaType(ResolvedJavaType.class); + parameterTypes[i] = metaAccess.lookupJavaType(ResolvedJavaType.class); } else { JavaConstant javaConstant = (JavaConstant) constant; if (folding) { @@ -253,7 +259,7 @@ reflectionCallArguments[i] = arg; } else { reflectionCallArguments[i] = argument; - parameterTypes[i] = providers.getMetaAccess().lookupJavaType(ValueNode.class); + parameterTypes[i] = metaAccess.lookupJavaType(ValueNode.class); } } return reflectionCallArguments; @@ -264,10 +270,10 @@ if (intrinsic.value() == NodeIntrinsic.class) { result = target.getDeclaringClass(); } else { - result = providers.getMetaAccess().lookupJavaType(intrinsic.value()); + result = metaAccess.lookupJavaType(intrinsic.value()); } - assert providers.getMetaAccess().lookupJavaType(ValueNode.class).isAssignableFrom(result) : "Node intrinsic class " + result.toJavaName(false) + " derived from @" + - NodeIntrinsic.class.getSimpleName() + " annotation on " + target.format("%H.%n(%p)") + " is not a subclass of " + ValueNode.class; + assert metaAccess.lookupJavaType(ValueNode.class).isAssignableFrom(result) : "Node intrinsic class " + result.toJavaName(false) + " derived from @" + NodeIntrinsic.class.getSimpleName() + + " annotation on " + target.format("%H.%n(%p)") + " is not a subclass of " + ValueNode.class; return result; } @@ -339,7 +345,6 @@ Object[] injected = null; ResolvedJavaType[] signature = resolveJavaTypes(c.getSignature().toParameterTypes(null), c.getDeclaringClass()); - MetaAccessProvider metaAccess = providers.getMetaAccess(); for (int i = 0; i < signature.length; i++) { if (c.getParameterAnnotation(InjectedNodeParameter.class, i) != null) { injected = injected == null ? new Object[1] : Arrays.copyOf(injected, injected.length + 1); @@ -351,13 +356,13 @@ } else if (signature[i].equals(metaAccess.lookupJavaType(StructuredGraph.class))) { injected[injected.length - 1] = graph; } else if (signature[i].equals(metaAccess.lookupJavaType(ForeignCallsProvider.class))) { - injected[injected.length - 1] = providers.getForeignCalls(); + injected[injected.length - 1] = foreignCalls; } else if (signature[i].equals(metaAccess.lookupJavaType(SnippetReflectionProvider.class))) { injected[injected.length - 1] = snippetReflection; } else if (signature[i].isAssignableFrom(metaAccess.lookupJavaType(Stamp.class))) { injected[injected.length - 1] = invokeStamp; } else if (signature[i].isAssignableFrom(metaAccess.lookupJavaType(StampProvider.class))) { - injected[injected.length - 1] = providers.getStampProvider(); + injected[injected.length - 1] = stampProvider; } else { throw new GraalInternalError("Cannot handle injected argument of type %s in %s", signature[i].toJavaName(), c.format("%H.%n(%p)")); } diff -r 3cc8aa066ed3 -r 6a684aeb1590 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Thu Mar 12 22:10:07 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Thu Mar 12 22:19:27 2015 +0100 @@ -299,7 +299,7 @@ } protected NodeIntrinsificationPhase createNodeIntrinsificationPhase() { - return new NodeIntrinsificationPhase(providers, snippetReflection); + return new NodeIntrinsificationPhase(providers.getMetaAccess(), providers.getConstantReflection(), snippetReflection, providers.getForeignCalls(), providers.getStampProvider()); } @Override