# HG changeset patch # User Doug Simon # Date 1429014403 -7200 # Node ID fb96fbd5acbd33183974c2624b22d252e1540550 # Parent cea0b72851900c95a2778102ce0be7644e6d29d4 added InvocationPlugin.inlineOnly to allow MacroNode creating plugins to indicate they should not be used as top level compilation roots diff -r cea0b7285190 -r fb96fbd5acbd graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/InvocationPlugin.java --- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/InvocationPlugin.java Tue Apr 14 12:08:41 2015 +0200 +++ b/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/InvocationPlugin.java Tue Apr 14 14:26:43 2015 +0200 @@ -44,6 +44,13 @@ } /** + * Determines if this plugin can only be used when inlining the method is it associated with. + */ + default boolean inlineOnly() { + return isSignaturePolymorphic(); + } + + /** * Handles invocation of a signature polymorphic method. * * @param receiver access to the receiver, {@code null} if {@code targetMethod} is static diff -r cea0b7285190 -r fb96fbd5acbd graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/MethodSubstitutionPlugin.java --- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/MethodSubstitutionPlugin.java Tue Apr 14 12:08:41 2015 +0200 +++ b/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/MethodSubstitutionPlugin.java Tue Apr 14 14:26:43 2015 +0200 @@ -62,6 +62,11 @@ this.originalIsStatic = parameters.length == 0 || parameters[0] != Receiver.class; } + public boolean inlineOnly() { + // Conservatively assume MacroNodes may be used in a substitution + return true; + } + /** * Gets the substitute method, resolving it first if necessary. */ @@ -121,8 +126,7 @@ return m; } } - throw new GraalInternalError("No method found in %s compatible with \"%s(%s)\"", declaringClass.getName(), name, Arrays.asList(parameters).stream().map(c -> c.getSimpleName()).collect( - Collectors.joining(", "))); + throw new GraalInternalError("No method found specified by %s", this); } /** @@ -165,4 +169,10 @@ } throw new GraalInternalError("could not find method named \"execute\" in " + c.getName()); } + + @Override + public String toString() { + return String.format("%s[%s.%s(%s)]", getClass().getSimpleName(), declaringClass.getName(), name, + Arrays.asList(parameters).stream().map(c -> c.getSimpleName()).collect(Collectors.joining(", "))); + } } diff -r cea0b7285190 -r fb96fbd5acbd 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 Tue Apr 14 12:08:41 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java Tue Apr 14 14:26:43 2015 +0200 @@ -99,6 +99,10 @@ b.addPush(Kind.Object, new ObjectCloneNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnType(), object)); return true; } + + public boolean inlineOnly() { + return true; + } }); r.registerMethodSubstitution(ObjectSubstitutions.class, "hashCode", Receiver.class); } @@ -118,6 +122,10 @@ } return true; } + + public boolean inlineOnly() { + return true; + } }); } r.register2("cast", Receiver.class, Object.class, new InvocationPlugin() { @@ -131,6 +139,10 @@ } return true; } + + public boolean inlineOnly() { + return true; + } }); } @@ -146,6 +158,10 @@ } return true; } + + public boolean inlineOnly() { + return true; + } }; plugins.register(plugin, ConstantCallSite.class, "getTarget", Receiver.class); plugins.register(plugin, MutableCallSite.class, "getTarget", Receiver.class); @@ -159,6 +175,10 @@ b.addPush(new ReflectionGetCallerClassNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnType())); return true; } + + public boolean inlineOnly() { + return true; + } }); } @@ -171,12 +191,20 @@ b.addPush(new IdentityHashCodeNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnType(), object)); return true; } + + public boolean inlineOnly() { + return true; + } }); r.register5("arraycopy", Object.class, int.class, Object.class, int.class, int.class, new InvocationPlugin() { public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode src, ValueNode srcPos, ValueNode dst, ValueNode dstPos, ValueNode length) { b.add(new ArrayCopyNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnType(), src, srcPos, dst, dstPos, length)); return true; } + + public boolean inlineOnly() { + return true; + } }); } diff -r cea0b7285190 -r fb96fbd5acbd graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInvocationPlugins.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInvocationPlugins.java Tue Apr 14 12:08:41 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInvocationPlugins.java Tue Apr 14 14:26:43 2015 +0200 @@ -40,6 +40,7 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.CallTargetNode.InvokeKind; import com.oracle.graal.replacements.StandardGraphBuilderPlugins.BoxPlugin; +import com.oracle.graal.replacements.nodes.*; /** * Extension of {@link InvocationPlugins} that disables plugins based on runtime configuration. @@ -136,6 +137,14 @@ @Override public void checkNewNodes(GraphBuilderContext b, InvocationPlugin plugin, NodeIterable newNodes) { + for (Node node : newNodes) { + if (node instanceof MacroNode) { + // MacroNode based plugins can only be used for inlining since they + // require a valid bci should they need to replace themselves with + // an InvokeNode during lowering. + assert plugin.inlineOnly() : String.format("plugin that creates a %s (%s) must return true for inlineOnly(): %s", MacroNode.class.getSimpleName(), node, plugin); + } + } if (GraalOptions.ImmutableCode.getValue()) { for (Node node : newNodes) { if (node.hasUsages() && node instanceof ConstantNode) {