# HG changeset patch # User Lukas Stadler # Date 1389274291 -3600 # Node ID 9267de45985bacb7efa6aa87dea67ae5fe4e0b99 # Parent 5ca6678140560cbb09b044d2af4630ad9e7c8e1d remove ForeignCallProvider reference from GraphBuilderPhase diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTestBase.java --- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTestBase.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTestBase.java Thu Jan 09 14:31:31 2014 +0100 @@ -74,7 +74,7 @@ Backend ptxBackend = getBackend(); TargetDescription target = ptxBackend.getTarget(); PhasePlan phasePlan = new PhasePlan(); - GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(getMetaAccess(), getForeignCalls(), GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.NONE); + GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(getMetaAccess(), GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.NONE); phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); phasePlan.addPhase(PhasePosition.AFTER_PARSING, new PTXPhase()); new PTXPhase().apply(graph); diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FinalizableSubclassTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FinalizableSubclassTest.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FinalizableSubclassTest.java Thu Jan 09 14:31:31 2014 +0100 @@ -66,7 +66,7 @@ StructuredGraph graph = new StructuredGraph(javaMethod); GraphBuilderConfiguration conf = GraphBuilderConfiguration.getSnippetDefault(); - new GraphBuilderPhase(getMetaAccess(), getForeignCalls(), conf, OptimisticOptimizations.ALL).apply(graph); + new GraphBuilderPhase(getMetaAccess(), conf, OptimisticOptimizations.ALL).apply(graph); HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); new CanonicalizerPhase(true).apply(graph, context); diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Thu Jan 09 14:31:31 2014 +0100 @@ -241,10 +241,6 @@ return getProviders().getConstantReflection(); } - protected ForeignCallsProvider getForeignCalls() { - return getProviders().getForeignCalls(); - } - protected MetaAccessProvider getMetaAccess() { return getProviders().getMetaAccess(); } @@ -554,7 +550,7 @@ } long start = System.currentTimeMillis(); PhasePlan phasePlan = new PhasePlan(); - GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(getMetaAccess(), getForeignCalls(), GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); + GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(getMetaAccess(), GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); final CompilationResult compResult = compileGraph(graph, cc, method, getProviders(), getBackend(), getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, @@ -621,7 +617,7 @@ assert m.getAnnotation(Test.class) == null : "shouldn't parse method with @Test annotation: " + m; ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(m); StructuredGraph graph = new StructuredGraph(javaMethod); - new GraphBuilderPhase(getMetaAccess(), getForeignCalls(), conf, OptimisticOptimizations.ALL).apply(graph); + new GraphBuilderPhase(getMetaAccess(), conf, OptimisticOptimizations.ALL).apply(graph); return graph; } @@ -633,7 +629,7 @@ PhasePlan plan = new PhasePlan(); GraphBuilderConfiguration gbConf = GraphBuilderConfiguration.getEagerDefault(); gbConf.setEagerInfopointMode(eagerInfopointMode); - plan.addPhase(PhasePosition.AFTER_PARSING, new GraphBuilderPhase(getMetaAccess(), getForeignCalls(), gbConf, OptimisticOptimizations.ALL)); + plan.addPhase(PhasePosition.AFTER_PARSING, new GraphBuilderPhase(getMetaAccess(), gbConf, OptimisticOptimizations.ALL)); return plan; } diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EATestBase.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EATestBase.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EATestBase.java Thu Jan 09 14:31:31 2014 +0100 @@ -146,7 +146,7 @@ ResolvedJavaMethod method = getMetaAccess().lookupJavaMethod(getMethod(snippet)); graph = new StructuredGraph(method); try (Scope s = Debug.scope(getClass().getSimpleName(), graph, method, getCodeCache())) { - new GraphBuilderPhase(getMetaAccess(), getForeignCalls(), GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); + new GraphBuilderPhase(getMetaAccess(), GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); Assumptions assumptions = new Assumptions(false); context = new HighTierContext(getProviders(), assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILCompilationResult.java --- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILCompilationResult.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILCompilationResult.java Thu Jan 09 14:31:31 2014 +0100 @@ -92,9 +92,8 @@ public static HSAILCompilationResult getHSAILCompilationResult(ResolvedJavaMethod javaMethod) { HotSpotMetaAccessProvider metaAccess = backend.getProviders().getMetaAccess(); - ForeignCallsProvider foreignCalls = backend.getProviders().getForeignCalls(); StructuredGraph graph = new StructuredGraph(javaMethod); - new GraphBuilderPhase(metaAccess, foreignCalls, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); + new GraphBuilderPhase(metaAccess, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); return getHSAILCompilationResult(graph); } @@ -143,7 +142,7 @@ HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) providers.getMetaAccess(); ResolvedJavaMethod rm = metaAccess.lookupJavaMethod(acceptMethod); StructuredGraph graph = new StructuredGraph(rm); - GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(providers.getMetaAccess(), providers.getForeignCalls(), GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); + GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(providers.getMetaAccess(), GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); graphBuilderPhase.apply(graph); NodeIterable nin = graph.getNodes(); ResolvedJavaMethod lambdaMethod = null; @@ -169,7 +168,7 @@ Providers providers = backend.getProviders(); TargetDescription target = providers.getCodeCache().getTarget(); PhasePlan phasePlan = new PhasePlan(); - GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(providers.getMetaAccess(), providers.getForeignCalls(), GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.NONE); + GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(providers.getMetaAccess(), GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.NONE); phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); phasePlan.addPhase(PhasePosition.AFTER_PARSING, new HSAILPhase()); new HSAILPhase().apply(graph); diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Thu Jan 09 14:31:31 2014 +0100 @@ -203,7 +203,7 @@ try (OverrideScope s = OptionValue.override(ImmutableCode, compileAOT)) { PhasePlan phasePlan = new PhasePlan(); - GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(getMetaAccess(), getForeignCalls(), GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); + GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(getMetaAccess(), GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); // create suites everytime, as we modify options for the compiler diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ExplicitExceptionTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ExplicitExceptionTest.java Thu Jan 09 14:31:31 2014 +0100 @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2011, 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.hotspot.test; + +import org.junit.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.test.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.extended.*; + +public class ExplicitExceptionTest extends GraalCompilerTest { + + private int expectedForeignCallCount; + + @Override + protected InstalledCode getCode(ResolvedJavaMethod method, StructuredGraph graph) { + InstalledCode installedCode = super.getCode(method, graph); + assertEquals(expectedForeignCallCount, graph.getNodes().filter(ForeignCallNode.class).count()); + return installedCode; + } + + public static int testAIOOBESnippet(int[] array) { + return array[10]; + } + + @Test + public void testAIOOBE() { + int[] array = new int[4]; + for (int i = 0; i < 10000; i++) { + try { + testAIOOBESnippet(array); + } catch (ArrayIndexOutOfBoundsException e) { + // nothing to do + } + } + expectedForeignCallCount = 2; + test("testAIOOBESnippet", array); + } + + public static int testNPEArraySnippet(int[] array) { + return array[10]; + } + + @Test + public void testNPEArray() { + int[] array = null; + for (int i = 0; i < 10000; i++) { + try { + testNPEArraySnippet(array); + } catch (NullPointerException e) { + // nothing to do + } + } + expectedForeignCallCount = 2; + test("testNPEArraySnippet", array); + } + + private static class TestClass { + int field; + } + + public static int testNPESnippet(TestClass obj) { + return obj.field; + } + + @SuppressWarnings("unused") + @Test + public void testNPE() { + new TestClass(); + TestClass obj = null; + for (int i = 0; i < 10000; i++) { + try { + testNPESnippet(obj); + } catch (NullPointerException e) { + // nothing to do + } + } + expectedForeignCallCount = 1; + test("testNPESnippet", obj); + } + +} diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu Jan 09 14:31:31 2014 +0100 @@ -122,8 +122,7 @@ boolean osrCompilation = entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI; PhasePlan phasePlan = new PhasePlan(); MetaAccessProvider metaAccess = providers.getMetaAccess(); - ForeignCallsProvider foreignCalls = providers.getForeignCalls(); - phasePlan.addPhase(PhasePosition.AFTER_PARSING, new GraphBuilderPhase(metaAccess, foreignCalls, GraphBuilderConfiguration.getDefault(), optimisticOpts)); + phasePlan.addPhase(PhasePosition.AFTER_PARSING, new GraphBuilderPhase(metaAccess, GraphBuilderConfiguration.getDefault(), optimisticOpts)); if (osrCompilation) { phasePlan.addPhase(PhasePosition.AFTER_PARSING, new OnStackReplacementPhase()); } diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Thu Jan 09 14:31:31 2014 +0100 @@ -145,7 +145,7 @@ HotSpotBackend hostBackend = runtime.getHostBackend(); final HotSpotProviders hostProviders = hostBackend.getProviders(); - assert VerifyOptionsPhase.checkOptions(hostProviders.getMetaAccess(), hostProviders.getForeignCalls()); + assert VerifyOptionsPhase.checkOptions(hostProviders.getMetaAccess()); // Complete initialization of backends hostBackend.completeInitialization(); diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java Thu Jan 09 14:31:31 2014 +0100 @@ -409,6 +409,12 @@ if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) { BenchmarkCounters.lower((DynamicCounterNode) n, registers, runtime.getConfig(), wordKind); } + } else if (n instanceof DeferredForeignCallNode) { + if (graph.getGuardsStage() == StructuredGraph.GuardsStage.FLOATING_GUARDS) { + DeferredForeignCallNode deferred = (DeferredForeignCallNode) n; + ForeignCallNode foreignCallNode = graph.add(new ForeignCallNode(foreignCalls, deferred.getDescriptor(), deferred.getArguments())); + graph.replaceFixedWithFixed(deferred, foreignCallNode); + } } else if (n instanceof CheckCastDynamicNode) { checkcastDynamicSnippets.lower((CheckCastDynamicNode) n, tool); } else if (n instanceof InstanceOfNode) { diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Thu Jan 09 14:31:31 2014 +0100 @@ -145,10 +145,9 @@ } PhasePlan phasePlan = new PhasePlan(); - ForeignCallsProvider foreignCalls = providers.getForeignCalls(); MetaAccessProvider metaAccess = providers.getMetaAccess(); CodeCacheProvider codeCache = providers.getCodeCache(); - GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(metaAccess, foreignCalls, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); + GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(metaAccess, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); // The stub itself needs the incoming calling convention. CallingConvention incomingCc = linkage.getIncomingCallingConvention(); diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java --- a/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java Thu Jan 09 14:31:31 2014 +0100 @@ -48,10 +48,9 @@ Suites suites = suitesProvider.createSuites(); StructuredGraph graph = new StructuredGraph(method); MetaAccessProvider metaAccess = providers.getMetaAccess(); - ForeignCallsProvider foreignCalls = providers.getForeignCalls(); - new GraphBuilderPhase(metaAccess, foreignCalls, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); + new GraphBuilderPhase(metaAccess, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); PhasePlan phasePlan = new PhasePlan(); - GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(metaAccess, foreignCalls, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); + GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(metaAccess, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); compileGraph(graph, cc, method, providers, backend, providers.getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, getProfilingInfo(graph), new SpeculationLog(), suites, diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Thu Jan 09 14:31:31 2014 +0100 @@ -94,7 +94,6 @@ protected BlockPlaceholderNode placeholders; private final MetaAccessProvider metaAccess; - private final ForeignCallsProvider foreignCalls; private ConstantPool constantPool; private ResolvedJavaMethod method; private int entryBCI; @@ -163,11 +162,10 @@ return method; } - public GraphBuilderPhase(MetaAccessProvider metaAccess, ForeignCallsProvider foreignCalls, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts) { + public GraphBuilderPhase(MetaAccessProvider metaAccess, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts) { this.graphBuilderConfig = graphBuilderConfig; this.optimisticOpts = optimisticOpts; this.metaAccess = metaAccess; - this.foreignCalls = foreignCalls; assert metaAccess != null; } @@ -984,7 +982,7 @@ ValueNode exception = ConstantNode.forObject(cachedNullPointerException, metaAccess, currentGraph); trueSucc.setNext(handleException(exception, bci())); } else { - ForeignCallNode call = currentGraph.add(new ForeignCallNode(foreignCalls, CREATE_NULL_POINTER_EXCEPTION)); + DeferredForeignCallNode call = currentGraph.add(new DeferredForeignCallNode(CREATE_NULL_POINTER_EXCEPTION)); call.setStateAfter(frameState.create(bci())); trueSucc.setNext(call); call.setNext(handleException(call, bci())); @@ -1008,7 +1006,7 @@ ValueNode exception = ConstantNode.forObject(cachedArrayIndexOutOfBoundsException, metaAccess, currentGraph); falseSucc.setNext(handleException(exception, bci())); } else { - ForeignCallNode call = currentGraph.add(new ForeignCallNode(foreignCalls, CREATE_OUT_OF_BOUNDS_EXCEPTION, index)); + DeferredForeignCallNode call = currentGraph.add(new DeferredForeignCallNode(CREATE_OUT_OF_BOUNDS_EXCEPTION, index)); call.setStateAfter(frameState.create(bci())); falseSucc.setNext(call); call.setNext(handleException(call, bci())); diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.java/src/com/oracle/graal/java/VerifyOptionsPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/VerifyOptionsPhase.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/VerifyOptionsPhase.java Thu Jan 09 14:31:31 2014 +0100 @@ -28,7 +28,6 @@ import java.util.*; -import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; @@ -45,29 +44,29 @@ */ public class VerifyOptionsPhase extends Phase { - public static boolean checkOptions(MetaAccessProvider metaAccess, ForeignCallsProvider foreignCalls) { + public static boolean checkOptions(MetaAccessProvider metaAccess) { ServiceLoader sl = ServiceLoader.loadInstalled(Options.class); Set checked = new HashSet<>(); for (Options opts : sl) { for (OptionDescriptor desc : opts) { ResolvedJavaType holder = metaAccess.lookupJavaType(desc.getDeclaringClass()); - checkType(holder, desc, metaAccess, foreignCalls, checked); + checkType(holder, desc, metaAccess, checked); } } return true; } - private static void checkType(ResolvedJavaType type, OptionDescriptor option, MetaAccessProvider metaAccess, ForeignCallsProvider foreignCalls, Set checked) { + private static void checkType(ResolvedJavaType type, OptionDescriptor option, MetaAccessProvider metaAccess, Set checked) { if (!checked.contains(type)) { checked.add(type); ResolvedJavaType superType = type.getSuperclass(); if (superType != null && !MetaUtil.isJavaLangObject(superType)) { - checkType(superType, option, metaAccess, foreignCalls, checked); + checkType(superType, option, metaAccess, checked); } ResolvedJavaMethod clinit = type.getClassInitializer(); if (clinit != null) { StructuredGraph graph = new StructuredGraph(clinit); - new GraphBuilderPhase(metaAccess, foreignCalls, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); + new GraphBuilderPhase(metaAccess, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); new VerifyOptionsPhase(type, metaAccess, option).apply(graph); } } diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/DeferredForeignCallNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/DeferredForeignCallNode.java Thu Jan 09 14:31:31 2014 +0100 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2011, 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.extended; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; + +/** + * A node that will be lowered to a {@linkplain ForeignCallDescriptor foreign} call. + */ +@NodeInfo(nameTemplate = "DeferredForeignCall#{p#descriptor/s}") +public class DeferredForeignCallNode extends AbstractMemoryCheckpoint implements Lowerable, MemoryCheckpoint.Single { + + @Input private final NodeInputList arguments; + @Input private FrameState deoptState; + + private final ForeignCallDescriptor descriptor; + + public DeferredForeignCallNode(ForeignCallDescriptor descriptor, ValueNode... arguments) { + super(StampFactory.forKind(Kind.fromJavaClass(descriptor.getResultType()))); + this.arguments = new NodeInputList<>(this, arguments); + this.descriptor = descriptor; + } + + public ForeignCallDescriptor getDescriptor() { + return descriptor; + } + + @Override + public String toString(Verbosity verbosity) { + if (verbosity == Verbosity.Name) { + return super.toString(verbosity) + "#" + descriptor; + } + return super.toString(verbosity); + } + + public LocationIdentity getLocationIdentity() { + return LocationIdentity.ANY_LOCATION; + } + + public void lower(LoweringTool tool) { + tool.getLowerer().lower(this, tool); + } + + public NodeInputList getArguments() { + return arguments; + } +} diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ForeignCallNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ForeignCallNode.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ForeignCallNode.java Thu Jan 09 14:31:31 2014 +0100 @@ -22,6 +22,8 @@ */ package com.oracle.graal.nodes.extended; +import java.util.*; + import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; @@ -48,6 +50,13 @@ this.foreignCalls = foreignCalls; } + public ForeignCallNode(@InjectedNodeParameter ForeignCallsProvider foreignCalls, ForeignCallDescriptor descriptor, List arguments) { + super(StampFactory.forKind(Kind.fromJavaClass(descriptor.getResultType()))); + this.arguments = new NodeInputList<>(this, arguments); + this.descriptor = descriptor; + this.foreignCalls = foreignCalls; + } + protected ForeignCallNode(@InjectedNodeParameter ForeignCallsProvider foreignCalls, ForeignCallDescriptor descriptor, Stamp stamp) { super(stamp); this.arguments = new NodeInputList<>(this); diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Thu Jan 09 14:31:31 2014 +0100 @@ -363,8 +363,7 @@ final StructuredGraph graph = new StructuredGraph(methodToParse); try (Scope s = Debug.scope("buildInitialGraph", graph)) { MetaAccessProvider metaAccess = providers.getMetaAccess(); - ForeignCallsProvider foreignCalls = providers.getForeignCalls(); - new GraphBuilderPhase(metaAccess, foreignCalls, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.NONE).apply(graph); + new GraphBuilderPhase(metaAccess, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.NONE).apply(graph); new WordTypeVerificationPhase(metaAccess, target.wordKind).apply(graph); new WordTypeRewriterPhase(metaAccess, target.wordKind).apply(graph); diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java --- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java Thu Jan 09 14:31:31 2014 +0100 @@ -172,7 +172,7 @@ // Additional inlining. final PhasePlan plan = new PhasePlan(); - GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(getMetaAccess(), getForeignCalls(), GraphBuilderConfiguration.getEagerDefault(), TruffleCompilerImpl.Optimizations); + GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(getMetaAccess(), GraphBuilderConfiguration.getEagerDefault(), TruffleCompilerImpl.Optimizations); plan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); canonicalizer.addToPhasePlan(plan, context); plan.addPhase(PhasePosition.AFTER_PARSING, new DeadCodeEliminationPhase()); diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Thu Jan 09 14:31:31 2014 +0100 @@ -198,10 +198,9 @@ Suites suites = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getSuites().createSuites(); suites.getHighTier().findPhase(InliningPhase.class).remove(); StructuredGraph graph = new StructuredGraph(javaMethod); - ForeignCallsProvider foreignCalls = providers.getForeignCalls(); - new GraphBuilderPhase(metaAccess, foreignCalls, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); + new GraphBuilderPhase(metaAccess, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); PhasePlan phasePlan = new PhasePlan(); - GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(metaAccess, foreignCalls, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); + GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(metaAccess, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); Backend backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend(); diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Thu Jan 09 14:31:31 2014 +0100 @@ -104,7 +104,7 @@ final StructuredGraph graph = new StructuredGraph(executeHelperMethod); try (Scope s = Debug.scope("createGraph", graph)) { - new GraphBuilderPhase(providers.getMetaAccess(), providers.getForeignCalls(), config, TruffleCompilerImpl.Optimizations).apply(graph); + new GraphBuilderPhase(providers.getMetaAccess(), config, TruffleCompilerImpl.Optimizations).apply(graph); // Replace thisNode with constant. LocalNode thisNode = graph.getLocal(0); diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCache.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCache.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCache.java Thu Jan 09 14:31:31 2014 +0100 @@ -95,7 +95,7 @@ final StructuredGraph graph = new StructuredGraph(method); PhaseContext phaseContext = new PhaseContext(providers, new Assumptions(false)); - new GraphBuilderPhase(phaseContext.getMetaAccess(), providers.getForeignCalls(), config, optimisticOptimizations).apply(graph); + new GraphBuilderPhase(phaseContext.getMetaAccess(), config, optimisticOptimizations).apply(graph); for (LocalNode l : graph.getNodes(LocalNode.class)) { if (l.kind() == Kind.Object) { diff -r 5ca667814056 -r 9267de45985b graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Thu Jan 09 18:56:15 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Thu Jan 09 14:31:31 2014 +0100 @@ -264,7 +264,7 @@ private PhasePlan createPhasePlan(final GraphBuilderConfiguration config) { final PhasePlan phasePlan = new PhasePlan(); - GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(providers.getMetaAccess(), providers.getForeignCalls(), config, TruffleCompilerImpl.Optimizations); + GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(providers.getMetaAccess(), config, TruffleCompilerImpl.Optimizations); phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); return phasePlan; }