Mercurial > hg > truffle
comparison src/cpu/sparc/vm/c1_LIRGenerator_sparc.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 | 7eca5de9e0b6 |
children | b800986664f4 |
comparison
equal
deleted
inserted
replaced
8780:98f3af397705 | 8860:46f6f063b272 |
---|---|
322 //---------------------------------------------------------------------- | 322 //---------------------------------------------------------------------- |
323 | 323 |
324 | 324 |
325 void LIRGenerator::do_StoreIndexed(StoreIndexed* x) { | 325 void LIRGenerator::do_StoreIndexed(StoreIndexed* x) { |
326 assert(x->is_pinned(),""); | 326 assert(x->is_pinned(),""); |
327 bool needs_range_check = true; | 327 bool needs_range_check = x->compute_needs_range_check(); |
328 bool use_length = x->length() != NULL; | 328 bool use_length = x->length() != NULL; |
329 bool obj_store = x->elt_type() == T_ARRAY || x->elt_type() == T_OBJECT; | 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 || | 330 bool needs_store_check = obj_store && (x->value()->as_Constant() == NULL || |
331 !get_jobject_constant(x->value())->is_null_object() || | 331 !get_jobject_constant(x->value())->is_null_object() || |
332 x->should_profile()); | 332 x->should_profile()); |
337 LIRItem length(this); | 337 LIRItem length(this); |
338 | 338 |
339 array.load_item(); | 339 array.load_item(); |
340 index.load_nonconstant(); | 340 index.load_nonconstant(); |
341 | 341 |
342 if (use_length) { | 342 if (use_length && needs_range_check) { |
343 needs_range_check = x->compute_needs_range_check(); | 343 length.set_instruction(x->length()); |
344 if (needs_range_check) { | 344 length.load_item(); |
345 length.set_instruction(x->length()); | |
346 length.load_item(); | |
347 } | |
348 } | 345 } |
349 if (needs_store_check) { | 346 if (needs_store_check) { |
350 value.load_item(); | 347 value.load_item(); |
351 } else { | 348 } else { |
352 value.load_for_store(x->elt_type()); | 349 value.load_for_store(x->elt_type()); |