1 class MergeIfElseParanoid { 2 static class Node { 3 public Node _next; 4 public Node() {} 5 } 6 7 static Object _global; 8 static Object _global2; 9 10 public static void test(boolean cond) { 11 Object foo = new Object(); 12 if (cond) { 13 _global = foo; 14 } 15 // When `cond == true`, we materialize foo a second time. We cannot 16 // eliminate the original allocation because we need for when 17 // `cond == false`. 18 // 19 // If we have passive materialization, we would materialize foo in the 20 // predecessor, and the original object would be dead. 21 _global2 = foo; 22 } 23 24 public static void main(String[] args ) { 25 for (int i=0; i < 100_000; ++i) { 26 test(0 == (i& 0xf)); 27 } 28 } 29 }