src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp

Print this page
rev 4136 : 7153771: array bound check elimination for c1
Summary: when possible optimize out array bound checks, inserting predicates when needed.
Reviewed-by:


 307 
 308 
 309 void LIRGenerator::store_stack_parameter (LIR_Opr item, ByteSize offset_from_sp) {
 310   BasicType t = item->type();
 311   LIR_Opr sp_opr = FrameMap::SP_opr;
 312   if ((t == T_LONG || t == T_DOUBLE) &&
 313       ((in_bytes(offset_from_sp) - STACK_BIAS) % 8 != 0)) {
 314     __ unaligned_move(item, new LIR_Address(sp_opr, in_bytes(offset_from_sp), t));
 315   } else {
 316     __ move(item, new LIR_Address(sp_opr, in_bytes(offset_from_sp), t));
 317   }
 318 }
 319 
 320 //----------------------------------------------------------------------
 321 //             visitor functions
 322 //----------------------------------------------------------------------
 323 
 324 
 325 void LIRGenerator::do_StoreIndexed(StoreIndexed* x) {
 326   assert(x->is_pinned(),"");
 327   bool needs_range_check = true;
 328   bool use_length = x->length() != NULL;
 329   bool obj_store = x->elt_type() == T_ARRAY || x->elt_type() == T_OBJECT;
 330   bool needs_store_check = obj_store && (x->value()->as_Constant() == NULL ||
 331                                          !get_jobject_constant(x->value())->is_null_object() ||
 332                                          x->should_profile());
 333 
 334   LIRItem array(x->array(), this);
 335   LIRItem index(x->index(), this);
 336   LIRItem value(x->value(), this);
 337   LIRItem length(this);
 338 
 339   array.load_item();
 340   index.load_nonconstant();
 341 
 342   if (use_length) {
 343     needs_range_check = x->compute_needs_range_check();
 344     if (needs_range_check) {
 345       length.set_instruction(x->length());
 346       length.load_item();
 347     }
 348   }
 349   if (needs_store_check) {
 350     value.load_item();
 351   } else {
 352     value.load_for_store(x->elt_type());
 353   }
 354 
 355   set_no_result(x);
 356 
 357   // the CodeEmitInfo must be duplicated for each different
 358   // LIR-instruction because spilling can occur anywhere between two
 359   // instructions and so the debug information must be different
 360   CodeEmitInfo* range_check_info = state_for(x);
 361   CodeEmitInfo* null_check_info = NULL;
 362   if (x->needs_null_check()) {
 363     null_check_info = new CodeEmitInfo(range_check_info);
 364   }
 365 
 366   // emit array address setup early so it schedules better
 367   LIR_Address* array_addr = emit_array_address(array.result(), index.result(), x->elt_type(), obj_store);




 307 
 308 
 309 void LIRGenerator::store_stack_parameter (LIR_Opr item, ByteSize offset_from_sp) {
 310   BasicType t = item->type();
 311   LIR_Opr sp_opr = FrameMap::SP_opr;
 312   if ((t == T_LONG || t == T_DOUBLE) &&
 313       ((in_bytes(offset_from_sp) - STACK_BIAS) % 8 != 0)) {
 314     __ unaligned_move(item, new LIR_Address(sp_opr, in_bytes(offset_from_sp), t));
 315   } else {
 316     __ move(item, new LIR_Address(sp_opr, in_bytes(offset_from_sp), t));
 317   }
 318 }
 319 
 320 //----------------------------------------------------------------------
 321 //             visitor functions
 322 //----------------------------------------------------------------------
 323 
 324 
 325 void LIRGenerator::do_StoreIndexed(StoreIndexed* x) {
 326   assert(x->is_pinned(),"");
 327   bool needs_range_check = x->compute_needs_range_check();
 328   bool use_length = x->length() != NULL;
 329   bool obj_store = x->elt_type() == T_ARRAY || x->elt_type() == T_OBJECT;
 330   bool needs_store_check = obj_store && (x->value()->as_Constant() == NULL ||
 331                                          !get_jobject_constant(x->value())->is_null_object() ||
 332                                          x->should_profile());
 333 
 334   LIRItem array(x->array(), this);
 335   LIRItem index(x->index(), this);
 336   LIRItem value(x->value(), this);
 337   LIRItem length(this);
 338 
 339   array.load_item();
 340   index.load_nonconstant();
 341 
 342   if (use_length && needs_range_check) {


 343     length.set_instruction(x->length());
 344     length.load_item();

 345   }
 346   if (needs_store_check) {
 347     value.load_item();
 348   } else {
 349     value.load_for_store(x->elt_type());
 350   }
 351 
 352   set_no_result(x);
 353 
 354   // the CodeEmitInfo must be duplicated for each different
 355   // LIR-instruction because spilling can occur anywhere between two
 356   // instructions and so the debug information must be different
 357   CodeEmitInfo* range_check_info = state_for(x);
 358   CodeEmitInfo* null_check_info = NULL;
 359   if (x->needs_null_check()) {
 360     null_check_info = new CodeEmitInfo(range_check_info);
 361   }
 362 
 363   // emit array address setup early so it schedules better
 364   LIR_Address* array_addr = emit_array_address(array.result(), index.result(), x->elt_type(), obj_store);