25
26 import jdk.test.lib.Asserts;
27 import compiler.lib.ir_framework.*;
28
29 /*
30 * @test
31 * @bug 8286104
32 * @summary Test that C2 uses aggressive liveness to get rid of the boxing object which is
33 * only consumed by uncommon_trap.
34 * @library /test/lib /
35 * @run driver compiler.c2.irTests.TestOptimizeUnstableIf
36 */
37 public class TestOptimizeUnstableIf {
38
39 public static void main(String[] args) {
40 TestFramework.run();
41 }
42
43 @Test
44 @Arguments(values = {Argument.MAX}) // the argument needs to be big enough to fall out of cache.
45 @IR(failOn = {IRNode.ALLOC_OF, "Integer"})
46 public static int boxing_object(int value) {
47 Integer ii = Integer.valueOf(value);
48 int sum = 0;
49
50 if (value > 999_999) {
51 sum += ii.intValue();
52 }
53
54 return sum;
55 }
56
57 @Check(test = "boxing_object")
58 public void checkWithTestInfo(int result, TestInfo info) {
59 if (info.isWarmUp()) {
60 // Accessing the cached boxing object during warm-up phase. It prevents parser from pruning that branch of Interger.valueOf();
61 // This guarantees that a phi node is generated, which merge a cached object and the newly allocated object. eg.
62 // 112: Phi === 108 168 188 [[ 50 ]] #java/lang/Integer:NotNull:exact * Oop:java/lang/Integer:NotNull:exact *
63 // 168: a cached object
64 // 188: result of AllocateNode
65 // 50: uncommon_trap unstable_if
|
25
26 import jdk.test.lib.Asserts;
27 import compiler.lib.ir_framework.*;
28
29 /*
30 * @test
31 * @bug 8286104
32 * @summary Test that C2 uses aggressive liveness to get rid of the boxing object which is
33 * only consumed by uncommon_trap.
34 * @library /test/lib /
35 * @run driver compiler.c2.irTests.TestOptimizeUnstableIf
36 */
37 public class TestOptimizeUnstableIf {
38
39 public static void main(String[] args) {
40 TestFramework.run();
41 }
42
43 @Test
44 @Arguments(values = {Argument.MAX}) // the argument needs to be big enough to fall out of cache.
45 // TODO 8328675 Re-enable
46 // @IR(failOn = {IRNode.ALLOC_OF, "Integer"})
47 public static int boxing_object(int value) {
48 Integer ii = Integer.valueOf(value);
49 int sum = 0;
50
51 if (value > 999_999) {
52 sum += ii.intValue();
53 }
54
55 return sum;
56 }
57
58 @Check(test = "boxing_object")
59 public void checkWithTestInfo(int result, TestInfo info) {
60 if (info.isWarmUp()) {
61 // Accessing the cached boxing object during warm-up phase. It prevents parser from pruning that branch of Interger.valueOf();
62 // This guarantees that a phi node is generated, which merge a cached object and the newly allocated object. eg.
63 // 112: Phi === 108 168 188 [[ 50 ]] #java/lang/Integer:NotNull:exact * Oop:java/lang/Integer:NotNull:exact *
64 // 168: a cached object
65 // 188: result of AllocateNode
66 // 50: uncommon_trap unstable_if
|