Mercurial > hg > jdk9-shenandoah > hotspot
changeset 9450:4e1b2fe49012
Added testcases that verify dependencies between barriers.
author | rkennke |
---|---|
date | Wed, 19 Aug 2015 20:37:30 +0200 |
parents | ea0fa7eace6e |
children | 04773a6b9229 |
files | test/gc/shenandoah/TestBarrierDependencies.java test/gc/shenandoah/TestBarrierDependencies2.java |
diffstat | 2 files changed, 94 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/gc/shenandoah/TestBarrierDependencies.java Wed Aug 19 20:37:30 2015 +0200 @@ -0,0 +1,43 @@ + +/* + * @test TestBarrierDependencies + * @run main/othervm -XX:ShenandoahGCHeuristics=aggressive -XX:+UseShenandoahGC -XX:-UseCompressedOops -XX:CompileOnly=TestBarrierDependencies.test TestBarrierDependencies + */ +public class TestBarrierDependencies { + + public static class Fluff { + public Test test1; + public Test test2; + } + + public static class Test { + public int x; + } + + public static Fluff fluff; + private static void setup() { + Test obj = new Test(); + fluff = new Fluff(); + fluff.test1 = obj; + fluff.test2 = obj; + } + public static void main(String[] args) { + setup(); + for (int x = 0; x < 1000000; x++) { + int val = (int) (Math.random() * Integer.MAX_VALUE); + String garbage = new String("hello world"); + test(fluff, val); + } + } + + private static void test(Fluff fluff, int value) { + Test b = fluff.test2; + if (b == null) throw new NullPointerException("b"); + Test a = fluff.test1; + if (a == null) throw new NullPointerException("a"); + a.x = value; + if (b.x != value) { + throw new RuntimeException("got wrong value"); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/gc/shenandoah/TestBarrierDependencies2.java Wed Aug 19 20:37:30 2015 +0200 @@ -0,0 +1,51 @@ + +/** + * @test TestBarrierDependencies2 + * @run main/othervm -XX:ShenandoahGCHeuristics=aggressive -XX:+UseShenandoahGC -XX:-UseCompressedOops -XX:CompileOnly=TestBarrierDependencies.test TestBarrierDependencies2 + */ +public class TestBarrierDependencies2 { + + public static class Fluff { + public TestA test1; + public TestA test2; + public TestB test3; + } + + public static class TestA { + public int x; + } + + public static class TestB { + public int x; + } + + public static Fluff fluff; + private static void setup() { + TestA obj = new TestA(); + fluff = new Fluff(); + fluff.test1 = obj; + fluff.test2 = obj; + fluff.test3 = new TestB(); + } + public static void main(String[] args) { + setup(); + for (int x = 0; x < 1000000; x++) { + int val = (int) (Math.random() * Integer.MAX_VALUE); + String garbage = new String("hello world"); + test(fluff, val); + } + } + + private static void test(Fluff fluff, int value) { + TestA b = fluff.test2; + if (b == null) throw new NullPointerException("b"); + TestA a = fluff.test1; + if (a == null) throw new NullPointerException("a"); + TestB x = fluff.test3; + a.x = value; + x.x = value + 1; //(int) (Math.random() * Integer.MAX_VALUE); // This should have its write barrier elided. + if (b.x != value) { + throw new RuntimeException("got wrong value"); + } + } +}