| Index: src/ia32/lithium-codegen-ia32.cc
|
| ===================================================================
|
| --- src/ia32/lithium-codegen-ia32.cc (revision 11854)
|
| +++ src/ia32/lithium-codegen-ia32.cc (working copy)
|
| @@ -3557,13 +3557,35 @@
|
|
|
|
|
| void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
|
| + int32_t lower_offset = instr->hydrogen()->lower_offset();
|
| + int32_t upper_offset = instr->hydrogen()->upper_offset();
|
| if (instr->index()->IsConstantOperand()) {
|
| - __ cmp(ToOperand(instr->length()),
|
| - Immediate(ToInteger32(LConstantOperand::cast(instr->index()))));
|
| + int32_t c_index = ToInteger32(LConstantOperand::cast(instr->index()));
|
| + int64_t upper_range = (int64_t)c_index + (int64_t)upper_offset;
|
| + if (c_index < -lower_offset || upper_range > ((int64_t)1 << 32)) {
|
| + DeoptimizeIf(no_condition, instr->environment());
|
| + }
|
| + __ cmp(ToOperand(instr->length()), Immediate(c_index + upper_offset));
|
| DeoptimizeIf(below_equal, instr->environment());
|
| } else {
|
| - __ cmp(ToRegister(instr->index()), ToOperand(instr->length()));
|
| - DeoptimizeIf(above_equal, instr->environment());
|
| + ASSERT(instr->index()->IsRegister());
|
| + Register reg_index = ToRegister(instr->index());
|
| + if (lower_offset == 0 && upper_offset == 0) {
|
| + __ cmp(reg_index, ToOperand(instr->length()));
|
| + DeoptimizeIf(above_equal, instr->environment());
|
| + } else {
|
| + Register temp_length = ToRegister(instr->TempAt(0));
|
| + __ mov(temp_length, ToOperand(instr->length()));
|
| + __ cmp(reg_index, Immediate(-lower_offset));
|
| + DeoptimizeIf(less, instr->environment());
|
| + __ sub(temp_length, Immediate(upper_offset));
|
| + __ cmp(reg_index, temp_length);
|
| + if (upper_offset >= 0) {
|
| + DeoptimizeIf(greater_equal, instr->environment());
|
| + } else {
|
| + DeoptimizeIf(above_equal, instr->environment());
|
| + }
|
| + }
|
| }
|
| }
|
|
|
|
|