Mercurial > hg > graal-compiler
changeset 23076:fb4379f87d4d
Merge com.oracle.graal.graphbuilderconf into com.oracle.graal.nodes project.
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64SuitesProvider.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64SuitesProvider.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -24,10 +24,10 @@ import static com.oracle.graal.compiler.common.BackendOptions.ShouldOptimizeStackToStackMoves; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.java.DefaultSuitesProvider; import com.oracle.graal.lir.amd64.phases.StackMoveOptimizationPhase; import com.oracle.graal.lir.phases.LIRSuites; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.phases.tiers.CompilerConfiguration; public class AMD64SuitesProvider extends DefaultSuitesProvider {
--- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCSuitesProvider.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCSuitesProvider.java Tue Nov 24 15:26:32 2015 +0100 @@ -22,8 +22,8 @@ */ package com.oracle.graal.compiler.sparc; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.java.DefaultSuitesProvider; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.phases.tiers.CompilerConfiguration; import com.oracle.graal.phases.tiers.Suites;
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java Tue Nov 24 15:26:32 2015 +0100 @@ -68,14 +68,14 @@ import com.oracle.graal.debug.GraalDebugConfig; import com.oracle.graal.graph.Node; import com.oracle.graal.graph.NodeClass; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; import com.oracle.graal.java.GraphBuilderPhase; import com.oracle.graal.nodeinfo.NodeInfo; import com.oracle.graal.nodes.PhiNode; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.phases.OptimisticOptimizations; import com.oracle.graal.phases.PhaseSuite; import com.oracle.graal.phases.VerifyPhase;
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CountedLoopTest.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CountedLoopTest.java Tue Nov 24 15:26:32 2015 +0100 @@ -28,16 +28,16 @@ import com.oracle.graal.api.directives.GraalDirectives; import com.oracle.graal.graph.NodeClass; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InvocationPlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.loop.InductionVariable; import com.oracle.graal.loop.LoopsData; import com.oracle.graal.nodeinfo.NodeInfo; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.ValueNode; import com.oracle.graal.nodes.calc.FloatingNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.nodes.spi.LIRLowerable; import com.oracle.graal.nodes.spi.NodeLIRBuilderTool;
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FinalizableSubclassTest.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FinalizableSubclassTest.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 @@ -37,10 +37,10 @@ import org.junit.Test; import com.oracle.graal.debug.Debug; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; import com.oracle.graal.java.GraphBuilderPhase; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; import com.oracle.graal.nodes.java.RegisterFinalizerNode; import com.oracle.graal.phases.OptimisticOptimizations; import com.oracle.graal.phases.common.CanonicalizerPhase;
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Tue Nov 24 15:26:32 2015 +0100 @@ -80,11 +80,6 @@ import com.oracle.graal.debug.TTY; import com.oracle.graal.graph.Node; import com.oracle.graal.graph.NodeMap; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InvocationPlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; import com.oracle.graal.java.ComputeLoopFrequenciesClosure; import com.oracle.graal.java.GraphBuilderPhase; import com.oracle.graal.lir.asm.CompilationResultBuilderFactory; @@ -99,6 +94,11 @@ import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; import com.oracle.graal.nodes.ValueNode; import com.oracle.graal.nodes.cfg.Block; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.nodes.spi.LoweringProvider; import com.oracle.graal.nodes.spi.Replacements; import com.oracle.graal.nodes.virtual.VirtualObjectNode;
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java Tue Nov 24 15:26:32 2015 +0100 @@ -37,11 +37,11 @@ import org.junit.Test; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; import com.oracle.graal.lir.asm.CompilationResultBuilderFactory; import com.oracle.graal.nodes.FullInfopointNode; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; import com.oracle.graal.phases.OptimisticOptimizations; import com.oracle.graal.phases.PhaseSuite; import com.oracle.graal.phases.tiers.HighTierContext;
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StaticInterfaceFieldTest.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StaticInterfaceFieldTest.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -36,12 +36,12 @@ import com.oracle.graal.debug.Debug; import com.oracle.graal.debug.DebugConfigScope; import com.oracle.graal.debug.DelegatingDebugConfig; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; import com.oracle.graal.java.GraphBuilderPhase; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.phases.OptimisticOptimizations; import com.oracle.graal.phases.PhaseSuite; import com.oracle.graal.phases.VerifyPhase;
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/UnbalancedMonitorsTest.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/UnbalancedMonitorsTest.java Tue Nov 24 15:26:32 2015 +0100 @@ -31,12 +31,12 @@ import org.junit.Test; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; import com.oracle.graal.java.GraphBuilderPhase; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.phases.OptimisticOptimizations; /**
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/inlining/InliningTest.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/inlining/InliningTest.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, 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 @@ -33,11 +33,11 @@ import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.debug.DebugDumpScope; import com.oracle.graal.graph.Node; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; import com.oracle.graal.nodes.FullInfopointNode; import com.oracle.graal.nodes.Invoke; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; import com.oracle.graal.phases.OptimisticOptimizations; import com.oracle.graal.phases.PhaseSuite; import com.oracle.graal.phases.common.CanonicalizerPhase;
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/StaticAnalysis.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/StaticAnalysis.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -42,9 +42,6 @@ import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.graph.Node; import com.oracle.graal.graph.NodeMap; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; import com.oracle.graal.java.GraphBuilderPhase; import com.oracle.graal.nodes.CallTargetNode.InvokeKind; import com.oracle.graal.nodes.ConstantNode; @@ -56,6 +53,9 @@ import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; import com.oracle.graal.nodes.ValueNode; import com.oracle.graal.nodes.ValuePhiNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.nodes.java.LoadFieldNode; import com.oracle.graal.nodes.java.MethodCallTargetNode; import com.oracle.graal.nodes.java.NewArrayNode;
--- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/ForeignCallPlugin.java Tue Nov 24 17:23:25 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2015, 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.graphbuilderconf; - -import jdk.vm.ci.meta.ResolvedJavaMethod; - -import com.oracle.graal.compiler.common.spi.ForeignCallDescriptor; -import com.oracle.graal.compiler.common.spi.ForeignCallsProvider; -import com.oracle.graal.nodes.ValueNode; -import com.oracle.graal.nodes.extended.ForeignCallNode; - -/** - * {@link InvocationPlugin} for converting a method call directly to a foreign call. - */ -public final class ForeignCallPlugin implements InvocationPlugin { - private final ForeignCallsProvider foreignCalls; - private final ForeignCallDescriptor descriptor; - - public ForeignCallPlugin(ForeignCallsProvider foreignCalls, ForeignCallDescriptor descriptor) { - this.foreignCalls = foreignCalls; - this.descriptor = descriptor; - } - - public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) { - ForeignCallNode foreignCall = new ForeignCallNode(foreignCalls, descriptor, args); - foreignCall.setBci(b.bci()); - b.addPush(targetMethod.getSignature().getReturnKind(), foreignCall); - return true; - } -}
--- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/GraphBuilderConfiguration.java Tue Nov 24 17:23:25 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,301 +0,0 @@ -/* - * Copyright (c) 2011, 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.graphbuilderconf; - -import java.util.Arrays; - -import jdk.vm.ci.meta.ResolvedJavaType; - -import com.oracle.graal.compiler.common.GraalOptions; -import com.oracle.graal.nodes.FullInfopointNode; -import com.oracle.graal.nodes.SimpleInfopointNode; - -public class GraphBuilderConfiguration { - - public static class Plugins { - private final InvocationPlugins invocationPlugins; - private NodePlugin[] nodePlugins; - private ParameterPlugin[] parameterPlugins; - private InlineInvokePlugin[] inlineInvokePlugins; - private LoopExplosionPlugin loopExplosionPlugin; - - /** - * Creates a copy of a given set of plugins. The {@link InvocationPlugins} in - * {@code copyFrom} become the {@linkplain InvocationPlugins#getParent() default} - * {@linkplain #getInvocationPlugins() invocation plugins} in this object. - */ - public Plugins(Plugins copyFrom) { - this.invocationPlugins = new InvocationPlugins(copyFrom.invocationPlugins); - this.nodePlugins = copyFrom.nodePlugins; - this.parameterPlugins = copyFrom.parameterPlugins; - this.inlineInvokePlugins = copyFrom.inlineInvokePlugins; - this.loopExplosionPlugin = copyFrom.loopExplosionPlugin; - } - - /** - * Creates a new set of plugins. - * - * @param invocationPlugins the {@linkplain #getInvocationPlugins() invocation plugins} in - * this object - */ - public Plugins(InvocationPlugins invocationPlugins) { - this.invocationPlugins = invocationPlugins; - this.nodePlugins = new NodePlugin[0]; - this.parameterPlugins = new ParameterPlugin[0]; - this.inlineInvokePlugins = new InlineInvokePlugin[0]; - } - - public InvocationPlugins getInvocationPlugins() { - return invocationPlugins; - } - - public NodePlugin[] getNodePlugins() { - return nodePlugins; - } - - public void appendNodePlugin(NodePlugin plugin) { - nodePlugins = Arrays.copyOf(nodePlugins, nodePlugins.length + 1); - nodePlugins[nodePlugins.length - 1] = plugin; - } - - public void prependNodePlugin(NodePlugin plugin) { - NodePlugin[] newPlugins = new NodePlugin[nodePlugins.length + 1]; - System.arraycopy(nodePlugins, 0, newPlugins, 1, nodePlugins.length); - newPlugins[0] = plugin; - nodePlugins = newPlugins; - } - - public void clearNodePlugin() { - nodePlugins = new NodePlugin[0]; - } - - public ParameterPlugin[] getParameterPlugins() { - return parameterPlugins; - } - - public void appendParameterPlugin(ParameterPlugin plugin) { - parameterPlugins = Arrays.copyOf(parameterPlugins, parameterPlugins.length + 1); - parameterPlugins[parameterPlugins.length - 1] = plugin; - } - - public void prependParameterPlugin(ParameterPlugin plugin) { - ParameterPlugin[] newPlugins = new ParameterPlugin[parameterPlugins.length + 1]; - System.arraycopy(parameterPlugins, 0, newPlugins, 1, parameterPlugins.length); - newPlugins[0] = plugin; - parameterPlugins = newPlugins; - } - - public void clearParameterPlugin() { - parameterPlugins = new ParameterPlugin[0]; - } - - public InlineInvokePlugin[] getInlineInvokePlugins() { - return inlineInvokePlugins; - } - - public void appendInlineInvokePlugin(InlineInvokePlugin plugin) { - inlineInvokePlugins = Arrays.copyOf(inlineInvokePlugins, inlineInvokePlugins.length + 1); - inlineInvokePlugins[inlineInvokePlugins.length - 1] = plugin; - } - - public void prependInlineInvokePlugin(InlineInvokePlugin plugin) { - InlineInvokePlugin[] newPlugins = new InlineInvokePlugin[inlineInvokePlugins.length + 1]; - System.arraycopy(inlineInvokePlugins, 0, newPlugins, 1, inlineInvokePlugins.length); - newPlugins[0] = plugin; - inlineInvokePlugins = newPlugins; - } - - public void clearInlineInvokePlugins() { - inlineInvokePlugins = new InlineInvokePlugin[0]; - } - - public LoopExplosionPlugin getLoopExplosionPlugin() { - return loopExplosionPlugin; - } - - public void setLoopExplosionPlugin(LoopExplosionPlugin plugin) { - this.loopExplosionPlugin = plugin; - } - } - - private static final ResolvedJavaType[] EMPTY = new ResolvedJavaType[]{}; - - private final boolean eagerResolving; - private final boolean omitAllExceptionEdges; - private final boolean omitAssertions; - private final ResolvedJavaType[] skippedExceptionTypes; - private final DebugInfoMode debugInfoMode; - private final boolean clearNonLiveLocals; - private boolean useProfiling; - private final Plugins plugins; - - public static enum DebugInfoMode { - SafePointsOnly, - /** - * This mode inserts {@link SimpleInfopointNode}s in places where no safepoints would be - * inserted: inlining boundaries, and line number switches. - * <p> - * In this mode the infopoint only have a location (method and bytecode index) and no - * values. - * <p> - * This is useful to have better program counter to bci mapping and has no influence on the - * generated code. However it can increase the amount of metadata and does not allow access - * to accessing values at runtime. - */ - Simple, - /** - * In this mode, {@link FullInfopointNode}s are generated in the same locations as in - * {@link #Simple} mode but the infopoints have access to the runtime values. - * <p> - * This is relevant when code is to be generated for native, machine-code level debugging - * but can have a limit the amount of optimization applied to the code. - */ - Full, - } - - protected GraphBuilderConfiguration(boolean eagerResolving, boolean omitAllExceptionEdges, boolean omitAssertions, DebugInfoMode debugInfoMode, ResolvedJavaType[] skippedExceptionTypes, - boolean clearNonLiveLocals, Plugins plugins) { - this.eagerResolving = eagerResolving; - this.omitAllExceptionEdges = omitAllExceptionEdges; - this.omitAssertions = omitAssertions; - this.debugInfoMode = debugInfoMode; - this.skippedExceptionTypes = skippedExceptionTypes; - this.clearNonLiveLocals = clearNonLiveLocals; - this.useProfiling = true; - this.plugins = plugins; - } - - /** - * Creates a copy of this configuration with all its plugins. The {@link InvocationPlugins} in - * this configuration become the {@linkplain InvocationPlugins#getParent() parent} of the - * {@link InvocationPlugins} in the copy. - */ - public GraphBuilderConfiguration copy() { - Plugins newPlugins = new Plugins(plugins); - GraphBuilderConfiguration result = new GraphBuilderConfiguration(eagerResolving, omitAllExceptionEdges, omitAssertions, debugInfoMode, skippedExceptionTypes, clearNonLiveLocals, newPlugins); - result.useProfiling = useProfiling; - return result; - } - - public boolean getUseProfiling() { - return useProfiling; - } - - public void setUseProfiling(boolean b) { - this.useProfiling = b; - } - - public GraphBuilderConfiguration withEagerResolving(boolean newEagerResolving) { - return new GraphBuilderConfiguration(newEagerResolving, omitAllExceptionEdges, omitAssertions, debugInfoMode, skippedExceptionTypes, clearNonLiveLocals, plugins); - } - - public GraphBuilderConfiguration withSkippedExceptionTypes(ResolvedJavaType[] newSkippedExceptionTypes) { - return new GraphBuilderConfiguration(eagerResolving, omitAllExceptionEdges, omitAssertions, debugInfoMode, newSkippedExceptionTypes, clearNonLiveLocals, plugins); - } - - public GraphBuilderConfiguration withOmitAllExceptionEdges(boolean newOmitAllExceptionEdges) { - return new GraphBuilderConfiguration(eagerResolving, newOmitAllExceptionEdges, omitAssertions, debugInfoMode, skippedExceptionTypes, clearNonLiveLocals, plugins); - } - - public GraphBuilderConfiguration withOmitAssertions(boolean newOmitAssertions) { - return new GraphBuilderConfiguration(eagerResolving, omitAllExceptionEdges, newOmitAssertions, debugInfoMode, skippedExceptionTypes, clearNonLiveLocals, plugins); - } - - public GraphBuilderConfiguration withDebugInfoMode(DebugInfoMode newDebugInfoMode) { - ResolvedJavaType[] newSkippedExceptionTypes = skippedExceptionTypes == EMPTY ? EMPTY : Arrays.copyOf(skippedExceptionTypes, skippedExceptionTypes.length); - return new GraphBuilderConfiguration(eagerResolving, omitAllExceptionEdges, omitAssertions, newDebugInfoMode, newSkippedExceptionTypes, clearNonLiveLocals, plugins); - } - - public GraphBuilderConfiguration withClearNonLiveLocals(boolean newClearNonLiveLocals) { - return new GraphBuilderConfiguration(eagerResolving, omitAllExceptionEdges, omitAssertions, debugInfoMode, skippedExceptionTypes, newClearNonLiveLocals, plugins); - } - - public ResolvedJavaType[] getSkippedExceptionTypes() { - return skippedExceptionTypes; - } - - public boolean eagerResolving() { - return eagerResolving; - } - - public boolean omitAllExceptionEdges() { - return omitAllExceptionEdges; - } - - public boolean omitAssertions() { - return omitAssertions; - } - - public boolean insertNonSafepointDebugInfo() { - return debugInfoMode.ordinal() >= DebugInfoMode.Simple.ordinal(); - } - - public boolean insertFullDebugInfo() { - return debugInfoMode.ordinal() >= DebugInfoMode.Full.ordinal(); - } - - public boolean insertSimpleDebugInfo() { - return debugInfoMode == DebugInfoMode.Simple; - } - - public boolean clearNonLiveLocals() { - return clearNonLiveLocals; - } - - public static GraphBuilderConfiguration getDefault(Plugins plugins) { - return new GraphBuilderConfiguration(false, false, false, DebugInfoMode.SafePointsOnly, EMPTY, GraalOptions.OptClearNonLiveLocals.getValue(), plugins); - } - - public static GraphBuilderConfiguration getInfopointDefault(Plugins plugins) { - return new GraphBuilderConfiguration(true, false, false, DebugInfoMode.Simple, EMPTY, GraalOptions.OptClearNonLiveLocals.getValue(), plugins); - } - - public static GraphBuilderConfiguration getEagerDefault(Plugins plugins) { - return new GraphBuilderConfiguration(true, false, false, DebugInfoMode.SafePointsOnly, EMPTY, GraalOptions.OptClearNonLiveLocals.getValue(), plugins); - } - - public static GraphBuilderConfiguration getInfopointEagerDefault(Plugins plugins) { - return new GraphBuilderConfiguration(true, false, false, DebugInfoMode.Simple, EMPTY, GraalOptions.OptClearNonLiveLocals.getValue(), plugins); - } - - public static GraphBuilderConfiguration getSnippetDefault(Plugins plugins) { - return new GraphBuilderConfiguration(true, true, false, DebugInfoMode.SafePointsOnly, EMPTY, GraalOptions.OptClearNonLiveLocals.getValue(), plugins); - } - - public static GraphBuilderConfiguration getFullDebugDefault(Plugins plugins) { - return new GraphBuilderConfiguration(true, false, false, DebugInfoMode.Full, EMPTY, GraalOptions.OptClearNonLiveLocals.getValue(), plugins); - } - - /** - * Returns {@code true} if it is an error for a class/field/method resolution to fail. The - * default is the same result as returned by {@link #eagerResolving()}. However, it may be - * overridden to allow failure even when {@link #eagerResolving} is {@code true}. - */ - public boolean unresolvedIsError() { - return eagerResolving; - } - - public Plugins getPlugins() { - return plugins; - } -}
--- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/GraphBuilderContext.java Tue Nov 24 17:23:25 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,266 +0,0 @@ -/* - * Copyright (c) 2015, 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.graphbuilderconf; - -import static com.oracle.graal.compiler.common.type.StampFactory.objectNonNull; -import static jdk.vm.ci.meta.DeoptimizationAction.InvalidateReprofile; -import static jdk.vm.ci.meta.DeoptimizationReason.NullCheckException; -import jdk.vm.ci.code.BailoutException; -import jdk.vm.ci.meta.Assumptions; -import jdk.vm.ci.meta.ConstantReflectionProvider; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; - -import com.oracle.graal.compiler.common.type.ObjectStamp; -import com.oracle.graal.compiler.common.type.Stamp; -import com.oracle.graal.compiler.common.type.StampFactory; -import com.oracle.graal.nodes.CallTargetNode.InvokeKind; -import com.oracle.graal.nodes.FixedGuardNode; -import com.oracle.graal.nodes.PiNode; -import com.oracle.graal.nodes.StateSplit; -import com.oracle.graal.nodes.StructuredGraph; -import com.oracle.graal.nodes.ValueNode; -import com.oracle.graal.nodes.calc.IsNullNode; -import com.oracle.graal.nodes.spi.StampProvider; -import com.oracle.graal.nodes.type.StampTool; - -/** - * Used by a {@link GraphBuilderPlugin} to interface with an object that parses the bytecode of a - * single {@linkplain #getMethod() method} as part of building a {@linkplain #getGraph() graph} . - */ -public interface GraphBuilderContext { - - /** - * Raw operation for adding a node to the graph when neither {@link #add} nor - * {@link #addPush(JavaKind, ValueNode)} can be used. - * - * @return either the node added or an equivalent node - */ - <T extends ValueNode> T append(T value); - - /** - * Adds the given node to the graph and also adds recursively all referenced inputs. - * - * @param value the node to be added to the graph - * @return either the node added or an equivalent node - */ - <T extends ValueNode> T recursiveAppend(T value); - - /** - * Pushes a given value to the frame state stack using an explicit kind. This should be used - * when {@code value.getJavaKind()} is different from the kind that the bytecode instruction - * currently being parsed pushes to the stack. - * - * @param kind the kind to use when type checking this operation - * @param value the value to push to the stack. The value must already have been - * {@linkplain #append(ValueNode) appended}. - */ - void push(JavaKind kind, ValueNode value); - - /** - * Adds a node to the graph. If the returned node is a {@link StateSplit} with a null - * {@linkplain StateSplit#stateAfter() frame state}, the frame state is initialized. - * - * @param value the value to add to the graph and push to the stack. The - * {@code value.getJavaKind()} kind is used when type checking this operation. - * @return a node equivalent to {@code value} in the graph - */ - default <T extends ValueNode> T add(T value) { - if (value.graph() != null) { - assert !(value instanceof StateSplit) || ((StateSplit) value).stateAfter() != null; - return value; - } - T equivalentValue = append(value); - if (equivalentValue instanceof StateSplit) { - StateSplit stateSplit = (StateSplit) equivalentValue; - if (stateSplit.stateAfter() == null && stateSplit.hasSideEffect()) { - setStateAfter(stateSplit); - } - } - return equivalentValue; - } - - /** - * Adds a node with a non-void kind to the graph, pushes it to the stack. If the returned node - * is a {@link StateSplit} with a null {@linkplain StateSplit#stateAfter() frame state}, the - * frame state is initialized. - * - * @param kind the kind to use when type checking this operation - * @param value the value to add to the graph and push to the stack - * @return a node equivalent to {@code value} in the graph - */ - default <T extends ValueNode> T addPush(JavaKind kind, T value) { - T equivalentValue = value.graph() != null ? value : append(value); - push(kind, equivalentValue); - if (equivalentValue instanceof StateSplit) { - StateSplit stateSplit = (StateSplit) equivalentValue; - if (stateSplit.stateAfter() == null && stateSplit.hasSideEffect()) { - setStateAfter(stateSplit); - } - } - return equivalentValue; - } - - /** - * Handles an invocation that a plugin determines can replace the original invocation (i.e., the - * one for which the plugin was applied). This applies all standard graph builder processing to - * the replaced invocation including applying any relevant plugins. - * - * @param invokeKind the kind of the replacement invocation - * @param targetMethod the target of the replacement invocation - * @param args the arguments to the replacement invocation - * @param forceInlineEverything specifies if all invocations encountered in the scope of - * handling the replaced invoke are to be force inlined - */ - void handleReplacedInvoke(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] args, boolean forceInlineEverything); - - /** - * Intrinsifies an invocation of a given method by inlining the bytecodes of a given - * substitution method. - * - * @param targetMethod the method being intrinsified - * @param substitute the intrinsic implementation - * @param args the arguments with which to inline the invocation - */ - void intrinsify(ResolvedJavaMethod targetMethod, ResolvedJavaMethod substitute, ValueNode[] args); - - StampProvider getStampProvider(); - - MetaAccessProvider getMetaAccess(); - - default Assumptions getAssumptions() { - return getGraph().getAssumptions(); - } - - ConstantReflectionProvider getConstantReflection(); - - /** - * Gets the graph being constructed. - */ - StructuredGraph getGraph(); - - /** - * Creates a snap shot of the current frame state with the BCI of the instruction after the one - * currently being parsed and assigns it to a given {@linkplain StateSplit#hasSideEffect() side - * effect} node. - * - * @param sideEffect a side effect node just appended to the graph - */ - void setStateAfter(StateSplit sideEffect); - - /** - * Gets the parsing context for the method that inlines the method being parsed by this context. - */ - GraphBuilderContext getParent(); - - /** - * Gets the first ancestor parsing context that is not parsing a - * {@linkplain #parsingIntrinsic() intrinsic}. - */ - default GraphBuilderContext getNonIntrinsicAncestor() { - GraphBuilderContext ancestor = getParent(); - while (ancestor != null && ancestor.parsingIntrinsic()) { - ancestor = ancestor.getParent(); - } - return ancestor; - } - - /** - * Gets the method being parsed by this context. - */ - ResolvedJavaMethod getMethod(); - - /** - * Gets the index of the bytecode instruction currently being parsed. - */ - int bci(); - - /** - * Gets the kind of invocation currently being parsed. - */ - InvokeKind getInvokeKind(); - - /** - * Gets the return type of the invocation currently being parsed. - */ - JavaType getInvokeReturnType(); - - default Stamp getInvokeReturnStamp() { - JavaType returnType = getInvokeReturnType(); - if (returnType.getJavaKind() == JavaKind.Object && returnType instanceof ResolvedJavaType) { - return StampFactory.declared((ResolvedJavaType) returnType); - } else { - return StampFactory.forKind(returnType.getJavaKind()); - } - } - - /** - * Gets the inline depth of this context. A return value of 0 implies that this is the context - * for the parse root. - */ - default int getDepth() { - GraphBuilderContext parent = getParent(); - return parent == null ? 0 : 1 + parent.getDepth(); - } - - /** - * Determines if this parsing context is within the bytecode of an intrinsic or a method inlined - * by an intrinsic. - */ - default boolean parsingIntrinsic() { - return getIntrinsic() != null; - } - - /** - * Gets the intrinsic of the current parsing context or {@code null} if not - * {@link #parsingIntrinsic() parsing an intrinsic}. - */ - IntrinsicContext getIntrinsic(); - - BailoutException bailout(String string); - - /** - * Gets a version of a given value that has a {@linkplain StampTool#isPointerNonNull(ValueNode) - * non-null} stamp. - */ - default ValueNode nullCheckedValue(ValueNode value) { - if (!StampTool.isPointerNonNull(value.stamp())) { - IsNullNode condition = getGraph().unique(new IsNullNode(value)); - ObjectStamp receiverStamp = (ObjectStamp) value.stamp(); - Stamp stamp = receiverStamp.join(objectNonNull()); - FixedGuardNode fixedGuard = append(new FixedGuardNode(condition, NullCheckException, InvalidateReprofile, true)); - PiNode nonNullReceiver = getGraph().unique(new PiNode(value, stamp)); - nonNullReceiver.setGuard(fixedGuard); - // TODO: Propogating the non-null into the frame state would - // remove subsequent null-checks on the same value. However, - // it currently causes an assertion failure when merging states. - // - // frameState.replace(value, nonNullReceiver); - return nonNullReceiver; - } - return value; - } -}
--- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/GraphBuilderPlugin.java Tue Nov 24 17:23:25 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2015, 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.graphbuilderconf; - -/** - * Marker interface for graph builder plugins. - */ -public interface GraphBuilderPlugin { -}
--- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/InlineInvokePlugin.java Tue Nov 24 17:23:25 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2015, 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.graphbuilderconf; - -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -import com.oracle.graal.nodes.Invoke; -import com.oracle.graal.nodes.ValueNode; - -/** - * Plugin for specifying what is inlined during graph parsing. This plugin is also notified - * {@link #notifyBeforeInline before} and {@link #notifyAfterInline} the inlining, as well as of - * {@link #notifyNotInlined non-inlined} invocations (i.e., those for which an {@link Invoke} node - * is created). - */ -public interface InlineInvokePlugin extends GraphBuilderPlugin { - - /** - * Result of a {@link #shouldInlineInvoke inlining decision}. - */ - public static class InlineInfo { - - /** - * Denotes a call site that must not be inlined and should be implemented by a node that - * does not speculate on the call not raising an exception. - */ - public static final InlineInfo DO_NOT_INLINE_WITH_EXCEPTION = new InlineInfo(null, false); - - /** - * Denotes a call site must not be inlined and can be implemented by a node that speculates - * the call will not throw an exception. - */ - public static final InlineInfo DO_NOT_INLINE_NO_EXCEPTION = new InlineInfo(null, false); - - private final ResolvedJavaMethod methodToInline; - private final boolean isIntrinsic; - - public InlineInfo(ResolvedJavaMethod methodToInline, boolean isIntrinsic) { - this.methodToInline = methodToInline; - this.isIntrinsic = isIntrinsic; - } - - /** - * Returns the method to be inlined, or {@code null} if the call site must not be inlined. - */ - public ResolvedJavaMethod getMethodToInline() { - return methodToInline; - } - - /** - * Specifies if {@link #methodToInline} is an intrinsic for the original method (i.e., the - * {@code method} passed to {@link InlineInvokePlugin#shouldInlineInvoke}). - */ - public boolean isIntrinsic() { - return isIntrinsic; - } - } - - /** - * Determines whether a call to a given method is to be inlined. The return value is a - * tri-state: - * <p> - * Non-null return value with a non-null {@link InlineInfo#getMethodToInline method}: That - * {@link InlineInfo#getMethodToInline method} is inlined. Note that it can be a different - * method than the one specified here as the parameter, which allows method substitutions. - * <p> - * Non-null return value with a null {@link InlineInfo#getMethodToInline method}, e.g., - * {@link InlineInfo#DO_NOT_INLINE_WITH_EXCEPTION}: The method is not inlined, and other plugins - * with a lower priority cannot overwrite this decision. - * <p> - * Null return value: This plugin made no decision, other plugins with a lower priority are - * asked. - * - * @param b the context - * @param method the target method of an invoke - * @param args the arguments to the invoke - * @param returnType the return type derived from {@code method}'s signature - */ - default InlineInfo shouldInlineInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args, JavaType returnType) { - return null; - } - - /** - * Notification that a method is about to be inlined. - * - * @param methodToInline the inlined method - */ - default void notifyBeforeInline(ResolvedJavaMethod methodToInline) { - } - - /** - * Notification that a method was inlined. - * - * @param methodToInline the inlined method - */ - default void notifyAfterInline(ResolvedJavaMethod methodToInline) { - } - - /** - * Notifies this plugin of the {@link Invoke} node created for a method that was not inlined per - * {@link #shouldInlineInvoke}. - * - * @param b the context - * @param method the method that was not inlined - * @param invoke the invoke node created for the call to {@code method} - */ - default void notifyNotInlined(GraphBuilderContext b, ResolvedJavaMethod method, Invoke invoke) { - } -}
--- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/IntrinsicContext.java Tue Nov 24 17:23:25 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2015, 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.graphbuilderconf; - -import static com.oracle.graal.graphbuilderconf.IntrinsicContext.CompilationContext.INLINE_AFTER_PARSING; -import static com.oracle.graal.graphbuilderconf.IntrinsicContext.CompilationContext.ROOT_COMPILATION; -import static jdk.vm.ci.code.BytecodeFrame.AFTER_BCI; -import static jdk.vm.ci.code.BytecodeFrame.BEFORE_BCI; -import static jdk.vm.ci.code.BytecodeFrame.INVALID_FRAMESTATE_BCI; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -import com.oracle.graal.nodes.AbstractMergeNode; -import com.oracle.graal.nodes.FrameState; -import com.oracle.graal.nodes.Invoke; -import com.oracle.graal.nodes.StateSplit; -import com.oracle.graal.nodes.StructuredGraph; - -/** - * An intrinsic is a substitute implementation of a Java method (or a bytecode in the case of - * snippets) that is itself implemented in Java. This interface provides information about the - * intrinsic currently being processed by the graph builder. - * - * When in the scope of an intrinsic, the graph builder does not check the value kinds flowing - * through the JVM state since intrinsics can employ non-Java kinds to represent values such as raw - * machine words and pointers. - */ -public class IntrinsicContext { - - /** - * Gets the method being intrinsified. - */ - final ResolvedJavaMethod method; - - /** - * Gets the method providing the intrinsic implementation. - */ - final ResolvedJavaMethod intrinsic; - - public ResolvedJavaMethod getOriginalMethod() { - return method; - } - - public ResolvedJavaMethod getIntrinsicMethod() { - return intrinsic; - } - - /** - * Determines if a call within the compilation scope of this intrinsic represents a call to the - * {@linkplain #getOriginalMethod() original} method. This denotes the path where a partial - * intrinsification falls back to the original method. - */ - public boolean isCallToOriginal(ResolvedJavaMethod targetMethod) { - return method.equals(targetMethod) || intrinsic.equals(targetMethod); - } - - final CompilationContext compilationContext; - - public IntrinsicContext(ResolvedJavaMethod method, ResolvedJavaMethod intrinsic, CompilationContext compilationContext) { - this.method = method; - this.intrinsic = intrinsic; - this.compilationContext = compilationContext; - assert !isCompilationRoot() || method.hasBytecodes() : "Cannot root compile intrinsic for native or abstract method " + method.format("%H.%n(%p)"); - } - - public boolean isPostParseInlined() { - return compilationContext.equals(INLINE_AFTER_PARSING); - } - - public boolean isCompilationRoot() { - return compilationContext.equals(ROOT_COMPILATION); - } - - /** - * Denotes the compilation context in which an intrinsic is being parsed. - */ - public enum CompilationContext { - /** - * An intrinsic is being processed when parsing an invoke bytecode that calls the - * intrinsified method. - */ - INLINE_DURING_PARSING, - - /** - * An intrinsic is being processed when inlining an {@link Invoke} in an existing graph. - */ - INLINE_AFTER_PARSING, - - /** - * An intrinsic is the root of compilation. - */ - ROOT_COMPILATION - } - - /** - * Models the state of a graph in terms of {@link StateSplit#hasSideEffect() side effects} that - * are control flow predecessors of the current point in a graph. - */ - public interface SideEffectsState { - - /** - * Determines if the current program point is preceded by one or more side effects. - */ - boolean isAfterSideEffect(); - - /** - * Gets the side effects preceding the current program point. - */ - Iterable<StateSplit> sideEffects(); - - /** - * Records a side effect for the current program point. - */ - void addSideEffect(StateSplit sideEffect); - } - - public FrameState createFrameState(StructuredGraph graph, SideEffectsState sideEffects, StateSplit forStateSplit) { - assert forStateSplit != graph.start(); - if (forStateSplit.hasSideEffect()) { - if (sideEffects.isAfterSideEffect()) { - // Only the last side effect on any execution path in a replacement - // can inherit the stateAfter of the replaced node - FrameState invalid = graph.add(new FrameState(INVALID_FRAMESTATE_BCI)); - for (StateSplit lastSideEffect : sideEffects.sideEffects()) { - lastSideEffect.setStateAfter(invalid); - } - } - sideEffects.addSideEffect(forStateSplit); - return graph.add(new FrameState(AFTER_BCI)); - } else { - if (forStateSplit instanceof AbstractMergeNode) { - // Merge nodes always need a frame state - if (sideEffects.isAfterSideEffect()) { - // A merge after one or more side effects - return graph.add(new FrameState(AFTER_BCI)); - } else { - // A merge before any side effects - return graph.add(new FrameState(BEFORE_BCI)); - } - } else { - // Other non-side-effects do not need a state - return null; - } - } - } - - @Override - public String toString() { - return "Intrinsic{original: " + method.format("%H.%n(%p)") + ", intrinsic: " + intrinsic.format("%H.%n(%p)") + ", context: " + compilationContext + "}"; - } -}
--- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/InvocationPlugin.java Tue Nov 24 17:23:25 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,208 +0,0 @@ -/* - * Copyright (c) 2015, 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.graphbuilderconf; - -import java.lang.invoke.MethodHandle; -import java.lang.reflect.Method; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -import com.oracle.graal.nodes.Invoke; -import com.oracle.graal.nodes.ValueNode; -import com.oracle.graal.nodes.type.StampTool; - -/** - * Plugin for handling a specific method invocation. - */ -public interface InvocationPlugin extends GraphBuilderPlugin { - - /** - * The receiver in a non-static method. The class literal for this interface must be used with - * {@link InvocationPlugins#put(InvocationPlugin, boolean, boolean, boolean, Class, String, Class...)} - * to denote the receiver argument for such a non-static method. - */ - public interface Receiver { - /** - * Gets the receiver value, null checking it first if necessary. - * - * @return the receiver value with a {@linkplain StampTool#isPointerNonNull(ValueNode) - * non-null} stamp - */ - ValueNode get(); - - /** - * Determines if the receiver is constant. - */ - default boolean isConstant() { - return false; - } - } - - /** - * Determines if this plugin is for a method with a polymorphic signature (e.g. - * {@link MethodHandle#invokeExact(Object...)}). - */ - default boolean isSignaturePolymorphic() { - return false; - } - - /** - * Determines if this plugin can only be used when inlining the method is it associated with. - * That is, this plugin cannot be used when the associated method is the compilation root. - */ - 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 - * @param argsIncludingReceiver all arguments to the invocation include the raw receiver in - * position 0 if {@code targetMethod} is not static - * @see #execute - */ - default boolean applyPolymorphic(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode... argsIncludingReceiver) { - return defaultHandler(b, targetMethod, receiver, argsIncludingReceiver); - } - - /** - * @see #execute - */ - default boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver) { - return defaultHandler(b, targetMethod, receiver); - } - - /** - * @see #execute - */ - default boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode arg) { - return defaultHandler(b, targetMethod, receiver, arg); - } - - /** - * @see #execute - */ - default boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode arg1, ValueNode arg2) { - return defaultHandler(b, targetMethod, receiver, arg1, arg2); - } - - /** - * @see #execute - */ - default boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode arg1, ValueNode arg2, ValueNode arg3) { - return defaultHandler(b, targetMethod, receiver, arg1, arg2, arg3); - } - - /** - * @see #execute - */ - default boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode arg1, ValueNode arg2, ValueNode arg3, ValueNode arg4) { - return defaultHandler(b, targetMethod, receiver, arg1, arg2, arg3, arg4); - } - - /** - * @see #execute - */ - default boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode arg1, ValueNode arg2, ValueNode arg3, ValueNode arg4, ValueNode arg5) { - return defaultHandler(b, targetMethod, receiver, arg1, arg2, arg3, arg4, arg5); - } - - /** - * Executes this plugin against a set of invocation arguments. - * - * The default implementation in {@link InvocationPlugin} dispatches to the {@code apply(...)} - * method that matches the number of arguments or to {@link #applyPolymorphic} if {@code plugin} - * is {@linkplain #isSignaturePolymorphic() signature polymorphic}. - * - * @param targetMethod the method for which this plugin is being applied - * @param receiver access to the receiver, {@code null} if {@code targetMethod} is static - * @param argsIncludingReceiver all arguments to the invocation include the receiver in position - * 0 if {@code targetMethod} is not static - * @return {@code true} if this plugin handled the invocation of {@code targetMethod} - * {@code false} if the graph builder should process the invoke further (e.g., by - * inlining it or creating an {@link Invoke} node). A plugin that does not handle an - * invocation must not modify the graph being constructed. - */ - default boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] argsIncludingReceiver) { - if (isSignaturePolymorphic()) { - return applyPolymorphic(b, targetMethod, receiver, argsIncludingReceiver); - } else if (receiver != null) { - assert !targetMethod.isStatic(); - assert argsIncludingReceiver.length > 0; - if (argsIncludingReceiver.length == 1) { - return apply(b, targetMethod, receiver); - } else if (argsIncludingReceiver.length == 2) { - return apply(b, targetMethod, receiver, argsIncludingReceiver[1]); - } else if (argsIncludingReceiver.length == 3) { - return apply(b, targetMethod, receiver, argsIncludingReceiver[1], argsIncludingReceiver[2]); - } else if (argsIncludingReceiver.length == 4) { - return apply(b, targetMethod, receiver, argsIncludingReceiver[1], argsIncludingReceiver[2], argsIncludingReceiver[3]); - } else if (argsIncludingReceiver.length == 5) { - return apply(b, targetMethod, receiver, argsIncludingReceiver[1], argsIncludingReceiver[2], argsIncludingReceiver[3], argsIncludingReceiver[4]); - } else { - return defaultHandler(b, targetMethod, receiver, argsIncludingReceiver); - } - } else { - assert targetMethod.isStatic(); - if (argsIncludingReceiver.length == 0) { - return apply(b, targetMethod, null); - } else if (argsIncludingReceiver.length == 1) { - return apply(b, targetMethod, null, argsIncludingReceiver[0]); - } else if (argsIncludingReceiver.length == 2) { - return apply(b, targetMethod, null, argsIncludingReceiver[0], argsIncludingReceiver[1]); - } else if (argsIncludingReceiver.length == 3) { - return apply(b, targetMethod, null, argsIncludingReceiver[0], argsIncludingReceiver[1], argsIncludingReceiver[2]); - } else if (argsIncludingReceiver.length == 4) { - return apply(b, targetMethod, null, argsIncludingReceiver[0], argsIncludingReceiver[1], argsIncludingReceiver[2], argsIncludingReceiver[3]); - } else if (argsIncludingReceiver.length == 5) { - return apply(b, targetMethod, null, argsIncludingReceiver[0], argsIncludingReceiver[1], argsIncludingReceiver[2], argsIncludingReceiver[3], argsIncludingReceiver[4]); - } else { - return defaultHandler(b, targetMethod, receiver, argsIncludingReceiver); - } - - } - } - - /** - * Handles an invocation when a specific {@code apply} method is not available. - */ - default boolean defaultHandler(@SuppressWarnings("unused") GraphBuilderContext b, ResolvedJavaMethod targetMethod, @SuppressWarnings("unused") InvocationPlugin.Receiver receiver, - ValueNode... args) { - throw new JVMCIError("Invocation plugin for %s does not handle invocations with %d arguments", targetMethod.format("%H.%n(%p)"), args.length); - } - - default StackTraceElement getApplySourceLocation(MetaAccessProvider metaAccess) { - Class<?> c = getClass(); - for (Method m : c.getDeclaredMethods()) { - if (m.getName().equals("apply")) { - return metaAccess.lookupJavaMethod(m).asStackTraceElement(0); - } else if (m.getName().equals("defaultHandler")) { - return metaAccess.lookupJavaMethod(m).asStackTraceElement(0); - } - } - throw new JVMCIError("could not find method named \"apply\" or \"defaultHandler\" in " + c.getName()); - } -}
--- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/InvocationPlugins.java Tue Nov 24 17:23:25 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,604 +0,0 @@ -/* - * Copyright (c) 2015, 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.graphbuilderconf; - -import static java.lang.String.format; - -import java.lang.reflect.Executable; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -import com.oracle.graal.graph.Node; -import com.oracle.graal.graph.iterators.NodeIterable; -import com.oracle.graal.nodes.ValueNode; - -/** - * Manages a set of {@link InvocationPlugin}s. - */ -public class InvocationPlugins { - - public static class InvocationPluginReceiver implements InvocationPlugin.Receiver { - private final GraphBuilderContext parser; - private ValueNode[] args; - private ValueNode value; - - public InvocationPluginReceiver(GraphBuilderContext parser) { - this.parser = parser; - } - - @Override - public ValueNode get() { - assert args != null : "Cannot get the receiver of a static method"; - if (value == null) { - value = parser.nullCheckedValue(args[0]); - if (value != args[0]) { - args[0] = value; - } - } - return value; - } - - @Override - public boolean isConstant() { - return args[0].isConstant(); - } - - public InvocationPluginReceiver init(ResolvedJavaMethod targetMethod, ValueNode[] newArgs) { - if (!targetMethod.isStatic()) { - this.args = newArgs; - this.value = null; - return this; - } - return null; - } - } - - /** - * Utility for - * {@linkplain InvocationPlugins#register(InvocationPlugin, Class, String, Class...) - * registration} of invocation plugins. - */ - public static class Registration { - - private final InvocationPlugins plugins; - private final Class<?> declaringClass; - private boolean allowOverwrite; - - /** - * Creates an object for registering {@link InvocationPlugin}s for methods declared by a - * given class. - * - * @param plugins where to register the plugins - * @param declaringClass the class declaring the methods for which plugins will be - * registered via this object - */ - public Registration(InvocationPlugins plugins, Class<?> declaringClass) { - this.plugins = plugins; - this.declaringClass = declaringClass; - } - - /** - * Creates an object for registering {@link InvocationPlugin}s for methods declared by a - * given class. - * - * @param plugins where to register the plugins - * @param declaringClassName the name of the class class declaring the methods for which - * plugins will be registered via this object - */ - public Registration(InvocationPlugins plugins, String declaringClassName) { - this.plugins = plugins; - try { - this.declaringClass = Class.forName(declaringClassName); - } catch (ClassNotFoundException ex) { - throw JVMCIError.shouldNotReachHere(ex); - } - } - - /** - * Configures this registration to allow or disallow overwriting of invocation plugins. - */ - public Registration setAllowOverwrite(boolean allowOverwrite) { - this.allowOverwrite = allowOverwrite; - return this; - } - - /** - * Registers a plugin for a method with no arguments. - * - * @param name the name of the method - * @param plugin the plugin to be registered - */ - public void register0(String name, InvocationPlugin plugin) { - plugins.register(plugin, false, allowOverwrite, declaringClass, name); - } - - /** - * Registers a plugin for a method with 1 argument. - * - * @param name the name of the method - * @param plugin the plugin to be registered - */ - public void register1(String name, Class<?> arg, InvocationPlugin plugin) { - plugins.register(plugin, false, allowOverwrite, declaringClass, name, arg); - } - - /** - * Registers a plugin for a method with 2 arguments. - * - * @param name the name of the method - * @param plugin the plugin to be registered - */ - public void register2(String name, Class<?> arg1, Class<?> arg2, InvocationPlugin plugin) { - plugins.register(plugin, false, allowOverwrite, declaringClass, name, arg1, arg2); - } - - /** - * Registers a plugin for a method with 3 arguments. - * - * @param name the name of the method - * @param plugin the plugin to be registered - */ - public void register3(String name, Class<?> arg1, Class<?> arg2, Class<?> arg3, InvocationPlugin plugin) { - plugins.register(plugin, false, allowOverwrite, declaringClass, name, arg1, arg2, arg3); - } - - /** - * Registers a plugin for a method with 4 arguments. - * - * @param name the name of the method - * @param plugin the plugin to be registered - */ - public void register4(String name, Class<?> arg1, Class<?> arg2, Class<?> arg3, Class<?> arg4, InvocationPlugin plugin) { - plugins.register(plugin, false, allowOverwrite, declaringClass, name, arg1, arg2, arg3, arg4); - } - - /** - * Registers a plugin for a method with 5 arguments. - * - * @param name the name of the method - * @param plugin the plugin to be registered - */ - public void register5(String name, Class<?> arg1, Class<?> arg2, Class<?> arg3, Class<?> arg4, Class<?> arg5, InvocationPlugin plugin) { - plugins.register(plugin, false, allowOverwrite, declaringClass, name, arg1, arg2, arg3, arg4, arg5); - } - - /** - * Registers a plugin for an optional method with no arguments. - * - * @param name the name of the method - * @param plugin the plugin to be registered - */ - public void registerOptional0(String name, InvocationPlugin plugin) { - plugins.register(plugin, true, allowOverwrite, declaringClass, name); - } - - /** - * Registers a plugin for an optional method with 1 argument. - * - * @param name the name of the method - * @param plugin the plugin to be registered - */ - public void registerOptional1(String name, Class<?> arg, InvocationPlugin plugin) { - plugins.register(plugin, true, allowOverwrite, declaringClass, name, arg); - } - - /** - * Registers a plugin for an optional method with 2 arguments. - * - * @param name the name of the method - * @param plugin the plugin to be registered - */ - public void registerOptional2(String name, Class<?> arg1, Class<?> arg2, InvocationPlugin plugin) { - plugins.register(plugin, true, allowOverwrite, declaringClass, name, arg1, arg2); - } - - /** - * Registers a plugin for an optional method with 3 arguments. - * - * @param name the name of the method - * @param plugin the plugin to be registered - */ - public void registerOptional3(String name, Class<?> arg1, Class<?> arg2, Class<?> arg3, InvocationPlugin plugin) { - plugins.register(plugin, true, allowOverwrite, declaringClass, name, arg1, arg2, arg3); - } - - /** - * Registers a plugin for an optional method with 4 arguments. - * - * @param name the name of the method - * @param plugin the plugin to be registered - */ - public void registerOptional4(String name, Class<?> arg1, Class<?> arg2, Class<?> arg3, Class<?> arg4, InvocationPlugin plugin) { - plugins.register(plugin, true, allowOverwrite, declaringClass, name, arg1, arg2, arg3, arg4); - } - - /** - * Registers a plugin that implements a method based on the bytecode of a substitute method. - * - * @param substituteDeclaringClass the class declaring the substitute method - * @param name the name of both the original and substitute method - * @param argumentTypes the argument types of the method. Element 0 of this array must be - * the {@link Class} value for {@link InvocationPlugin.Receiver} iff the method - * is non-static. Upon returning, element 0 will have been rewritten to - * {@code declaringClass} - */ - public void registerMethodSubstitution(Class<?> substituteDeclaringClass, String name, Class<?>... argumentTypes) { - registerMethodSubstitution(substituteDeclaringClass, name, name, argumentTypes); - } - - /** - * Registers a plugin that implements a method based on the bytecode of a substitute method. - * - * @param substituteDeclaringClass the class declaring the substitute method - * @param name the name of both the original method - * @param substituteName the name of the substitute method - * @param argumentTypes the argument types of the method. Element 0 of this array must be - * the {@link Class} value for {@link InvocationPlugin.Receiver} iff the method - * is non-static. Upon returning, element 0 will have been rewritten to - * {@code declaringClass} - */ - public void registerMethodSubstitution(Class<?> substituteDeclaringClass, String name, String substituteName, Class<?>... argumentTypes) { - MethodSubstitutionPlugin plugin = new MethodSubstitutionPlugin(substituteDeclaringClass, substituteName, argumentTypes); - plugins.register(plugin, false, allowOverwrite, declaringClass, name, argumentTypes); - } - } - - /** - * Key for a method. - */ - static class MethodKey { - final boolean isStatic; - - /** - * This method is optional. This is used for new API methods not present in previous JDK - * versions. - */ - final boolean isOptional; - - final Class<?> declaringClass; - final String name; - final Class<?>[] argumentTypes; - final InvocationPlugin value; - - MethodKey(InvocationPlugin data, boolean isStatic, boolean isOptional, Class<?> declaringClass, String name, Class<?>... argumentTypes) { - assert isStatic || argumentTypes[0] == declaringClass; - this.value = data; - this.isStatic = isStatic; - this.isOptional = isOptional; - this.declaringClass = declaringClass; - this.name = name; - this.argumentTypes = argumentTypes; - assert isOptional || resolveJava() != null; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof MethodKey) { - MethodKey that = (MethodKey) obj; - boolean res = this.name.equals(that.name) && this.declaringClass.equals(that.declaringClass) && Arrays.equals(this.argumentTypes, that.argumentTypes); - assert !res || this.isStatic == that.isStatic; - return res; - } - return false; - } - - public int getDeclaredParameterCount() { - return isStatic ? argumentTypes.length : argumentTypes.length - 1; - } - - @Override - public int hashCode() { - // Replay compilation mandates use of stable hash codes - return declaringClass.getName().hashCode() ^ name.hashCode(); - } - - private ResolvedJavaMethod resolve(MetaAccessProvider metaAccess) { - Executable method = resolveJava(); - if (method == null) { - return null; - } - return metaAccess.lookupJavaMethod(method); - } - - private Executable resolveJava() { - try { - Executable res; - Class<?>[] parameterTypes = isStatic ? argumentTypes : Arrays.copyOfRange(argumentTypes, 1, argumentTypes.length); - if (name.equals("<init>")) { - res = declaringClass.getDeclaredConstructor(parameterTypes); - } else { - res = declaringClass.getDeclaredMethod(name, parameterTypes); - } - assert Modifier.isStatic(res.getModifiers()) == isStatic; - return res; - } catch (NoSuchMethodException | SecurityException e) { - if (isOptional) { - return null; - } - throw new InternalError(e); - } - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(declaringClass.getName()).append('.').append(name).append('('); - for (Class<?> p : argumentTypes) { - if (sb.charAt(sb.length() - 1) != '(') { - sb.append(", "); - } - sb.append(p.getSimpleName()); - } - return sb.append(')').toString(); - } - } - - private final MetaAccessProvider metaAccess; - - /** - * Initial list of entries. - */ - private final List<MethodKey> registrations = new ArrayList<>(INITIAL_CAPACITY); - - /** - * Entry map that is initialized upon first call to {@link #get(ResolvedJavaMethod)}. - * - * Note: this must be volatile since double-checked locking is used to initialize it - */ - private volatile Map<ResolvedJavaMethod, InvocationPlugin> entries; - - private static final int INITIAL_CAPACITY = 64; - - /** - * Adds an entry to this map for a specified method. - * - * @param value value to be associated with the specified method - * @param isStatic specifies if the method is static - * @param isOptional specifies if the method is optional - * @param declaringClass the class declaring the method - * @param name the name of the method - * @param argumentTypes the argument types of the method. Element 0 of this array must be - * {@code declaringClass} iff the method is non-static. - * @return an object representing the method - */ - MethodKey put(InvocationPlugin value, boolean isStatic, boolean isOptional, boolean allowOverwrite, Class<?> declaringClass, String name, Class<?>... argumentTypes) { - assert isStatic || argumentTypes[0] == declaringClass; - MethodKey methodKey = new MethodKey(value, isStatic, isOptional, declaringClass, name, argumentTypes); - assert entries == null : "registration is closed"; - assert allowOverwrite || !registrations.contains(methodKey) : "a value is already registered for " + methodKey; - registrations.add(methodKey); - return methodKey; - } - - /** - * Determines if a method denoted by a given {@link MethodKey} is in this map. - */ - boolean containsKey(MethodKey key) { - return registrations.contains(key); - } - - InvocationPlugin get(ResolvedJavaMethod method) { - if (entries == null) { - initializeMap(); - } - - return entries.get(method); - } - - /** - * Disallows new registrations of new plugins, and creates the internal tables for method - * lookup. - */ - public void closeRegistration() { - if (entries == null) { - initializeMap(); - } - } - - void initializeMap() { - if (registrations.isEmpty()) { - entries = Collections.emptyMap(); - } else { - Map<ResolvedJavaMethod, InvocationPlugin> newEntries = new HashMap<>(); - for (MethodKey methodKey : registrations) { - ResolvedJavaMethod m = methodKey.resolve(metaAccess); - newEntries.put(m, methodKey.value); - } - entries = newEntries; - } - } - - public int size() { - return registrations.size(); - } - - /** - * The plugins {@linkplain #lookupInvocation(ResolvedJavaMethod) searched} before searching in - * this object. - */ - protected final InvocationPlugins parent; - - private InvocationPlugins(InvocationPlugins parent, MetaAccessProvider metaAccess) { - this.metaAccess = metaAccess; - InvocationPlugins p = parent; - this.parent = p; - } - - /** - * Creates a set of invocation plugins with a non-null {@linkplain #getParent() parent}. - */ - public InvocationPlugins(InvocationPlugins parent) { - this(parent, parent.getMetaAccess()); - } - - public MetaAccessProvider getMetaAccess() { - return metaAccess; - } - - public InvocationPlugins(MetaAccessProvider metaAccess) { - this(null, metaAccess); - } - - private void register(InvocationPlugin plugin, boolean isOptional, boolean allowOverwrite, Class<?> declaringClass, String name, Class<?>... argumentTypes) { - boolean isStatic = argumentTypes.length == 0 || argumentTypes[0] != InvocationPlugin.Receiver.class; - if (!isStatic) { - argumentTypes[0] = declaringClass; - } - MethodKey methodInfo = put(plugin, isStatic, isOptional, allowOverwrite, declaringClass, name, argumentTypes); - assert Checker.check(this, methodInfo, plugin); - } - - /** - * Registers an invocation plugin for a given method. There must be no plugin currently - * registered for {@code method}. - * - * @param argumentTypes the argument types of the method. Element 0 of this array must be the - * {@link Class} value for {@link InvocationPlugin.Receiver} iff the method is - * non-static. Upon returning, element 0 will have been rewritten to - * {@code declaringClass} - */ - public void register(InvocationPlugin plugin, Class<?> declaringClass, String name, Class<?>... argumentTypes) { - register(plugin, false, false, declaringClass, name, argumentTypes); - } - - /** - * Registers an invocation plugin for a given, optional method. There must be no plugin - * currently registered for {@code method}. - * - * @param argumentTypes the argument types of the method. Element 0 of this array must be the - * {@link Class} value for {@link InvocationPlugin.Receiver} iff the method is - * non-static. Upon returning, element 0 will have been rewritten to - * {@code declaringClass} - */ - public void registerOptional(InvocationPlugin plugin, Class<?> declaringClass, String name, Class<?>... argumentTypes) { - register(plugin, true, false, declaringClass, name, argumentTypes); - } - - /** - * Gets the plugin for a given method. - * - * @param method the method to lookup - * @return the plugin associated with {@code method} or {@code null} if none exists - */ - public InvocationPlugin lookupInvocation(ResolvedJavaMethod method) { - if (parent != null) { - InvocationPlugin plugin = parent.lookupInvocation(method); - if (plugin != null) { - return plugin; - } - } - return get(method); - } - - /** - * Gets the invocation plugins {@linkplain #lookupInvocation(ResolvedJavaMethod) searched} - * before searching in this object. - */ - public InvocationPlugins getParent() { - return parent; - } - - @Override - public String toString() { - return registrations.stream().map(MethodKey::toString).collect(Collectors.joining(", ")) + " / parent: " + this.parent; - } - - private static class Checker { - private static final int MAX_ARITY = 5; - /** - * The set of all {@link InvocationPlugin#apply} method signatures. - */ - static final Class<?>[][] SIGS; - - static { - ArrayList<Class<?>[]> sigs = new ArrayList<>(MAX_ARITY); - for (Method method : InvocationPlugin.class.getDeclaredMethods()) { - if (!Modifier.isStatic(method.getModifiers()) && method.getName().equals("apply")) { - Class<?>[] sig = method.getParameterTypes(); - assert sig[0] == GraphBuilderContext.class; - assert sig[1] == ResolvedJavaMethod.class; - assert sig[2] == InvocationPlugin.Receiver.class; - assert Arrays.asList(sig).subList(3, sig.length).stream().allMatch(c -> c == ValueNode.class); - while (sigs.size() < sig.length - 2) { - sigs.add(null); - } - sigs.set(sig.length - 3, sig); - } - } - assert sigs.indexOf(null) == -1 : format("need to add an apply() method to %s that takes %d %s arguments ", InvocationPlugin.class.getName(), sigs.indexOf(null), - ValueNode.class.getSimpleName()); - SIGS = sigs.toArray(new Class<?>[sigs.size()][]); - } - - public static boolean check(InvocationPlugins plugins, MethodKey method, InvocationPlugin plugin) { - InvocationPlugins p = plugins.parent; - while (p != null) { - assert !p.containsKey(method) : "a plugin is already registered for " + method; - p = p.parent; - } - if (plugin instanceof ForeignCallPlugin) { - return true; - } - if (plugin instanceof MethodSubstitutionPlugin) { - MethodSubstitutionPlugin msplugin = (MethodSubstitutionPlugin) plugin; - msplugin.getJavaSubstitute(); - return true; - } - int arguments = method.getDeclaredParameterCount(); - assert arguments < SIGS.length : format("need to extend %s to support method with %d arguments: %s", InvocationPlugin.class.getSimpleName(), arguments, method); - for (Method m : plugin.getClass().getDeclaredMethods()) { - if (m.getName().equals("apply")) { - Class<?>[] parameterTypes = m.getParameterTypes(); - if (Arrays.equals(SIGS[arguments], parameterTypes)) { - return true; - } - } - } - throw new AssertionError(format("graph builder plugin for %s not found", method)); - } - } - - /** - * Checks a set of nodes added to the graph by an {@link InvocationPlugin}. - * - * @param b the graph builder that applied the plugin - * @param plugin a plugin that was just applied - * @param newNodes the nodes added to the graph by {@code plugin} - * @throws AssertionError if any check fail - */ - public void checkNewNodes(GraphBuilderContext b, InvocationPlugin plugin, NodeIterable<Node> newNodes) { - if (parent != null) { - parent.checkNewNodes(b, plugin, newNodes); - } - } -}
--- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/LoopExplosionPlugin.java Tue Nov 24 17:23:25 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2015, 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.graphbuilderconf; - -import jdk.vm.ci.meta.ResolvedJavaMethod; - -public interface LoopExplosionPlugin extends GraphBuilderPlugin { - boolean shouldExplodeLoops(ResolvedJavaMethod method); - - boolean shouldMergeExplosions(ResolvedJavaMethod method); -}
--- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/MethodSubstitutionPlugin.java Tue Nov 24 17:23:25 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,206 +0,0 @@ -/* - * Copyright (c) 2015, 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.graphbuilderconf; - -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Arrays; -import java.util.stream.Collectors; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import sun.misc.Launcher; - -import com.oracle.graal.nodes.ValueNode; - -/** - * An {@link InvocationPlugin} for a method where the implementation of the method is provided by a - * {@linkplain #getSubstitute(MetaAccessProvider) substitute} method. A substitute method must be - * static even if the substituted method is not. - */ -public final class MethodSubstitutionPlugin implements InvocationPlugin { - - private ResolvedJavaMethod cachedSubstitute; - - /** - * The class in which the substitute method is declared. - */ - private final Class<?> declaringClass; - - /** - * The name of the original and substitute method. - */ - private final String name; - - /** - * The parameter types of the substitute method. - */ - private final Class<?>[] parameters; - - private final boolean originalIsStatic; - - /** - * Creates a method substitution plugin. - * - * @param declaringClass the class in which the substitute method is declared - * @param name the name of the substitute method - * @param parameters the parameter types of the substitute method. If the original method is not - * static, then {@code parameters[0]} must be the {@link Class} value denoting - * {@link InvocationPlugin.Receiver} - */ - public MethodSubstitutionPlugin(Class<?> declaringClass, String name, Class<?>... parameters) { - this.declaringClass = declaringClass; - this.name = name; - this.parameters = parameters; - this.originalIsStatic = parameters.length == 0 || parameters[0] != InvocationPlugin.Receiver.class; - } - - /** - * Creates a method substitution plugin. - * - * @param declaringClass the class in which the substitute method is declared - * @param name the name of the substitute method - * @param parameters the parameter types of the substitute method - */ - public MethodSubstitutionPlugin(boolean originalIsStatic, Class<?> declaringClass, String name, Class<?>... parameters) { - this.declaringClass = declaringClass; - this.name = name; - this.parameters = parameters; - this.originalIsStatic = originalIsStatic; - } - - public boolean inlineOnly() { - // Conservatively assume MacroNodes may be used in a substitution - return true; - } - - /** - * Gets the substitute method, resolving it first if necessary. - */ - public ResolvedJavaMethod getSubstitute(MetaAccessProvider metaAccess) { - if (cachedSubstitute == null) { - cachedSubstitute = metaAccess.lookupJavaMethod(getJavaSubstitute()); - } - return cachedSubstitute; - } - - /** - * Gets the reflection API version of the substitution method. - */ - Method getJavaSubstitute() throws JVMCIError { - Method substituteMethod = lookupSubstitute(); - int modifiers = substituteMethod.getModifiers(); - if (Modifier.isAbstract(modifiers) || Modifier.isNative(modifiers)) { - throw new JVMCIError("Substitution method must not be abstract or native: " + substituteMethod); - } - if (!Modifier.isStatic(modifiers)) { - throw new JVMCIError("Substitution method must be static: " + substituteMethod); - } - return substituteMethod; - } - - /** - * Determines if a given method is the substitute method of this plugin. - */ - private boolean isSubstitute(Method m) { - if (Modifier.isStatic(m.getModifiers()) && m.getName().equals(name)) { - if (parameters.length == m.getParameterCount()) { - Class<?>[] mparams = m.getParameterTypes(); - int start = 0; - if (!originalIsStatic) { - start = 1; - if (!mparams[0].isAssignableFrom(parameters[0])) { - return false; - } - } - for (int i = start; i < mparams.length; i++) { - if (mparams[i] != parameters[i]) { - return false; - } - } - } - return true; - } - return false; - } - - /** - * Gets the substitute method of this plugin. - */ - private Method lookupSubstitute() { - for (Method m : declaringClass.getDeclaredMethods()) { - if (isSubstitute(m)) { - return m; - } - } - throw new JVMCIError("No method found specified by %s", this); - } - - /** - * Resolves a name to a class. - * - * @param className the name of the class to resolve - * @param optional if true, resolution failure returns null - * @return the resolved class or null if resolution fails and {@code optional} is true - */ - public static Class<?> resolveClass(String className, boolean optional) { - try { - // Need to use launcher class path to handle classes - // that are not on the boot class path - ClassLoader cl = Launcher.getLauncher().getClassLoader(); - return Class.forName(className, false, cl); - } catch (ClassNotFoundException e) { - if (optional) { - return null; - } - throw new JVMCIError("Could not resolve type " + className); - } - } - - @Override - public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] argsIncludingReceiver) { - ResolvedJavaMethod subst = getSubstitute(b.getMetaAccess()); - if (receiver != null) { - receiver.get(); - } - b.intrinsify(targetMethod, subst, argsIncludingReceiver); - return true; - } - - public StackTraceElement getApplySourceLocation(MetaAccessProvider metaAccess) { - Class<?> c = getClass(); - for (Method m : c.getDeclaredMethods()) { - if (m.getName().equals("execute")) { - return metaAccess.lookupJavaMethod(m).asStackTraceElement(0); - } - } - throw new JVMCIError("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(", "))); - } -}
--- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/NodePlugin.java Tue Nov 24 17:23:25 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,213 +0,0 @@ -/* - * Copyright (c) 2015, 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.graphbuilderconf; - -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaTypeProfile; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.Signature; - -import com.oracle.graal.nodes.ValueNode; - -public interface NodePlugin extends GraphBuilderPlugin { - /** - * Handle the parsing of a method invocation bytecode to a method that can be bound statically. - * If the method returns true, it must {@link GraphBuilderContext#push push} a value as the - * result of the method invocation using the {@link Signature#getReturnKind return kind} of the - * method. - * - * @param b the context - * @param method the statically bound, invoked method - * @param args the arguments of the method invocation - * @return true if the plugin handles the invocation, false otherwise - */ - default boolean handleInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args) { - return false; - } - - /** - * Handle the parsing of a GETFIELD bytecode. If the method returns true, it must - * {@link GraphBuilderContext#push push} a value using the - * {@link ResolvedJavaField#getJavaKind() kind} of the field. - * - * @param b the context - * @param object the receiver object for the field access - * @param field the accessed field - * @return true if the plugin handles the field access, false otherwise - */ - default boolean handleLoadField(GraphBuilderContext b, ValueNode object, ResolvedJavaField field) { - return false; - } - - /** - * Handle the parsing of a GETSTATIC bytecode. If the method returns true, it must - * {@link GraphBuilderContext#push push} a value using the - * {@link ResolvedJavaField#getJavaKind() kind} of the field. - * - * @param b the context - * @param field the accessed field - * @return true if the plugin handles the field access, false otherwise - */ - default boolean handleLoadStaticField(GraphBuilderContext b, ResolvedJavaField field) { - return false; - } - - /** - * Handle the parsing of a PUTFIELD bytecode. - * - * @param b the context - * @param object the receiver object for the field access - * @param field the accessed field - * @param value the value to be stored into the field - * @return true if the plugin handles the field access, false otherwise - */ - default boolean handleStoreField(GraphBuilderContext b, ValueNode object, ResolvedJavaField field, ValueNode value) { - return false; - } - - /** - * Handle the parsing of a PUTSTATIC bytecode. - * - * @param b the context - * @param field the accessed field - * @param value the value to be stored into the field - * @return true if the plugin handles the field access, false otherwise. - */ - default boolean handleStoreStaticField(GraphBuilderContext b, ResolvedJavaField field, ValueNode value) { - return false; - } - - /** - * Handle the parsing of an array load bytecode. If the method returns true, it must - * {@link GraphBuilderContext#push push} a value using the provided elementKind. - * - * @param b the context - * @param array the accessed array - * @param index the index for the array access - * @param elementKind the element kind of the accessed array - * @return true if the plugin handles the array access, false otherwise. - */ - default boolean handleLoadIndexed(GraphBuilderContext b, ValueNode array, ValueNode index, JavaKind elementKind) { - return false; - } - - /** - * Handle the parsing of an array store bytecode. - * - * @param b the context - * @param array the accessed array - * @param index the index for the array access - * @param elementKind the element kind of the accessed array - * @param value the value to be stored into the array - * @return true if the plugin handles the array access, false otherwise. - */ - default boolean handleStoreIndexed(GraphBuilderContext b, ValueNode array, ValueNode index, JavaKind elementKind, ValueNode value) { - return false; - } - - /** - * Handle the parsing of a CHECKCAST bytecode. If the method returns true, it must - * {@link GraphBuilderContext#push push} a value with the result of the cast using - * {@link JavaKind#Object}. - * - * @param b the context - * @param object the object to be type checked - * @param type the type that the object is checked against - * @param profile the profiling information for the type check, or null if no profiling - * information is available - * @return true if the plugin handles the cast, false otherwise - */ - default boolean handleCheckCast(GraphBuilderContext b, ValueNode object, ResolvedJavaType type, JavaTypeProfile profile) { - return false; - } - - /** - * Handle the parsing of a INSTANCEOF bytecode. If the method returns true, it must - * {@link GraphBuilderContext#push push} a value with the result of the instanceof using - * {@link JavaKind#Int}. - * - * @param b the context - * @param object the object to be type checked - * @param type the type that the object is checked against - * @param profile the profiling information for the type check, or null if no profiling - * information is available - * @return true if the plugin handles the instanceof, false otherwise - */ - default boolean handleInstanceOf(GraphBuilderContext b, ValueNode object, ResolvedJavaType type, JavaTypeProfile profile) { - return false; - } - - /** - * Handle the parsing of a NEW bytecode. If the method returns true, it must - * {@link GraphBuilderContext#push push} a value with the result of the allocation using - * {@link JavaKind#Object}. - * - * @param b the context - * @param type the type to be instantiated - * @return true if the plugin handles the bytecode, false otherwise - */ - default boolean handleNewInstance(GraphBuilderContext b, ResolvedJavaType type) { - return false; - } - - /** - * Handle the parsing of a NEWARRAY and ANEWARRAY bytecode. If the method returns true, it must - * {@link GraphBuilderContext#push push} a value with the result of the allocation using - * {@link JavaKind#Object}. - * - * @param b the context - * @param elementType the element type of the array to be instantiated - * @param length the length of the new array - * @return true if the plugin handles the bytecode, false otherwise - */ - default boolean handleNewArray(GraphBuilderContext b, ResolvedJavaType elementType, ValueNode length) { - return false; - } - - /** - * Handle the parsing of a MULTIANEWARRAY bytecode. If the method returns true, it must - * {@link GraphBuilderContext#push push} a value with the result of the allocation using - * {@link JavaKind#Object}. - * - * @param b the context - * @param type the type of the outermost array to be instantiated - * @param dimensions the array of lengths for all the dimensions to be instantiated - * @return true if the plugin handles the bytecode, false otherwise - */ - default boolean handleNewMultiArray(GraphBuilderContext b, ResolvedJavaType type, ValueNode[] dimensions) { - return false; - } - - /** - * If the plugin {@link GraphBuilderContext#push pushes} a value with a different - * {@link JavaKind} than specified by the bytecode, it must override this method and return - * {@code true}. This disables assertion checking for value kinds. - * - * @param b the context - */ - default boolean canChangeStackKind(GraphBuilderContext b) { - return false; - } -}
--- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/ParameterPlugin.java Tue Nov 24 17:23:25 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2015, 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.graphbuilderconf; - -import com.oracle.graal.compiler.common.type.Stamp; -import com.oracle.graal.nodes.calc.FloatingNode; - -public interface ParameterPlugin extends GraphBuilderPlugin { - FloatingNode interceptParameter(GraphBuilderContext b, int index, Stamp stamp); -}
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Tue Nov 24 15:26:32 2015 +0100 @@ -45,7 +45,6 @@ import com.oracle.graal.api.replacements.SnippetReflectionProvider; import com.oracle.graal.compiler.amd64.AMD64SuitesProvider; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.hotspot.DefaultHotSpotGraalCompilerFactory; import com.oracle.graal.hotspot.HotSpotBackend; import com.oracle.graal.hotspot.HotSpotBackendFactory; @@ -63,6 +62,7 @@ import com.oracle.graal.hotspot.meta.HotSpotStampProvider; import com.oracle.graal.hotspot.meta.HotSpotSuitesProvider; import com.oracle.graal.hotspot.word.HotSpotWordTypes; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.phases.tiers.CompilerConfiguration; import com.oracle.graal.phases.util.Providers; import com.oracle.graal.replacements.amd64.AMD64GraphBuilderPlugins;
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Tue Nov 24 15:26:32 2015 +0100 @@ -42,7 +42,6 @@ import com.oracle.graal.compiler.sparc.SPARCAddressLowering; import com.oracle.graal.compiler.sparc.SPARCSuitesProvider; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.hotspot.DefaultHotSpotGraalCompilerFactory; import com.oracle.graal.hotspot.HotSpotBackend; import com.oracle.graal.hotspot.HotSpotBackendFactory; @@ -59,6 +58,7 @@ import com.oracle.graal.hotspot.meta.HotSpotStampProvider; import com.oracle.graal.hotspot.meta.HotSpotSuitesProvider; import com.oracle.graal.hotspot.word.HotSpotWordTypes; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.nodes.spi.LoweringProvider; import com.oracle.graal.phases.tiers.CompilerConfiguration; import com.oracle.graal.phases.util.Providers;
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java Tue Nov 24 15:26:32 2015 +0100 @@ -22,7 +22,7 @@ */ package com.oracle.graal.hotspot.test; -import static com.oracle.graal.graphbuilderconf.IntrinsicContext.CompilationContext.ROOT_COMPILATION; +import static com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext.CompilationContext.ROOT_COMPILATION; import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; import java.io.ByteArrayOutputStream; @@ -44,14 +44,14 @@ import org.junit.Assert; import org.junit.Test; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.IntrinsicContext; import com.oracle.graal.hotspot.meta.HotSpotGraphBuilderPlugins; import com.oracle.graal.hotspot.meta.HotSpotProviders; import com.oracle.graal.java.GraphBuilderPhase; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.phases.OptimisticOptimizations; /**
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompiler.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompiler.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -23,7 +23,7 @@ package com.oracle.graal.hotspot; import static com.oracle.graal.compiler.common.GraalOptions.OptAssumptions; -import static com.oracle.graal.graphbuilderconf.IntrinsicContext.CompilationContext.ROOT_COMPILATION; +import static com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext.CompilationContext.ROOT_COMPILATION; import static jdk.vm.ci.code.CallingConvention.Type.JavaCallee; import static jdk.vm.ci.code.CodeUtil.getCallingConvention; import jdk.vm.ci.code.CallingConvention; @@ -47,9 +47,6 @@ import com.oracle.graal.debug.TTY; import com.oracle.graal.debug.TopLevelDebugConfig; import com.oracle.graal.debug.internal.DebugScope; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.IntrinsicContext; import com.oracle.graal.hotspot.meta.HotSpotProviders; import com.oracle.graal.hotspot.meta.HotSpotSuitesProvider; import com.oracle.graal.hotspot.phases.OnStackReplacementPhase; @@ -58,6 +55,9 @@ import com.oracle.graal.lir.phases.LIRSuites; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.nodes.spi.Replacements; import com.oracle.graal.phases.OptimisticOptimizations; import com.oracle.graal.phases.OptimisticOptimizations.Optimization;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -43,14 +43,6 @@ import com.oracle.graal.api.replacements.SnippetReflectionProvider; import com.oracle.graal.compiler.common.spi.ForeignCallsProvider; -import com.oracle.graal.graphbuilderconf.ForeignCallPlugin; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InvocationPlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugin.Receiver; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; -import com.oracle.graal.graphbuilderconf.InvocationPlugins.Registration; -import com.oracle.graal.graphbuilderconf.MethodSubstitutionPlugin; import com.oracle.graal.hotspot.nodes.ClassCastNode; import com.oracle.graal.hotspot.nodes.CurrentJavaThreadNode; import com.oracle.graal.hotspot.replacements.AESCryptSubstitutions; @@ -68,6 +60,14 @@ import com.oracle.graal.nodes.ConstantNode; import com.oracle.graal.nodes.PiNode; import com.oracle.graal.nodes.ValueNode; +import com.oracle.graal.nodes.graphbuilderconf.ForeignCallPlugin; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; +import com.oracle.graal.nodes.graphbuilderconf.MethodSubstitutionPlugin; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin.Receiver; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.nodes.memory.HeapAccess.BarrierType; import com.oracle.graal.nodes.memory.address.AddressNode; import com.oracle.graal.nodes.memory.address.OffsetAddressNode;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInvocationPlugins.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInvocationPlugins.java Tue Nov 24 15:26:32 2015 +0100 @@ -30,12 +30,12 @@ import com.oracle.graal.compiler.common.GraalOptions; import com.oracle.graal.graph.Node; import com.oracle.graal.graph.iterators.NodeIterable; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InvocationPlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; import com.oracle.graal.hotspot.phases.AheadOfTimeVerificationPhase; import com.oracle.graal.nodes.ConstantNode; import com.oracle.graal.nodes.FrameState; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; import com.oracle.graal.nodes.type.StampTool; import com.oracle.graal.replacements.nodes.MacroNode;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNodePlugin.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNodePlugin.java Tue Nov 24 15:26:32 2015 +0100 @@ -34,13 +34,13 @@ import com.oracle.graal.api.replacements.Fold; import com.oracle.graal.compiler.common.type.Stamp; import com.oracle.graal.graph.Node.NodeIntrinsic; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InlineInvokePlugin; -import com.oracle.graal.graphbuilderconf.NodePlugin; -import com.oracle.graal.graphbuilderconf.ParameterPlugin; import com.oracle.graal.nodes.ConstantNode; import com.oracle.graal.nodes.ValueNode; import com.oracle.graal.nodes.calc.FloatingNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InlineInvokePlugin; +import com.oracle.graal.nodes.graphbuilderconf.NodePlugin; +import com.oracle.graal.nodes.graphbuilderconf.ParameterPlugin; import com.oracle.graal.replacements.NodeIntrinsificationPlugin; import com.oracle.graal.replacements.WordOperationPlugin; import com.oracle.graal.word.Word;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProviders.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProviders.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 @@ -27,8 +27,8 @@ import jdk.vm.ci.meta.MetaAccessProvider; import com.oracle.graal.api.replacements.SnippetReflectionProvider; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.hotspot.word.HotSpotWordTypes; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.nodes.spi.LoweringProvider; import com.oracle.graal.nodes.spi.Replacements; import com.oracle.graal.phases.tiers.SuitesProvider;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java Tue Nov 24 15:26:32 2015 +0100 @@ -28,8 +28,6 @@ import jdk.vm.ci.options.DerivedOptionValue; import jdk.vm.ci.options.DerivedOptionValue.OptionSupplier; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.DebugInfoMode; import com.oracle.graal.hotspot.HotSpotBackend; import com.oracle.graal.hotspot.HotSpotGraalRuntimeProvider; import com.oracle.graal.hotspot.HotSpotInstructionProfiling; @@ -44,6 +42,8 @@ import com.oracle.graal.nodes.SimplifyingGraphDecoder; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.DebugInfoMode; import com.oracle.graal.phases.BasePhase; import com.oracle.graal.phases.PhaseSuite; import com.oracle.graal.phases.common.AddressLoweringPhase;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotWordOperationPlugin.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotWordOperationPlugin.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -35,7 +35,6 @@ import com.oracle.graal.api.replacements.SnippetReflectionProvider; import com.oracle.graal.compiler.common.type.Stamp; import com.oracle.graal.compiler.common.type.StampFactory; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; import com.oracle.graal.hotspot.nodes.LoadIndexedPointerNode; import com.oracle.graal.hotspot.nodes.type.KlassPointerStamp; import com.oracle.graal.hotspot.nodes.type.MetaspacePointerStamp; @@ -48,6 +47,7 @@ import com.oracle.graal.nodes.calc.ConditionalNode; import com.oracle.graal.nodes.calc.IsNullNode; import com.oracle.graal.nodes.calc.PointerEqualsNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; import com.oracle.graal.nodes.java.LoadIndexedNode; import com.oracle.graal.nodes.memory.HeapAccess.BarrierType; import com.oracle.graal.nodes.memory.ReadNode;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, 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 @@ -22,7 +22,7 @@ */ package com.oracle.graal.hotspot.stubs; -import static com.oracle.graal.graphbuilderconf.IntrinsicContext.CompilationContext.INLINE_AFTER_PARSING; +import static com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext.CompilationContext.INLINE_AFTER_PARSING; import java.lang.reflect.Method; @@ -34,15 +34,15 @@ import com.oracle.graal.debug.Debug; import com.oracle.graal.debug.Debug.Scope; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.IntrinsicContext; import com.oracle.graal.hotspot.HotSpotForeignCallLinkage; import com.oracle.graal.hotspot.meta.HotSpotProviders; import com.oracle.graal.java.GraphBuilderPhase; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; import com.oracle.graal.nodes.StructuredGraph.GuardsStage; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.nodes.spi.LoweringTool; import com.oracle.graal.phases.OptimisticOptimizations; import com.oracle.graal.phases.common.CanonicalizerPhase;
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java Tue Nov 24 15:26:32 2015 +0100 @@ -231,12 +231,12 @@ import static com.oracle.graal.compiler.common.GraalOptions.ResolveClassBeforeStaticInvoke; import static com.oracle.graal.compiler.common.GraalOptions.StressInvokeWithExceptionNode; import static com.oracle.graal.compiler.common.type.StampFactory.objectNonNull; -import static com.oracle.graal.graphbuilderconf.IntrinsicContext.CompilationContext.INLINE_DURING_PARSING; import static com.oracle.graal.java.BytecodeParserOptions.DumpDuringGraphBuilding; import static com.oracle.graal.java.BytecodeParserOptions.FailedLoopExplosionIsFatal; import static com.oracle.graal.java.BytecodeParserOptions.MaximumLoopExplosionCount; import static com.oracle.graal.java.BytecodeParserOptions.TraceInlineDuringParsing; import static com.oracle.graal.java.BytecodeParserOptions.TraceParserPlugins; +import static com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext.CompilationContext.INLINE_DURING_PARSING; import static com.oracle.graal.nodes.type.StampTool.isPointerNonNull; import static java.lang.String.format; import static jdk.vm.ci.common.JVMCIError.guarantee; @@ -312,15 +312,6 @@ import com.oracle.graal.graph.Node.ValueNumberable; import com.oracle.graal.graph.NodeBitMap; import com.oracle.graal.graph.iterators.NodeIterable; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InlineInvokePlugin; -import com.oracle.graal.graphbuilderconf.InlineInvokePlugin.InlineInfo; -import com.oracle.graal.graphbuilderconf.IntrinsicContext; -import com.oracle.graal.graphbuilderconf.InvocationPlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugins.InvocationPluginReceiver; -import com.oracle.graal.graphbuilderconf.LoopExplosionPlugin; -import com.oracle.graal.graphbuilderconf.NodePlugin; import com.oracle.graal.java.BciBlockMapping.BciBlock; import com.oracle.graal.java.BciBlockMapping.ExceptionDispatchBlock; import com.oracle.graal.nodeinfo.InputType; @@ -393,6 +384,15 @@ import com.oracle.graal.nodes.extended.GuardedNode; import com.oracle.graal.nodes.extended.GuardingNode; import com.oracle.graal.nodes.extended.IntegerSwitchNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InlineInvokePlugin; +import com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin; +import com.oracle.graal.nodes.graphbuilderconf.LoopExplosionPlugin; +import com.oracle.graal.nodes.graphbuilderconf.NodePlugin; +import com.oracle.graal.nodes.graphbuilderconf.InlineInvokePlugin.InlineInfo; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins.InvocationPluginReceiver; import com.oracle.graal.nodes.java.ArrayLengthNode; import com.oracle.graal.nodes.java.CheckCastNode; import com.oracle.graal.nodes.java.ExceptionObjectNode;
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultSuitesProvider.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultSuitesProvider.java Tue Nov 24 15:26:32 2015 +0100 @@ -25,9 +25,9 @@ import jdk.vm.ci.options.DerivedOptionValue; import jdk.vm.ci.options.DerivedOptionValue.OptionSupplier; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.lir.phases.LIRSuites; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.phases.PhaseSuite; import com.oracle.graal.phases.tiers.CompilerConfiguration; import com.oracle.graal.phases.tiers.HighTierContext;
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/FrameStateBuilder.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/FrameStateBuilder.java Tue Nov 24 15:26:32 2015 +0100 @@ -54,8 +54,6 @@ import com.oracle.graal.compiler.common.type.Stamp; import com.oracle.graal.compiler.common.type.StampFactory; import com.oracle.graal.debug.Debug; -import com.oracle.graal.graphbuilderconf.IntrinsicContext.SideEffectsState; -import com.oracle.graal.graphbuilderconf.ParameterPlugin; import com.oracle.graal.java.BciBlockMapping.BciBlock; import com.oracle.graal.nodeinfo.Verbosity; import com.oracle.graal.nodes.AbstractMergeNode; @@ -71,6 +69,8 @@ import com.oracle.graal.nodes.ValuePhiNode; import com.oracle.graal.nodes.ValueProxyNode; import com.oracle.graal.nodes.calc.FloatingNode; +import com.oracle.graal.nodes.graphbuilderconf.ParameterPlugin; +import com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext.SideEffectsState; import com.oracle.graal.nodes.java.MonitorIdNode; import com.oracle.graal.nodes.util.GraphUtil;
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2015, 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 @@ -26,9 +26,9 @@ import jdk.vm.ci.meta.MetaAccessProvider; import jdk.vm.ci.meta.ResolvedJavaMethod; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.IntrinsicContext; import com.oracle.graal.nodes.StructuredGraph; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext; import com.oracle.graal.nodes.spi.StampProvider; import com.oracle.graal.phases.BasePhase; import com.oracle.graal.phases.OptimisticOptimizations;
--- a/graal/com.oracle.graal.lir.jtt/src/com/oracle/graal/lir/jtt/LIRTest.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.lir.jtt/src/com/oracle/graal/lir/jtt/LIRTest.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -38,14 +38,14 @@ import com.oracle.graal.compiler.common.type.StampFactory; import com.oracle.graal.graph.NodeClass; import com.oracle.graal.graph.NodeInputList; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InvocationPlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; import com.oracle.graal.jtt.JTTTest; import com.oracle.graal.nodeinfo.NodeInfo; import com.oracle.graal.nodes.FixedWithNextNode; import com.oracle.graal.nodes.ValueNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; import com.oracle.graal.nodes.spi.LIRLowerable; import com.oracle.graal.nodes.spi.NodeLIRBuilderTool;
--- a/graal/com.oracle.graal.microbenchmarks/src/com/oracle/graal/microbenchmarks/graal/util/GraalUtil.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.microbenchmarks/src/com/oracle/graal/microbenchmarks/graal/util/GraalUtil.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -29,11 +29,11 @@ import jdk.vm.ci.meta.ResolvedJavaMethod; import com.oracle.graal.graph.Node; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; import com.oracle.graal.java.GraphBuilderPhase; import com.oracle.graal.nodes.StructuredGraph; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.phases.OptimisticOptimizations; import com.oracle.graal.phases.PhaseSuite; import com.oracle.graal.phases.tiers.HighTierContext;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/graphbuilderconf/ForeignCallPlugin.java Tue Nov 24 15:26:32 2015 +0100 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2015, 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.nodes.graphbuilderconf; + +import jdk.vm.ci.meta.ResolvedJavaMethod; + +import com.oracle.graal.compiler.common.spi.ForeignCallDescriptor; +import com.oracle.graal.compiler.common.spi.ForeignCallsProvider; +import com.oracle.graal.nodes.ValueNode; +import com.oracle.graal.nodes.extended.ForeignCallNode; + +/** + * {@link InvocationPlugin} for converting a method call directly to a foreign call. + */ +public final class ForeignCallPlugin implements InvocationPlugin { + private final ForeignCallsProvider foreignCalls; + private final ForeignCallDescriptor descriptor; + + public ForeignCallPlugin(ForeignCallsProvider foreignCalls, ForeignCallDescriptor descriptor) { + this.foreignCalls = foreignCalls; + this.descriptor = descriptor; + } + + public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) { + ForeignCallNode foreignCall = new ForeignCallNode(foreignCalls, descriptor, args); + foreignCall.setBci(b.bci()); + b.addPush(targetMethod.getSignature().getReturnKind(), foreignCall); + return true; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/graphbuilderconf/GraphBuilderConfiguration.java Tue Nov 24 15:26:32 2015 +0100 @@ -0,0 +1,301 @@ +/* + * Copyright (c) 2011, 2015, 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.nodes.graphbuilderconf; + +import java.util.Arrays; + +import jdk.vm.ci.meta.ResolvedJavaType; + +import com.oracle.graal.compiler.common.GraalOptions; +import com.oracle.graal.nodes.FullInfopointNode; +import com.oracle.graal.nodes.SimpleInfopointNode; + +public class GraphBuilderConfiguration { + + public static class Plugins { + private final InvocationPlugins invocationPlugins; + private NodePlugin[] nodePlugins; + private ParameterPlugin[] parameterPlugins; + private InlineInvokePlugin[] inlineInvokePlugins; + private LoopExplosionPlugin loopExplosionPlugin; + + /** + * Creates a copy of a given set of plugins. The {@link InvocationPlugins} in + * {@code copyFrom} become the {@linkplain InvocationPlugins#getParent() default} + * {@linkplain #getInvocationPlugins() invocation plugins} in this object. + */ + public Plugins(Plugins copyFrom) { + this.invocationPlugins = new InvocationPlugins(copyFrom.invocationPlugins); + this.nodePlugins = copyFrom.nodePlugins; + this.parameterPlugins = copyFrom.parameterPlugins; + this.inlineInvokePlugins = copyFrom.inlineInvokePlugins; + this.loopExplosionPlugin = copyFrom.loopExplosionPlugin; + } + + /** + * Creates a new set of plugins. + * + * @param invocationPlugins the {@linkplain #getInvocationPlugins() invocation plugins} in + * this object + */ + public Plugins(InvocationPlugins invocationPlugins) { + this.invocationPlugins = invocationPlugins; + this.nodePlugins = new NodePlugin[0]; + this.parameterPlugins = new ParameterPlugin[0]; + this.inlineInvokePlugins = new InlineInvokePlugin[0]; + } + + public InvocationPlugins getInvocationPlugins() { + return invocationPlugins; + } + + public NodePlugin[] getNodePlugins() { + return nodePlugins; + } + + public void appendNodePlugin(NodePlugin plugin) { + nodePlugins = Arrays.copyOf(nodePlugins, nodePlugins.length + 1); + nodePlugins[nodePlugins.length - 1] = plugin; + } + + public void prependNodePlugin(NodePlugin plugin) { + NodePlugin[] newPlugins = new NodePlugin[nodePlugins.length + 1]; + System.arraycopy(nodePlugins, 0, newPlugins, 1, nodePlugins.length); + newPlugins[0] = plugin; + nodePlugins = newPlugins; + } + + public void clearNodePlugin() { + nodePlugins = new NodePlugin[0]; + } + + public ParameterPlugin[] getParameterPlugins() { + return parameterPlugins; + } + + public void appendParameterPlugin(ParameterPlugin plugin) { + parameterPlugins = Arrays.copyOf(parameterPlugins, parameterPlugins.length + 1); + parameterPlugins[parameterPlugins.length - 1] = plugin; + } + + public void prependParameterPlugin(ParameterPlugin plugin) { + ParameterPlugin[] newPlugins = new ParameterPlugin[parameterPlugins.length + 1]; + System.arraycopy(parameterPlugins, 0, newPlugins, 1, parameterPlugins.length); + newPlugins[0] = plugin; + parameterPlugins = newPlugins; + } + + public void clearParameterPlugin() { + parameterPlugins = new ParameterPlugin[0]; + } + + public InlineInvokePlugin[] getInlineInvokePlugins() { + return inlineInvokePlugins; + } + + public void appendInlineInvokePlugin(InlineInvokePlugin plugin) { + inlineInvokePlugins = Arrays.copyOf(inlineInvokePlugins, inlineInvokePlugins.length + 1); + inlineInvokePlugins[inlineInvokePlugins.length - 1] = plugin; + } + + public void prependInlineInvokePlugin(InlineInvokePlugin plugin) { + InlineInvokePlugin[] newPlugins = new InlineInvokePlugin[inlineInvokePlugins.length + 1]; + System.arraycopy(inlineInvokePlugins, 0, newPlugins, 1, inlineInvokePlugins.length); + newPlugins[0] = plugin; + inlineInvokePlugins = newPlugins; + } + + public void clearInlineInvokePlugins() { + inlineInvokePlugins = new InlineInvokePlugin[0]; + } + + public LoopExplosionPlugin getLoopExplosionPlugin() { + return loopExplosionPlugin; + } + + public void setLoopExplosionPlugin(LoopExplosionPlugin plugin) { + this.loopExplosionPlugin = plugin; + } + } + + private static final ResolvedJavaType[] EMPTY = new ResolvedJavaType[]{}; + + private final boolean eagerResolving; + private final boolean omitAllExceptionEdges; + private final boolean omitAssertions; + private final ResolvedJavaType[] skippedExceptionTypes; + private final DebugInfoMode debugInfoMode; + private final boolean clearNonLiveLocals; + private boolean useProfiling; + private final Plugins plugins; + + public static enum DebugInfoMode { + SafePointsOnly, + /** + * This mode inserts {@link SimpleInfopointNode}s in places where no safepoints would be + * inserted: inlining boundaries, and line number switches. + * <p> + * In this mode the infopoint only have a location (method and bytecode index) and no + * values. + * <p> + * This is useful to have better program counter to bci mapping and has no influence on the + * generated code. However it can increase the amount of metadata and does not allow access + * to accessing values at runtime. + */ + Simple, + /** + * In this mode, {@link FullInfopointNode}s are generated in the same locations as in + * {@link #Simple} mode but the infopoints have access to the runtime values. + * <p> + * This is relevant when code is to be generated for native, machine-code level debugging + * but can have a limit the amount of optimization applied to the code. + */ + Full, + } + + protected GraphBuilderConfiguration(boolean eagerResolving, boolean omitAllExceptionEdges, boolean omitAssertions, DebugInfoMode debugInfoMode, ResolvedJavaType[] skippedExceptionTypes, + boolean clearNonLiveLocals, Plugins plugins) { + this.eagerResolving = eagerResolving; + this.omitAllExceptionEdges = omitAllExceptionEdges; + this.omitAssertions = omitAssertions; + this.debugInfoMode = debugInfoMode; + this.skippedExceptionTypes = skippedExceptionTypes; + this.clearNonLiveLocals = clearNonLiveLocals; + this.useProfiling = true; + this.plugins = plugins; + } + + /** + * Creates a copy of this configuration with all its plugins. The {@link InvocationPlugins} in + * this configuration become the {@linkplain InvocationPlugins#getParent() parent} of the + * {@link InvocationPlugins} in the copy. + */ + public GraphBuilderConfiguration copy() { + Plugins newPlugins = new Plugins(plugins); + GraphBuilderConfiguration result = new GraphBuilderConfiguration(eagerResolving, omitAllExceptionEdges, omitAssertions, debugInfoMode, skippedExceptionTypes, clearNonLiveLocals, newPlugins); + result.useProfiling = useProfiling; + return result; + } + + public boolean getUseProfiling() { + return useProfiling; + } + + public void setUseProfiling(boolean b) { + this.useProfiling = b; + } + + public GraphBuilderConfiguration withEagerResolving(boolean newEagerResolving) { + return new GraphBuilderConfiguration(newEagerResolving, omitAllExceptionEdges, omitAssertions, debugInfoMode, skippedExceptionTypes, clearNonLiveLocals, plugins); + } + + public GraphBuilderConfiguration withSkippedExceptionTypes(ResolvedJavaType[] newSkippedExceptionTypes) { + return new GraphBuilderConfiguration(eagerResolving, omitAllExceptionEdges, omitAssertions, debugInfoMode, newSkippedExceptionTypes, clearNonLiveLocals, plugins); + } + + public GraphBuilderConfiguration withOmitAllExceptionEdges(boolean newOmitAllExceptionEdges) { + return new GraphBuilderConfiguration(eagerResolving, newOmitAllExceptionEdges, omitAssertions, debugInfoMode, skippedExceptionTypes, clearNonLiveLocals, plugins); + } + + public GraphBuilderConfiguration withOmitAssertions(boolean newOmitAssertions) { + return new GraphBuilderConfiguration(eagerResolving, omitAllExceptionEdges, newOmitAssertions, debugInfoMode, skippedExceptionTypes, clearNonLiveLocals, plugins); + } + + public GraphBuilderConfiguration withDebugInfoMode(DebugInfoMode newDebugInfoMode) { + ResolvedJavaType[] newSkippedExceptionTypes = skippedExceptionTypes == EMPTY ? EMPTY : Arrays.copyOf(skippedExceptionTypes, skippedExceptionTypes.length); + return new GraphBuilderConfiguration(eagerResolving, omitAllExceptionEdges, omitAssertions, newDebugInfoMode, newSkippedExceptionTypes, clearNonLiveLocals, plugins); + } + + public GraphBuilderConfiguration withClearNonLiveLocals(boolean newClearNonLiveLocals) { + return new GraphBuilderConfiguration(eagerResolving, omitAllExceptionEdges, omitAssertions, debugInfoMode, skippedExceptionTypes, newClearNonLiveLocals, plugins); + } + + public ResolvedJavaType[] getSkippedExceptionTypes() { + return skippedExceptionTypes; + } + + public boolean eagerResolving() { + return eagerResolving; + } + + public boolean omitAllExceptionEdges() { + return omitAllExceptionEdges; + } + + public boolean omitAssertions() { + return omitAssertions; + } + + public boolean insertNonSafepointDebugInfo() { + return debugInfoMode.ordinal() >= DebugInfoMode.Simple.ordinal(); + } + + public boolean insertFullDebugInfo() { + return debugInfoMode.ordinal() >= DebugInfoMode.Full.ordinal(); + } + + public boolean insertSimpleDebugInfo() { + return debugInfoMode == DebugInfoMode.Simple; + } + + public boolean clearNonLiveLocals() { + return clearNonLiveLocals; + } + + public static GraphBuilderConfiguration getDefault(Plugins plugins) { + return new GraphBuilderConfiguration(false, false, false, DebugInfoMode.SafePointsOnly, EMPTY, GraalOptions.OptClearNonLiveLocals.getValue(), plugins); + } + + public static GraphBuilderConfiguration getInfopointDefault(Plugins plugins) { + return new GraphBuilderConfiguration(true, false, false, DebugInfoMode.Simple, EMPTY, GraalOptions.OptClearNonLiveLocals.getValue(), plugins); + } + + public static GraphBuilderConfiguration getEagerDefault(Plugins plugins) { + return new GraphBuilderConfiguration(true, false, false, DebugInfoMode.SafePointsOnly, EMPTY, GraalOptions.OptClearNonLiveLocals.getValue(), plugins); + } + + public static GraphBuilderConfiguration getInfopointEagerDefault(Plugins plugins) { + return new GraphBuilderConfiguration(true, false, false, DebugInfoMode.Simple, EMPTY, GraalOptions.OptClearNonLiveLocals.getValue(), plugins); + } + + public static GraphBuilderConfiguration getSnippetDefault(Plugins plugins) { + return new GraphBuilderConfiguration(true, true, false, DebugInfoMode.SafePointsOnly, EMPTY, GraalOptions.OptClearNonLiveLocals.getValue(), plugins); + } + + public static GraphBuilderConfiguration getFullDebugDefault(Plugins plugins) { + return new GraphBuilderConfiguration(true, false, false, DebugInfoMode.Full, EMPTY, GraalOptions.OptClearNonLiveLocals.getValue(), plugins); + } + + /** + * Returns {@code true} if it is an error for a class/field/method resolution to fail. The + * default is the same result as returned by {@link #eagerResolving()}. However, it may be + * overridden to allow failure even when {@link #eagerResolving} is {@code true}. + */ + public boolean unresolvedIsError() { + return eagerResolving; + } + + public Plugins getPlugins() { + return plugins; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/graphbuilderconf/GraphBuilderContext.java Tue Nov 24 15:26:32 2015 +0100 @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2015, 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.nodes.graphbuilderconf; + +import static com.oracle.graal.compiler.common.type.StampFactory.objectNonNull; +import static jdk.vm.ci.meta.DeoptimizationAction.InvalidateReprofile; +import static jdk.vm.ci.meta.DeoptimizationReason.NullCheckException; +import jdk.vm.ci.code.BailoutException; +import jdk.vm.ci.meta.Assumptions; +import jdk.vm.ci.meta.ConstantReflectionProvider; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.MetaAccessProvider; +import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.ResolvedJavaType; + +import com.oracle.graal.compiler.common.type.ObjectStamp; +import com.oracle.graal.compiler.common.type.Stamp; +import com.oracle.graal.compiler.common.type.StampFactory; +import com.oracle.graal.nodes.CallTargetNode.InvokeKind; +import com.oracle.graal.nodes.FixedGuardNode; +import com.oracle.graal.nodes.PiNode; +import com.oracle.graal.nodes.StateSplit; +import com.oracle.graal.nodes.StructuredGraph; +import com.oracle.graal.nodes.ValueNode; +import com.oracle.graal.nodes.calc.IsNullNode; +import com.oracle.graal.nodes.spi.StampProvider; +import com.oracle.graal.nodes.type.StampTool; + +/** + * Used by a {@link GraphBuilderPlugin} to interface with an object that parses the bytecode of a + * single {@linkplain #getMethod() method} as part of building a {@linkplain #getGraph() graph} . + */ +public interface GraphBuilderContext { + + /** + * Raw operation for adding a node to the graph when neither {@link #add} nor + * {@link #addPush(JavaKind, ValueNode)} can be used. + * + * @return either the node added or an equivalent node + */ + <T extends ValueNode> T append(T value); + + /** + * Adds the given node to the graph and also adds recursively all referenced inputs. + * + * @param value the node to be added to the graph + * @return either the node added or an equivalent node + */ + <T extends ValueNode> T recursiveAppend(T value); + + /** + * Pushes a given value to the frame state stack using an explicit kind. This should be used + * when {@code value.getJavaKind()} is different from the kind that the bytecode instruction + * currently being parsed pushes to the stack. + * + * @param kind the kind to use when type checking this operation + * @param value the value to push to the stack. The value must already have been + * {@linkplain #append(ValueNode) appended}. + */ + void push(JavaKind kind, ValueNode value); + + /** + * Adds a node to the graph. If the returned node is a {@link StateSplit} with a null + * {@linkplain StateSplit#stateAfter() frame state}, the frame state is initialized. + * + * @param value the value to add to the graph and push to the stack. The + * {@code value.getJavaKind()} kind is used when type checking this operation. + * @return a node equivalent to {@code value} in the graph + */ + default <T extends ValueNode> T add(T value) { + if (value.graph() != null) { + assert !(value instanceof StateSplit) || ((StateSplit) value).stateAfter() != null; + return value; + } + T equivalentValue = append(value); + if (equivalentValue instanceof StateSplit) { + StateSplit stateSplit = (StateSplit) equivalentValue; + if (stateSplit.stateAfter() == null && stateSplit.hasSideEffect()) { + setStateAfter(stateSplit); + } + } + return equivalentValue; + } + + /** + * Adds a node with a non-void kind to the graph, pushes it to the stack. If the returned node + * is a {@link StateSplit} with a null {@linkplain StateSplit#stateAfter() frame state}, the + * frame state is initialized. + * + * @param kind the kind to use when type checking this operation + * @param value the value to add to the graph and push to the stack + * @return a node equivalent to {@code value} in the graph + */ + default <T extends ValueNode> T addPush(JavaKind kind, T value) { + T equivalentValue = value.graph() != null ? value : append(value); + push(kind, equivalentValue); + if (equivalentValue instanceof StateSplit) { + StateSplit stateSplit = (StateSplit) equivalentValue; + if (stateSplit.stateAfter() == null && stateSplit.hasSideEffect()) { + setStateAfter(stateSplit); + } + } + return equivalentValue; + } + + /** + * Handles an invocation that a plugin determines can replace the original invocation (i.e., the + * one for which the plugin was applied). This applies all standard graph builder processing to + * the replaced invocation including applying any relevant plugins. + * + * @param invokeKind the kind of the replacement invocation + * @param targetMethod the target of the replacement invocation + * @param args the arguments to the replacement invocation + * @param forceInlineEverything specifies if all invocations encountered in the scope of + * handling the replaced invoke are to be force inlined + */ + void handleReplacedInvoke(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] args, boolean forceInlineEverything); + + /** + * Intrinsifies an invocation of a given method by inlining the bytecodes of a given + * substitution method. + * + * @param targetMethod the method being intrinsified + * @param substitute the intrinsic implementation + * @param args the arguments with which to inline the invocation + */ + void intrinsify(ResolvedJavaMethod targetMethod, ResolvedJavaMethod substitute, ValueNode[] args); + + StampProvider getStampProvider(); + + MetaAccessProvider getMetaAccess(); + + default Assumptions getAssumptions() { + return getGraph().getAssumptions(); + } + + ConstantReflectionProvider getConstantReflection(); + + /** + * Gets the graph being constructed. + */ + StructuredGraph getGraph(); + + /** + * Creates a snap shot of the current frame state with the BCI of the instruction after the one + * currently being parsed and assigns it to a given {@linkplain StateSplit#hasSideEffect() side + * effect} node. + * + * @param sideEffect a side effect node just appended to the graph + */ + void setStateAfter(StateSplit sideEffect); + + /** + * Gets the parsing context for the method that inlines the method being parsed by this context. + */ + GraphBuilderContext getParent(); + + /** + * Gets the first ancestor parsing context that is not parsing a + * {@linkplain #parsingIntrinsic() intrinsic}. + */ + default GraphBuilderContext getNonIntrinsicAncestor() { + GraphBuilderContext ancestor = getParent(); + while (ancestor != null && ancestor.parsingIntrinsic()) { + ancestor = ancestor.getParent(); + } + return ancestor; + } + + /** + * Gets the method being parsed by this context. + */ + ResolvedJavaMethod getMethod(); + + /** + * Gets the index of the bytecode instruction currently being parsed. + */ + int bci(); + + /** + * Gets the kind of invocation currently being parsed. + */ + InvokeKind getInvokeKind(); + + /** + * Gets the return type of the invocation currently being parsed. + */ + JavaType getInvokeReturnType(); + + default Stamp getInvokeReturnStamp() { + JavaType returnType = getInvokeReturnType(); + if (returnType.getJavaKind() == JavaKind.Object && returnType instanceof ResolvedJavaType) { + return StampFactory.declared((ResolvedJavaType) returnType); + } else { + return StampFactory.forKind(returnType.getJavaKind()); + } + } + + /** + * Gets the inline depth of this context. A return value of 0 implies that this is the context + * for the parse root. + */ + default int getDepth() { + GraphBuilderContext parent = getParent(); + return parent == null ? 0 : 1 + parent.getDepth(); + } + + /** + * Determines if this parsing context is within the bytecode of an intrinsic or a method inlined + * by an intrinsic. + */ + default boolean parsingIntrinsic() { + return getIntrinsic() != null; + } + + /** + * Gets the intrinsic of the current parsing context or {@code null} if not + * {@link #parsingIntrinsic() parsing an intrinsic}. + */ + IntrinsicContext getIntrinsic(); + + BailoutException bailout(String string); + + /** + * Gets a version of a given value that has a {@linkplain StampTool#isPointerNonNull(ValueNode) + * non-null} stamp. + */ + default ValueNode nullCheckedValue(ValueNode value) { + if (!StampTool.isPointerNonNull(value.stamp())) { + IsNullNode condition = getGraph().unique(new IsNullNode(value)); + ObjectStamp receiverStamp = (ObjectStamp) value.stamp(); + Stamp stamp = receiverStamp.join(objectNonNull()); + FixedGuardNode fixedGuard = append(new FixedGuardNode(condition, NullCheckException, InvalidateReprofile, true)); + PiNode nonNullReceiver = getGraph().unique(new PiNode(value, stamp)); + nonNullReceiver.setGuard(fixedGuard); + // TODO: Propogating the non-null into the frame state would + // remove subsequent null-checks on the same value. However, + // it currently causes an assertion failure when merging states. + // + // frameState.replace(value, nonNullReceiver); + return nonNullReceiver; + } + return value; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/graphbuilderconf/GraphBuilderPlugin.java Tue Nov 24 15:26:32 2015 +0100 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015, 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.nodes.graphbuilderconf; + +/** + * Marker interface for graph builder plugins. + */ +public interface GraphBuilderPlugin { +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/graphbuilderconf/InlineInvokePlugin.java Tue Nov 24 15:26:32 2015 +0100 @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2015, 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.nodes.graphbuilderconf; + +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.ResolvedJavaMethod; + +import com.oracle.graal.nodes.Invoke; +import com.oracle.graal.nodes.ValueNode; + +/** + * Plugin for specifying what is inlined during graph parsing. This plugin is also notified + * {@link #notifyBeforeInline before} and {@link #notifyAfterInline} the inlining, as well as of + * {@link #notifyNotInlined non-inlined} invocations (i.e., those for which an {@link Invoke} node + * is created). + */ +public interface InlineInvokePlugin extends GraphBuilderPlugin { + + /** + * Result of a {@link #shouldInlineInvoke inlining decision}. + */ + public static class InlineInfo { + + /** + * Denotes a call site that must not be inlined and should be implemented by a node that + * does not speculate on the call not raising an exception. + */ + public static final InlineInfo DO_NOT_INLINE_WITH_EXCEPTION = new InlineInfo(null, false); + + /** + * Denotes a call site must not be inlined and can be implemented by a node that speculates + * the call will not throw an exception. + */ + public static final InlineInfo DO_NOT_INLINE_NO_EXCEPTION = new InlineInfo(null, false); + + private final ResolvedJavaMethod methodToInline; + private final boolean isIntrinsic; + + public InlineInfo(ResolvedJavaMethod methodToInline, boolean isIntrinsic) { + this.methodToInline = methodToInline; + this.isIntrinsic = isIntrinsic; + } + + /** + * Returns the method to be inlined, or {@code null} if the call site must not be inlined. + */ + public ResolvedJavaMethod getMethodToInline() { + return methodToInline; + } + + /** + * Specifies if {@link #methodToInline} is an intrinsic for the original method (i.e., the + * {@code method} passed to {@link InlineInvokePlugin#shouldInlineInvoke}). + */ + public boolean isIntrinsic() { + return isIntrinsic; + } + } + + /** + * Determines whether a call to a given method is to be inlined. The return value is a + * tri-state: + * <p> + * Non-null return value with a non-null {@link InlineInfo#getMethodToInline method}: That + * {@link InlineInfo#getMethodToInline method} is inlined. Note that it can be a different + * method than the one specified here as the parameter, which allows method substitutions. + * <p> + * Non-null return value with a null {@link InlineInfo#getMethodToInline method}, e.g., + * {@link InlineInfo#DO_NOT_INLINE_WITH_EXCEPTION}: The method is not inlined, and other plugins + * with a lower priority cannot overwrite this decision. + * <p> + * Null return value: This plugin made no decision, other plugins with a lower priority are + * asked. + * + * @param b the context + * @param method the target method of an invoke + * @param args the arguments to the invoke + * @param returnType the return type derived from {@code method}'s signature + */ + default InlineInfo shouldInlineInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args, JavaType returnType) { + return null; + } + + /** + * Notification that a method is about to be inlined. + * + * @param methodToInline the inlined method + */ + default void notifyBeforeInline(ResolvedJavaMethod methodToInline) { + } + + /** + * Notification that a method was inlined. + * + * @param methodToInline the inlined method + */ + default void notifyAfterInline(ResolvedJavaMethod methodToInline) { + } + + /** + * Notifies this plugin of the {@link Invoke} node created for a method that was not inlined per + * {@link #shouldInlineInvoke}. + * + * @param b the context + * @param method the method that was not inlined + * @param invoke the invoke node created for the call to {@code method} + */ + default void notifyNotInlined(GraphBuilderContext b, ResolvedJavaMethod method, Invoke invoke) { + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/graphbuilderconf/IntrinsicContext.java Tue Nov 24 15:26:32 2015 +0100 @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2015, 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.nodes.graphbuilderconf; + +import static com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext.CompilationContext.INLINE_AFTER_PARSING; +import static com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext.CompilationContext.ROOT_COMPILATION; +import static jdk.vm.ci.code.BytecodeFrame.AFTER_BCI; +import static jdk.vm.ci.code.BytecodeFrame.BEFORE_BCI; +import static jdk.vm.ci.code.BytecodeFrame.INVALID_FRAMESTATE_BCI; +import jdk.vm.ci.meta.ResolvedJavaMethod; + +import com.oracle.graal.nodes.AbstractMergeNode; +import com.oracle.graal.nodes.FrameState; +import com.oracle.graal.nodes.Invoke; +import com.oracle.graal.nodes.StateSplit; +import com.oracle.graal.nodes.StructuredGraph; + +/** + * An intrinsic is a substitute implementation of a Java method (or a bytecode in the case of + * snippets) that is itself implemented in Java. This interface provides information about the + * intrinsic currently being processed by the graph builder. + * + * When in the scope of an intrinsic, the graph builder does not check the value kinds flowing + * through the JVM state since intrinsics can employ non-Java kinds to represent values such as raw + * machine words and pointers. + */ +public class IntrinsicContext { + + /** + * Gets the method being intrinsified. + */ + final ResolvedJavaMethod method; + + /** + * Gets the method providing the intrinsic implementation. + */ + final ResolvedJavaMethod intrinsic; + + public ResolvedJavaMethod getOriginalMethod() { + return method; + } + + public ResolvedJavaMethod getIntrinsicMethod() { + return intrinsic; + } + + /** + * Determines if a call within the compilation scope of this intrinsic represents a call to the + * {@linkplain #getOriginalMethod() original} method. This denotes the path where a partial + * intrinsification falls back to the original method. + */ + public boolean isCallToOriginal(ResolvedJavaMethod targetMethod) { + return method.equals(targetMethod) || intrinsic.equals(targetMethod); + } + + final CompilationContext compilationContext; + + public IntrinsicContext(ResolvedJavaMethod method, ResolvedJavaMethod intrinsic, CompilationContext compilationContext) { + this.method = method; + this.intrinsic = intrinsic; + this.compilationContext = compilationContext; + assert !isCompilationRoot() || method.hasBytecodes() : "Cannot root compile intrinsic for native or abstract method " + method.format("%H.%n(%p)"); + } + + public boolean isPostParseInlined() { + return compilationContext.equals(INLINE_AFTER_PARSING); + } + + public boolean isCompilationRoot() { + return compilationContext.equals(ROOT_COMPILATION); + } + + /** + * Denotes the compilation context in which an intrinsic is being parsed. + */ + public enum CompilationContext { + /** + * An intrinsic is being processed when parsing an invoke bytecode that calls the + * intrinsified method. + */ + INLINE_DURING_PARSING, + + /** + * An intrinsic is being processed when inlining an {@link Invoke} in an existing graph. + */ + INLINE_AFTER_PARSING, + + /** + * An intrinsic is the root of compilation. + */ + ROOT_COMPILATION + } + + /** + * Models the state of a graph in terms of {@link StateSplit#hasSideEffect() side effects} that + * are control flow predecessors of the current point in a graph. + */ + public interface SideEffectsState { + + /** + * Determines if the current program point is preceded by one or more side effects. + */ + boolean isAfterSideEffect(); + + /** + * Gets the side effects preceding the current program point. + */ + Iterable<StateSplit> sideEffects(); + + /** + * Records a side effect for the current program point. + */ + void addSideEffect(StateSplit sideEffect); + } + + public FrameState createFrameState(StructuredGraph graph, SideEffectsState sideEffects, StateSplit forStateSplit) { + assert forStateSplit != graph.start(); + if (forStateSplit.hasSideEffect()) { + if (sideEffects.isAfterSideEffect()) { + // Only the last side effect on any execution path in a replacement + // can inherit the stateAfter of the replaced node + FrameState invalid = graph.add(new FrameState(INVALID_FRAMESTATE_BCI)); + for (StateSplit lastSideEffect : sideEffects.sideEffects()) { + lastSideEffect.setStateAfter(invalid); + } + } + sideEffects.addSideEffect(forStateSplit); + return graph.add(new FrameState(AFTER_BCI)); + } else { + if (forStateSplit instanceof AbstractMergeNode) { + // Merge nodes always need a frame state + if (sideEffects.isAfterSideEffect()) { + // A merge after one or more side effects + return graph.add(new FrameState(AFTER_BCI)); + } else { + // A merge before any side effects + return graph.add(new FrameState(BEFORE_BCI)); + } + } else { + // Other non-side-effects do not need a state + return null; + } + } + } + + @Override + public String toString() { + return "Intrinsic{original: " + method.format("%H.%n(%p)") + ", intrinsic: " + intrinsic.format("%H.%n(%p)") + ", context: " + compilationContext + "}"; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/graphbuilderconf/InvocationPlugin.java Tue Nov 24 15:26:32 2015 +0100 @@ -0,0 +1,208 @@ +/* + * Copyright (c) 2015, 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.nodes.graphbuilderconf; + +import java.lang.invoke.MethodHandle; +import java.lang.reflect.Method; + +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.meta.MetaAccessProvider; +import jdk.vm.ci.meta.ResolvedJavaMethod; + +import com.oracle.graal.nodes.Invoke; +import com.oracle.graal.nodes.ValueNode; +import com.oracle.graal.nodes.type.StampTool; + +/** + * Plugin for handling a specific method invocation. + */ +public interface InvocationPlugin extends GraphBuilderPlugin { + + /** + * The receiver in a non-static method. The class literal for this interface must be used with + * {@link InvocationPlugins#put(InvocationPlugin, boolean, boolean, boolean, Class, String, Class...)} + * to denote the receiver argument for such a non-static method. + */ + public interface Receiver { + /** + * Gets the receiver value, null checking it first if necessary. + * + * @return the receiver value with a {@linkplain StampTool#isPointerNonNull(ValueNode) + * non-null} stamp + */ + ValueNode get(); + + /** + * Determines if the receiver is constant. + */ + default boolean isConstant() { + return false; + } + } + + /** + * Determines if this plugin is for a method with a polymorphic signature (e.g. + * {@link MethodHandle#invokeExact(Object...)}). + */ + default boolean isSignaturePolymorphic() { + return false; + } + + /** + * Determines if this plugin can only be used when inlining the method is it associated with. + * That is, this plugin cannot be used when the associated method is the compilation root. + */ + 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 + * @param argsIncludingReceiver all arguments to the invocation include the raw receiver in + * position 0 if {@code targetMethod} is not static + * @see #execute + */ + default boolean applyPolymorphic(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode... argsIncludingReceiver) { + return defaultHandler(b, targetMethod, receiver, argsIncludingReceiver); + } + + /** + * @see #execute + */ + default boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver) { + return defaultHandler(b, targetMethod, receiver); + } + + /** + * @see #execute + */ + default boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode arg) { + return defaultHandler(b, targetMethod, receiver, arg); + } + + /** + * @see #execute + */ + default boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode arg1, ValueNode arg2) { + return defaultHandler(b, targetMethod, receiver, arg1, arg2); + } + + /** + * @see #execute + */ + default boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode arg1, ValueNode arg2, ValueNode arg3) { + return defaultHandler(b, targetMethod, receiver, arg1, arg2, arg3); + } + + /** + * @see #execute + */ + default boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode arg1, ValueNode arg2, ValueNode arg3, ValueNode arg4) { + return defaultHandler(b, targetMethod, receiver, arg1, arg2, arg3, arg4); + } + + /** + * @see #execute + */ + default boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode arg1, ValueNode arg2, ValueNode arg3, ValueNode arg4, ValueNode arg5) { + return defaultHandler(b, targetMethod, receiver, arg1, arg2, arg3, arg4, arg5); + } + + /** + * Executes this plugin against a set of invocation arguments. + * + * The default implementation in {@link InvocationPlugin} dispatches to the {@code apply(...)} + * method that matches the number of arguments or to {@link #applyPolymorphic} if {@code plugin} + * is {@linkplain #isSignaturePolymorphic() signature polymorphic}. + * + * @param targetMethod the method for which this plugin is being applied + * @param receiver access to the receiver, {@code null} if {@code targetMethod} is static + * @param argsIncludingReceiver all arguments to the invocation include the receiver in position + * 0 if {@code targetMethod} is not static + * @return {@code true} if this plugin handled the invocation of {@code targetMethod} + * {@code false} if the graph builder should process the invoke further (e.g., by + * inlining it or creating an {@link Invoke} node). A plugin that does not handle an + * invocation must not modify the graph being constructed. + */ + default boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] argsIncludingReceiver) { + if (isSignaturePolymorphic()) { + return applyPolymorphic(b, targetMethod, receiver, argsIncludingReceiver); + } else if (receiver != null) { + assert !targetMethod.isStatic(); + assert argsIncludingReceiver.length > 0; + if (argsIncludingReceiver.length == 1) { + return apply(b, targetMethod, receiver); + } else if (argsIncludingReceiver.length == 2) { + return apply(b, targetMethod, receiver, argsIncludingReceiver[1]); + } else if (argsIncludingReceiver.length == 3) { + return apply(b, targetMethod, receiver, argsIncludingReceiver[1], argsIncludingReceiver[2]); + } else if (argsIncludingReceiver.length == 4) { + return apply(b, targetMethod, receiver, argsIncludingReceiver[1], argsIncludingReceiver[2], argsIncludingReceiver[3]); + } else if (argsIncludingReceiver.length == 5) { + return apply(b, targetMethod, receiver, argsIncludingReceiver[1], argsIncludingReceiver[2], argsIncludingReceiver[3], argsIncludingReceiver[4]); + } else { + return defaultHandler(b, targetMethod, receiver, argsIncludingReceiver); + } + } else { + assert targetMethod.isStatic(); + if (argsIncludingReceiver.length == 0) { + return apply(b, targetMethod, null); + } else if (argsIncludingReceiver.length == 1) { + return apply(b, targetMethod, null, argsIncludingReceiver[0]); + } else if (argsIncludingReceiver.length == 2) { + return apply(b, targetMethod, null, argsIncludingReceiver[0], argsIncludingReceiver[1]); + } else if (argsIncludingReceiver.length == 3) { + return apply(b, targetMethod, null, argsIncludingReceiver[0], argsIncludingReceiver[1], argsIncludingReceiver[2]); + } else if (argsIncludingReceiver.length == 4) { + return apply(b, targetMethod, null, argsIncludingReceiver[0], argsIncludingReceiver[1], argsIncludingReceiver[2], argsIncludingReceiver[3]); + } else if (argsIncludingReceiver.length == 5) { + return apply(b, targetMethod, null, argsIncludingReceiver[0], argsIncludingReceiver[1], argsIncludingReceiver[2], argsIncludingReceiver[3], argsIncludingReceiver[4]); + } else { + return defaultHandler(b, targetMethod, receiver, argsIncludingReceiver); + } + + } + } + + /** + * Handles an invocation when a specific {@code apply} method is not available. + */ + default boolean defaultHandler(@SuppressWarnings("unused") GraphBuilderContext b, ResolvedJavaMethod targetMethod, @SuppressWarnings("unused") InvocationPlugin.Receiver receiver, + ValueNode... args) { + throw new JVMCIError("Invocation plugin for %s does not handle invocations with %d arguments", targetMethod.format("%H.%n(%p)"), args.length); + } + + default StackTraceElement getApplySourceLocation(MetaAccessProvider metaAccess) { + Class<?> c = getClass(); + for (Method m : c.getDeclaredMethods()) { + if (m.getName().equals("apply")) { + return metaAccess.lookupJavaMethod(m).asStackTraceElement(0); + } else if (m.getName().equals("defaultHandler")) { + return metaAccess.lookupJavaMethod(m).asStackTraceElement(0); + } + } + throw new JVMCIError("could not find method named \"apply\" or \"defaultHandler\" in " + c.getName()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/graphbuilderconf/InvocationPlugins.java Tue Nov 24 15:26:32 2015 +0100 @@ -0,0 +1,604 @@ +/* + * Copyright (c) 2015, 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.nodes.graphbuilderconf; + +import static java.lang.String.format; + +import java.lang.reflect.Executable; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.meta.MetaAccessProvider; +import jdk.vm.ci.meta.ResolvedJavaMethod; + +import com.oracle.graal.graph.Node; +import com.oracle.graal.graph.iterators.NodeIterable; +import com.oracle.graal.nodes.ValueNode; + +/** + * Manages a set of {@link InvocationPlugin}s. + */ +public class InvocationPlugins { + + public static class InvocationPluginReceiver implements InvocationPlugin.Receiver { + private final GraphBuilderContext parser; + private ValueNode[] args; + private ValueNode value; + + public InvocationPluginReceiver(GraphBuilderContext parser) { + this.parser = parser; + } + + @Override + public ValueNode get() { + assert args != null : "Cannot get the receiver of a static method"; + if (value == null) { + value = parser.nullCheckedValue(args[0]); + if (value != args[0]) { + args[0] = value; + } + } + return value; + } + + @Override + public boolean isConstant() { + return args[0].isConstant(); + } + + public InvocationPluginReceiver init(ResolvedJavaMethod targetMethod, ValueNode[] newArgs) { + if (!targetMethod.isStatic()) { + this.args = newArgs; + this.value = null; + return this; + } + return null; + } + } + + /** + * Utility for + * {@linkplain InvocationPlugins#register(InvocationPlugin, Class, String, Class...) + * registration} of invocation plugins. + */ + public static class Registration { + + private final InvocationPlugins plugins; + private final Class<?> declaringClass; + private boolean allowOverwrite; + + /** + * Creates an object for registering {@link InvocationPlugin}s for methods declared by a + * given class. + * + * @param plugins where to register the plugins + * @param declaringClass the class declaring the methods for which plugins will be + * registered via this object + */ + public Registration(InvocationPlugins plugins, Class<?> declaringClass) { + this.plugins = plugins; + this.declaringClass = declaringClass; + } + + /** + * Creates an object for registering {@link InvocationPlugin}s for methods declared by a + * given class. + * + * @param plugins where to register the plugins + * @param declaringClassName the name of the class class declaring the methods for which + * plugins will be registered via this object + */ + public Registration(InvocationPlugins plugins, String declaringClassName) { + this.plugins = plugins; + try { + this.declaringClass = Class.forName(declaringClassName); + } catch (ClassNotFoundException ex) { + throw JVMCIError.shouldNotReachHere(ex); + } + } + + /** + * Configures this registration to allow or disallow overwriting of invocation plugins. + */ + public Registration setAllowOverwrite(boolean allowOverwrite) { + this.allowOverwrite = allowOverwrite; + return this; + } + + /** + * Registers a plugin for a method with no arguments. + * + * @param name the name of the method + * @param plugin the plugin to be registered + */ + public void register0(String name, InvocationPlugin plugin) { + plugins.register(plugin, false, allowOverwrite, declaringClass, name); + } + + /** + * Registers a plugin for a method with 1 argument. + * + * @param name the name of the method + * @param plugin the plugin to be registered + */ + public void register1(String name, Class<?> arg, InvocationPlugin plugin) { + plugins.register(plugin, false, allowOverwrite, declaringClass, name, arg); + } + + /** + * Registers a plugin for a method with 2 arguments. + * + * @param name the name of the method + * @param plugin the plugin to be registered + */ + public void register2(String name, Class<?> arg1, Class<?> arg2, InvocationPlugin plugin) { + plugins.register(plugin, false, allowOverwrite, declaringClass, name, arg1, arg2); + } + + /** + * Registers a plugin for a method with 3 arguments. + * + * @param name the name of the method + * @param plugin the plugin to be registered + */ + public void register3(String name, Class<?> arg1, Class<?> arg2, Class<?> arg3, InvocationPlugin plugin) { + plugins.register(plugin, false, allowOverwrite, declaringClass, name, arg1, arg2, arg3); + } + + /** + * Registers a plugin for a method with 4 arguments. + * + * @param name the name of the method + * @param plugin the plugin to be registered + */ + public void register4(String name, Class<?> arg1, Class<?> arg2, Class<?> arg3, Class<?> arg4, InvocationPlugin plugin) { + plugins.register(plugin, false, allowOverwrite, declaringClass, name, arg1, arg2, arg3, arg4); + } + + /** + * Registers a plugin for a method with 5 arguments. + * + * @param name the name of the method + * @param plugin the plugin to be registered + */ + public void register5(String name, Class<?> arg1, Class<?> arg2, Class<?> arg3, Class<?> arg4, Class<?> arg5, InvocationPlugin plugin) { + plugins.register(plugin, false, allowOverwrite, declaringClass, name, arg1, arg2, arg3, arg4, arg5); + } + + /** + * Registers a plugin for an optional method with no arguments. + * + * @param name the name of the method + * @param plugin the plugin to be registered + */ + public void registerOptional0(String name, InvocationPlugin plugin) { + plugins.register(plugin, true, allowOverwrite, declaringClass, name); + } + + /** + * Registers a plugin for an optional method with 1 argument. + * + * @param name the name of the method + * @param plugin the plugin to be registered + */ + public void registerOptional1(String name, Class<?> arg, InvocationPlugin plugin) { + plugins.register(plugin, true, allowOverwrite, declaringClass, name, arg); + } + + /** + * Registers a plugin for an optional method with 2 arguments. + * + * @param name the name of the method + * @param plugin the plugin to be registered + */ + public void registerOptional2(String name, Class<?> arg1, Class<?> arg2, InvocationPlugin plugin) { + plugins.register(plugin, true, allowOverwrite, declaringClass, name, arg1, arg2); + } + + /** + * Registers a plugin for an optional method with 3 arguments. + * + * @param name the name of the method + * @param plugin the plugin to be registered + */ + public void registerOptional3(String name, Class<?> arg1, Class<?> arg2, Class<?> arg3, InvocationPlugin plugin) { + plugins.register(plugin, true, allowOverwrite, declaringClass, name, arg1, arg2, arg3); + } + + /** + * Registers a plugin for an optional method with 4 arguments. + * + * @param name the name of the method + * @param plugin the plugin to be registered + */ + public void registerOptional4(String name, Class<?> arg1, Class<?> arg2, Class<?> arg3, Class<?> arg4, InvocationPlugin plugin) { + plugins.register(plugin, true, allowOverwrite, declaringClass, name, arg1, arg2, arg3, arg4); + } + + /** + * Registers a plugin that implements a method based on the bytecode of a substitute method. + * + * @param substituteDeclaringClass the class declaring the substitute method + * @param name the name of both the original and substitute method + * @param argumentTypes the argument types of the method. Element 0 of this array must be + * the {@link Class} value for {@link InvocationPlugin.Receiver} iff the method + * is non-static. Upon returning, element 0 will have been rewritten to + * {@code declaringClass} + */ + public void registerMethodSubstitution(Class<?> substituteDeclaringClass, String name, Class<?>... argumentTypes) { + registerMethodSubstitution(substituteDeclaringClass, name, name, argumentTypes); + } + + /** + * Registers a plugin that implements a method based on the bytecode of a substitute method. + * + * @param substituteDeclaringClass the class declaring the substitute method + * @param name the name of both the original method + * @param substituteName the name of the substitute method + * @param argumentTypes the argument types of the method. Element 0 of this array must be + * the {@link Class} value for {@link InvocationPlugin.Receiver} iff the method + * is non-static. Upon returning, element 0 will have been rewritten to + * {@code declaringClass} + */ + public void registerMethodSubstitution(Class<?> substituteDeclaringClass, String name, String substituteName, Class<?>... argumentTypes) { + MethodSubstitutionPlugin plugin = new MethodSubstitutionPlugin(substituteDeclaringClass, substituteName, argumentTypes); + plugins.register(plugin, false, allowOverwrite, declaringClass, name, argumentTypes); + } + } + + /** + * Key for a method. + */ + static class MethodKey { + final boolean isStatic; + + /** + * This method is optional. This is used for new API methods not present in previous JDK + * versions. + */ + final boolean isOptional; + + final Class<?> declaringClass; + final String name; + final Class<?>[] argumentTypes; + final InvocationPlugin value; + + MethodKey(InvocationPlugin data, boolean isStatic, boolean isOptional, Class<?> declaringClass, String name, Class<?>... argumentTypes) { + assert isStatic || argumentTypes[0] == declaringClass; + this.value = data; + this.isStatic = isStatic; + this.isOptional = isOptional; + this.declaringClass = declaringClass; + this.name = name; + this.argumentTypes = argumentTypes; + assert isOptional || resolveJava() != null; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof MethodKey) { + MethodKey that = (MethodKey) obj; + boolean res = this.name.equals(that.name) && this.declaringClass.equals(that.declaringClass) && Arrays.equals(this.argumentTypes, that.argumentTypes); + assert !res || this.isStatic == that.isStatic; + return res; + } + return false; + } + + public int getDeclaredParameterCount() { + return isStatic ? argumentTypes.length : argumentTypes.length - 1; + } + + @Override + public int hashCode() { + // Replay compilation mandates use of stable hash codes + return declaringClass.getName().hashCode() ^ name.hashCode(); + } + + private ResolvedJavaMethod resolve(MetaAccessProvider metaAccess) { + Executable method = resolveJava(); + if (method == null) { + return null; + } + return metaAccess.lookupJavaMethod(method); + } + + private Executable resolveJava() { + try { + Executable res; + Class<?>[] parameterTypes = isStatic ? argumentTypes : Arrays.copyOfRange(argumentTypes, 1, argumentTypes.length); + if (name.equals("<init>")) { + res = declaringClass.getDeclaredConstructor(parameterTypes); + } else { + res = declaringClass.getDeclaredMethod(name, parameterTypes); + } + assert Modifier.isStatic(res.getModifiers()) == isStatic; + return res; + } catch (NoSuchMethodException | SecurityException e) { + if (isOptional) { + return null; + } + throw new InternalError(e); + } + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(declaringClass.getName()).append('.').append(name).append('('); + for (Class<?> p : argumentTypes) { + if (sb.charAt(sb.length() - 1) != '(') { + sb.append(", "); + } + sb.append(p.getSimpleName()); + } + return sb.append(')').toString(); + } + } + + private final MetaAccessProvider metaAccess; + + /** + * Initial list of entries. + */ + private final List<MethodKey> registrations = new ArrayList<>(INITIAL_CAPACITY); + + /** + * Entry map that is initialized upon first call to {@link #get(ResolvedJavaMethod)}. + * + * Note: this must be volatile since double-checked locking is used to initialize it + */ + private volatile Map<ResolvedJavaMethod, InvocationPlugin> entries; + + private static final int INITIAL_CAPACITY = 64; + + /** + * Adds an entry to this map for a specified method. + * + * @param value value to be associated with the specified method + * @param isStatic specifies if the method is static + * @param isOptional specifies if the method is optional + * @param declaringClass the class declaring the method + * @param name the name of the method + * @param argumentTypes the argument types of the method. Element 0 of this array must be + * {@code declaringClass} iff the method is non-static. + * @return an object representing the method + */ + MethodKey put(InvocationPlugin value, boolean isStatic, boolean isOptional, boolean allowOverwrite, Class<?> declaringClass, String name, Class<?>... argumentTypes) { + assert isStatic || argumentTypes[0] == declaringClass; + MethodKey methodKey = new MethodKey(value, isStatic, isOptional, declaringClass, name, argumentTypes); + assert entries == null : "registration is closed"; + assert allowOverwrite || !registrations.contains(methodKey) : "a value is already registered for " + methodKey; + registrations.add(methodKey); + return methodKey; + } + + /** + * Determines if a method denoted by a given {@link MethodKey} is in this map. + */ + boolean containsKey(MethodKey key) { + return registrations.contains(key); + } + + InvocationPlugin get(ResolvedJavaMethod method) { + if (entries == null) { + initializeMap(); + } + + return entries.get(method); + } + + /** + * Disallows new registrations of new plugins, and creates the internal tables for method + * lookup. + */ + public void closeRegistration() { + if (entries == null) { + initializeMap(); + } + } + + void initializeMap() { + if (registrations.isEmpty()) { + entries = Collections.emptyMap(); + } else { + Map<ResolvedJavaMethod, InvocationPlugin> newEntries = new HashMap<>(); + for (MethodKey methodKey : registrations) { + ResolvedJavaMethod m = methodKey.resolve(metaAccess); + newEntries.put(m, methodKey.value); + } + entries = newEntries; + } + } + + public int size() { + return registrations.size(); + } + + /** + * The plugins {@linkplain #lookupInvocation(ResolvedJavaMethod) searched} before searching in + * this object. + */ + protected final InvocationPlugins parent; + + private InvocationPlugins(InvocationPlugins parent, MetaAccessProvider metaAccess) { + this.metaAccess = metaAccess; + InvocationPlugins p = parent; + this.parent = p; + } + + /** + * Creates a set of invocation plugins with a non-null {@linkplain #getParent() parent}. + */ + public InvocationPlugins(InvocationPlugins parent) { + this(parent, parent.getMetaAccess()); + } + + public MetaAccessProvider getMetaAccess() { + return metaAccess; + } + + public InvocationPlugins(MetaAccessProvider metaAccess) { + this(null, metaAccess); + } + + private void register(InvocationPlugin plugin, boolean isOptional, boolean allowOverwrite, Class<?> declaringClass, String name, Class<?>... argumentTypes) { + boolean isStatic = argumentTypes.length == 0 || argumentTypes[0] != InvocationPlugin.Receiver.class; + if (!isStatic) { + argumentTypes[0] = declaringClass; + } + MethodKey methodInfo = put(plugin, isStatic, isOptional, allowOverwrite, declaringClass, name, argumentTypes); + assert Checker.check(this, methodInfo, plugin); + } + + /** + * Registers an invocation plugin for a given method. There must be no plugin currently + * registered for {@code method}. + * + * @param argumentTypes the argument types of the method. Element 0 of this array must be the + * {@link Class} value for {@link InvocationPlugin.Receiver} iff the method is + * non-static. Upon returning, element 0 will have been rewritten to + * {@code declaringClass} + */ + public void register(InvocationPlugin plugin, Class<?> declaringClass, String name, Class<?>... argumentTypes) { + register(plugin, false, false, declaringClass, name, argumentTypes); + } + + /** + * Registers an invocation plugin for a given, optional method. There must be no plugin + * currently registered for {@code method}. + * + * @param argumentTypes the argument types of the method. Element 0 of this array must be the + * {@link Class} value for {@link InvocationPlugin.Receiver} iff the method is + * non-static. Upon returning, element 0 will have been rewritten to + * {@code declaringClass} + */ + public void registerOptional(InvocationPlugin plugin, Class<?> declaringClass, String name, Class<?>... argumentTypes) { + register(plugin, true, false, declaringClass, name, argumentTypes); + } + + /** + * Gets the plugin for a given method. + * + * @param method the method to lookup + * @return the plugin associated with {@code method} or {@code null} if none exists + */ + public InvocationPlugin lookupInvocation(ResolvedJavaMethod method) { + if (parent != null) { + InvocationPlugin plugin = parent.lookupInvocation(method); + if (plugin != null) { + return plugin; + } + } + return get(method); + } + + /** + * Gets the invocation plugins {@linkplain #lookupInvocation(ResolvedJavaMethod) searched} + * before searching in this object. + */ + public InvocationPlugins getParent() { + return parent; + } + + @Override + public String toString() { + return registrations.stream().map(MethodKey::toString).collect(Collectors.joining(", ")) + " / parent: " + this.parent; + } + + private static class Checker { + private static final int MAX_ARITY = 5; + /** + * The set of all {@link InvocationPlugin#apply} method signatures. + */ + static final Class<?>[][] SIGS; + + static { + ArrayList<Class<?>[]> sigs = new ArrayList<>(MAX_ARITY); + for (Method method : InvocationPlugin.class.getDeclaredMethods()) { + if (!Modifier.isStatic(method.getModifiers()) && method.getName().equals("apply")) { + Class<?>[] sig = method.getParameterTypes(); + assert sig[0] == GraphBuilderContext.class; + assert sig[1] == ResolvedJavaMethod.class; + assert sig[2] == InvocationPlugin.Receiver.class; + assert Arrays.asList(sig).subList(3, sig.length).stream().allMatch(c -> c == ValueNode.class); + while (sigs.size() < sig.length - 2) { + sigs.add(null); + } + sigs.set(sig.length - 3, sig); + } + } + assert sigs.indexOf(null) == -1 : format("need to add an apply() method to %s that takes %d %s arguments ", InvocationPlugin.class.getName(), sigs.indexOf(null), + ValueNode.class.getSimpleName()); + SIGS = sigs.toArray(new Class<?>[sigs.size()][]); + } + + public static boolean check(InvocationPlugins plugins, MethodKey method, InvocationPlugin plugin) { + InvocationPlugins p = plugins.parent; + while (p != null) { + assert !p.containsKey(method) : "a plugin is already registered for " + method; + p = p.parent; + } + if (plugin instanceof ForeignCallPlugin) { + return true; + } + if (plugin instanceof MethodSubstitutionPlugin) { + MethodSubstitutionPlugin msplugin = (MethodSubstitutionPlugin) plugin; + msplugin.getJavaSubstitute(); + return true; + } + int arguments = method.getDeclaredParameterCount(); + assert arguments < SIGS.length : format("need to extend %s to support method with %d arguments: %s", InvocationPlugin.class.getSimpleName(), arguments, method); + for (Method m : plugin.getClass().getDeclaredMethods()) { + if (m.getName().equals("apply")) { + Class<?>[] parameterTypes = m.getParameterTypes(); + if (Arrays.equals(SIGS[arguments], parameterTypes)) { + return true; + } + } + } + throw new AssertionError(format("graph builder plugin for %s not found", method)); + } + } + + /** + * Checks a set of nodes added to the graph by an {@link InvocationPlugin}. + * + * @param b the graph builder that applied the plugin + * @param plugin a plugin that was just applied + * @param newNodes the nodes added to the graph by {@code plugin} + * @throws AssertionError if any check fail + */ + public void checkNewNodes(GraphBuilderContext b, InvocationPlugin plugin, NodeIterable<Node> newNodes) { + if (parent != null) { + parent.checkNewNodes(b, plugin, newNodes); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/graphbuilderconf/LoopExplosionPlugin.java Tue Nov 24 15:26:32 2015 +0100 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2015, 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.nodes.graphbuilderconf; + +import jdk.vm.ci.meta.ResolvedJavaMethod; + +public interface LoopExplosionPlugin extends GraphBuilderPlugin { + boolean shouldExplodeLoops(ResolvedJavaMethod method); + + boolean shouldMergeExplosions(ResolvedJavaMethod method); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/graphbuilderconf/MethodSubstitutionPlugin.java Tue Nov 24 15:26:32 2015 +0100 @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2015, 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.nodes.graphbuilderconf; + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.Arrays; +import java.util.stream.Collectors; + +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.meta.MetaAccessProvider; +import jdk.vm.ci.meta.ResolvedJavaMethod; +import sun.misc.Launcher; + +import com.oracle.graal.nodes.ValueNode; + +/** + * An {@link InvocationPlugin} for a method where the implementation of the method is provided by a + * {@linkplain #getSubstitute(MetaAccessProvider) substitute} method. A substitute method must be + * static even if the substituted method is not. + */ +public final class MethodSubstitutionPlugin implements InvocationPlugin { + + private ResolvedJavaMethod cachedSubstitute; + + /** + * The class in which the substitute method is declared. + */ + private final Class<?> declaringClass; + + /** + * The name of the original and substitute method. + */ + private final String name; + + /** + * The parameter types of the substitute method. + */ + private final Class<?>[] parameters; + + private final boolean originalIsStatic; + + /** + * Creates a method substitution plugin. + * + * @param declaringClass the class in which the substitute method is declared + * @param name the name of the substitute method + * @param parameters the parameter types of the substitute method. If the original method is not + * static, then {@code parameters[0]} must be the {@link Class} value denoting + * {@link InvocationPlugin.Receiver} + */ + public MethodSubstitutionPlugin(Class<?> declaringClass, String name, Class<?>... parameters) { + this.declaringClass = declaringClass; + this.name = name; + this.parameters = parameters; + this.originalIsStatic = parameters.length == 0 || parameters[0] != InvocationPlugin.Receiver.class; + } + + /** + * Creates a method substitution plugin. + * + * @param declaringClass the class in which the substitute method is declared + * @param name the name of the substitute method + * @param parameters the parameter types of the substitute method + */ + public MethodSubstitutionPlugin(boolean originalIsStatic, Class<?> declaringClass, String name, Class<?>... parameters) { + this.declaringClass = declaringClass; + this.name = name; + this.parameters = parameters; + this.originalIsStatic = originalIsStatic; + } + + public boolean inlineOnly() { + // Conservatively assume MacroNodes may be used in a substitution + return true; + } + + /** + * Gets the substitute method, resolving it first if necessary. + */ + public ResolvedJavaMethod getSubstitute(MetaAccessProvider metaAccess) { + if (cachedSubstitute == null) { + cachedSubstitute = metaAccess.lookupJavaMethod(getJavaSubstitute()); + } + return cachedSubstitute; + } + + /** + * Gets the reflection API version of the substitution method. + */ + Method getJavaSubstitute() throws JVMCIError { + Method substituteMethod = lookupSubstitute(); + int modifiers = substituteMethod.getModifiers(); + if (Modifier.isAbstract(modifiers) || Modifier.isNative(modifiers)) { + throw new JVMCIError("Substitution method must not be abstract or native: " + substituteMethod); + } + if (!Modifier.isStatic(modifiers)) { + throw new JVMCIError("Substitution method must be static: " + substituteMethod); + } + return substituteMethod; + } + + /** + * Determines if a given method is the substitute method of this plugin. + */ + private boolean isSubstitute(Method m) { + if (Modifier.isStatic(m.getModifiers()) && m.getName().equals(name)) { + if (parameters.length == m.getParameterCount()) { + Class<?>[] mparams = m.getParameterTypes(); + int start = 0; + if (!originalIsStatic) { + start = 1; + if (!mparams[0].isAssignableFrom(parameters[0])) { + return false; + } + } + for (int i = start; i < mparams.length; i++) { + if (mparams[i] != parameters[i]) { + return false; + } + } + } + return true; + } + return false; + } + + /** + * Gets the substitute method of this plugin. + */ + private Method lookupSubstitute() { + for (Method m : declaringClass.getDeclaredMethods()) { + if (isSubstitute(m)) { + return m; + } + } + throw new JVMCIError("No method found specified by %s", this); + } + + /** + * Resolves a name to a class. + * + * @param className the name of the class to resolve + * @param optional if true, resolution failure returns null + * @return the resolved class or null if resolution fails and {@code optional} is true + */ + public static Class<?> resolveClass(String className, boolean optional) { + try { + // Need to use launcher class path to handle classes + // that are not on the boot class path + ClassLoader cl = Launcher.getLauncher().getClassLoader(); + return Class.forName(className, false, cl); + } catch (ClassNotFoundException e) { + if (optional) { + return null; + } + throw new JVMCIError("Could not resolve type " + className); + } + } + + @Override + public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] argsIncludingReceiver) { + ResolvedJavaMethod subst = getSubstitute(b.getMetaAccess()); + if (receiver != null) { + receiver.get(); + } + b.intrinsify(targetMethod, subst, argsIncludingReceiver); + return true; + } + + public StackTraceElement getApplySourceLocation(MetaAccessProvider metaAccess) { + Class<?> c = getClass(); + for (Method m : c.getDeclaredMethods()) { + if (m.getName().equals("execute")) { + return metaAccess.lookupJavaMethod(m).asStackTraceElement(0); + } + } + throw new JVMCIError("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(", "))); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/graphbuilderconf/NodePlugin.java Tue Nov 24 15:26:32 2015 +0100 @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2015, 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.nodes.graphbuilderconf; + +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.JavaTypeProfile; +import jdk.vm.ci.meta.ResolvedJavaField; +import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.ResolvedJavaType; +import jdk.vm.ci.meta.Signature; + +import com.oracle.graal.nodes.ValueNode; + +public interface NodePlugin extends GraphBuilderPlugin { + /** + * Handle the parsing of a method invocation bytecode to a method that can be bound statically. + * If the method returns true, it must {@link GraphBuilderContext#push push} a value as the + * result of the method invocation using the {@link Signature#getReturnKind return kind} of the + * method. + * + * @param b the context + * @param method the statically bound, invoked method + * @param args the arguments of the method invocation + * @return true if the plugin handles the invocation, false otherwise + */ + default boolean handleInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args) { + return false; + } + + /** + * Handle the parsing of a GETFIELD bytecode. If the method returns true, it must + * {@link GraphBuilderContext#push push} a value using the + * {@link ResolvedJavaField#getJavaKind() kind} of the field. + * + * @param b the context + * @param object the receiver object for the field access + * @param field the accessed field + * @return true if the plugin handles the field access, false otherwise + */ + default boolean handleLoadField(GraphBuilderContext b, ValueNode object, ResolvedJavaField field) { + return false; + } + + /** + * Handle the parsing of a GETSTATIC bytecode. If the method returns true, it must + * {@link GraphBuilderContext#push push} a value using the + * {@link ResolvedJavaField#getJavaKind() kind} of the field. + * + * @param b the context + * @param field the accessed field + * @return true if the plugin handles the field access, false otherwise + */ + default boolean handleLoadStaticField(GraphBuilderContext b, ResolvedJavaField field) { + return false; + } + + /** + * Handle the parsing of a PUTFIELD bytecode. + * + * @param b the context + * @param object the receiver object for the field access + * @param field the accessed field + * @param value the value to be stored into the field + * @return true if the plugin handles the field access, false otherwise + */ + default boolean handleStoreField(GraphBuilderContext b, ValueNode object, ResolvedJavaField field, ValueNode value) { + return false; + } + + /** + * Handle the parsing of a PUTSTATIC bytecode. + * + * @param b the context + * @param field the accessed field + * @param value the value to be stored into the field + * @return true if the plugin handles the field access, false otherwise. + */ + default boolean handleStoreStaticField(GraphBuilderContext b, ResolvedJavaField field, ValueNode value) { + return false; + } + + /** + * Handle the parsing of an array load bytecode. If the method returns true, it must + * {@link GraphBuilderContext#push push} a value using the provided elementKind. + * + * @param b the context + * @param array the accessed array + * @param index the index for the array access + * @param elementKind the element kind of the accessed array + * @return true if the plugin handles the array access, false otherwise. + */ + default boolean handleLoadIndexed(GraphBuilderContext b, ValueNode array, ValueNode index, JavaKind elementKind) { + return false; + } + + /** + * Handle the parsing of an array store bytecode. + * + * @param b the context + * @param array the accessed array + * @param index the index for the array access + * @param elementKind the element kind of the accessed array + * @param value the value to be stored into the array + * @return true if the plugin handles the array access, false otherwise. + */ + default boolean handleStoreIndexed(GraphBuilderContext b, ValueNode array, ValueNode index, JavaKind elementKind, ValueNode value) { + return false; + } + + /** + * Handle the parsing of a CHECKCAST bytecode. If the method returns true, it must + * {@link GraphBuilderContext#push push} a value with the result of the cast using + * {@link JavaKind#Object}. + * + * @param b the context + * @param object the object to be type checked + * @param type the type that the object is checked against + * @param profile the profiling information for the type check, or null if no profiling + * information is available + * @return true if the plugin handles the cast, false otherwise + */ + default boolean handleCheckCast(GraphBuilderContext b, ValueNode object, ResolvedJavaType type, JavaTypeProfile profile) { + return false; + } + + /** + * Handle the parsing of a INSTANCEOF bytecode. If the method returns true, it must + * {@link GraphBuilderContext#push push} a value with the result of the instanceof using + * {@link JavaKind#Int}. + * + * @param b the context + * @param object the object to be type checked + * @param type the type that the object is checked against + * @param profile the profiling information for the type check, or null if no profiling + * information is available + * @return true if the plugin handles the instanceof, false otherwise + */ + default boolean handleInstanceOf(GraphBuilderContext b, ValueNode object, ResolvedJavaType type, JavaTypeProfile profile) { + return false; + } + + /** + * Handle the parsing of a NEW bytecode. If the method returns true, it must + * {@link GraphBuilderContext#push push} a value with the result of the allocation using + * {@link JavaKind#Object}. + * + * @param b the context + * @param type the type to be instantiated + * @return true if the plugin handles the bytecode, false otherwise + */ + default boolean handleNewInstance(GraphBuilderContext b, ResolvedJavaType type) { + return false; + } + + /** + * Handle the parsing of a NEWARRAY and ANEWARRAY bytecode. If the method returns true, it must + * {@link GraphBuilderContext#push push} a value with the result of the allocation using + * {@link JavaKind#Object}. + * + * @param b the context + * @param elementType the element type of the array to be instantiated + * @param length the length of the new array + * @return true if the plugin handles the bytecode, false otherwise + */ + default boolean handleNewArray(GraphBuilderContext b, ResolvedJavaType elementType, ValueNode length) { + return false; + } + + /** + * Handle the parsing of a MULTIANEWARRAY bytecode. If the method returns true, it must + * {@link GraphBuilderContext#push push} a value with the result of the allocation using + * {@link JavaKind#Object}. + * + * @param b the context + * @param type the type of the outermost array to be instantiated + * @param dimensions the array of lengths for all the dimensions to be instantiated + * @return true if the plugin handles the bytecode, false otherwise + */ + default boolean handleNewMultiArray(GraphBuilderContext b, ResolvedJavaType type, ValueNode[] dimensions) { + return false; + } + + /** + * If the plugin {@link GraphBuilderContext#push pushes} a value with a different + * {@link JavaKind} than specified by the bytecode, it must override this method and return + * {@code true}. This disables assertion checking for value kinds. + * + * @param b the context + */ + default boolean canChangeStackKind(GraphBuilderContext b) { + return false; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/graphbuilderconf/ParameterPlugin.java Tue Nov 24 15:26:32 2015 +0100 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015, 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.nodes.graphbuilderconf; + +import com.oracle.graal.compiler.common.type.Stamp; +import com.oracle.graal.nodes.calc.FloatingNode; + +public interface ParameterPlugin extends GraphBuilderPlugin { + FloatingNode interceptParameter(GraphBuilderContext b, int index, Stamp stamp); +}
--- a/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64GraphBuilderPlugins.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64GraphBuilderPlugins.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -32,14 +32,14 @@ import sun.misc.Unsafe; import com.oracle.graal.compiler.common.spi.ForeignCallsProvider; -import com.oracle.graal.graphbuilderconf.ForeignCallPlugin; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InvocationPlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugin.Receiver; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; -import com.oracle.graal.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.nodes.ValueNode; +import com.oracle.graal.nodes.graphbuilderconf.ForeignCallPlugin; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin.Receiver; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.nodes.java.AtomicReadAndAddNode; import com.oracle.graal.nodes.java.AtomicReadAndWriteNode; import com.oracle.graal.nodes.memory.address.AddressNode;
--- a/graal/com.oracle.graal.replacements.sparc/src/com/oracle/graal/replacements/sparc/SPARCGraphBuilderPlugins.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.replacements.sparc/src/com/oracle/graal/replacements/sparc/SPARCGraphBuilderPlugins.java Tue Nov 24 15:26:32 2015 +0100 @@ -33,13 +33,13 @@ import jdk.vm.ci.meta.ResolvedJavaMethod; import com.oracle.graal.compiler.common.spi.ForeignCallsProvider; -import com.oracle.graal.graphbuilderconf.ForeignCallPlugin; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InvocationPlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; -import com.oracle.graal.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.nodes.ValueNode; +import com.oracle.graal.nodes.graphbuilderconf.ForeignCallPlugin; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.replacements.IntegerSubstitutions; import com.oracle.graal.replacements.LongSubstitutions; import com.oracle.graal.replacements.nodes.BitCountNode;
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/DerivedOopTest.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/DerivedOopTest.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -31,12 +31,12 @@ import com.oracle.graal.api.directives.GraalDirectives; import com.oracle.graal.compiler.test.GraalCompilerTest; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InvocationPlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.ValueNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.replacements.Snippets; import com.oracle.graal.word.Word; import com.oracle.graal.word.nodes.WordCastNode;
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/PEGraphDecoderTest.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/PEGraphDecoderTest.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -32,16 +32,16 @@ import com.oracle.graal.compiler.common.type.StampFactory; import com.oracle.graal.compiler.test.GraalCompilerTest; import com.oracle.graal.debug.Debug; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InlineInvokePlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; -import com.oracle.graal.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.nodes.AbstractBeginNode; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; import com.oracle.graal.nodes.ValueNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InlineInvokePlugin; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.nodes.memory.HeapAccess.BarrierType; import com.oracle.graal.nodes.memory.ReadNode; import com.oracle.graal.nodes.memory.address.AddressNode;
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/PointerTrackingTest.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/PointerTrackingTest.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -31,11 +31,11 @@ import com.oracle.graal.compiler.test.GraalCompilerTest; import com.oracle.graal.debug.Debug; import com.oracle.graal.debug.DebugConfigScope; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InvocationPlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.nodes.ValueNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.replacements.Snippets; import com.oracle.graal.word.Word;
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/CachingPEGraphDecoder.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/CachingPEGraphDecoder.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -22,7 +22,7 @@ */ package com.oracle.graal.replacements; -import static com.oracle.graal.graphbuilderconf.IntrinsicContext.CompilationContext.INLINE_AFTER_PARSING; +import static com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext.CompilationContext.INLINE_AFTER_PARSING; import java.util.HashMap; import java.util.Map; @@ -31,13 +31,13 @@ import jdk.vm.ci.meta.ResolvedJavaMethod; import com.oracle.graal.debug.Debug; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.IntrinsicContext; import com.oracle.graal.java.GraphBuilderPhase; import com.oracle.graal.nodes.EncodedGraph; import com.oracle.graal.nodes.GraphEncoder; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext; import com.oracle.graal.phases.OptimisticOptimizations; import com.oracle.graal.phases.common.CanonicalizerPhase; import com.oracle.graal.phases.tiers.PhaseContext;
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ConstantBindingParameterPlugin.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ConstantBindingParameterPlugin.java Tue Nov 24 15:26:32 2015 +0100 @@ -27,10 +27,10 @@ import com.oracle.graal.api.replacements.SnippetReflectionProvider; import com.oracle.graal.compiler.common.type.Stamp; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.ParameterPlugin; import com.oracle.graal.nodes.ConstantNode; import com.oracle.graal.nodes.calc.FloatingNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.ParameterPlugin; /** * A {@link ParameterPlugin} that binds constant values to some parameters.
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java Tue Nov 24 15:26:32 2015 +0100 @@ -22,7 +22,7 @@ */ package com.oracle.graal.replacements; -import static com.oracle.graal.graphbuilderconf.IntrinsicContext.CompilationContext.INLINE_AFTER_PARSING; +import static com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext.CompilationContext.INLINE_AFTER_PARSING; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -39,9 +39,6 @@ import com.oracle.graal.graph.Graph; import com.oracle.graal.graph.Node; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.IntrinsicContext; import com.oracle.graal.java.FrameStateBuilder; import com.oracle.graal.java.GraphBuilderPhase; import com.oracle.graal.nodes.AbstractBeginNode; @@ -60,6 +57,9 @@ import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; import com.oracle.graal.nodes.ValueNode; import com.oracle.graal.nodes.calc.FloatingNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.nodes.java.MethodCallTargetNode; import com.oracle.graal.nodes.type.StampTool; import com.oracle.graal.phases.OptimisticOptimizations;
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InlineDuringParsingPlugin.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InlineDuringParsingPlugin.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 @@ -27,9 +27,9 @@ import jdk.vm.ci.meta.JavaType; import jdk.vm.ci.meta.ResolvedJavaMethod; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InlineInvokePlugin; import com.oracle.graal.nodes.ValueNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InlineInvokePlugin; public final class InlineDuringParsingPlugin implements InlineInvokePlugin {
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/IntrinsicGraphBuilder.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/IntrinsicGraphBuilder.java Tue Nov 24 15:26:32 2015 +0100 @@ -35,10 +35,6 @@ import com.oracle.graal.compiler.common.type.Stamp; import com.oracle.graal.compiler.common.type.StampFactory; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.IntrinsicContext; -import com.oracle.graal.graphbuilderconf.InvocationPlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugin.Receiver; import com.oracle.graal.nodes.CallTargetNode.InvokeKind; import com.oracle.graal.nodes.FixedNode; import com.oracle.graal.nodes.FixedWithNextNode; @@ -50,6 +46,10 @@ import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; import com.oracle.graal.nodes.ValueNode; import com.oracle.graal.nodes.calc.FloatingNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin.Receiver; import com.oracle.graal.nodes.spi.StampProvider; /**
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MethodHandlePlugin.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MethodHandlePlugin.java Tue Nov 24 15:26:32 2015 +0100 @@ -29,10 +29,10 @@ import jdk.vm.ci.meta.ResolvedJavaMethod; import com.oracle.graal.graph.NodeInputList; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.NodePlugin; import com.oracle.graal.nodes.CallTargetNode; import com.oracle.graal.nodes.CallTargetNode.InvokeKind; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.NodePlugin; import com.oracle.graal.nodes.InvokeNode; import com.oracle.graal.nodes.ValueNode; import com.oracle.graal.replacements.nodes.MethodHandleNode;
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPlugin.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPlugin.java Tue Nov 24 15:26:32 2015 +0100 @@ -43,8 +43,6 @@ import com.oracle.graal.compiler.common.type.StampFactory; import com.oracle.graal.debug.MethodFilter; import com.oracle.graal.graph.Node.NodeIntrinsic; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.NodePlugin; import com.oracle.graal.nodeinfo.InputType; import com.oracle.graal.nodeinfo.StructuralInput; import com.oracle.graal.nodeinfo.StructuralInput.MarkerType; @@ -54,6 +52,8 @@ import com.oracle.graal.nodes.extended.UnsafeCopyNode; import com.oracle.graal.nodes.extended.UnsafeLoadNode; import com.oracle.graal.nodes.extended.UnsafeStoreNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.NodePlugin; import com.oracle.graal.word.WordTypes; /**
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/PEGraphDecoder.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/PEGraphDecoder.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -53,15 +53,6 @@ import com.oracle.graal.graph.Node; import com.oracle.graal.graph.NodeClass; import com.oracle.graal.graph.spi.Canonicalizable; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InlineInvokePlugin; -import com.oracle.graal.graphbuilderconf.InlineInvokePlugin.InlineInfo; -import com.oracle.graal.graphbuilderconf.IntrinsicContext; -import com.oracle.graal.graphbuilderconf.InvocationPlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; -import com.oracle.graal.graphbuilderconf.InvocationPlugins.InvocationPluginReceiver; -import com.oracle.graal.graphbuilderconf.LoopExplosionPlugin; -import com.oracle.graal.graphbuilderconf.ParameterPlugin; import com.oracle.graal.java.GraphBuilderPhase; import com.oracle.graal.nodeinfo.NodeInfo; import com.oracle.graal.nodes.AbstractBeginNode; @@ -87,6 +78,15 @@ import com.oracle.graal.nodes.ValueNode; import com.oracle.graal.nodes.extended.ForeignCallNode; import com.oracle.graal.nodes.extended.IntegerSwitchNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InlineInvokePlugin; +import com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; +import com.oracle.graal.nodes.graphbuilderconf.LoopExplosionPlugin; +import com.oracle.graal.nodes.graphbuilderconf.ParameterPlugin; +import com.oracle.graal.nodes.graphbuilderconf.InlineInvokePlugin.InlineInfo; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins.InvocationPluginReceiver; import com.oracle.graal.nodes.java.MethodCallTargetNode; import com.oracle.graal.nodes.java.MonitorIdNode; import com.oracle.graal.nodes.spi.StampProvider;
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Tue Nov 24 15:26:32 2015 +0100 @@ -24,9 +24,9 @@ import static com.oracle.graal.compiler.common.GraalOptions.DeoptALot; import static com.oracle.graal.compiler.common.GraalOptions.OptCanonicalizer; -import static com.oracle.graal.graphbuilderconf.IntrinsicContext.CompilationContext.INLINE_AFTER_PARSING; import static com.oracle.graal.java.BytecodeParserOptions.InlineDuringParsing; import static com.oracle.graal.java.BytecodeParserOptions.InlineIntrinsicsDuringParsing; +import static com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext.CompilationContext.INLINE_AFTER_PARSING; import static com.oracle.graal.phases.common.DeadCodeEliminationPhase.Optionality.Required; import static java.lang.String.format; import static jdk.vm.ci.meta.MetaUtil.toInternalName; @@ -73,13 +73,6 @@ import com.oracle.graal.debug.DebugTimer; import com.oracle.graal.graph.Node; import com.oracle.graal.graph.Node.NodeIntrinsic; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InlineInvokePlugin; -import com.oracle.graal.graphbuilderconf.IntrinsicContext; -import com.oracle.graal.graphbuilderconf.InvocationPlugin; -import com.oracle.graal.graphbuilderconf.MethodSubstitutionPlugin; import com.oracle.graal.java.GraphBuilderPhase; import com.oracle.graal.java.GraphBuilderPhase.Instance; import com.oracle.graal.nodes.CallTargetNode; @@ -88,6 +81,13 @@ import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; import com.oracle.graal.nodes.ValueNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InlineInvokePlugin; +import com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin; +import com.oracle.graal.nodes.graphbuilderconf.MethodSubstitutionPlugin; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.nodes.java.MethodCallTargetNode; import com.oracle.graal.nodes.spi.Replacements; import com.oracle.graal.nodes.spi.StampProvider;
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java Tue Nov 24 15:26:32 2015 +0100 @@ -41,12 +41,6 @@ import com.oracle.graal.graph.Edges; import com.oracle.graal.graph.Node; import com.oracle.graal.graph.NodeList; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InvocationPlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugin.Receiver; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; -import com.oracle.graal.graphbuilderconf.InvocationPlugins.Registration; -import com.oracle.graal.graphbuilderconf.MethodSubstitutionPlugin; import com.oracle.graal.nodes.ConstantNode; import com.oracle.graal.nodes.DeoptimizeNode; import com.oracle.graal.nodes.FixedGuardNode; @@ -78,6 +72,12 @@ import com.oracle.graal.nodes.extended.UnboxNode; import com.oracle.graal.nodes.extended.UnsafeLoadNode; import com.oracle.graal.nodes.extended.UnsafeStoreNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; +import com.oracle.graal.nodes.graphbuilderconf.MethodSubstitutionPlugin; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin.Receiver; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.nodes.java.ClassIsAssignableFromNode; import com.oracle.graal.nodes.java.CompareAndSwapNode; import com.oracle.graal.nodes.java.DynamicNewArrayNode;
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StringSubstitutions.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StringSubstitutions.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 @@ -23,7 +23,7 @@ package com.oracle.graal.replacements; import com.oracle.graal.compiler.common.SuppressFBWarnings; -import com.oracle.graal.graphbuilderconf.InvocationPlugin; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin; import com.oracle.graal.nodes.java.LoadFieldNode; import com.oracle.graal.replacements.nodes.ArrayEqualsNode;
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/WordOperationPlugin.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/WordOperationPlugin.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -39,10 +39,6 @@ import com.oracle.graal.api.replacements.SnippetReflectionProvider; import com.oracle.graal.compiler.common.calc.Condition; import com.oracle.graal.compiler.common.type.Stamp; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InlineInvokePlugin; -import com.oracle.graal.graphbuilderconf.NodePlugin; -import com.oracle.graal.graphbuilderconf.ParameterPlugin; import com.oracle.graal.nodes.ConstantNode; import com.oracle.graal.nodes.Invoke; import com.oracle.graal.nodes.ParameterNode; @@ -59,6 +55,10 @@ import com.oracle.graal.nodes.calc.ZeroExtendNode; import com.oracle.graal.nodes.extended.JavaReadNode; import com.oracle.graal.nodes.extended.JavaWriteNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InlineInvokePlugin; +import com.oracle.graal.nodes.graphbuilderconf.NodePlugin; +import com.oracle.graal.nodes.graphbuilderconf.ParameterPlugin; import com.oracle.graal.nodes.java.LoadFieldNode; import com.oracle.graal.nodes.java.LoadIndexedNode; import com.oracle.graal.nodes.java.StoreIndexedNode;
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Tue Nov 24 15:26:32 2015 +0100 @@ -64,9 +64,6 @@ import com.oracle.graal.debug.DebugEnvironment; import com.oracle.graal.debug.GraalDebugConfig; import com.oracle.graal.debug.TTY; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; import com.oracle.graal.hotspot.HotSpotBackend; import com.oracle.graal.hotspot.meta.HotSpotProviders; import com.oracle.graal.java.GraphBuilderPhase; @@ -74,6 +71,9 @@ import com.oracle.graal.lir.phases.LIRSuites; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.phases.BasePhase; import com.oracle.graal.phases.OptimisticOptimizations; import com.oracle.graal.phases.PhaseSuite;
--- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/ConditionAnchoringTest.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/ConditionAnchoringTest.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -36,10 +36,6 @@ import com.oracle.graal.compiler.test.GraalCompilerTest; import com.oracle.graal.graph.iterators.NodeIterable; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InlineInvokePlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.nodes.BeginNode; import com.oracle.graal.nodes.ConditionAnchorNode; import com.oracle.graal.nodes.IfNode; @@ -47,6 +43,10 @@ import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; import com.oracle.graal.nodes.ValueNode; import com.oracle.graal.nodes.extended.UnsafeLoadNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InlineInvokePlugin; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.nodes.memory.FloatingReadNode; import com.oracle.graal.nodes.memory.ReadNode; import com.oracle.graal.nodes.spi.LoweringTool.StandardLoweringStage;
--- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/ExactMathTest.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/ExactMathTest.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 @@ -25,7 +25,7 @@ import org.junit.Test; import com.oracle.graal.compiler.test.GraalCompilerTest; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; import com.oracle.graal.truffle.substitutions.TruffleGraphBuilderPlugins; import com.oracle.truffle.api.ExactMath;
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/DefaultTruffleCompiler.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/DefaultTruffleCompiler.java Tue Nov 24 15:26:32 2015 +0100 @@ -26,9 +26,9 @@ import com.oracle.graal.api.replacements.SnippetReflectionProvider; import com.oracle.graal.compiler.target.Backend; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.java.GraphBuilderPhase; import com.oracle.graal.lir.phases.LIRSuites; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.phases.BasePhase; import com.oracle.graal.phases.PhaseSuite; import com.oracle.graal.phases.tiers.HighTierContext;
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Tue Nov 24 15:26:32 2015 +0100 @@ -50,13 +50,6 @@ import com.oracle.graal.debug.Debug; import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.debug.Indent; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InlineInvokePlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; -import com.oracle.graal.graphbuilderconf.LoopExplosionPlugin; -import com.oracle.graal.graphbuilderconf.ParameterPlugin; import com.oracle.graal.java.ComputeLoopFrequenciesClosure; import com.oracle.graal.java.GraphBuilderPhase; import com.oracle.graal.nodes.ConstantNode; @@ -64,6 +57,13 @@ import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; import com.oracle.graal.nodes.ValueNode; import com.oracle.graal.nodes.calc.FloatingNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InlineInvokePlugin; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; +import com.oracle.graal.nodes.graphbuilderconf.LoopExplosionPlugin; +import com.oracle.graal.nodes.graphbuilderconf.ParameterPlugin; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.nodes.java.CheckCastNode; import com.oracle.graal.nodes.java.InstanceOfNode; import com.oracle.graal.nodes.java.MethodCallTargetNode;
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompiler.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompiler.java Tue Nov 24 15:26:32 2015 +0100 @@ -50,12 +50,12 @@ import com.oracle.graal.debug.DebugEnvironment; import com.oracle.graal.debug.DebugMemUseTracker; import com.oracle.graal.debug.DebugTimer; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration; -import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.lir.asm.CompilationResultBuilderFactory; import com.oracle.graal.lir.phases.LIRSuites; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.phases.OptimisticOptimizations; import com.oracle.graal.phases.PhaseSuite; import com.oracle.graal.phases.tiers.HighTierContext;
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/debug/HistogramInlineInvokePlugin.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/debug/HistogramInlineInvokePlugin.java Tue Nov 24 15:26:32 2015 +0100 @@ -31,11 +31,11 @@ import jdk.vm.ci.meta.ResolvedJavaMethod; import com.oracle.graal.graph.Node; -import com.oracle.graal.graphbuilderconf.InlineInvokePlugin; import com.oracle.graal.nodes.BeginNode; import com.oracle.graal.nodes.DeoptimizeNode; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.VirtualState; +import com.oracle.graal.nodes.graphbuilderconf.InlineInvokePlugin; import com.oracle.graal.nodes.java.MethodCallTargetNode; import com.oracle.graal.nodes.virtual.VirtualObjectNode; import com.oracle.graal.truffle.OptimizedCallTarget;
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleGraphBuilderPlugins.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleGraphBuilderPlugins.java Tue Nov 24 15:26:32 2015 +0100 @@ -43,11 +43,6 @@ import com.oracle.graal.compiler.common.type.StampFactory; import com.oracle.graal.debug.Debug; import com.oracle.graal.graph.Node; -import com.oracle.graal.graphbuilderconf.GraphBuilderContext; -import com.oracle.graal.graphbuilderconf.InvocationPlugin; -import com.oracle.graal.graphbuilderconf.InvocationPlugin.Receiver; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; -import com.oracle.graal.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.nodes.CallTargetNode; import com.oracle.graal.nodes.CallTargetNode.InvokeKind; import com.oracle.graal.nodes.ConditionAnchorNode; @@ -65,6 +60,11 @@ import com.oracle.graal.nodes.extended.BranchProbabilityNode; import com.oracle.graal.nodes.extended.UnsafeLoadNode; import com.oracle.graal.nodes.extended.UnsafeStoreNode; +import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderContext; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugin.Receiver; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.nodes.java.MethodCallTargetNode; import com.oracle.graal.nodes.virtual.EnsureVirtualizedNode; import com.oracle.graal.replacements.nodes.arithmetic.IntegerAddExactNode;
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleInvocationPluginProvider.java Tue Nov 24 17:23:25 2015 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleInvocationPluginProvider.java Tue Nov 24 15:26:32 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -25,7 +25,7 @@ import jdk.vm.ci.meta.MetaAccessProvider; import com.oracle.graal.api.replacements.SnippetReflectionProvider; -import com.oracle.graal.graphbuilderconf.InvocationPlugins; +import com.oracle.graal.nodes.graphbuilderconf.InvocationPlugins; public interface TruffleInvocationPluginProvider { void registerInvocationPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins, boolean canDelayIntrinsification, SnippetReflectionProvider snippetReflection);
--- a/mx.graal/suite.py Tue Nov 24 17:23:25 2015 +0100 +++ b/mx.graal/suite.py Tue Nov 24 15:26:32 2015 +0100 @@ -784,7 +784,6 @@ "sourceDirs" : ["src"], "dependencies" : [ "com.oracle.graal.phases", - "com.oracle.graal.graphbuilderconf", ], "annotationProcessors" : deps(["jvmci:JVMCI_OPTIONS_PROCESSOR"]), "checkstyle" : "com.oracle.graal.graph", @@ -792,17 +791,6 @@ "workingSets" : "Graal,Java", }, - "com.oracle.graal.graphbuilderconf" : { - "subDir" : "graal", - "sourceDirs" : ["src"], - "dependencies" : [ - "com.oracle.graal.nodes", - ], - "checkstyle" : "com.oracle.graal.graph", - "javaCompliance" : "1.8", - "workingSets" : "Graal,Java", - }, - "com.oracle.graal.compiler.common" : { "subDir" : "graal", "sourceDirs" : ["src"],