Mercurial > hg > graal-compiler
changeset 15783:99662e393b52
Merge
author | Erik Eckstein <erik.eckstein@oracle.com> |
---|---|
date | Tue, 20 May 2014 12:40:07 +0200 |
parents | 6a6cb7f2db90 (diff) 8b9e7f235d85 (current diff) |
children | fb530b9fa474 |
files | |
diffstat | 2 files changed, 48 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java Tue May 20 11:50:30 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java Tue May 20 12:40:07 2014 +0200 @@ -374,6 +374,30 @@ assertReadAndWriteInSameBlock(schedule, false); } + public static int testAntiDependencySnippet(int a) { + /* + * This read must not be scheduled after the following write. + */ + int res = container.a; + container.a = 10; + + /* + * Add some more basic blocks. + */ + if (a < 0) { + container.b = 20; + } + container.c = 30; + return res; + } + + @Test + public void testAntiDependency() { + SchedulePhase schedule = getFinalSchedule("testAntiDependencySnippet", TestMode.WITHOUT_FRAMESTATES); + assertDeepEquals(4, schedule.getCFG().getBlocks().size()); + assertReadBeforeAllWritesInStartBlock(schedule); + } + /** * testing scheduling within a block. */ @@ -574,6 +598,20 @@ assertTrue(!(inSame ^ schedule.getCFG().blockFor(read) == schedule.getCFG().blockFor(write))); } + private static void assertReadBeforeAllWritesInStartBlock(SchedulePhase schedule) { + boolean writeNodeFound = false; + boolean readNodeFound = false; + for (Node node : schedule.nodesFor(schedule.getCFG().getStartBlock())) { + if (node instanceof FloatingReadNode) { + assertTrue(!writeNodeFound); + readNodeFound = true; + } else if (node instanceof WriteNode) { + writeNodeFound = true; + } + } + assertTrue(readNodeFound); + } + private SchedulePhase getFinalSchedule(final String snippet, final TestMode mode) { return getFinalSchedule(snippet, mode, MemoryScheduling.OPTIMAL); }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Tue May 20 11:50:30 2014 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Tue May 20 12:40:07 2014 +0200 @@ -235,18 +235,17 @@ if (!foundExcludeNode && node == excludeNode) { foundExcludeNode = true; } - if (node == startNode) { - continue; + if (node != startNode) { + if (node instanceof MemoryCheckpoint.Single) { + LocationIdentity identity = ((MemoryCheckpoint.Single) node).getLocationIdentity(); + accm.add(identity); + } else if (node instanceof MemoryCheckpoint.Multi) { + for (LocationIdentity identity : ((MemoryCheckpoint.Multi) node).getLocationIdentities()) { + accm.add(identity); + } + } + assert MemoryCheckpoint.TypeAssertion.correctType(node); } - if (node instanceof MemoryCheckpoint.Single) { - LocationIdentity identity = ((MemoryCheckpoint.Single) node).getLocationIdentity(); - accm.add(identity); - } else if (node instanceof MemoryCheckpoint.Multi) { - for (LocationIdentity identity : ((MemoryCheckpoint.Multi) node).getLocationIdentities()) { - accm.add(identity); - } - } - assert MemoryCheckpoint.TypeAssertion.correctType(node); if (foundExcludeNode) { accm = set;