# HG changeset patch # User Bernhard Urban # Date 1417549692 -3600 # Node ID be63951fa2bcbed3d7e5b5da8ad58603c4a19189 # Parent 1f379e2a623f73d412cca0fdd48d98ae18bf84ee WriteBarrierVerification: relax check diff -r 1f379e2a623f -r be63951fa2bc 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 Tue Dec 02 19:27:50 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java Tue Dec 02 20:48:12 2014 +0100 @@ -35,6 +35,7 @@ import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.phases.*; +import com.oracle.graal.hotspot.replacements.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; @@ -610,10 +611,20 @@ @Test public void test61() { - test("test13Snippet", 1, new int[]{}); + GraphPredicate checkForUnsafeArrayCopy = graph -> graph.getNodes().filter(UnsafeArrayCopyNode.class).count() > 0 ? 1 : 0; + testPredicate("test13Snippet", checkForUnsafeArrayCopy, new int[]{}); + } + + private interface GraphPredicate { + int apply(StructuredGraph graph); } private void test(final String snippet, final int expectedBarriers, final int... removedBarrierIndices) { + GraphPredicate noCheck = noArg -> expectedBarriers; + testPredicate(snippet, noCheck, removedBarrierIndices); + } + + private void testPredicate(final String snippet, final GraphPredicate expectedBarriers, final int... removedBarrierIndices) { try (Scope d = Debug.scope("WriteBarrierVerificationTest", new DebugDumpScope(snippet))) { final StructuredGraph graph = parseEager(snippet); HighTierContext highTierContext = new HighTierContext(getProviders(), new Assumptions(false), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL); @@ -633,10 +644,10 @@ 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(); - Assert.assertTrue(expectedBarriers * 2 == barriers); + Assert.assertTrue(expectedBarriers.apply(graph) * 2 == barriers); } else { barriers = graph.getNodes().filter(SerialWriteBarrier.class).count() + graph.getNodes().filter(SerialArrayRangeWriteBarrier.class).count(); - Assert.assertTrue(expectedBarriers == barriers); + Assert.assertTrue(expectedBarriers.apply(graph) == barriers); } // Iterate over all write nodes and remove barriers according to input indices. NodeIteratorClosure closure = new NodeIteratorClosure() {