# HG changeset patch # User Doug Simon # Date 1351787555 -3600 # Node ID 3f25ffc69fecae663b7da48a31cdd9424e85a88a # Parent eb980b869753574572bd4e68f961f4401cd7bc5e added more tests to InstanceOfTest diff -r eb980b869753 -r 3f25ffc69fec graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InstanceOfTest.java --- a/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InstanceOfTest.java Thu Nov 01 17:30:53 2012 +0100 +++ b/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InstanceOfTest.java Thu Nov 01 17:32:35 2012 +0100 @@ -26,6 +26,9 @@ import org.junit.*; +import com.oracle.graal.api.code.CompilationResult.Call; +import com.oracle.graal.api.code.CompilationResult.Mark; +import com.oracle.graal.api.code.CompilationResult.Site; import com.oracle.graal.api.meta.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; @@ -198,15 +201,12 @@ return -1; } - public static int isThrowableInt(Object o) { + int result = o instanceof Throwable ? 4 : 5; if (o instanceof Throwable) { - return id(1); + return id(4); } - if (o instanceof Throwable) { - return id(2); - } - return 0; + return result; } public static boolean isMap(Object o) { @@ -231,6 +231,66 @@ return id(0); } + abstract static class MySite { + final int offset; + MySite(int offset) { + this.offset = offset; + } + } + + static class MyMark extends MySite { + MyMark(int offset) { + super(offset); + } + } + + abstract static class MySafepoint extends MySite { + MySafepoint(int offset) { + super(offset); + } + } + + static class MyCall extends MySafepoint { + MyCall(int offset) { + super(offset); + } + } + + @Test + public void test9() { + MyCall callAt63 = new MyCall(63); + MyMark markAt63 = new MyMark(63); + test("compareMySites", callAt63, callAt63); + test("compareMySites", callAt63, markAt63); + test("compareMySites", markAt63, callAt63); + test("compareMySites", markAt63, markAt63); + } + + public static int compareMySites(MySite s1, MySite s2) { + if (s1.offset == s2.offset && (s1 instanceof MyMark ^ s2 instanceof MyMark)) { + return s1 instanceof MyMark ? -1 : 1; + } + return s1.offset - s2.offset; + } + + @Test + public void test10() { + Mark[] noMarks = {}; + Call callAt63 = new Call("ignore", 63, 5, true, null); + Mark markAt63 = new Mark(63, "1", noMarks); + test("compareSites", callAt63, callAt63); + test("compareSites", callAt63, markAt63); + test("compareSites", markAt63, callAt63); + test("compareSites", markAt63, markAt63); + } + + public static int compareSites(Site s1, Site s2) { + if (s1.pcOffset == s2.pcOffset && (s1 instanceof Mark ^ s2 instanceof Mark)) { + return s1 instanceof Mark ? -1 : 1; + } + return s1.pcOffset - s2.pcOffset; + } + /** * This test exists to show the kind of pattern that is be optimizable by * {@code removeIntermediateMaterialization()} in {@link IfNode}.