comparison src/share/vm/c1/c1_Optimizer.cpp @ 3362:d4c1fbc3de95

7042153: guarantee(x_compare_res != Constant::not_comparable) failed: incomparable constants in IfOp Summary: Handle IfOps folding properly in case of unloaded constant oop arguments Reviewed-by: kvn, never
author iveresov
date Fri, 06 May 2011 12:12:29 -0700
parents 13bc79b5c9c8
children 15559220ce79
comparison
equal deleted inserted replaced
3348:f879eafd5835 3362:d4c1fbc3de95
250 Instruction::Condition x_ifop_cond = x_ifop->cond(); 250 Instruction::Condition x_ifop_cond = x_ifop->cond();
251 251
252 Constant::CompareResult t_compare_res = x_tval_const->compare(cond, y_const); 252 Constant::CompareResult t_compare_res = x_tval_const->compare(cond, y_const);
253 Constant::CompareResult f_compare_res = x_fval_const->compare(cond, y_const); 253 Constant::CompareResult f_compare_res = x_fval_const->compare(cond, y_const);
254 254
255 guarantee(t_compare_res != Constant::not_comparable && f_compare_res != Constant::not_comparable, "incomparable constants in IfOp"); 255 // not_comparable here is a valid return in case we're comparing unloaded oop constants
256 256 if (t_compare_res != Constant::not_comparable && f_compare_res != Constant::not_comparable) {
257 Value new_tval = t_compare_res == Constant::cond_true ? tval : fval; 257 Value new_tval = t_compare_res == Constant::cond_true ? tval : fval;
258 Value new_fval = f_compare_res == Constant::cond_true ? tval : fval; 258 Value new_fval = f_compare_res == Constant::cond_true ? tval : fval;
259 259
260 _ifop_count++; 260 _ifop_count++;
261 if (new_tval == new_fval) { 261 if (new_tval == new_fval) {
262 return new_tval; 262 return new_tval;
263 } else { 263 } else {
264 return new IfOp(x_ifop->x(), x_ifop_cond, x_ifop->y(), new_tval, new_fval); 264 return new IfOp(x_ifop->x(), x_ifop_cond, x_ifop->y(), new_tval, new_fval);
265 }
265 } 266 }
266 } 267 }
267 } else { 268 } else {
268 Constant* x_const = x->as_Constant(); 269 Constant* x_const = x->as_Constant();
269 if (x_const != NULL) { // x and y are constants 270 if (x_const != NULL) { // x and y are constants
270 Constant::CompareResult x_compare_res = x_const->compare(cond, y_const); 271 Constant::CompareResult x_compare_res = x_const->compare(cond, y_const);
271 guarantee(x_compare_res != Constant::not_comparable, "incomparable constants in IfOp"); 272 // not_comparable here is a valid return in case we're comparing unloaded oop constants
272 273 if (x_compare_res != Constant::not_comparable) {
273 _ifop_count++; 274 _ifop_count++;
274 return x_compare_res == Constant::cond_true ? tval : fval; 275 return x_compare_res == Constant::cond_true ? tval : fval;
276 }
275 } 277 }
276 } 278 }
277 } 279 }
278 return new IfOp(x, cond, y, tval, fval); 280 return new IfOp(x, cond, y, tval, fval);
279 } 281 }