# HG changeset patch # User Doug Simon # Date 1381486749 -7200 # Node ID 0afe7370260c88a3e883701fcbf34cbb9d4be0a6 # Parent 9c2111d10e40e3d0ae93b439dfacd88d21bf9e6d refactored constantEquals(), lookupArrayLength() and readUnsafeConstant() out of MetaAccessProvider into ConstantReflectionProvider (GRAAL-511) diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestMetaAccessProvider.java --- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestMetaAccessProvider.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestMetaAccessProvider.java Fri Oct 11 12:19:09 2013 +0200 @@ -96,9 +96,9 @@ for (Constant c1 : constants) { for (Constant c2 : constants) { // test symmetry - assertEquals(metaAccess.constantEquals(c1, c2), metaAccess.constantEquals(c2, c1)); + assertEquals(constantReflection.constantEquals(c1, c2), constantReflection.constantEquals(c2, c1)); if (c1.getKind() != Kind.Object && c2.getKind() != Kind.Object) { - assertEquals(c1.equals(c2), metaAccess.constantEquals(c2, c1)); + assertEquals(c1.equals(c2), constantReflection.constantEquals(c2, c1)); } } } @@ -107,7 +107,7 @@ @Test public void lookupArrayLengthTest() { for (Constant c : constants) { - Integer actual = metaAccess.lookupArrayLength(c); + Integer actual = constantReflection.lookupArrayLength(c); if (c.getKind() != Kind.Object || c.isNull() || !c.asObject().getClass().isArray()) { assertNull(actual); } else { diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TypeUniverse.java --- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TypeUniverse.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TypeUniverse.java Fri Oct 11 12:19:09 2013 +0200 @@ -41,6 +41,7 @@ public final Unsafe unsafe; public final MetaAccessProvider metaAccess = Graal.getRequiredCapability(MetaAccessProvider.class); + public final ConstantReflectionProvider constantReflection = Graal.getRequiredCapability(ConstantReflectionProvider.class); public final Collection> classes = new HashSet<>(); public final Map, Class> arrayClasses = new HashMap<>(); public final List constants = new ArrayList<>(); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantReflectionProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantReflectionProvider.java Fri Oct 11 12:19:09 2013 +0200 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2012, 2012, 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.api.meta; + +/** + * Reflection operations on values represented as {@linkplain Constant constants}. + */ +public interface ConstantReflectionProvider { + + /** + * Compares two constants for equality. The equality relationship is symmetric. + * + * @return {@code true} if the two parameters represent the same runtime object, {@code false} + * otherwise + */ + boolean constantEquals(Constant x, Constant y); + + /** + * Returns the length of an array that is wrapped in a {@link Constant} object. If {@code array} + * is not an array, or the array length is not available at this point, the return value is + * {@code null}. + */ + Integer lookupArrayLength(Constant array); + + /** + * Reads a value of this kind using a base address and a displacement. + * + * @param base the base address from which the value is read + * @param displacement the displacement within the object in bytes + * @param compressible whether this is a read of a compressed or an uncompressed pointer + * @return the read value encapsulated in a {@link Constant} object, or {@code null} if the + * value cannot be read. + */ + Constant readUnsafeConstant(Kind kind, Object base, long displacement, boolean compressible); +} diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaAccessProvider.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaAccessProvider.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaAccessProvider.java Fri Oct 11 12:19:09 2013 +0200 @@ -68,35 +68,6 @@ Signature parseMethodDescriptor(String methodDescriptor); /** - * Compares two constants for equality. This is used instead of {@link Constant#equals(Object)} - * in case the runtime has an interpretation for object equality other than - * {@code x.asObject() == y.asObject()}. For primitive constants, this is equivalent to calling - * {@code x.equals(y)}. The equality relationship is symmetric. - * - * @return {@code true} if the two parameters represent the same runtime object, {@code false} - * otherwise - */ - boolean constantEquals(Constant x, Constant y); - - /** - * Returns the length of an array that is wrapped in a {@link Constant} object. If {@code array} - * is not an array, or the array length is not available at this point, the return value is - * {@code null}. - */ - Integer lookupArrayLength(Constant array); - - /** - * Reads a value of this kind using a base address and a displacement. - * - * @param base the base address from which the value is read - * @param displacement the displacement within the object in bytes - * @param compressible whether this is a read of a compressed or an uncompressed pointer - * @return the read value encapsulated in a {@link Constant} object, or {@code null} if the - * value cannot be read. - */ - Constant readUnsafeConstant(Kind kind, Object base, long displacement, boolean compressible); - - /** * Determines if a given foreign call is side-effect free. Deoptimization cannot return * execution to a point before a foreign call that has a side effect. */ diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILCompilationResult.java --- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILCompilationResult.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILCompilationResult.java Fri Oct 11 12:19:09 2013 +0200 @@ -117,6 +117,7 @@ TargetDescription target = new TargetDescription(new HSAIL(), true, 8, 0, true); MetaAccessProvider metaAccess = Graal.getRequiredCapability(MetaAccessProvider.class); CodeCacheProvider codeCache = Graal.getRequiredCapability(CodeCacheProvider.class); + ConstantReflectionProvider constantReflection = Graal.getRequiredCapability(ConstantReflectionProvider.class); LoweringProvider lowerer = Graal.getRequiredCapability(LoweringProvider.class); HSAILBackend hsailBackend = new HSAILBackend(metaAccess, codeCache, target); PhasePlan phasePlan = new PhasePlan(); @@ -128,8 +129,8 @@ Replacements replacements = Graal.getRequiredCapability(Replacements.class); SuitesProvider suitesProvider = Graal.getRequiredCapability(SuitesProvider.class); try { - CompilationResult compResult = GraalCompiler.compileGraph(graph, cc, graph.method(), metaAccess, codeCache, lowerer, replacements, hsailBackend, target, null, phasePlan, - OptimisticOptimizations.NONE, new SpeculationLog(), suitesProvider.getDefaultSuites(), new CompilationResult()); + CompilationResult compResult = GraalCompiler.compileGraph(graph, cc, graph.method(), metaAccess, constantReflection, codeCache, lowerer, replacements, hsailBackend, target, null, + phasePlan, OptimisticOptimizations.NONE, new SpeculationLog(), suitesProvider.getDefaultSuites(), new CompilationResult()); return new HSAILCompilationResult(compResult); } catch (GraalInternalError e) { String partialCode = hsailBackend.getPartialCodeString(); diff -r 9c2111d10e40 -r 0afe7370260c 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 Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTestBase.java Fri Oct 11 12:19:09 2013 +0200 @@ -77,8 +77,8 @@ * Ultimately we might want to have both the kernel and the code natively compiled for * GPU fallback to CPU in cases of ECC failure on kernel invocation. */ - CompilationResult result = GraalCompiler.compileGraph(graph, cc, graph.method(), getMetaAccess(), getCodeCache(), getLowerer(), graalRuntime().getReplacements(), ptxBackend, target, null, phasePlan, - OptimisticOptimizations.NONE, new SpeculationLog(), Suites.createDefaultSuites(), new ExternalCompilationResult()); + CompilationResult result = GraalCompiler.compileGraph(graph, cc, graph.method(), getMetaAccess(), getConstantReflection(), getCodeCache(), getLowerer(), graalRuntime().getReplacements(), + ptxBackend, target, null, phasePlan, OptimisticOptimizations.NONE, new SpeculationLog(), Suites.createDefaultSuites(), new ExternalCompilationResult()); return result; } else { return null; diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -307,7 +307,7 @@ private void processMethod(final String snippet) { graph = parse(snippet); Assumptions assumptions = new Assumptions(false); - HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); + HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); new PartialEscapePhase(false, new CanonicalizerPhase(true)).apply(graph, context); } @@ -324,7 +324,7 @@ graph = parse(snippet); Assumptions assumptions = new Assumptions(false); - HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); + HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true); new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); if (loopPeeling) { diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompareCanonicalizerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompareCanonicalizerTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompareCanonicalizerTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -36,7 +36,7 @@ private StructuredGraph getCanonicalizedGraph(String name) { StructuredGraph graph = parse(name); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), null, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), null, replacements)); return graph; } @@ -54,7 +54,7 @@ assertEquals(referenceGraph, graph); } Assumptions assumptions = new Assumptions(false); - new CanonicalizerPhase(true).apply(referenceGraph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements)); + new CanonicalizerPhase(true).apply(referenceGraph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements)); for (int i = 1; i < 4; i++) { StructuredGraph graph = getCanonicalizedGraph("canonicalCompare" + i); assertEquals(referenceGraph, graph); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -142,7 +142,7 @@ StructuredGraph graph = parse("testNullnessSnippet"); new ConditionalEliminationPhase(getMetaAccess()).apply(graph); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), null, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), null, replacements)); for (ConstantNode constant : graph.getNodes().filter(ConstantNode.class)) { assertTrue("unexpected constant: " + constant, constant.asConstant().isNull() || constant.asConstant().asInt() > 0); } @@ -164,7 +164,7 @@ @Test public void testDisjunction() { StructuredGraph graph = parse("testDisjunctionSnippet"); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), null, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), null, replacements)); IfNode ifNode = (IfNode) graph.start().next(); InstanceOfNode instanceOf = (InstanceOfNode) ifNode.condition(); IsNullNode x = graph.unique(new IsNullNode(graph.getLocal(0))); @@ -172,9 +172,9 @@ ShortCircuitOrNode disjunction = graph.unique(new ShortCircuitOrNode(x, false, y, false, NOT_FREQUENT_PROBABILITY)); LogicNegationNode negation = graph.unique(new LogicNegationNode(disjunction)); ifNode.setCondition(negation); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), null, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), null, replacements)); new ConditionalEliminationPhase(getMetaAccess()).apply(graph); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), null, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), null, replacements)); for (ConstantNode constant : graph.getNodes().filter(ConstantNode.class)) { assertTrue("unexpected constant: " + constant, constant.asConstant().isNull() || constant.asConstant().asInt() > 0); } @@ -192,7 +192,7 @@ public void testInvoke() { test("testInvokeSnippet", new Integer(16)); StructuredGraph graph = parse("testInvokeSnippet"); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), null, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), null, replacements)); new ConditionalEliminationPhase(getMetaAccess()).apply(graph); InvokeNode invoke = graph.getNodes().filter(InvokeNode.class).first(); @@ -222,9 +222,9 @@ @Test public void testTypeMerging() { StructuredGraph graph = parse("testTypeMergingSnippet"); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), null, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), null, replacements)); new ConditionalEliminationPhase(getMetaAccess()).apply(graph); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), null, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), null, replacements)); assertEquals(0, graph.getNodes().filter(StoreFieldNode.class).count()); } @@ -239,9 +239,9 @@ @Test public void testInstanceOfCheckCast() { StructuredGraph graph = parse("testInstanceOfCheckCastSnippet"); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), null, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), null, replacements)); new ConditionalEliminationPhase(getMetaAccess()).apply(graph); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), null, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), null, replacements)); assertEquals(0, graph.getNodes().filter(CheckCastNode.class).count()); } @@ -252,7 +252,7 @@ StructuredGraph graph = parse("testInstanceOfCheckCastSnippet"); CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true); - PhaseContext context = new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), null, replacements); + PhaseContext context = new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), null, replacements); new LoweringPhase(canonicalizer).apply(graph, context); canonicalizer.apply(graph, context); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/DegeneratedLoopsTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/DegeneratedLoopsTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/DegeneratedLoopsTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -82,7 +82,7 @@ public void run() { StructuredGraph graph = parse(snippet); - HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); + HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), new Assumptions(false), replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); new CanonicalizerPhase(true).apply(graph, context); Debug.dump(graph, "Graph"); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -114,7 +114,7 @@ public StructuredGraph call() throws Exception { Debug.dump(graph, "After parsing: " + snippet); Assert.assertEquals(checkcasts, graph.getNodes().filter(CheckCastNode.class).count()); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), new Assumptions(false), replacements)); Assert.assertEquals(afterCanon, graph.getNodes().filter(CheckCastNode.class).count()); return graph; } diff -r 9c2111d10e40 -r 0afe7370260c 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 Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FinalizableSubclassTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -68,7 +68,7 @@ GraphBuilderConfiguration conf = GraphBuilderConfiguration.getSnippetDefault(); new GraphBuilderPhase(getMetaAccess(), conf, OptimisticOptimizations.ALL).apply(graph); - HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); + HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); new CanonicalizerPhase(true).apply(graph, context); return graph; diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FloatingReadTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FloatingReadTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FloatingReadTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -58,7 +58,7 @@ public void run() { StructuredGraph graph = parse(snippet); - PhaseContext context = new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), replacements); + PhaseContext context = new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), new Assumptions(false), replacements); new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, context); new FloatingReadPhase().apply(graph); diff -r 9c2111d10e40 -r 0afe7370260c 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 Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -78,6 +78,7 @@ private final CodeCacheProvider codeCache; private final MetaAccessProvider metaAccess; + private final ConstantReflectionProvider constantReflection; private final LoweringProvider lowerer; protected final Replacements replacements; protected final Backend backend; @@ -86,6 +87,7 @@ public GraalCompilerTest() { this.replacements = Graal.getRequiredCapability(Replacements.class); this.metaAccess = Graal.getRequiredCapability(MetaAccessProvider.class); + this.constantReflection = Graal.getRequiredCapability(ConstantReflectionProvider.class); this.codeCache = Graal.getRequiredCapability(CodeCacheProvider.class); this.lowerer = Graal.getRequiredCapability(LoweringProvider.class); this.backend = Graal.getRequiredCapability(Backend.class); @@ -166,6 +168,10 @@ return codeCache; } + protected ConstantReflectionProvider getConstantReflection() { + return constantReflection; + } + protected MetaAccessProvider getMetaAccess() { return metaAccess; } @@ -480,8 +486,8 @@ GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(metaAccess, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); - final CompilationResult compResult = GraalCompiler.compileGraph(graph, cc, method, metaAccess, getCodeCache(), getLowerer(), replacements, backend, getCodeCache().getTarget(), null, - phasePlan, OptimisticOptimizations.ALL, new SpeculationLog(), suites, new CompilationResult()); + final CompilationResult compResult = GraalCompiler.compileGraph(graph, cc, method, metaAccess, getConstantReflection(), getCodeCache(), getLowerer(), replacements, backend, + getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, new SpeculationLog(), suites, new CompilationResult()); if (printCompilation) { TTY.println(String.format("@%-6d Graal %-70s %-45s %-50s | %4dms %5dB", id, "", "", "", System.currentTimeMillis() - start, compResult.getTargetCodeSize())); } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfCanonicalizerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfCanonicalizerTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfCanonicalizerTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -145,7 +145,7 @@ n.replaceFirstInput(local, constant); } Debug.dump(graph, "Graph"); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), new Assumptions(false), replacements)); for (FrameState fs : local.usages().filter(FrameState.class).snapshot()) { fs.replaceFirstInput(local, null); } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -59,8 +59,8 @@ final Method method = getMethod("testMethod"); final StructuredGraph graph = parse(method); CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); - final CompilationResult cr = GraalCompiler.compileGraph(graph, cc, graph.method(), getMetaAccess(), getCodeCache(), getLowerer(), replacements, backend, getCodeCache().getTarget(), null, getDefaultPhasePlan(), - OptimisticOptimizations.ALL, new SpeculationLog(), suites, new CompilationResult()); + final CompilationResult cr = GraalCompiler.compileGraph(graph, cc, graph.method(), getMetaAccess(), getConstantReflection(), getCodeCache(), getLowerer(), replacements, backend, + getCodeCache().getTarget(), null, getDefaultPhasePlan(), OptimisticOptimizations.ALL, new SpeculationLog(), suites, new CompilationResult()); for (Infopoint sp : cr.getInfopoints()) { assertNotNull(sp.reason); if (sp instanceof Call) { @@ -81,8 +81,8 @@ } assertTrue(graphLineSPs > 0); CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); - final CompilationResult cr = GraalCompiler.compileGraph(graph, cc, graph.method(), getMetaAccess(), getCodeCache(), getLowerer(), replacements, backend, getCodeCache().getTarget(), null, getDefaultPhasePlan(true), - OptimisticOptimizations.ALL, new SpeculationLog(), suites, new CompilationResult()); + final CompilationResult cr = GraalCompiler.compileGraph(graph, cc, graph.method(), getMetaAccess(), getConstantReflection(), getCodeCache(), getLowerer(), replacements, backend, + getCodeCache().getTarget(), null, getDefaultPhasePlan(true), OptimisticOptimizations.ALL, new SpeculationLog(), suites, new CompilationResult()); int lineSPs = 0; for (Infopoint sp : cr.getInfopoints()) { assertNotNull(sp.reason); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeExceptionTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeExceptionTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeExceptionTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -66,7 +66,7 @@ hints.put(invoke, 1000d); } Assumptions assumptions = new Assumptions(false); - HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); + HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); new InliningPhase(hints, new CanonicalizerPhase(true)).apply(graph, context); new CanonicalizerPhase(true).apply(graph, context); new DeadCodeEliminationPhase().apply(graph); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeHintsTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeHintsTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeHintsTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -77,7 +77,7 @@ } Assumptions assumptions = new Assumptions(false); - HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); + HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); new InliningPhase(hints, new CanonicalizerPhase(true)).apply(graph, context); new CanonicalizerPhase(true).apply(graph, context); new DeadCodeEliminationPhase().apply(graph); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LockEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LockEliminationTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LockEliminationTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -61,7 +61,7 @@ test("testSynchronizedSnippet", new A(), new A()); StructuredGraph graph = getGraph("testSynchronizedSnippet"); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), null, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), null, replacements)); new LockEliminationPhase().apply(graph); assertEquals(1, graph.getNodes().filter(MonitorEnterNode.class).count()); assertEquals(1, graph.getNodes().filter(MonitorExitNode.class).count()); @@ -79,7 +79,7 @@ test("testSynchronizedMethodSnippet", new A()); StructuredGraph graph = getGraph("testSynchronizedMethodSnippet"); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), null, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), null, replacements)); new LockEliminationPhase().apply(graph); assertEquals(1, graph.getNodes().filter(MonitorEnterNode.class).count()); assertEquals(1, graph.getNodes().filter(MonitorExitNode.class).count()); @@ -90,7 +90,7 @@ StructuredGraph graph = parse(method); PhasePlan phasePlan = getDefaultPhasePlan(); Assumptions assumptions = new Assumptions(true); - HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements, null, phasePlan, OptimisticOptimizations.ALL); + HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements, null, phasePlan, OptimisticOptimizations.ALL); new CanonicalizerPhase(true).apply(graph, context); new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); new CanonicalizerPhase(true).apply(graph, context); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LoopUnswitchTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LoopUnswitchTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LoopUnswitchTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -134,8 +134,8 @@ } Assumptions assumptions = new Assumptions(false); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements)); - new CanonicalizerPhase(true).apply(referenceGraph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements)); + new CanonicalizerPhase(true).apply(referenceGraph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements)); Debug.scope("Test", new DebugDumpScope("Test:" + snippet), new Runnable() { @Override diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -553,7 +553,8 @@ @Override public SchedulePhase call() throws Exception { Assumptions assumptions = new Assumptions(false); - HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); + HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), + OptimisticOptimizations.ALL); new CanonicalizerPhase(true).apply(graph, context); if (mode == TestMode.INLINED_WITHOUT_FRAMESTATES) { new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); @@ -575,7 +576,8 @@ new FloatingReadPhase().apply(graph); new RemoveValueProxyPhase().apply(graph); - MidTierContext midContext = new MidTierContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements, getCodeCache().getTarget(), OptimisticOptimizations.ALL); + MidTierContext midContext = new MidTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements, getCodeCache().getTarget(), + OptimisticOptimizations.ALL); new GuardLoweringPhase().apply(graph, midContext); new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, midContext); new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, midContext); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MonitorGraphTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MonitorGraphTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MonitorGraphTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -94,7 +94,7 @@ hints.put(invoke, 1000d); } Assumptions assumptions = new Assumptions(false); - HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); + HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); new InliningPhase(hints, new CanonicalizerPhase(true)).apply(graph, context); new CanonicalizerPhase(true).apply(graph, context); new DeadCodeEliminationPhase().apply(graph); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -91,7 +91,7 @@ private StructuredGraph compileTestSnippet(final String snippet) { StructuredGraph graph = parse(snippet); - PhaseContext context = new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), replacements); + PhaseContext context = new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), new Assumptions(false), replacements); CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true); new LoweringPhase(canonicalizer).apply(graph, context); canonicalizer.apply(graph, context); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -83,7 +83,7 @@ // structure changes significantly public void run() { StructuredGraph graph = parse(snippet); - PhaseContext context = new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), replacements); + PhaseContext context = new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), new Assumptions(false), replacements); new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, context); new FloatingReadPhase().apply(graph); new EliminatePartiallyRedundantGuardsPhase(true, false).apply(graph); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReassociateAndCanonicalTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReassociateAndCanonicalTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReassociateAndCanonicalTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -245,9 +245,9 @@ private void test(String test, String ref) { StructuredGraph testGraph = parse(test); Assumptions assumptions = new Assumptions(false); - new CanonicalizerPhase(true).apply(testGraph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements)); + new CanonicalizerPhase(true).apply(testGraph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements)); StructuredGraph refGraph = parse(ref); - new CanonicalizerPhase(true).apply(refGraph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements)); + new CanonicalizerPhase(true).apply(refGraph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements)); assertEquals(testGraph, refGraph); } } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ScalarTypeSystemTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ScalarTypeSystemTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ScalarTypeSystemTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -167,9 +167,9 @@ StructuredGraph graph = parse(snippet); Debug.dump(graph, "Graph"); Assumptions assumptions = new Assumptions(false); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements)); new ConditionalEliminationPhase(getMetaAccess()).apply(graph); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements)); StructuredGraph referenceGraph = parse(referenceSnippet); assertEquals(referenceGraph, graph); } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StampCanonicalizerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StampCanonicalizerTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StampCanonicalizerTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -110,7 +110,7 @@ private void testZeroReturn(String methodName) { StructuredGraph graph = parse(methodName); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), new Assumptions(false), replacements)); new DeadCodeEliminationPhase().apply(graph); assertConstantReturn(graph, 0); } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StraighteningTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StraighteningTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StraighteningTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -90,7 +90,7 @@ // No debug scope to reduce console noise for @Test(expected = ...) tests StructuredGraph graph = parse(snippet); Debug.dump(graph, "Graph"); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), new Assumptions(false), replacements)); StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET); assertEquals(referenceGraph, graph); } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -185,13 +185,13 @@ StructuredGraph graph = parse(snippet); Debug.dump(graph, "Graph"); Assumptions assumptions = new Assumptions(false); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements)); new ConditionalEliminationPhase(getMetaAccess()).apply(graph); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements)); // a second canonicalizer is needed to process nested MaterializeNodes - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements)); StructuredGraph referenceGraph = parse(referenceSnippet); - new CanonicalizerPhase(true).apply(referenceGraph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements)); + new CanonicalizerPhase(true).apply(referenceGraph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements)); assertEquals(referenceGraph, graph); } @@ -241,9 +241,9 @@ StructuredGraph graph = parse(snippet); Debug.dump(graph, "Graph"); Assumptions assumptions = new Assumptions(false); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements)); new ConditionalEliminationPhase(getMetaAccess()).apply(graph); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements)); Debug.dump(graph, "Graph"); Assert.assertFalse("shouldn't have nodes of type " + clazz, graph.getNodes().filter(clazz).iterator().hasNext()); } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -119,8 +119,8 @@ @Override public LIR call() { - return GraalCompiler.emitHIR(getMetaAccess(), getCodeCache(), getLowerer(), backend.target, graph, replacements, assumptions, null, phasePlan, OptimisticOptimizations.NONE, - new SpeculationLog(), suites); + return GraalCompiler.emitHIR(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), backend.target, graph, replacements, assumptions, null, phasePlan, + OptimisticOptimizations.NONE, new SpeculationLog(), suites); } }); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/CompiledMethodTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/CompiledMethodTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/CompiledMethodTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -56,7 +56,7 @@ public void test1() { Method method = getMethod("testMethod"); final StructuredGraph graph = parse(method); - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), new Assumptions(false), replacements)); new DeadCodeEliminationPhase().apply(graph); for (Node node : graph.getNodes()) { diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EarlyReadEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EarlyReadEliminationTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EarlyReadEliminationTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -41,7 +41,7 @@ protected void processMethod(final String snippet) { graph = parse(snippet); Assumptions assumptions = new Assumptions(false); - HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); + HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); new EarlyReadEliminationPhase(new CanonicalizerPhase(true)).apply(graph, context); } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -233,7 +233,7 @@ new GraphBuilderPhase(getMetaAccess(), GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); Assumptions assumptions = new Assumptions(false); - HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); + HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); new DeadCodeEliminationPhase().apply(graph); new CanonicalizerPhase(true).apply(graph, context); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/IterativeInliningTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/IterativeInliningTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/IterativeInliningTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -88,7 +88,7 @@ private void processMethod(final String snippet) { graph = parse(snippet); - HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); + HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), new Assumptions(false), replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); new IterativeInliningPhase(new CanonicalizerPhase(true)).apply(graph, context); } } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -243,7 +243,7 @@ protected void processMethod(final String snippet) { graph = parse(snippet); Assumptions assumptions = new Assumptions(false); - HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); + HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); new PartialEscapePhase(false, true, new CanonicalizerPhase(true)).apply(graph, context); } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -198,7 +198,7 @@ StructuredGraph graph = parse(snippet); Assumptions assumptions = new Assumptions(false); - HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); + HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); new DeadCodeEliminationPhase().apply(graph); new CanonicalizerPhase(true).apply(graph, context); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/inlining/InliningTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/inlining/InliningTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/inlining/InliningTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -237,7 +237,7 @@ StructuredGraph graph = eagerInfopointMode ? parseDebug(method) : parse(method); PhasePlan phasePlan = getDefaultPhasePlan(eagerInfopointMode); Assumptions assumptions = new Assumptions(true); - HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements, null, phasePlan, OptimisticOptimizations.ALL); + HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements, null, phasePlan, OptimisticOptimizations.ALL); Debug.dump(graph, "Graph"); new CanonicalizerPhase(true).apply(graph, context); new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Fri Oct 11 12:19:09 2013 +0200 @@ -132,8 +132,9 @@ * @return the result of the compilation */ public static CompilationResult compileGraph(final StructuredGraph graph, final CallingConvention cc, final ResolvedJavaMethod installedCodeOwner, final MetaAccessProvider metaAccess, - final CodeCacheProvider codeCache, final LoweringProvider lowerer, final Replacements replacements, final Backend backend, final TargetDescription target, final GraphCache cache, - final PhasePlan plan, final OptimisticOptimizations optimisticOpts, final SpeculationLog speculationLog, final Suites suites, final CompilationResult compilationResult) { + final ConstantReflectionProvider constantReflection, final CodeCacheProvider codeCache, final LoweringProvider lowerer, final Replacements replacements, final Backend backend, + final TargetDescription target, final GraphCache cache, final PhasePlan plan, final OptimisticOptimizations optimisticOpts, final SpeculationLog speculationLog, + final Suites suites, final CompilationResult compilationResult) { Debug.scope("GraalCompiler", new Object[]{graph, codeCache}, new Runnable() { public void run() { @@ -142,7 +143,7 @@ public LIR call() { try (TimerCloseable a = FrontEnd.start()) { - return emitHIR(metaAccess, codeCache, lowerer, target, graph, replacements, assumptions, cache, plan, optimisticOpts, speculationLog, suites); + return emitHIR(metaAccess, codeCache, constantReflection, lowerer, target, graph, replacements, assumptions, cache, plan, optimisticOpts, speculationLog, suites); } } }); @@ -184,8 +185,9 @@ * @param codeCache * @param target */ - public static LIR emitHIR(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, TargetDescription target, final StructuredGraph graph, Replacements replacements, - Assumptions assumptions, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts, final SpeculationLog speculationLog, final Suites suites) { + public static LIR emitHIR(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, LoweringProvider lowerer, TargetDescription target, + final StructuredGraph graph, Replacements replacements, Assumptions assumptions, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts, + final SpeculationLog speculationLog, final Suites suites) { if (speculationLog != null) { speculationLog.snapshot(); @@ -198,13 +200,13 @@ Debug.dump(graph, "initial state"); } - HighTierContext highTierContext = new HighTierContext(metaAccess, codeCache, lowerer, assumptions, replacements, cache, plan, optimisticOpts); + HighTierContext highTierContext = new HighTierContext(metaAccess, codeCache, constantReflection, lowerer, assumptions, replacements, cache, plan, optimisticOpts); suites.getHighTier().apply(graph, highTierContext); - MidTierContext midTierContext = new MidTierContext(metaAccess, codeCache, lowerer, assumptions, replacements, target, optimisticOpts); + MidTierContext midTierContext = new MidTierContext(metaAccess, codeCache, constantReflection, lowerer, assumptions, replacements, target, optimisticOpts); suites.getMidTier().apply(graph, midTierContext); - LowTierContext lowTierContext = new LowTierContext(metaAccess, codeCache, lowerer, assumptions, replacements, target); + LowTierContext lowTierContext = new LowTierContext(metaAccess, codeCache, constantReflection, lowerer, assumptions, replacements, target); suites.getLowTier().apply(graph, lowTierContext); // we do not want to store statistics about OSR compilations because it may prevent inlining diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.graph/src/com/oracle/graal/graph/spi/CanonicalizerTool.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/spi/CanonicalizerTool.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/spi/CanonicalizerTool.java Fri Oct 11 12:19:09 2013 +0200 @@ -32,6 +32,8 @@ MetaAccessProvider getMetaAccess(); + ConstantReflectionProvider getConstantReflection(); + boolean canonicalizeReads(); void removeIfUnused(Node node); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java Fri Oct 11 12:19:09 2013 +0200 @@ -72,7 +72,7 @@ registerForeignCall(DECRYPT, config.cipherBlockChainingDecryptAESCryptStub, NativeCall, PRESERVES_REGISTERS, LEAF, NOT_REEXECUTABLE, ANY_LOCATION); registerForeignCall(UPDATE_BYTES_CRC32, config.updateBytesCRC32Stub, NativeCall, PRESERVES_REGISTERS, LEAF, NOT_REEXECUTABLE, ANY_LOCATION); - convertSnippets = new AMD64ConvertSnippets.Templates(this, this, this, replacements, graalRuntime.getTarget()); + convertSnippets = new AMD64ConvertSnippets.Templates(this, this, this, this, replacements, graalRuntime.getTarget()); super.registerReplacements(replacements); } diff -r 9c2111d10e40 -r 0afe7370260c 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 Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -205,8 +205,8 @@ CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); // create suites everytime, as we modify options for the compiler final Suites suitesLocal = Graal.getRequiredCapability(SuitesProvider.class).createSuites(); - final CompilationResult compResult = GraalCompiler.compileGraph(graph, cc, method, getMetaAccess(), getCodeCache(), getLowerer(), replacements, backend, getCodeCache().getTarget(), null, phasePlan, - OptimisticOptimizations.ALL, new SpeculationLog(), suitesLocal, new CompilationResult()); + final CompilationResult compResult = GraalCompiler.compileGraph(graph, cc, method, getMetaAccess(), getConstantReflection(), getCodeCache(), getLowerer(), replacements, backend, + getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, new SpeculationLog(), suitesLocal, new CompilationResult()); addMethod(method, compResult); AOTCompilation.setValue(originalSetting); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -246,10 +246,10 @@ public void run() { StructuredGraph graph = parse(snippet); - HighTierContext highContext = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), replacements, null, getDefaultPhasePlan(), - OptimisticOptimizations.ALL); - MidTierContext midContext = new MidTierContext(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), replacements, getCodeCache().getTarget(), - OptimisticOptimizations.ALL); + HighTierContext highContext = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), new Assumptions(false), replacements, null, + getDefaultPhasePlan(), OptimisticOptimizations.ALL); + MidTierContext midContext = new MidTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), new Assumptions(false), replacements, + getCodeCache().getTarget(), OptimisticOptimizations.ALL); new InliningPhase(new InliningPhase.InlineEverythingPolicy(), new CanonicalizerPhase(true)).apply(graph, highContext); new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, highContext); new GuardLoweringPhase().apply(graph, midContext); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -632,10 +632,10 @@ public AssertionError call() { final StructuredGraph graph = parse(snippet); - HighTierContext highTierContext = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); + HighTierContext highTierContext = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), new Assumptions(false), replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); new InliningPhase(new CanonicalizerPhase(true)).apply(graph, highTierContext); - MidTierContext midTierContext = new MidTierContext(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), replacements, getCodeCache().getTarget(), OptimisticOptimizations.ALL); + MidTierContext midTierContext = new MidTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), new Assumptions(false), replacements, getCodeCache().getTarget(), OptimisticOptimizations.ALL); new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, highTierContext); new GuardLoweringPhase().apply(graph, midTierContext); diff -r 9c2111d10e40 -r 0afe7370260c 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 Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Fri Oct 11 12:19:09 2013 +0200 @@ -154,8 +154,8 @@ InliningUtil.InlinedBytecodes.add(method.getCodeSize()); HotSpotRuntime runtime = graalRuntime.getRuntime(); CallingConvention cc = getCallingConvention(runtime, Type.JavaCallee, graph.method(), false); - return GraalCompiler.compileGraph(graph, cc, method, runtime, runtime, runtime, replacements, graalRuntime.getBackend(), graalRuntime.getTarget(), graalRuntime.getCache(), - plan, optimisticOpts, method.getSpeculationLog(), suitesProvider.getDefaultSuites(), new CompilationResult()); + return GraalCompiler.compileGraph(graph, cc, method, runtime, runtime, runtime, runtime, replacements, graalRuntime.getBackend(), graalRuntime.getTarget(), + graalRuntime.getCache(), plan, optimisticOpts, method.getSpeculationLog(), suitesProvider.getDefaultSuites(), new CompilationResult()); } }); } finally { diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Fri Oct 11 12:19:09 2013 +0200 @@ -349,7 +349,7 @@ @SuppressWarnings("unchecked") @Override public T getCapability(Class clazz) { - if (clazz == LoweringProvider.class || clazz == CodeCacheProvider.class || clazz == MetaAccessProvider.class) { + if (clazz == LoweringProvider.class || clazz == CodeCacheProvider.class || clazz == MetaAccessProvider.class || clazz == ConstantReflectionProvider.class) { return (T) getRuntime(); } if (clazz == DisassemblerProvider.class || clazz == BytecodeDisassemblerProvider.class || clazz == SuitesProvider.class) { diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java Fri Oct 11 12:19:09 2013 +0200 @@ -40,7 +40,7 @@ private final HotSpotVMConfig config; public HotSpotReplacementsImpl(HotSpotRuntime runtime, Assumptions assumptions, TargetDescription target) { - super(runtime, runtime, runtime, assumptions, target); + super(runtime, runtime, runtime, runtime, assumptions, target); this.config = runtime.config; } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Fri Oct 11 12:19:09 2013 +0200 @@ -98,7 +98,7 @@ /** * HotSpot implementation of {@link LoweringProvider}. */ -public abstract class HotSpotRuntime implements MetaAccessProvider, CodeCacheProvider, LoweringProvider, DisassemblerProvider, BytecodeDisassemblerProvider, SuitesProvider { +public abstract class HotSpotRuntime implements MetaAccessProvider, ConstantReflectionProvider, CodeCacheProvider, LoweringProvider, DisassemblerProvider, BytecodeDisassemblerProvider, SuitesProvider { public static final ForeignCallDescriptor OSR_MIGRATION_END = new ForeignCallDescriptor("OSR_migration_end", void.class, long.class); public static final ForeignCallDescriptor IDENTITY_HASHCODE = new ForeignCallDescriptor("identity_hashcode", int.class, Object.class); @@ -325,16 +325,16 @@ r.registerSubstitutions(CRC32Substitutions.class); r.registerSubstitutions(ReflectionSubstitutions.class); - checkcastDynamicSnippets = new CheckCastDynamicSnippets.Templates(this, this, this, r, graalRuntime.getTarget()); - instanceofSnippets = new InstanceOfSnippets.Templates(this, this, this, r, graalRuntime.getTarget()); - newObjectSnippets = new NewObjectSnippets.Templates(this, this, this, r, graalRuntime.getTarget()); - monitorSnippets = new MonitorSnippets.Templates(this, this, this, r, graalRuntime.getTarget(), c.useFastLocking); - writeBarrierSnippets = new WriteBarrierSnippets.Templates(this, this, this, r, graalRuntime.getTarget()); - boxingSnippets = new BoxingSnippets.Templates(this, this, this, r, graalRuntime.getTarget()); - exceptionObjectSnippets = new LoadExceptionObjectSnippets.Templates(this, this, this, r, graalRuntime.getTarget()); - unsafeLoadSnippets = new UnsafeLoadSnippets.Templates(this, this, this, r, graalRuntime.getTarget()); + checkcastDynamicSnippets = new CheckCastDynamicSnippets.Templates(this, this, this, this, r, graalRuntime.getTarget()); + instanceofSnippets = new InstanceOfSnippets.Templates(this, this, this, this, r, graalRuntime.getTarget()); + newObjectSnippets = new NewObjectSnippets.Templates(this, this, this, this, r, graalRuntime.getTarget()); + monitorSnippets = new MonitorSnippets.Templates(this, this, this, this, r, graalRuntime.getTarget(), c.useFastLocking); + writeBarrierSnippets = new WriteBarrierSnippets.Templates(this, this, this, this, r, graalRuntime.getTarget()); + boxingSnippets = new BoxingSnippets.Templates(this, this, this, this, r, graalRuntime.getTarget()); + exceptionObjectSnippets = new LoadExceptionObjectSnippets.Templates(this, this, this, this, r, graalRuntime.getTarget()); + unsafeLoadSnippets = new UnsafeLoadSnippets.Templates(this, this, this, this, r, graalRuntime.getTarget()); - r.registerSnippetTemplateCache(new UnsafeArrayCopySnippets.Templates(this, this, this, r, graalRuntime.getTarget())); + r.registerSnippetTemplateCache(new UnsafeArrayCopySnippets.Templates(this, this, this, this, r, graalRuntime.getTarget())); } public HotSpotGraalRuntime getGraalRuntime() { @@ -1048,7 +1048,7 @@ private GuardingNode createBoundsCheck(AccessIndexedNode n, LoweringTool tool) { StructuredGraph g = n.graph(); ValueNode array = n.array(); - ValueNode arrayLength = readArrayLength(array, tool.getMetaAccess()); + ValueNode arrayLength = readArrayLength(array, tool.getConstantReflection()); if (arrayLength == null) { Stamp stamp = StampFactory.positiveInt(); ReadNode readArrayLength = g.add(new ReadNode(array, ConstantLocationNode.create(FINAL_LOCATION, Kind.Int, config.arrayLengthOffset, g), stamp, BarrierType.NONE, false)); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java Fri Oct 11 12:19:09 2013 +0200 @@ -93,7 +93,7 @@ } // the canonicalization before loop unrolling is needed to propagate the length into // additions, etc. - PhaseContext context = new PhaseContext(tool.getMetaAccess(), tool.getCodeCache(), tool.getLowerer(), tool.assumptions(), tool.getReplacements()); + PhaseContext context = new PhaseContext(tool.getMetaAccess(), tool.getCodeCache(), tool.getConstantReflection(), tool.getLowerer(), tool.assumptions(), tool.getReplacements()); new CanonicalizerPhase(true).apply(snippetGraph, context); new LoopFullUnrollPhase(new CanonicalizerPhase(true)).apply(snippetGraph, context); new CanonicalizerPhase(true).apply(snippetGraph, context); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CheckCastDynamicSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CheckCastDynamicSnippets.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CheckCastDynamicSnippets.java Fri Oct 11 12:19:09 2013 +0200 @@ -67,8 +67,9 @@ private final SnippetInfo dynamic = snippet(CheckCastDynamicSnippets.class, "checkcastDynamic"); - public Templates(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, TargetDescription target) { - super(metaAccess, codeCache, lowerer, replacements, target); + public Templates(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, + TargetDescription target) { + super(metaAccess, constantReflection, codeCache, lowerer, replacements, target); } public void lower(CheckCastDynamicNode checkcast) { diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java Fri Oct 11 12:19:09 2013 +0200 @@ -200,8 +200,9 @@ private final SnippetInfo instanceofSecondary = snippet(InstanceOfSnippets.class, "instanceofSecondary"); private final SnippetInfo instanceofDynamic = snippet(InstanceOfSnippets.class, "instanceofDynamic"); - public Templates(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, TargetDescription target) { - super(metaAccess, codeCache, lowerer, replacements, target); + public Templates(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, + TargetDescription target) { + super(metaAccess, constantReflection, codeCache, lowerer, replacements, target); } @Override diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/LoadExceptionObjectSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/LoadExceptionObjectSnippets.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/LoadExceptionObjectSnippets.java Fri Oct 11 12:19:09 2013 +0200 @@ -65,8 +65,9 @@ private final SnippetInfo loadException = snippet(LoadExceptionObjectSnippets.class, "loadException"); - public Templates(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, TargetDescription target) { - super(metaAccess, codeCache, lowerer, replacements, target); + public Templates(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, + TargetDescription target) { + super(metaAccess, constantReflection, codeCache, lowerer, replacements, target); } public void lower(LoadExceptionObjectNode loadExceptionObject) { diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java Fri Oct 11 12:19:09 2013 +0200 @@ -415,8 +415,9 @@ private final boolean useFastLocking; - public Templates(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, TargetDescription target, boolean useFastLocking) { - super(metaAccess, codeCache, lowerer, replacements, target); + public Templates(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, + TargetDescription target, boolean useFastLocking) { + super(metaAccess, constantReflection, codeCache, lowerer, replacements, target); this.useFastLocking = useFastLocking; } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java Fri Oct 11 12:19:09 2013 +0200 @@ -296,8 +296,9 @@ private final SnippetInfo allocateArrayDynamic = snippet(NewObjectSnippets.class, "allocateArrayDynamic"); private final SnippetInfo newmultiarray = snippet(NewObjectSnippets.class, "newmultiarray"); - public Templates(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, TargetDescription target) { - super(metaAccess, codeCache, lowerer, replacements, target); + public Templates(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, + TargetDescription target) { + super(metaAccess, constantReflection, codeCache, lowerer, replacements, target); } /** diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopySnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopySnippets.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopySnippets.java Fri Oct 11 12:19:09 2013 +0200 @@ -256,8 +256,9 @@ private final SnippetInfo[] arraycopySnippets; private final SnippetInfo genericPrimitiveSnippet; - public Templates(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, TargetDescription target) { - super(metaAccess, codeCache, lowerer, replacements, target); + public Templates(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, + TargetDescription target) { + super(metaAccess, constantReflection, codeCache, lowerer, replacements, target); arraycopySnippets = new SnippetInfo[Kind.values().length]; arraycopySnippets[Kind.Boolean.ordinal()] = snippet(UnsafeArrayCopySnippets.class, "arraycopyBoolean"); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeLoadSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeLoadSnippets.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeLoadSnippets.java Fri Oct 11 12:19:09 2013 +0200 @@ -53,8 +53,9 @@ private final SnippetInfo unsafeLoad = snippet(UnsafeLoadSnippets.class, "lowerUnsafeLoad"); - public Templates(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, TargetDescription target) { - super(metaAccess, codeCache, lowerer, replacements, target); + public Templates(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, + TargetDescription target) { + super(metaAccess, constantReflection, codeCache, lowerer, replacements, target); } public void lower(UnsafeLoadNode load, @SuppressWarnings("unused") LoweringTool tool) { diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java Fri Oct 11 12:19:09 2013 +0200 @@ -336,8 +336,9 @@ private final SnippetInfo g1ArrayRangePreWriteBarrier = snippet(WriteBarrierSnippets.class, "g1ArrayRangePreWriteBarrier"); private final SnippetInfo g1ArrayRangePostWriteBarrier = snippet(WriteBarrierSnippets.class, "g1ArrayRangePostWriteBarrier"); - public Templates(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, TargetDescription target) { - super(metaAccess, codeCache, lowerer, replacements, target); + public Templates(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, + TargetDescription target) { + super(metaAccess, constantReflection, codeCache, lowerer, replacements, target); } public void lower(SerialWriteBarrier writeBarrier, @SuppressWarnings("unused") LoweringTool tool) { diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Fri Oct 11 12:19:09 2013 +0200 @@ -304,7 +304,7 @@ private void inline(InvokeNode invoke) { ResolvedJavaMethod method = ((MethodCallTargetNode) invoke.callTarget()).targetMethod(); - ReplacementsImpl repl = new ReplacementsImpl(runtime, runtime, runtime, new Assumptions(false), runtime.getTarget()); + ReplacementsImpl repl = new ReplacementsImpl(runtime, runtime, runtime, runtime, new Assumptions(false), runtime.getTarget()); StructuredGraph calleeGraph = repl.makeGraph(method, null, null, false); InliningUtil.inline(invoke, calleeGraph, false); } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java Fri Oct 11 12:19:09 2013 +0200 @@ -44,7 +44,7 @@ static class Template extends AbstractTemplates { Template(HotSpotRuntime runtime, Replacements replacements, TargetDescription target, Class declaringClass) { - super(runtime, runtime, runtime, replacements, target); + super(runtime, runtime, runtime, runtime, replacements, target); this.info = snippet(declaringClass, null); } diff -r 9c2111d10e40 -r 0afe7370260c 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 Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Fri Oct 11 12:19:09 2013 +0200 @@ -156,8 +156,8 @@ phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); // The stub itself needs the incoming calling convention. CallingConvention incomingCc = linkage.getIncomingCallingConvention(); - final CompilationResult compResult = GraalCompiler.compileGraph(graph, incomingCc, getInstalledCodeOwner(), runtime, runtime, runtime, replacements, backend, runtime.getTarget(), - null, phasePlan, OptimisticOptimizations.ALL, new SpeculationLog(), runtime.getDefaultSuites(), new CompilationResult()); + final CompilationResult compResult = GraalCompiler.compileGraph(graph, incomingCc, getInstalledCodeOwner(), runtime, runtime, runtime, runtime, replacements, backend, + runtime.getTarget(), null, phasePlan, OptimisticOptimizations.ALL, new SpeculationLog(), runtime.getDefaultSuites(), new CompilationResult()); assert destroyedRegisters != null; code = Debug.scope("CodeInstall", new Callable() { diff -r 9c2111d10e40 -r 0afe7370260c 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 Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java Fri Oct 11 12:19:09 2013 +0200 @@ -42,6 +42,7 @@ public static void compileMethod(ResolvedJavaMethod method) { MetaAccessProvider metaAccess = Graal.getRequiredCapability(MetaAccessProvider.class); CodeCacheProvider codeCache = Graal.getRequiredCapability(CodeCacheProvider.class); + ConstantReflectionProvider constantReflection = Graal.getRequiredCapability(ConstantReflectionProvider.class); LoweringProvider lowerer = Graal.getRequiredCapability(LoweringProvider.class); Replacements replacements = Graal.getRequiredCapability(Replacements.class); Suites suites = Graal.getRequiredCapability(SuitesProvider.class).createSuites(); @@ -52,7 +53,7 @@ phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); CallingConvention cc = getCallingConvention(codeCache, Type.JavaCallee, graph.method(), false); Backend backend = Graal.getRequiredCapability(Backend.class); - GraalCompiler.compileGraph(graph, cc, method, metaAccess, codeCache, lowerer, replacements, backend, codeCache.getTarget(), null, phasePlan, OptimisticOptimizations.ALL, new SpeculationLog(), - suites, new CompilationResult()); + GraalCompiler.compileGraph(graph, cc, method, metaAccess, constantReflection, codeCache, lowerer, replacements, backend, codeCache.getTarget(), null, phasePlan, OptimisticOptimizations.ALL, + new SpeculationLog(), suites, new CompilationResult()); } } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Fri Oct 11 12:19:09 2013 +0200 @@ -183,7 +183,7 @@ if (this.trueSuccessorProbability < probabilityB) { // Reordering of those two if statements is beneficial from the point of view of // their probabilities. - if (prepareForSwap(tool.getMetaAccess(), condition(), nextIf.condition(), this.trueSuccessorProbability, probabilityB)) { + if (prepareForSwap(tool.getConstantReflection(), condition(), nextIf.condition(), this.trueSuccessorProbability, probabilityB)) { // Reording is allowed from (if1 => begin => if2) to (if2 => begin => if1). assert intermediateBegin.next() == nextIf; AbstractBeginNode bothFalseBegin = nextIf.falseSuccessor(); @@ -208,7 +208,7 @@ } } - private static boolean prepareForSwap(MetaAccessProvider metaAccess, LogicNode a, LogicNode b, double probabilityA, double probabilityB) { + private static boolean prepareForSwap(ConstantReflectionProvider constantReflection, LogicNode a, LogicNode b, double probabilityA, double probabilityB) { if (a instanceof InstanceOfNode) { InstanceOfNode instanceOfA = (InstanceOfNode) a; if (b instanceof IsNullNode) { @@ -297,13 +297,13 @@ } } else if (conditionA == Condition.EQ && conditionB == Condition.EQ) { boolean canSwap = false; - if ((compareA.x() == compareB.x() && valuesDistinct(metaAccess, compareA.y(), compareB.y()))) { + if ((compareA.x() == compareB.x() && valuesDistinct(constantReflection, compareA.y(), compareB.y()))) { canSwap = true; - } else if ((compareA.x() == compareB.y() && valuesDistinct(metaAccess, compareA.y(), compareB.x()))) { + } else if ((compareA.x() == compareB.y() && valuesDistinct(constantReflection, compareA.y(), compareB.x()))) { canSwap = true; - } else if ((compareA.y() == compareB.x() && valuesDistinct(metaAccess, compareA.x(), compareB.y()))) { + } else if ((compareA.y() == compareB.x() && valuesDistinct(constantReflection, compareA.x(), compareB.y()))) { canSwap = true; - } else if ((compareA.y() == compareB.y() && valuesDistinct(metaAccess, compareA.x(), compareB.x()))) { + } else if ((compareA.y() == compareB.y() && valuesDistinct(constantReflection, compareA.x(), compareB.x()))) { canSwap = true; } @@ -318,9 +318,9 @@ return false; } - private static boolean valuesDistinct(MetaAccessProvider metaAccess, ValueNode a, ValueNode b) { + private static boolean valuesDistinct(ConstantReflectionProvider constantReflection, ValueNode a, ValueNode b) { if (a.isConstant() && b.isConstant()) { - return !metaAccess.constantEquals(a.asConstant(), b.asConstant()); + return !constantReflection.constantEquals(a.asConstant(), b.asConstant()); } Stamp stampA = a.stamp(); @@ -487,7 +487,7 @@ for (int i = 0; i < xs.length; i++) { AbstractEndNode end = ends.next(); phiValues.put(end, phi.valueAt(end)); - if (compare.condition().foldCondition(xs[i], ys[i], tool.getMetaAccess(), compare.unorderedIsTrue())) { + if (compare.condition().foldCondition(xs[i], ys[i], tool.getConstantReflection(), compare.unorderedIsTrue())) { trueEnds.add(end); } else { falseEnds.add(end); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/CompareNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/CompareNode.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/CompareNode.java Fri Oct 11 12:19:09 2013 +0200 @@ -77,13 +77,13 @@ public void generate(LIRGeneratorTool gen) { } - private LogicNode optimizeConditional(Constant constant, ConditionalNode conditionalNode, MetaAccessProvider metaAccess, Condition cond) { + private LogicNode optimizeConditional(Constant constant, ConditionalNode conditionalNode, ConstantReflectionProvider constantReflection, Condition cond) { Constant trueConstant = conditionalNode.trueValue().asConstant(); Constant falseConstant = conditionalNode.falseValue().asConstant(); - if (falseConstant != null && trueConstant != null && metaAccess != null) { - boolean trueResult = cond.foldCondition(trueConstant, constant, metaAccess, unorderedIsTrue()); - boolean falseResult = cond.foldCondition(falseConstant, constant, metaAccess, unorderedIsTrue()); + if (falseConstant != null && trueConstant != null && constantReflection != null) { + boolean trueResult = cond.foldCondition(trueConstant, constant, constantReflection, unorderedIsTrue()); + boolean falseResult = cond.foldCondition(falseConstant, constant, constantReflection, unorderedIsTrue()); if (trueResult == falseResult) { return LogicConstantNode.forBoolean(trueResult, graph()); @@ -118,17 +118,17 @@ @Override public Node canonical(CanonicalizerTool tool) { if (x().isConstant() && y().isConstant() && tool.getMetaAccess() != null) { - return LogicConstantNode.forBoolean(condition().foldCondition(x().asConstant(), y().asConstant(), tool.getMetaAccess(), unorderedIsTrue()), graph()); + return LogicConstantNode.forBoolean(condition().foldCondition(x().asConstant(), y().asConstant(), tool.getConstantReflection(), unorderedIsTrue()), graph()); } if (x().isConstant()) { if (y() instanceof ConditionalNode) { - return optimizeConditional(x().asConstant(), (ConditionalNode) y(), tool.getMetaAccess(), condition().mirror()); + return optimizeConditional(x().asConstant(), (ConditionalNode) y(), tool.getConstantReflection(), condition().mirror()); } else if (y() instanceof NormalizeCompareNode) { return optimizeNormalizeCmp(x().asConstant(), (NormalizeCompareNode) y(), true); } } else if (y().isConstant()) { if (x() instanceof ConditionalNode) { - return optimizeConditional(y().asConstant(), (ConditionalNode) x(), tool.getMetaAccess(), condition()); + return optimizeConditional(y().asConstant(), (ConditionalNode) x(), tool.getConstantReflection(), condition()); } else if (x() instanceof NormalizeCompareNode) { return optimizeNormalizeCmp(y().asConstant(), (NormalizeCompareNode) x(), false); } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/Condition.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/Condition.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/Condition.java Fri Oct 11 12:19:09 2013 +0200 @@ -317,13 +317,13 @@ * * @param lt the constant on the left side of the comparison * @param rt the constant on the right side of the comparison - * @param metaAccess needed to compare runtime-specific types + * @param constantReflection needed to compare constants * @return {@link Boolean#TRUE} if the comparison is known to be true, {@link Boolean#FALSE} if * the comparison is known to be false */ - public boolean foldCondition(Constant lt, Constant rt, MetaAccessProvider metaAccess) { + public boolean foldCondition(Constant lt, Constant rt, ConstantReflectionProvider constantReflection) { assert lt.getKind() != Kind.Double && lt.getKind() != Kind.Float && rt.getKind() != Kind.Double && rt.getKind() != Kind.Float; - return foldCondition(lt, rt, metaAccess, false); + return foldCondition(lt, rt, constantReflection, false); } /** @@ -331,12 +331,12 @@ * * @param lt the constant on the left side of the comparison * @param rt the constant on the right side of the comparison - * @param metaAccess needed to compare runtime-specific types + * @param constantReflection needed to compare constants * @param unorderedIsTrue true if an undecided float comparison should result in "true" * @return true if the comparison is known to be true, false if the comparison is known to be * false */ - public boolean foldCondition(Constant lt, Constant rt, MetaAccessProvider metaAccess, boolean unorderedIsTrue) { + public boolean foldCondition(Constant lt, Constant rt, ConstantReflectionProvider constantReflection, boolean unorderedIsTrue) { switch (lt.getKind()) { case Boolean: case Byte: @@ -401,9 +401,9 @@ case Object: { switch (this) { case EQ: - return metaAccess.constantEquals(lt, rt); + return constantReflection.constantEquals(lt, rt); case NE: - return !metaAccess.constantEquals(lt, rt); + return !constantReflection.constantEquals(lt, rt); default: throw new GraalInternalError("expected condition: %s", this); } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java Fri Oct 11 12:19:09 2013 +0200 @@ -72,7 +72,7 @@ if (object.kind() == Kind.Object) { Object base = object.asConstant().asObject(); if (base != null) { - Constant constant = tool.getMetaAccess().readUnsafeConstant(kind, base, displacement, compressible); + Constant constant = tool.getConstantReflection().readUnsafeConstant(kind, base, displacement, compressible); if (constant != null) { return ConstantNode.forConstant(constant, metaAccess, read.graph()); } @@ -80,7 +80,7 @@ } else if (object.kind() == Kind.Long || object.kind().getStackKind() == Kind.Int) { long base = object.asConstant().asLong(); if (base != 0L) { - Constant constant = tool.getMetaAccess().readUnsafeConstant(kind, null, base + displacement, compressible); + Constant constant = tool.getConstantReflection().readUnsafeConstant(kind, null, base + displacement, compressible); if (constant != null) { return ConstantNode.forConstant(constant, metaAccess, read.graph()); } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java Fri Oct 11 12:19:09 2013 +0200 @@ -47,7 +47,7 @@ @Override public Node canonical(CanonicalizerTool tool) { - ValueNode length = readArrayLength(array(), tool.getMetaAccess()); + ValueNode length = readArrayLength(array(), tool.getConstantReflection()); if (length != null) { return length; } @@ -60,17 +60,17 @@ * @param array an array * @return a node representing the length of {@code array} or null if it is not available */ - public static ValueNode readArrayLength(ValueNode array, MetaAccessProvider metaAccess) { + public static ValueNode readArrayLength(ValueNode array, ConstantReflectionProvider constantReflection) { if (array instanceof ArrayLengthProvider) { ValueNode length = ((ArrayLengthProvider) array).length(); if (length != null) { return length; } } - if (metaAccess != null && array.isConstant() && !array.isNullConstant()) { + if (constantReflection != null && array.isConstant() && !array.isNullConstant()) { Constant constantValue = array.asConstant(); if (constantValue != null && constantValue.isNonNull()) { - Integer constantLength = metaAccess.lookupArrayLength(constantValue); + Integer constantLength = constantReflection.lookupArrayLength(constantValue); if (constantLength != null) { return ConstantNode.forInt(constantLength, array.graph()); } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeSwitchNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeSwitchNode.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeSwitchNode.java Fri Oct 11 12:19:09 2013 +0200 @@ -86,7 +86,7 @@ for (int i = 0; i < keyCount(); i++) { Constant typeHub = keyAt(i); assert constant.getKind() == typeHub.getKind(); - if (tool.getMetaAccess().constantEquals(constant, typeHub)) { + if (tool.getConstantReflection().constantEquals(constant, typeHub)) { survivingEdge = keySuccessorIndex(i); } } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java Fri Oct 11 12:19:09 2013 +0200 @@ -37,6 +37,8 @@ LoweringProvider getLowerer(); + ConstantReflectionProvider getConstantReflection(); + Replacements getReplacements(); GuardingNode createNullCheckGuard(GuardedNode guardedNode, ValueNode object); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java Fri Oct 11 12:19:09 2013 +0200 @@ -67,7 +67,7 @@ @Override protected void run(StructuredGraph graph, PhaseContext context) { - new Instance(context.getMetaAccess(), context.getAssumptions(), canonicalizeReads, customCanonicalizer).run(graph); + new Instance(context, canonicalizeReads, customCanonicalizer).run(graph); } /** @@ -79,7 +79,7 @@ } public void applyIncremental(StructuredGraph graph, PhaseContext context, int newNodesMark, boolean dumpGraph) { - new Instance(context.getMetaAccess(), context.getAssumptions(), canonicalizeReads, newNodesMark, customCanonicalizer).apply(graph, dumpGraph); + new Instance(context, canonicalizeReads, newNodesMark, customCanonicalizer).apply(graph, dumpGraph); } /** @@ -91,7 +91,7 @@ } public void applyIncremental(StructuredGraph graph, PhaseContext context, Iterable workingSet, boolean dumpGraph) { - new Instance(context.getMetaAccess(), context.getAssumptions(), canonicalizeReads, workingSet, customCanonicalizer).apply(graph, dumpGraph); + new Instance(context, canonicalizeReads, workingSet, customCanonicalizer).apply(graph, dumpGraph); } public void applyIncremental(StructuredGraph graph, PhaseContext context, Iterable workingSet, int newNodesMark) { @@ -99,19 +99,18 @@ } public void applyIncremental(StructuredGraph graph, PhaseContext context, Iterable workingSet, int newNodesMark, boolean dumpGraph) { - new Instance(context.getMetaAccess(), context.getAssumptions(), canonicalizeReads, workingSet, newNodesMark, customCanonicalizer).apply(graph, dumpGraph); + new Instance(context, canonicalizeReads, workingSet, newNodesMark, customCanonicalizer).apply(graph, dumpGraph); } @Deprecated public void addToPhasePlan(PhasePlan plan, PhaseContext context) { - plan.addPhase(PhasePosition.AFTER_PARSING, new Instance(context.getMetaAccess(), context.getAssumptions(), canonicalizeReads, customCanonicalizer)); + plan.addPhase(PhasePosition.AFTER_PARSING, new Instance(context, canonicalizeReads, customCanonicalizer)); } private static final class Instance extends Phase { private final int newNodesMark; - private final Assumptions assumptions; - private final MetaAccessProvider metaAccess; + private final PhaseContext context; private final CustomCanonicalizer customCanonicalizer; private final Iterable initWorkingSet; private final boolean canonicalizeReads; @@ -119,23 +118,22 @@ private NodeWorkList workList; private Tool tool; - private Instance(MetaAccessProvider metaAccess, Assumptions assumptions, boolean canonicalizeReads, CustomCanonicalizer customCanonicalizer) { - this(metaAccess, assumptions, canonicalizeReads, null, 0, customCanonicalizer); + private Instance(PhaseContext context, boolean canonicalizeReads, CustomCanonicalizer customCanonicalizer) { + this(context, canonicalizeReads, null, 0, customCanonicalizer); } - private Instance(MetaAccessProvider metaAccess, Assumptions assumptions, boolean canonicalizeReads, Iterable workingSet, CustomCanonicalizer customCanonicalizer) { - this(metaAccess, assumptions, canonicalizeReads, workingSet, 0, customCanonicalizer); + private Instance(PhaseContext context, boolean canonicalizeReads, Iterable workingSet, CustomCanonicalizer customCanonicalizer) { + this(context, canonicalizeReads, workingSet, 0, customCanonicalizer); } - private Instance(MetaAccessProvider metaAccess, Assumptions assumptions, boolean canonicalizeReads, int newNodesMark, CustomCanonicalizer customCanonicalizer) { - this(metaAccess, assumptions, canonicalizeReads, null, newNodesMark, customCanonicalizer); + private Instance(PhaseContext context, boolean canonicalizeReads, int newNodesMark, CustomCanonicalizer customCanonicalizer) { + this(context, canonicalizeReads, null, newNodesMark, customCanonicalizer); } - private Instance(MetaAccessProvider metaAccess, Assumptions assumptions, boolean canonicalizeReads, Iterable workingSet, int newNodesMark, CustomCanonicalizer customCanonicalizer) { + private Instance(PhaseContext context, boolean canonicalizeReads, Iterable workingSet, int newNodesMark, CustomCanonicalizer customCanonicalizer) { super("Canonicalizer"); this.newNodesMark = newNodesMark; - this.assumptions = assumptions; - this.metaAccess = metaAccess; + this.context = context; this.canonicalizeReads = canonicalizeReads; this.customCanonicalizer = customCanonicalizer; this.initWorkingSet = workingSet; @@ -192,7 +190,7 @@ boolean improvedStamp = tryInferStamp(valueNode); Constant constant = valueNode.stamp().asConstant(); if (constant != null && !(node instanceof ConstantNode)) { - performReplacement(valueNode, ConstantNode.forConstant(constant, metaAccess, valueNode.graph())); + performReplacement(valueNode, ConstantNode.forConstant(constant, context.getMetaAccess(), valueNode.graph())); } else if (improvedStamp) { // the improved stamp may enable additional canonicalization tryCanonicalize(valueNode, nodeClass); @@ -372,12 +370,17 @@ */ @Override public Assumptions assumptions() { - return assumptions; + return context.getAssumptions(); } @Override public MetaAccessProvider getMetaAccess() { - return metaAccess; + return context.getMetaAccess(); + } + + @Override + public ConstantReflectionProvider getConstantReflection() { + return context.getConstantReflection(); } @Override diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Fri Oct 11 12:19:09 2013 +0200 @@ -184,7 +184,7 @@ InlineInfo callee = calleeInfo.callee(); try { List invokeUsages = callee.invoke().asNode().usages().snapshot(); - callee.inline(context.getMetaAccess(), context.getCodeCache(), callerAssumptions, context.getReplacements()); + callee.inline(context.getMetaAccess(), context.getConstantReflection(), context.getCodeCache(), callerAssumptions, context.getReplacements()); callerAssumptions.record(calleeInfo.assumptions()); metricInliningRuns.increment(); Debug.dump(callerGraph, "after %s", callee); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Fri Oct 11 12:19:09 2013 +0200 @@ -292,8 +292,10 @@ * Performs the inlining described by this object and returns the node that represents the * return value of the inlined method (or null for void methods and methods that have no * non-exceptional exit). + * + * @param constantReflection TODO */ - void inline(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, Assumptions assumptions, Replacements replacements); + void inline(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, Assumptions assumptions, Replacements replacements); /** * Try to make the call static bindable to avoid interface and virtual method calls. @@ -367,7 +369,7 @@ } @Override - public void inline(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, Assumptions assumptions, Replacements replacements) { + public void inline(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, Assumptions assumptions, Replacements replacements) { inline(invoke, concrete, inlineableElement, assumptions, !suppressNullCheck); } @@ -470,7 +472,7 @@ } @Override - public void inline(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, Assumptions assumptions, Replacements replacements) { + public void inline(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, Assumptions assumptions, Replacements replacements) { createGuard(graph(), metaAccess); inline(invoke, concrete, inlineableElement, assumptions, false); } @@ -587,11 +589,11 @@ } @Override - public void inline(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, Assumptions assumptions, Replacements replacements) { + public void inline(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, Assumptions assumptions, Replacements replacements) { if (hasSingleMethod()) { inlineSingleMethod(graph(), metaAccess, assumptions); } else { - inlineMultipleMethods(graph(), metaAccess, assumptions, replacements, codeCache); + inlineMultipleMethods(graph(), metaAccess, constantReflection, assumptions, replacements, codeCache); } } @@ -603,7 +605,8 @@ return notRecordedTypeProbability > 0; } - private void inlineMultipleMethods(StructuredGraph graph, MetaAccessProvider metaAccess, Assumptions assumptions, Replacements replacements, CodeCacheProvider codeCache) { + private void inlineMultipleMethods(StructuredGraph graph, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, Assumptions assumptions, Replacements replacements, + CodeCacheProvider codeCache) { int numberOfMethods = concretes.size(); FixedNode continuation = invoke.next(); @@ -713,8 +716,8 @@ if (opportunities > 0) { metricInliningTailDuplication.increment(); Debug.log("MultiTypeGuardInlineInfo starting tail duplication (%d opportunities)", opportunities); - TailDuplicationPhase.tailDuplicate(returnMerge, TailDuplicationPhase.TRUE_DECISION, replacementNodes, new PhaseContext(metaAccess, codeCache, null, assumptions, replacements), - new CanonicalizerPhase(!AOTCompilation.getValue())); + TailDuplicationPhase.tailDuplicate(returnMerge, TailDuplicationPhase.TRUE_DECISION, replacementNodes, new PhaseContext(metaAccess, codeCache, constantReflection, null, + assumptions, replacements), new CanonicalizerPhase(!AOTCompilation.getValue())); } } } @@ -1006,9 +1009,9 @@ } @Override - public void inline(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, Assumptions assumptions, Replacements replacements) { + public void inline(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, Assumptions assumptions, Replacements replacements) { assumptions.record(takenAssumption); - super.inline(metaAccess, codeCache, assumptions, replacements); + super.inline(metaAccess, constantReflection, codeCache, assumptions, replacements); } @Override diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java Fri Oct 11 12:19:09 2013 +0200 @@ -68,6 +68,11 @@ } @Override + public ConstantReflectionProvider getConstantReflection() { + return context.getConstantReflection(); + } + + @Override public MetaAccessProvider getMetaAccess() { return context.getMetaAccess(); } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java Fri Oct 11 12:19:09 2013 +0200 @@ -34,9 +34,9 @@ private final GraphCache cache; private final OptimisticOptimizations optimisticOpts; - public HighTierContext(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Assumptions assumptions, Replacements replacements, GraphCache cache, PhasePlan plan, - OptimisticOptimizations optimisticOpts) { - super(metaAccess, codeCache, lowerer, assumptions, replacements); + public HighTierContext(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, LoweringProvider lowerer, Assumptions assumptions, + Replacements replacements, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts) { + super(metaAccess, codeCache, constantReflection, lowerer, assumptions, replacements); this.plan = plan; this.cache = cache; this.optimisticOpts = optimisticOpts; @@ -55,6 +55,7 @@ } public HighTierContext replaceAssumptions(Assumptions newAssumptions) { - return new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), newAssumptions, getReplacements(), getGraphCache(), getPhasePlan(), getOptimisticOptimizations()); + return new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), newAssumptions, getReplacements(), getGraphCache(), getPhasePlan(), + getOptimisticOptimizations()); } } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/LowTierContext.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/LowTierContext.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/LowTierContext.java Fri Oct 11 12:19:09 2013 +0200 @@ -30,8 +30,9 @@ private final TargetDescription target; - public LowTierContext(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Assumptions assumptions, Replacements replacements, TargetDescription target) { - super(metaAccess, codeCache, lowerer, assumptions, replacements); + public LowTierContext(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, LoweringProvider lowerer, Assumptions assumptions, + Replacements replacements, TargetDescription target) { + super(metaAccess, codeCache, constantReflection, lowerer, assumptions, replacements); this.target = target; } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java Fri Oct 11 12:19:09 2013 +0200 @@ -32,8 +32,9 @@ private final TargetDescription target; private final OptimisticOptimizations optimisticOpts; - public MidTierContext(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Assumptions assumptions, Replacements replacements, TargetDescription target, OptimisticOptimizations optimisticOpts) { - super(metaAccess, codeCache, lowerer, assumptions, replacements); + public MidTierContext(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, LoweringProvider lowerer, Assumptions assumptions, + Replacements replacements, TargetDescription target, OptimisticOptimizations optimisticOpts) { + super(metaAccess, codeCache, constantReflection, lowerer, assumptions, replacements); this.target = target; this.optimisticOpts = optimisticOpts; } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/PhaseContext.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/PhaseContext.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/PhaseContext.java Fri Oct 11 12:19:09 2013 +0200 @@ -31,12 +31,15 @@ private final MetaAccessProvider metaAccess; private final CodeCacheProvider codeCache; private final LoweringProvider lowerer; + private final ConstantReflectionProvider constantReflection; private final Assumptions assumptions; private final Replacements replacements; - public PhaseContext(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Assumptions assumptions, Replacements replacements) { + public PhaseContext(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, LoweringProvider lowerer, Assumptions assumptions, + Replacements replacements) { this.metaAccess = metaAccess; this.codeCache = codeCache; + this.constantReflection = constantReflection; this.lowerer = lowerer; this.assumptions = assumptions; this.replacements = replacements; @@ -58,6 +61,10 @@ return assumptions; } + public ConstantReflectionProvider getConstantReflection() { + return constantReflection; + } + public Replacements getReplacements() { return replacements; } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64ConvertSnippets.java --- a/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64ConvertSnippets.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64ConvertSnippets.java Fri Oct 11 12:19:09 2013 +0200 @@ -149,8 +149,9 @@ private final EnumMap snippets; - public Templates(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, TargetDescription target) { - super(metaAccess, codeCache, lowerer, replacements, target); + public Templates(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, + TargetDescription target) { + super(metaAccess, constantReflection, codeCache, lowerer, replacements, target); snippets = new EnumMap<>(Op.class); snippets.put(Op.F2I, snippet(AMD64ConvertSnippets.class, "f2i")); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/MethodSubstitutionTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/MethodSubstitutionTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/MethodSubstitutionTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -51,7 +51,7 @@ StructuredGraph graph = parse(snippet); PhasePlan phasePlan = getDefaultPhasePlan(); Assumptions assumptions = new Assumptions(true); - HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements, null, phasePlan, OptimisticOptimizations.ALL); + HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements, null, phasePlan, OptimisticOptimizations.ALL); Debug.dump(graph, "Graph"); new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); Debug.dump(graph, "Graph"); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ObjectAccessTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ObjectAccessTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ObjectAccessTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -49,7 +49,7 @@ public ObjectAccessTest() { target = Graal.getRequiredCapability(CodeCacheProvider.class).getTarget(); - installer = new ReplacementsImpl(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), target); + installer = new ReplacementsImpl(getMetaAccess(), getConstantReflection(), getCodeCache(), getLowerer(), new Assumptions(false), target); } private static final ThreadLocal inliningPolicy = new ThreadLocal<>(); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/PointerTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/PointerTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/PointerTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -53,7 +53,7 @@ public PointerTest() { target = Graal.getRequiredCapability(CodeCacheProvider.class).getTarget(); - installer = new ReplacementsImpl(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), target); + installer = new ReplacementsImpl(getMetaAccess(), getConstantReflection(), getCodeCache(), getLowerer(), new Assumptions(false), target); } private static final ThreadLocal inliningPolicy = new ThreadLocal<>(); @@ -404,7 +404,7 @@ private void assertNumWordCasts(String snippetName, int expectedWordCasts) { Assumptions assumptions = new Assumptions(true); - HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements, null, null, OptimisticOptimizations.ALL); + HighTierContext context = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements, null, null, OptimisticOptimizations.ALL); StructuredGraph graph = parse(snippetName); new CanonicalizerPhase(false).apply(graph, context); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/WordTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/WordTest.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/WordTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -43,7 +43,7 @@ public WordTest() { TargetDescription target = Graal.getRequiredCapability(CodeCacheProvider.class).getTarget(); - installer = new ReplacementsImpl(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), target); + installer = new ReplacementsImpl(getMetaAccess(), getConstantReflection(), getCodeCache(), getLowerer(), new Assumptions(false), target); } private static final ThreadLocal inliningPolicy = new ThreadLocal<>(); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BoxingSnippets.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BoxingSnippets.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BoxingSnippets.java Fri Oct 11 12:19:09 2013 +0200 @@ -206,8 +206,9 @@ private final EnumMap boxSnippets = new EnumMap<>(Kind.class); private final EnumMap unboxSnippets = new EnumMap<>(Kind.class); - public Templates(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, TargetDescription target) { - super(metaAccess, codeCache, lowerer, replacements, target); + public Templates(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, + TargetDescription target) { + super(metaAccess, constantReflection, codeCache, lowerer, replacements, target); for (Kind kind : new Kind[]{Kind.Boolean, Kind.Byte, Kind.Char, Kind.Double, Kind.Float, Kind.Int, Kind.Long, Kind.Short}) { boxSnippets.put(kind, snippet(BoxingSnippets.class, kind.getJavaName() + "ValueOf")); unboxSnippets.put(kind, snippet(BoxingSnippets.class, kind.getJavaName() + "Value")); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java Fri Oct 11 12:19:09 2013 +0200 @@ -53,8 +53,9 @@ */ public abstract class InstanceOfSnippetsTemplates extends AbstractTemplates { - public InstanceOfSnippetsTemplates(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, TargetDescription target) { - super(metaAccess, codeCache, lowerer, replacements, target); + public InstanceOfSnippetsTemplates(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, + TargetDescription target) { + super(metaAccess, constantReflection, codeCache, lowerer, replacements, target); } /** diff -r 9c2111d10e40 -r 0afe7370260c 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 Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Fri Oct 11 12:19:09 2013 +0200 @@ -53,6 +53,7 @@ protected final MetaAccessProvider metaAccess; protected final CodeCacheProvider codeCache; + protected final ConstantReflectionProvider constantReflection; protected final LoweringProvider lowerer; protected final TargetDescription target; protected final Assumptions assumptions; @@ -69,8 +70,10 @@ private final Set forcedSubstitutions; private final Map, SnippetTemplateCache> snippetTemplateCache; - public ReplacementsImpl(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Assumptions assumptions, TargetDescription target) { + public ReplacementsImpl(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, LoweringProvider lowerer, Assumptions assumptions, + TargetDescription target) { this.metaAccess = metaAccess; + this.constantReflection = constantReflection; this.codeCache = codeCache; this.lowerer = lowerer; this.target = target; @@ -340,7 +343,7 @@ new WordTypeRewriterPhase(metaAccess, target.wordKind).apply(graph); if (OptCanonicalizer.getValue()) { - new CanonicalizerPhase(true).apply(graph, new PhaseContext(metaAccess, codeCache, lowerer, assumptions, ReplacementsImpl.this)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(metaAccess, codeCache, constantReflection, lowerer, assumptions, ReplacementsImpl.this)); } } }); @@ -360,7 +363,7 @@ */ protected void afterInline(StructuredGraph caller, StructuredGraph callee, Object beforeInlineData) { if (OptCanonicalizer.getValue()) { - new CanonicalizerPhase(true).apply(caller, new PhaseContext(metaAccess, codeCache, lowerer, assumptions, ReplacementsImpl.this)); + new CanonicalizerPhase(true).apply(caller, new PhaseContext(metaAccess, codeCache, constantReflection, lowerer, assumptions, ReplacementsImpl.this)); } } @@ -371,7 +374,7 @@ new NodeIntrinsificationPhase(metaAccess).apply(graph); new DeadCodeEliminationPhase().apply(graph); if (OptCanonicalizer.getValue()) { - new CanonicalizerPhase(true).apply(graph, new PhaseContext(metaAccess, codeCache, lowerer, assumptions, ReplacementsImpl.this)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(metaAccess, codeCache, constantReflection, lowerer, assumptions, ReplacementsImpl.this)); } } diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Fri Oct 11 12:19:09 2013 +0200 @@ -322,15 +322,18 @@ public abstract static class AbstractTemplates implements SnippetTemplateCache { protected final MetaAccessProvider metaAccess; + protected final ConstantReflectionProvider constantReflection; protected final CodeCacheProvider codeCache; protected final LoweringProvider lowerer; protected final Replacements replacements; protected final TargetDescription target; private final ConcurrentHashMap templates; - protected AbstractTemplates(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, TargetDescription target) { + protected AbstractTemplates(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, + TargetDescription target) { this.metaAccess = metaAccess; this.codeCache = codeCache; + this.constantReflection = constantReflection; this.lowerer = lowerer; this.replacements = replacements; this.target = target; @@ -365,7 +368,7 @@ @Override public SnippetTemplate call() throws Exception { - return new SnippetTemplate(metaAccess, codeCache, lowerer, replacements, args); + return new SnippetTemplate(metaAccess, constantReflection, codeCache, lowerer, replacements, args); } }); templates.put(args.cacheKey, template); @@ -396,13 +399,14 @@ /** * Creates a snippet template. */ - protected SnippetTemplate(final MetaAccessProvider metaAccess, final CodeCacheProvider codeCache, final LoweringProvider lowerer, final Replacements replacements, Arguments args) { + protected SnippetTemplate(final MetaAccessProvider metaAccess, final ConstantReflectionProvider constantReflection, final CodeCacheProvider codeCache, final LoweringProvider lowerer, + final Replacements replacements, Arguments args) { StructuredGraph snippetGraph = replacements.getSnippet(args.info.method); ResolvedJavaMethod method = snippetGraph.method(); Signature signature = method.getSignature(); - PhaseContext context = new PhaseContext(metaAccess, codeCache, lowerer, replacements.getAssumptions(), replacements); + PhaseContext context = new PhaseContext(metaAccess, codeCache, constantReflection, lowerer, replacements.getAssumptions(), replacements); // Copy snippet graph, replacing constant parameters with given arguments final StructuredGraph snippetCopy = new StructuredGraph(snippetGraph.name, snippetGraph.method()); @@ -512,7 +516,7 @@ Debug.scope("LoweringSnippetTemplate", snippetCopy, new Runnable() { public void run() { - PhaseContext c = new PhaseContext(metaAccess, codeCache, lowerer, new Assumptions(false), replacements); + PhaseContext c = new PhaseContext(metaAccess, codeCache, constantReflection, lowerer, new Assumptions(false), replacements); new LoweringPhase(new CanonicalizerPhase(true)).apply(snippetCopy, c); } }); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java Fri Oct 11 12:19:09 2013 +0200 @@ -96,7 +96,7 @@ */ protected StructuredGraph lowerReplacement(final StructuredGraph replacementGraph, LoweringTool tool) { replacementGraph.setGuardsStage(graph().getGuardsStage()); - final PhaseContext c = new PhaseContext(tool.getMetaAccess(), tool.getCodeCache(), tool.getLowerer(), tool.assumptions(), tool.getReplacements()); + final PhaseContext c = new PhaseContext(tool.getMetaAccess(), tool.getCodeCache(), tool.getConstantReflection(), tool.getLowerer(), tool.assumptions(), tool.getReplacements()); Debug.scope("LoweringReplacement", replacementGraph, new Runnable() { public void run() { diff -r 9c2111d10e40 -r 0afe7370260c 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 Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java Fri Oct 11 12:19:09 2013 +0200 @@ -58,8 +58,9 @@ // Make sure Truffle runtime is initialized. Assert.assertTrue(Truffle.getRuntime() instanceof GraalTruffleRuntime); Replacements truffleReplacements = ((GraalTruffleRuntime) Truffle.getRuntime()).getReplacements(); - TruffleCache truffleCache = new TruffleCache(getMetaAccess(), getCodeCache(), getLowerer(), GraphBuilderConfiguration.getDefault(), TruffleCompilerImpl.Optimizations, truffleReplacements); - this.partialEvaluator = new PartialEvaluator(getMetaAccess(), getCodeCache(), getLowerer(), truffleReplacements, truffleCache); + TruffleCache truffleCache = new TruffleCache(getMetaAccess(), getConstantReflection(), getCodeCache(), getLowerer(), GraphBuilderConfiguration.getDefault(), TruffleCompilerImpl.Optimizations, + truffleReplacements); + this.partialEvaluator = new PartialEvaluator(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), truffleReplacements, truffleCache); DebugEnvironment.initialize(System.out); } @@ -107,7 +108,7 @@ public StructuredGraph call() { StructuredGraph resultGraph = partialEvaluator.createGraph(compilable, assumptions); CanonicalizerPhase canonicalizer = new CanonicalizerPhase(canonicalizeReads); - PhaseContext context = new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements); + PhaseContext context = new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements); if (resultGraph.hasLoops()) { boolean unrolled; @@ -162,7 +163,7 @@ frameState.replaceAtUsages(null); frameState.safeDelete(); } - new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), new Assumptions(false), replacements)); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), new Assumptions(false), replacements)); new DeadCodeEliminationPhase().apply(graph); } @@ -174,7 +175,7 @@ public StructuredGraph call() { Assumptions assumptions = new Assumptions(false); StructuredGraph graph = parse(methodName); - PhaseContext context = new PhaseContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements); + PhaseContext context = new PhaseContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements); CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true); canonicalizer.apply(graph, context); @@ -189,7 +190,8 @@ canonicalizer.apply(graph, context); new DeadCodeEliminationPhase().apply(graph); - HighTierContext highTierContext = new HighTierContext(getMetaAccess(), getCodeCache(), getLowerer(), assumptions, replacements, null, plan, OptimisticOptimizations.NONE); + HighTierContext highTierContext = new HighTierContext(getMetaAccess(), getCodeCache(), getConstantReflection(), getLowerer(), assumptions, replacements, null, plan, + OptimisticOptimizations.NONE); InliningPhase inliningPhase = new InliningPhase(canonicalizer); inliningPhase.apply(graph, highTierContext); removeFrameStates(graph); diff -r 9c2111d10e40 -r 0afe7370260c 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 Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Fri Oct 11 12:19:09 2013 +0200 @@ -67,6 +67,7 @@ public class PartialEvaluator { private final MetaAccessProvider metaAccess; + private final ConstantReflectionProvider constantReflection; private final CodeCacheProvider codeCache; private final LoweringProvider lowerer; private final ResolvedJavaMethod executeHelperMethod; @@ -77,11 +78,13 @@ private final HotSpotGraphCache cache; private final TruffleCache truffleCache; - public PartialEvaluator(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Replacements replacements, TruffleCache truffleCache) { + public PartialEvaluator(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, LoweringProvider lowerer, Replacements replacements, + TruffleCache truffleCache) { this.metaAccess = metaAccess; this.codeCache = codeCache; + this.constantReflection = constantReflection; this.lowerer = lowerer; - CustomCanonicalizer customCanonicalizer = new PartialEvaluatorCanonicalizer(metaAccess); + CustomCanonicalizer customCanonicalizer = new PartialEvaluatorCanonicalizer(metaAccess, constantReflection); this.canonicalizer = new CanonicalizerPhase(!AOTCompilation.getValue(), customCanonicalizer); this.skippedExceptionTypes = TruffleCompilerImpl.getSkippedExceptionTypes(metaAccess); this.replacements = replacements; @@ -127,7 +130,7 @@ thisNode.replaceAndDelete(ConstantNode.forObject(node, metaAccess, graph)); // Canonicalize / constant propagate. - PhaseContext baseContext = new PhaseContext(metaAccess, codeCache, lowerer, assumptions, replacements); + PhaseContext baseContext = new PhaseContext(metaAccess, codeCache, constantReflection, lowerer, assumptions, replacements); canonicalizer.apply(graph, baseContext); // Intrinsify methods. @@ -161,7 +164,7 @@ // Additional inlining. final PhasePlan plan = new PhasePlan(); canonicalizer.apply(graph, baseContext); - HighTierContext context = new HighTierContext(metaAccess, codeCache, lowerer, assumptions, replacements, cache, plan, OptimisticOptimizations.NONE); + HighTierContext context = new HighTierContext(metaAccess, codeCache, constantReflection, lowerer, assumptions, replacements, cache, plan, OptimisticOptimizations.NONE); for (NeverPartOfCompilationNode neverPartOfCompilationNode : graph.getNodes(NeverPartOfCompilationNode.class)) { Throwable exception = new VerificationError(neverPartOfCompilationNode.getMessage()); @@ -194,7 +197,7 @@ } private void expandTree(StructuredGraph graph, Assumptions assumptions) { - PhaseContext context = new PhaseContext(metaAccess, codeCache, lowerer, assumptions, replacements); + PhaseContext context = new PhaseContext(metaAccess, codeCache, constantReflection, lowerer, assumptions, replacements); boolean changed; do { changed = false; diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluatorCanonicalizer.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluatorCanonicalizer.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluatorCanonicalizer.java Fri Oct 11 12:19:09 2013 +0200 @@ -37,9 +37,11 @@ final class PartialEvaluatorCanonicalizer implements CanonicalizerPhase.CustomCanonicalizer { private final MetaAccessProvider metaAccess; + private final ConstantReflectionProvider constantReflection; - PartialEvaluatorCanonicalizer(MetaAccessProvider metaAccess) { + PartialEvaluatorCanonicalizer(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection) { this.metaAccess = metaAccess; + this.constantReflection = constantReflection; } @Override @@ -62,7 +64,7 @@ if (index >= 0 && index < Array.getLength(array)) { int arrayBaseOffset = Unsafe.getUnsafe().arrayBaseOffset(array.getClass()); int arrayIndexScale = Unsafe.getUnsafe().arrayIndexScale(array.getClass()); - Constant constant = metaAccess.readUnsafeConstant(loadIndexedNode.elementKind(), array, arrayBaseOffset + index * arrayIndexScale, + Constant constant = constantReflection.readUnsafeConstant(loadIndexedNode.elementKind(), array, arrayBaseOffset + index * arrayIndexScale, loadIndexedNode.elementKind() == Kind.Object); return ConstantNode.forConstant(constant, metaAccess, loadIndexedNode.graph()); } diff -r 9c2111d10e40 -r 0afe7370260c 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 Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCache.java Fri Oct 11 12:19:09 2013 +0200 @@ -55,6 +55,7 @@ public final class TruffleCache { private final MetaAccessProvider metaAccess; + private final ConstantReflectionProvider constantReflection; private final CodeCacheProvider codeCache; private final LoweringProvider lowerer; private final GraphBuilderConfiguration config; @@ -65,10 +66,11 @@ private final StructuredGraph markerGraph = new StructuredGraph(); private final ResolvedJavaType stringBuilderClass; - public TruffleCache(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, GraphBuilderConfiguration config, OptimisticOptimizations optimisticOptimizations, - Replacements replacements) { + public TruffleCache(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, LoweringProvider lowerer, GraphBuilderConfiguration config, + OptimisticOptimizations optimisticOptimizations, Replacements replacements) { this.metaAccess = metaAccess; this.codeCache = codeCache; + this.constantReflection = constantReflection; this.lowerer = lowerer; this.config = config; this.optimisticOptimizations = optimisticOptimizations; @@ -102,7 +104,7 @@ public StructuredGraph call() { final StructuredGraph graph = new StructuredGraph(method); - PhaseContext context = new PhaseContext(metaAccess, codeCache, lowerer, new Assumptions(false), replacements); + PhaseContext context = new PhaseContext(metaAccess, codeCache, constantReflection, lowerer, new Assumptions(false), replacements); new GraphBuilderPhase(metaAccess, config, optimisticOptimizations).apply(graph); for (LocalNode l : graph.getNodes(LocalNode.class)) { diff -r 9c2111d10e40 -r 0afe7370260c 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 Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Fri Oct 11 12:19:09 2013 +0200 @@ -55,6 +55,7 @@ private final MetaAccessProvider metaAccess; private final CodeCacheProvider codeCache; + private final ConstantReflectionProvider constantReflection; private final LoweringProvider lowerer; private final Suites suites; private final PartialEvaluator partialEvaluator; @@ -72,6 +73,7 @@ public TruffleCompilerImpl() { this.metaAccess = Graal.getRequiredCapability(MetaAccessProvider.class); this.codeCache = Graal.getRequiredCapability(CodeCacheProvider.class); + this.constantReflection = Graal.getRequiredCapability(ConstantReflectionProvider.class); this.lowerer = Graal.getRequiredCapability(LoweringProvider.class); this.suites = Graal.getRequiredCapability(SuitesProvider.class).createSuites(); this.backend = Graal.getRequiredCapability(Backend.class); @@ -81,9 +83,9 @@ final GraphBuilderConfiguration config = GraphBuilderConfiguration.getEagerDefault(); config.setSkippedExceptionTypes(skippedExceptionTypes); - this.truffleCache = new TruffleCache(this.metaAccess, codeCache, lowerer, config, TruffleCompilerImpl.Optimizations, this.replacements); + this.truffleCache = new TruffleCache(this.metaAccess, constantReflection, codeCache, lowerer, config, TruffleCompilerImpl.Optimizations, this.replacements); - this.partialEvaluator = new PartialEvaluator(metaAccess, codeCache, lowerer, replacements, truffleCache); + this.partialEvaluator = new PartialEvaluator(metaAccess, codeCache, constantReflection, lowerer, replacements, truffleCache); if (Debug.isEnabled()) { DebugEnvironment.initialize(System.out); @@ -153,8 +155,8 @@ public CompilationResult call() { try (TimerCloseable a = CompilationTime.start()) { CallingConvention cc = getCallingConvention(codeCache, Type.JavaCallee, graph.method(), false); - return GraalCompiler.compileGraph(graph, cc, graph.method(), metaAccess, codeCache, lowerer, replacements, backend, codeCache.getTarget(), null, plan, OptimisticOptimizations.ALL, - new SpeculationLog(), suites, new CompilationResult()); + return GraalCompiler.compileGraph(graph, cc, graph.method(), metaAccess, constantReflection, codeCache, lowerer, replacements, backend, codeCache.getTarget(), null, plan, + OptimisticOptimizations.ALL, new SpeculationLog(), suites, new CompilationResult()); } } }); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleReplacements.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleReplacements.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleReplacements.java Fri Oct 11 12:19:09 2013 +0200 @@ -41,18 +41,20 @@ private final Replacements graalReplacements; - private TruffleReplacements(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, LoweringProvider lowerer, Assumptions assumptions, TargetDescription target, Replacements graalReplacements) { - super(metaAccess, codeCache, lowerer, assumptions, target); + private TruffleReplacements(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, LoweringProvider lowerer, Assumptions assumptions, + TargetDescription target, Replacements graalReplacements) { + super(metaAccess, constantReflection, codeCache, lowerer, assumptions, target); this.graalReplacements = graalReplacements; } static Replacements makeInstance() { MetaAccessProvider metaAccess = Graal.getRequiredCapability(MetaAccessProvider.class); CodeCacheProvider codeCache = Graal.getRequiredCapability(CodeCacheProvider.class); + ConstantReflectionProvider constantReflection = Graal.getRequiredCapability(ConstantReflectionProvider.class); LoweringProvider lowerer = Graal.getRequiredCapability(LoweringProvider.class); TargetDescription targetDescription = Graal.getRequiredCapability(CodeCacheProvider.class).getTarget(); Replacements graalReplacements = Graal.getRequiredCapability(Replacements.class); - Replacements truffleReplacements = new TruffleReplacements(metaAccess, codeCache, lowerer, graalReplacements.getAssumptions(), targetDescription, graalReplacements); + Replacements truffleReplacements = new TruffleReplacements(metaAccess, constantReflection, codeCache, lowerer, graalReplacements.getAssumptions(), targetDescription, graalReplacements); truffleReplacements.registerSubstitutions(CompilerAssertsSubstitutions.class); truffleReplacements.registerSubstitutions(CompilerDirectivesSubstitutions.class); diff -r 9c2111d10e40 -r 0afe7370260c graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/LoadIndexedFinalNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/LoadIndexedFinalNode.java Thu Oct 10 23:20:04 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/LoadIndexedFinalNode.java Fri Oct 11 12:19:09 2013 +0200 @@ -58,7 +58,7 @@ if (index >= 0 && index < Array.getLength(array)) { int arrayBaseOffset = Unsafe.getUnsafe().arrayBaseOffset(array.getClass()); int arrayIndexScale = Unsafe.getUnsafe().arrayIndexScale(array.getClass()); - Constant constant = tool.getMetaAccess().readUnsafeConstant(elementKind(), array().asConstant(), arrayBaseOffset + index * arrayIndexScale, elementKind() == Kind.Object); + Constant constant = tool.getConstantReflection().readUnsafeConstant(elementKind(), array().asConstant(), arrayBaseOffset + index * arrayIndexScale, elementKind() == Kind.Object); return ConstantNode.forConstant(constant, tool.getMetaAccess(), graph()); } }