168 // Merge value types created from two branches 169 @Test(failOn = ALLOC + STORE + TRAP) 170 public long test8(boolean b) { 171 MyValue1 v; 172 if (b) { 173 v = MyValue1.createWithFieldsInline(rI, rL); 174 } else { 175 v = MyValue1.createWithFieldsDontInline(rI + 1, rL + 1); 176 } 177 return v.hash(); 178 } 179 180 @DontCompile 181 public void test8_verifier(boolean warmup) { 182 Asserts.assertEQ(test8(true), hash()); 183 Asserts.assertEQ(test8(false), hash(rI + 1, rL + 1)); 184 } 185 186 // Merge value types created from two branches 187 @Test(valid = ValueTypePassFieldsAsArgsOn, match = {LOAD}, matchCount = {12}, failOn = TRAP + ALLOC + STORE) 188 @Test(valid = ValueTypePassFieldsAsArgsOff, match = {ALLOC, STORE}, matchCount = {1, 5}, failOn = LOAD + TRAP) 189 public MyValue1 test9(boolean b) { 190 MyValue1 v; 191 if (b) { 192 // Value type is not allocated 193 v = MyValue1.createWithFieldsInline(rI, rL); 194 } else { 195 // Value type is allocated by the callee 196 v = MyValue1.createWithFieldsDontInline(rI + 1, rL + 1); 197 } 198 // Need to allocate value type if 'b' is true 199 long sum = v.hashInterpreted(); 200 if (b) { 201 v = MyValue1.createWithFieldsDontInline(rI, sum); 202 } else { 203 v = MyValue1.createWithFieldsDontInline(rI, sum + 1); 204 } 205 // Don't need to allocate value type because both branches allocate 206 return v; 207 } 208 209 @DontCompile 210 public void test9_verifier(boolean warmup) { 211 MyValue1 v = test9(true); 212 Asserts.assertEQ(v.x, rI); 213 Asserts.assertEQ(v.y, hash()); 214 v = test9(false); 215 Asserts.assertEQ(v.x, rI); 216 Asserts.assertEQ(v.y, hash(rI + 1, rL + 1) + 1); 217 } 218 219 // Merge value types created in a loop (not inlined) 220 @Test(failOn = ALLOC + STORE + TRAP) 221 public long test10(int x, long y) { 222 MyValue1 v = MyValue1.createWithFieldsDontInline(x, y); 223 for (int i = 0; i < 10; ++i) { 224 v = MyValue1.createWithFieldsDontInline(v.x + 1, v.y + 1); 225 } 226 return v.hash(); 227 } 228 229 @DontCompile 230 public void test10_verifier(boolean warmup) { 231 long result = test10(rI, rL); 232 Asserts.assertEQ(result, hash(rI + 10, rL + 10)); 233 } 234 | 168 // Merge value types created from two branches 169 @Test(failOn = ALLOC + STORE + TRAP) 170 public long test8(boolean b) { 171 MyValue1 v; 172 if (b) { 173 v = MyValue1.createWithFieldsInline(rI, rL); 174 } else { 175 v = MyValue1.createWithFieldsDontInline(rI + 1, rL + 1); 176 } 177 return v.hash(); 178 } 179 180 @DontCompile 181 public void test8_verifier(boolean warmup) { 182 Asserts.assertEQ(test8(true), hash()); 183 Asserts.assertEQ(test8(false), hash(rI + 1, rL + 1)); 184 } 185 186 // Merge value types created from two branches 187 @Test(valid = ValueTypePassFieldsAsArgsOn, match = {LOAD}, matchCount = {12}, failOn = TRAP + ALLOC + STORE) 188 @Test(valid = ValueTypePassFieldsAsArgsOff, match = {ALLOC, STORE}, matchCount = {1, 12}, failOn = LOAD + TRAP) 189 public MyValue1 test9(boolean b, int localrI, long localrL) { 190 MyValue1 v; 191 if (b) { 192 // Value type is not allocated 193 // Do not use rI/rL directly here as null values may cause 194 // some redundant null initializations to be optimized out 195 // and matching to fail. 196 v = MyValue1.createWithFieldsInline(localrI, localrL); 197 } else { 198 // Value type is allocated by the callee 199 v = MyValue1.createWithFieldsDontInline(rI + 1, rL + 1); 200 } 201 // Need to allocate value type if 'b' is true 202 long sum = v.hashInterpreted(); 203 if (b) { 204 v = MyValue1.createWithFieldsDontInline(rI, sum); 205 } else { 206 v = MyValue1.createWithFieldsDontInline(rI, sum + 1); 207 } 208 // Don't need to allocate value type because both branches allocate 209 return v; 210 } 211 212 @DontCompile 213 public void test9_verifier(boolean warmup) { 214 MyValue1 v = test9(true, rI, rL); 215 Asserts.assertEQ(v.x, rI); 216 Asserts.assertEQ(v.y, hash()); 217 v = test9(false, rI, rL); 218 Asserts.assertEQ(v.x, rI); 219 Asserts.assertEQ(v.y, hash(rI + 1, rL + 1) + 1); 220 } 221 222 // Merge value types created in a loop (not inlined) 223 @Test(failOn = ALLOC + STORE + TRAP) 224 public long test10(int x, long y) { 225 MyValue1 v = MyValue1.createWithFieldsDontInline(x, y); 226 for (int i = 0; i < 10; ++i) { 227 v = MyValue1.createWithFieldsDontInline(v.x + 1, v.y + 1); 228 } 229 return v.hash(); 230 } 231 232 @DontCompile 233 public void test10_verifier(boolean warmup) { 234 long result = test10(rI, rL); 235 Asserts.assertEQ(result, hash(rI + 10, rL + 10)); 236 } 237 |