# HG changeset patch # User Doug Simon # Date 1417006670 -3600 # Node ID cdb9c605051ad1f38cd458f41a35a1dad0246e96 # Parent 2906b3cc3e2fd16b8f02cf22897f9a59560c154d removed some static accesses to HotSpotGraalRuntime from some tests diff -r 2906b3cc3e2f -r cdb9c605051a graal/com.oracle.graal.hotspot.amd64.test/src/com/oracle/graal/hotspot/amd64/test/DataPatchInConstantsTest.java --- a/graal/com.oracle.graal.hotspot.amd64.test/src/com/oracle/graal/hotspot/amd64/test/DataPatchInConstantsTest.java Wed Nov 26 13:20:14 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64.test/src/com/oracle/graal/hotspot/amd64/test/DataPatchInConstantsTest.java Wed Nov 26 13:57:50 2014 +0100 @@ -32,11 +32,11 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.asm.amd64.*; -import com.oracle.graal.compiler.test.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.nodes.CompressionNode.CompressionOp; import com.oracle.graal.hotspot.nodes.type.*; +import com.oracle.graal.hotspot.test.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; import com.oracle.graal.lir.gen.*; @@ -44,7 +44,7 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; -public class DataPatchInConstantsTest extends GraalCompilerTest { +public class DataPatchInConstantsTest extends HotSpotGraalCompilerTest { @Before public void checkAMD64() { diff -r 2906b3cc3e2f -r cdb9c605051a graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java Wed Nov 26 13:20:14 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java Wed Nov 26 13:57:50 2014 +0100 @@ -22,8 +22,6 @@ */ package com.oracle.graal.hotspot.test; -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; - import java.io.*; import java.lang.reflect.*; import java.security.*; @@ -34,7 +32,6 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.test.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.bridge.CompilerToVM.CodeInstallResult; import com.oracle.graal.hotspot.meta.*; @@ -43,7 +40,7 @@ /** * Tests the intrinsification of certain crypto methods. */ -public class HotSpotCryptoSubstitutionTest extends GraalCompilerTest { +public class HotSpotCryptoSubstitutionTest extends HotSpotGraalCompilerTest { @Override protected InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult) { diff -r 2906b3cc3e2f -r cdb9c605051a graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotGraalCompilerTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotGraalCompilerTest.java Wed Nov 26 13:57:50 2014 +0100 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.test; + +import com.oracle.graal.compiler.test.*; +import com.oracle.graal.hotspot.*; + +/** + * A Graal compiler test that needs access to the {@link HotSpotGraalRuntimeProvider}. + */ +public abstract class HotSpotGraalCompilerTest extends GraalCompilerTest { + + /** + * Gets the {@link HotSpotGraalRuntimeProvider}. + */ + protected HotSpotGraalRuntimeProvider runtime() { + return ((HotSpotBackend) getBackend()).getRuntime(); + } +} diff -r 2906b3cc3e2f -r cdb9c605051a graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java Wed Nov 26 13:20:14 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java Wed Nov 26 13:57:50 2014 +0100 @@ -25,7 +25,6 @@ import static com.oracle.graal.debug.internal.MemUseTrackerImpl.*; import static com.oracle.graal.hotspot.CompileTheWorld.*; import static com.oracle.graal.hotspot.CompileTheWorld.Options.*; -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; import static com.oracle.graal.nodes.StructuredGraph.*; import com.oracle.graal.api.runtime.*; @@ -52,7 +51,7 @@ * mx --vm server vm -XX:-UseGraalClassLoader -G:CompileTheWorldClasspath=$HOME/SPECjvm2008/SPECjvm2008.jar -cp @com.oracle.graal.hotspot.test com.oracle.graal.hotspot.test.MemoryUsageBenchmark * */ -public class MemoryUsageBenchmark extends GraalCompilerTest { +public class MemoryUsageBenchmark extends HotSpotGraalCompilerTest { public static int simple(int a, int b) { return a + b; diff -r 2906b3cc3e2f -r cdb9c605051a 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 Wed Nov 26 13:20:14 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java Wed Nov 26 13:57:50 2014 +0100 @@ -22,8 +22,6 @@ */ package com.oracle.graal.hotspot.test; -import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; - import java.lang.ref.*; import org.junit.*; @@ -34,9 +32,11 @@ import com.oracle.graal.compiler.test.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; +import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.phases.*; +import com.oracle.graal.hotspot.replacements.*; import com.oracle.graal.nodes.HeapAccess.BarrierType; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; @@ -46,6 +46,7 @@ import com.oracle.graal.phases.common.inlining.*; import com.oracle.graal.phases.common.inlining.policy.*; import com.oracle.graal.phases.tiers.*; +import com.oracle.graal.replacements.*; /** * The following unit tests assert the presence of write barriers for both Serial and G1 GCs. @@ -58,6 +59,9 @@ */ public class WriteBarrierAdditionTest extends GraalCompilerTest { + private static final HotSpotVMConfig config = HotSpotGraalRuntime.runtime().getConfig(); + private static final long referentOffset = HotSpotReplacementsUtil.referentOffset(); + public static class Container { public Container a; @@ -69,7 +73,7 @@ */ @Test public void test1() throws Exception { - test("test1Snippet", (useG1GC()) ? 4 : 2); + testHelper("test1Snippet", (config.useG1GC) ? 4 : 2); } public static void test1Snippet() { @@ -85,7 +89,7 @@ */ @Test public void test2() throws Exception { - test("test2Snippet", (useG1GC()) ? 8 : 4); + testHelper("test2Snippet", config.useG1GC ? 8 : 4); } public static void test2Snippet(boolean test) { @@ -108,7 +112,7 @@ */ @Test public void test3() throws Exception { - test("test3Snippet", useG1GC() ? 8 : 4); + testHelper("test3Snippet", config.useG1GC ? 8 : 4); } public static void test3Snippet() { @@ -131,7 +135,7 @@ */ @Test public void test4() throws Exception { - test("test4Snippet", (useG1GC()) ? 5 : 2); + testHelper("test4Snippet", config.useG1GC ? 5 : 2); } public static Object test4Snippet() { @@ -149,11 +153,11 @@ */ @Test public void test5() throws Exception { - test("test5Snippet", useG1GC() ? 1 : 0); + testHelper("test5Snippet", config.useG1GC ? 1 : 0); } public static Object test5Snippet() throws Exception { - return UnsafeAccess.unsafe.getObject(wr, useCompressedOops() ? 12L : 16L); + return UnsafeAccess.unsafe.getObject(wr, config.useCompressedOops ? 12L : 16L); } /** @@ -162,7 +166,7 @@ */ @Test public void test6() throws Exception { - test2("testUnsafeLoad", wr, new Long(referentOffset()), null); + test2("testUnsafeLoad", wr, new Long(referentOffset), null); } /** @@ -171,7 +175,7 @@ */ @Test public void test7() throws Exception { - test2("testUnsafeLoad", con, new Long(referentOffset()), null); + test2("testUnsafeLoad", con, new Long(referentOffset), null); } /** @@ -181,7 +185,7 @@ */ @Test public void test8() throws Exception { - test2("testUnsafeLoad", wr, new Long(useCompressedOops() ? 20 : 32), null); + test2("testUnsafeLoad", wr, new Long(config.useCompressedOops ? 20 : 32), null); } /** @@ -191,7 +195,7 @@ */ @Test public void test10() throws Exception { - test2("testUnsafeLoad", wr, new Long(useCompressedOops() ? 6 : 8), new Integer(useCompressedOops() ? 6 : 8)); + test2("testUnsafeLoad", wr, new Long(config.useCompressedOops ? 6 : 8), new Integer(config.useCompressedOops ? 6 : 8)); } /** @@ -201,7 +205,7 @@ */ @Test public void test9() throws Exception { - test2("testUnsafeLoad", wr, new Long(useCompressedOops() ? 10 : 16), new Integer(useCompressedOops() ? 10 : 16)); + test2("testUnsafeLoad", wr, new Long(config.useCompressedOops ? 10 : 16), new Integer(config.useCompressedOops ? 10 : 16)); } static Object[] src = new Object[1]; @@ -237,20 +241,22 @@ return installedBenchmarkCode; } - private void test(final String snippet, final int expectedBarriers) throws Exception, SecurityException { - try (Scope s = Debug.scope("WriteBarrierAdditionTest", new DebugDumpScope(snippet))) { + private void testHelper(final String snippetName, final int expectedBarriers) throws Exception, SecurityException { + ResolvedJavaMethod snippet = getResolvedJavaMethod(snippetName); + try (Scope s = Debug.scope("WriteBarrierAdditionTest", snippet)) { StructuredGraph graph = parseEager(snippet); HighTierContext highContext = new HighTierContext(getProviders(), new Assumptions(false), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL); MidTierContext midContext = new MidTierContext(getProviders(), new Assumptions(false), getCodeCache().getTarget(), OptimisticOptimizations.ALL, graph.method().getProfilingInfo(), null); + new NodeIntrinsificationPhase(getProviders(), getSnippetReflection()).apply(graph); new InliningPhase(new InlineEverythingPolicy(), new CanonicalizerPhase(true)).apply(graph, highContext); new LoweringPhase(new CanonicalizerPhase(true), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, highContext); new GuardLoweringPhase().apply(graph, midContext); new LoweringPhase(new CanonicalizerPhase(true), LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, midContext); - new WriteBarrierAdditionPhase().apply(graph); + new WriteBarrierAdditionPhase(config).apply(graph); Debug.dump(graph, "After Write Barrier Addition"); int barriers = 0; - if (useG1GC()) { + if (config.useG1GC) { barriers = graph.getNodes().filter(G1ReferentFieldReadBarrier.class).count() + graph.getNodes().filter(G1PreWriteBarrier.class).count() + graph.getNodes().filter(G1PostWriteBarrier.class).count(); } else { @@ -258,7 +264,7 @@ } Assert.assertEquals(expectedBarriers, barriers); for (WriteNode write : graph.getNodes().filter(WriteNode.class)) { - if (useG1GC()) { + if (config.useG1GC) { if (write.getBarrierType() != BarrierType.NONE) { Assert.assertEquals(1, write.successors().count()); Assert.assertTrue(write.next() instanceof G1PostWriteBarrier); @@ -275,9 +281,9 @@ for (ReadNode read : graph.getNodes().filter(ReadNode.class)) { if (read.getBarrierType() != BarrierType.NONE) { if (read.location() instanceof ConstantLocationNode) { - Assert.assertEquals(referentOffset(), ((ConstantLocationNode) (read.location())).getDisplacement()); + Assert.assertEquals(referentOffset, ((ConstantLocationNode) (read.location())).getDisplacement()); } - Assert.assertTrue(useG1GC()); + Assert.assertTrue(config.useG1GC); Assert.assertEquals(BarrierType.PRECISE, read.getBarrierType()); Assert.assertTrue(read.next() instanceof G1ReferentFieldReadBarrier); } diff -r 2906b3cc3e2f -r cdb9c605051a 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 Wed Nov 26 13:20:14 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java Wed Nov 26 13:57:50 2014 +0100 @@ -56,6 +56,8 @@ public static int barrierIndex; + private final HotSpotVMConfig config = HotSpotGraalRuntime.runtime().getConfig(); + public static class Container { public Container a; @@ -624,11 +626,10 @@ new LoopSafepointInsertionPhase().apply(graph); new LoweringPhase(new CanonicalizerPhase(true), LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, highTierContext); - new WriteBarrierAdditionPhase().apply(graph); + new WriteBarrierAdditionPhase(config).apply(graph); int barriers = 0; // First, the total number of expected barriers is checked. - HotSpotVMConfig config = HotSpotGraalRuntime.runtime().getConfig(); if (config.useG1GC) { barriers = graph.getNodes().filter(G1PreWriteBarrier.class).count() + graph.getNodes().filter(G1PostWriteBarrier.class).count() + graph.getNodes().filter(G1ArrayRangePreWriteBarrier.class).count() + graph.getNodes().filter(G1ArrayRangePostWriteBarrier.class).count(); diff -r 2906b3cc3e2f -r cdb9c605051a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java Wed Nov 26 13:20:14 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java Wed Nov 26 13:57:50 2014 +0100 @@ -73,7 +73,7 @@ } } - ret.getMidTier().appendPhase(new WriteBarrierAdditionPhase()); + ret.getMidTier().appendPhase(new WriteBarrierAdditionPhase(runtime.getConfig())); if (VerifyPhases.getValue()) { ret.getMidTier().appendPhase(new WriteBarrierVerificationPhase()); } diff -r 2906b3cc3e2f -r cdb9c605051a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java Wed Nov 26 13:20:14 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java Wed Nov 26 13:57:50 2014 +0100 @@ -22,10 +22,9 @@ */ package com.oracle.graal.hotspot.phases; -import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; - import com.oracle.graal.compiler.common.*; import com.oracle.graal.graph.*; +import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.nodes.HeapAccess.BarrierType; import com.oracle.graal.nodes.*; @@ -36,7 +35,10 @@ public class WriteBarrierAdditionPhase extends Phase { - public WriteBarrierAdditionPhase() { + private HotSpotVMConfig config; + + public WriteBarrierAdditionPhase(HotSpotVMConfig config) { + this.config = config; } @Override @@ -60,9 +62,9 @@ } } - private static void addReadNodeBarriers(ReadNode node, StructuredGraph graph) { + private void addReadNodeBarriers(ReadNode node, StructuredGraph graph) { if (node.getBarrierType() == BarrierType.PRECISE) { - assert useG1GC(); + assert config.useG1GC; G1ReferentFieldReadBarrier barrier = graph.add(G1ReferentFieldReadBarrier.create(node.object(), node, node.location(), false)); graph.addAfterFixed(node, barrier); } else { @@ -98,7 +100,7 @@ case IMPRECISE: case PRECISE: boolean precise = barrierType == BarrierType.PRECISE; - if (useG1GC()) { + if (config.useG1GC) { if (!node.isInitialization()) { addG1PreWriteBarrier(node, node.object(), null, node.location(), true, node.getNullCheck(), graph); } @@ -121,7 +123,7 @@ case IMPRECISE: case PRECISE: boolean precise = barrierType == BarrierType.PRECISE; - if (useG1GC()) { + if (config.useG1GC) { addG1PreWriteBarrier(node, node.object(), null, node.location(), true, node.getNullCheck(), graph); addG1PostWriteBarrier(node, node.object(), node.getNewValue(), node.location(), precise, graph); } else { @@ -142,7 +144,7 @@ case IMPRECISE: case PRECISE: boolean precise = barrierType == BarrierType.PRECISE; - if (useG1GC()) { + if (config.useG1GC) { addG1PreWriteBarrier(node, node.object(), node.getExpectedValue(), node.location(), false, false, graph); addG1PostWriteBarrier(node, node.object(), node.getNewValue(), node.location(), precise, graph); } else { @@ -154,8 +156,8 @@ } } - private static void addArrayRangeBarriers(ArrayRangeWriteNode node, StructuredGraph graph) { - if (useG1GC()) { + private void addArrayRangeBarriers(ArrayRangeWriteNode node, StructuredGraph graph) { + if (config.useG1GC) { if (!node.isInitialization()) { G1ArrayRangePreWriteBarrier g1ArrayRangePreWriteBarrier = graph.add(G1ArrayRangePreWriteBarrier.create(node.getArray(), node.getIndex(), node.getLength())); graph.addBeforeFixed(node, g1ArrayRangePreWriteBarrier); diff -r 2906b3cc3e2f -r cdb9c605051a mx/suite.py --- a/mx/suite.py Wed Nov 26 13:20:14 2014 +0100 +++ b/mx/suite.py Wed Nov 26 13:57:50 2014 +0100 @@ -443,8 +443,7 @@ "sourceDirs" : ["src"], "dependencies" : [ "com.oracle.graal.asm.amd64", - "com.oracle.graal.compiler.test", - "com.oracle.graal.hotspot", + "com.oracle.graal.hotspot.test", ], "checkstyle" : "com.oracle.graal.graph", "javaCompliance" : "1.8",