comparison src/cpu/x86/vm/c1_LIRGenerator_x86.cpp @ 8860:46f6f063b272

7153771: array bound check elimination for c1 Summary: when possible optimize out array bound checks, inserting predicates when needed. Reviewed-by: never, kvn, twisti Contributed-by: thomaswue <thomas.wuerthinger@oracle.com>
author roland
date Thu, 21 Mar 2013 09:27:54 +0100
parents 8e47bac5643a
children b800986664f4
comparison
equal deleted inserted replaced
8780:98f3af397705 8860:46f6f063b272
261 //---------------------------------------------------------------------- 261 //----------------------------------------------------------------------
262 262
263 263
264 void LIRGenerator::do_StoreIndexed(StoreIndexed* x) { 264 void LIRGenerator::do_StoreIndexed(StoreIndexed* x) {
265 assert(x->is_pinned(),""); 265 assert(x->is_pinned(),"");
266 bool needs_range_check = true; 266 bool needs_range_check = x->compute_needs_range_check();
267 bool use_length = x->length() != NULL; 267 bool use_length = x->length() != NULL;
268 bool obj_store = x->elt_type() == T_ARRAY || x->elt_type() == T_OBJECT; 268 bool obj_store = x->elt_type() == T_ARRAY || x->elt_type() == T_OBJECT;
269 bool needs_store_check = obj_store && (x->value()->as_Constant() == NULL || 269 bool needs_store_check = obj_store && (x->value()->as_Constant() == NULL ||
270 !get_jobject_constant(x->value())->is_null_object() || 270 !get_jobject_constant(x->value())->is_null_object() ||
271 x->should_profile()); 271 x->should_profile());
276 LIRItem length(this); 276 LIRItem length(this);
277 277
278 array.load_item(); 278 array.load_item();
279 index.load_nonconstant(); 279 index.load_nonconstant();
280 280
281 if (use_length) { 281 if (use_length && needs_range_check) {
282 needs_range_check = x->compute_needs_range_check(); 282 length.set_instruction(x->length());
283 if (needs_range_check) { 283 length.load_item();
284 length.set_instruction(x->length()); 284
285 length.load_item();
286 }
287 } 285 }
288 if (needs_store_check) { 286 if (needs_store_check) {
289 value.load_item(); 287 value.load_item();
290 } else { 288 } else {
291 value.load_for_store(x->elt_type()); 289 value.load_for_store(x->elt_type());