--- old/test/compiler/valhalla/valuetypes/ValueTypeTestBench.java 2016-11-04 15:55:17.453286588 +0100 +++ new/test/compiler/valhalla/valuetypes/ValueTypeTestBench.java 2016-11-04 15:55:17.297286596 +0100 @@ -73,6 +73,16 @@ public static MyValue createInline(int x, long y, double z) { return __Make MyValue(x, y, z); } + + @DontInline + public String toStringDontInline() { + return "MyValue: x=" + x + " y=" + y + " z=" + z; + } + + @ForceInline + public String toStringInline() { + return "MyValue: x=" + x + " y=" + y + " z=" + z; + } } public class ValueTypeTestBench { @@ -315,13 +325,73 @@ Asserts.assertEQ(result, warmup ? 42 + (1000*(double)rI) : (rI + rL + rD)); } + // Create a value type in a non-inlined method and then call a + // non-inlined method on that value type. + @Test(failOn = (ALLOC + STORE)) + public String test14() { + MyValue v = MyValue.createDontInline(32, 64L, 128.0); + String s = v.toStringDontInline(); + return s; + } + + @DontCompile + public void test14_verifier(boolean b) { + String s = test14(); + System.out.println("Result is: " + s); + } + + // Create a value type in an inlined method and then call a + // non-inlined method on that value type. + @Test(match = {ALLOC}, matchCount = {1}) + public String test15() { + MyValue v = MyValue.createInline(65, 129L, 257.0); + String s = v.toStringDontInline(); + return s; + } + + @DontCompile + public void test15_verifier(boolean b) { + String s = test15(); + System.out.println("Result is: " + s); + } + + // Create a value type in a non-inlined method and then call an + // inlined method on that value type. Allocations are due to building + // String objects and not due to allocating value types. + @Test(match = {ALLOC}, matchCount = {2}) + public String test16() { + MyValue v = MyValue.createDontInline(130, 258L, 514.0); + String s = v.toStringInline(); + return s; + } + + @DontCompile + public void test16_verifier(boolean b) { + String s = test16(); + System.out.println("Result is: " + s); + } + + // Create a value type in an inlined method and then call an + // inlined method on that value type. + @Test(match = {ALLOC}, matchCount = {2}) + public String test17() { + MyValue v = MyValue.createInline(259, 515L, 1027.0); + String s = v.toStringInline(); + return s; + } + + @DontCompile + public void test17_verifier(boolean b) { + String s = test17(); + System.out.println("Result is: " + s); + } // ========== Helper methods ========== @DontCompile public double sumValue(MyValue v) { return v.x + v.y + v.z; - } + } // ========== Test infrastructure ========== @@ -362,12 +432,12 @@ if (args.length == 0) { // Run tests in own process and verify output OutputAnalyzer oa = ProcessTools.executeTestJvm("-noverify", - "-XX:+UnlockDiagnosticVMOptions", "-Xbootclasspath/a:.", "-XX:+WhiteBoxAPI", - "-XX:-TieredCompilation", "-XX:-BackgroundCompilation", "-XX:-UseOnStackReplacement", - "-XX:CompileCommand=quiet", "-XX:+PrintCompilation", "-XX:+PrintIdeal", "-XX:+PrintOptoAssembly", - "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.ValueTypeTestBench::*", - "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.MyValue::*", - ValueTypeTestBench.class.getName(), "run"); + "-XX:+UnlockDiagnosticVMOptions", "-Xbootclasspath/a:.", "-XX:+WhiteBoxAPI", + "-XX:-TieredCompilation", "-XX:-BackgroundCompilation", "-XX:-UseOnStackReplacement", + "-XX:CompileCommand=quiet", "-XX:+PrintCompilation", "-XX:+PrintIdeal", "-XX:+PrintOptoAssembly", + "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.ValueTypeTestBench::*", + "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.MyValue::*", + ValueTypeTestBench.class.getName(), "run"); String output = oa.getOutput(); oa.shouldHaveExitValue(0); parseOutput(output); @@ -498,4 +568,4 @@ // Prevent method compilation @Retention(RetentionPolicy.RUNTIME) -@interface DontCompile { } \ No newline at end of file +@interface DontCompile { }