Chromium Code Reviews| Index: src/ia32/lithium-codegen-ia32.cc |
| diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc |
| index 32c66a05f509df7df7d7314401f628dfbdcf4e87..f0d1ddd5c8f6fca6131df1778360e65a4dfcd449 100644 |
| --- a/src/ia32/lithium-codegen-ia32.cc |
| +++ b/src/ia32/lithium-codegen-ia32.cc |
| @@ -2749,95 +2749,7 @@ void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) { |
| } |
| -void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { |
| - Register result = ToRegister(instr->result()); |
| - |
| - // Load the result. |
| - __ mov(result, |
| - BuildFastArrayOperand(instr->elements(), |
| - instr->key(), |
| - instr->hydrogen()->key()->representation(), |
| - FAST_ELEMENTS, |
| - FixedArray::kHeaderSize - kHeapObjectTag, |
| - instr->additional_index())); |
| - |
| - // Check for the hole value. |
| - if (instr->hydrogen()->RequiresHoleCheck()) { |
| - if (IsFastSmiElementsKind(instr->hydrogen()->elements_kind())) { |
| - __ test(result, Immediate(kSmiTagMask)); |
| - DeoptimizeIf(not_equal, instr->environment()); |
| - } else { |
| - __ cmp(result, factory()->the_hole_value()); |
| - DeoptimizeIf(equal, instr->environment()); |
| - } |
| - } |
| -} |
| - |
| - |
| -void LCodeGen::DoLoadKeyedFastDoubleElement( |
| - LLoadKeyedFastDoubleElement* instr) { |
| - XMMRegister result = ToDoubleRegister(instr->result()); |
| - |
| - if (instr->hydrogen()->RequiresHoleCheck()) { |
| - int offset = FixedDoubleArray::kHeaderSize - kHeapObjectTag + |
| - sizeof(kHoleNanLower32); |
| - Operand hole_check_operand = BuildFastArrayOperand( |
| - instr->elements(), instr->key(), |
| - instr->hydrogen()->key()->representation(), |
| - FAST_DOUBLE_ELEMENTS, |
| - offset, |
| - instr->additional_index()); |
| - __ cmp(hole_check_operand, Immediate(kHoleNanUpper32)); |
| - DeoptimizeIf(equal, instr->environment()); |
| - } |
| - |
| - Operand double_load_operand = BuildFastArrayOperand( |
| - instr->elements(), |
| - instr->key(), |
| - instr->hydrogen()->key()->representation(), |
| - FAST_DOUBLE_ELEMENTS, |
| - FixedDoubleArray::kHeaderSize - kHeapObjectTag, |
| - instr->additional_index()); |
| - __ movdbl(result, double_load_operand); |
| -} |
| - |
| - |
| -Operand LCodeGen::BuildFastArrayOperand( |
| - LOperand* elements_pointer, |
| - LOperand* key, |
| - Representation key_representation, |
| - ElementsKind elements_kind, |
| - uint32_t offset, |
| - uint32_t additional_index) { |
| - Register elements_pointer_reg = ToRegister(elements_pointer); |
| - int shift_size = ElementsKindToShiftSize(elements_kind); |
| - // Even though the HLoad/StoreKeyedFastElement instructions force the input |
| - // representation for the key to be an integer, the input gets replaced during |
| - // bound check elimination with the index argument to the bounds check, which |
| - // can be tagged, so that case must be handled here, too. |
| - if (key_representation.IsTagged() && (shift_size >= 1)) { |
| - shift_size -= kSmiTagSize; |
| - } |
| - if (key->IsConstantOperand()) { |
| - int constant_value = ToInteger32(LConstantOperand::cast(key)); |
| - if (constant_value & 0xF0000000) { |
| - Abort("array index constant value too big"); |
| - } |
| - return Operand(elements_pointer_reg, |
| - ((constant_value + additional_index) << shift_size) |
| - + offset); |
| - } else { |
| - ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size); |
| - return Operand(elements_pointer_reg, |
| - ToRegister(key), |
| - scale_factor, |
| - offset + (additional_index << shift_size)); |
| - } |
| -} |
| - |
| - |
| -void LCodeGen::DoLoadKeyedSpecializedArrayElement( |
| - LLoadKeyedSpecializedArrayElement* instr) { |
| +void LCodeGen::DoLoadKeyedExternal(LLoadKeyed* instr) { |
| ElementsKind elements_kind = instr->elements_kind(); |
| LOperand* key = instr->key(); |
| if (!key->IsConstantOperand() && |
| @@ -2846,7 +2758,7 @@ void LCodeGen::DoLoadKeyedSpecializedArrayElement( |
| __ SmiUntag(ToRegister(key)); |
| } |
| Operand operand(BuildFastArrayOperand( |
| - instr->external_pointer(), |
| + instr->object(), |
| key, |
| instr->hydrogen()->key()->representation(), |
| elements_kind, |
| @@ -2901,6 +2813,102 @@ void LCodeGen::DoLoadKeyedSpecializedArrayElement( |
| } |
| +void LCodeGen::DoLoadKeyedDouble(LLoadKeyed* instr) { |
| + XMMRegister result = ToDoubleRegister(instr->result()); |
| + |
| + if (instr->hydrogen()->RequiresHoleCheck()) { |
| + int offset = FixedDoubleArray::kHeaderSize - kHeapObjectTag + |
| + sizeof(kHoleNanLower32); |
| + Operand hole_check_operand = BuildFastArrayOperand( |
| + instr->object(), instr->key(), |
| + instr->hydrogen()->key()->representation(), |
| + FAST_DOUBLE_ELEMENTS, |
| + offset, |
| + instr->additional_index()); |
| + __ cmp(hole_check_operand, Immediate(kHoleNanUpper32)); |
| + DeoptimizeIf(equal, instr->environment()); |
| + } |
| + |
| + Operand double_load_operand = BuildFastArrayOperand( |
| + instr->object(), |
| + instr->key(), |
| + instr->hydrogen()->key()->representation(), |
| + FAST_DOUBLE_ELEMENTS, |
| + FixedDoubleArray::kHeaderSize - kHeapObjectTag, |
| + instr->additional_index()); |
| + __ movdbl(result, double_load_operand); |
| +} |
| + |
| + |
| +void LCodeGen::DoLoadKeyedFixed(LLoadKeyed* instr) { |
| + Register result = ToRegister(instr->result()); |
| + |
| + // Load the result. |
| + __ mov(result, |
| + BuildFastArrayOperand(instr->object(), |
| + instr->key(), |
| + instr->hydrogen()->key()->representation(), |
| + FAST_ELEMENTS, |
| + FixedArray::kHeaderSize - kHeapObjectTag, |
| + instr->additional_index())); |
| + |
| + // Check for the hole value. |
| + if (instr->hydrogen()->RequiresHoleCheck()) { |
| + if (IsFastSmiElementsKind(instr->hydrogen()->elements_kind())) { |
| + __ test(result, Immediate(kSmiTagMask)); |
| + DeoptimizeIf(not_equal, instr->environment()); |
| + } else { |
| + __ cmp(result, factory()->the_hole_value()); |
| + DeoptimizeIf(equal, instr->environment()); |
| + } |
| + } |
| +} |
| + |
|
danno
2012/10/24 11:42:43
nit: two spaces
mvstanton
2012/10/24 18:24:21
Done.
|
| +void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) { |
| + if (instr->is_external()) { |
| + DoLoadKeyedExternal(instr); |
| + } else if (instr->hydrogen()->representation().IsDouble()) { |
| + DoLoadKeyedDouble(instr); |
| + } else { |
| + DoLoadKeyedFixed(instr); |
| + } |
| +} |
| + |
| + |
| +Operand LCodeGen::BuildFastArrayOperand( |
| + LOperand* elements_pointer, |
| + LOperand* key, |
| + Representation key_representation, |
| + ElementsKind elements_kind, |
| + uint32_t offset, |
| + uint32_t additional_index) { |
| + Register elements_pointer_reg = ToRegister(elements_pointer); |
| + int shift_size = ElementsKindToShiftSize(elements_kind); |
| + // Even though the HLoad/StoreKeyed instructions force the input |
| + // representation for the key to be an integer, the input gets replaced during |
| + // bound check elimination with the index argument to the bounds check, which |
| + // can be tagged, so that case must be handled here, too. |
| + if (key_representation.IsTagged() && (shift_size >= 1)) { |
| + shift_size -= kSmiTagSize; |
| + } |
| + if (key->IsConstantOperand()) { |
| + int constant_value = ToInteger32(LConstantOperand::cast(key)); |
| + if (constant_value & 0xF0000000) { |
| + Abort("array index constant value too big"); |
| + } |
| + return Operand(elements_pointer_reg, |
| + ((constant_value + additional_index) << shift_size) |
| + + offset); |
| + } else { |
| + ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size); |
| + return Operand(elements_pointer_reg, |
| + ToRegister(key), |
| + scale_factor, |
| + offset + (additional_index << shift_size)); |
| + } |
| +} |
| + |
| + |
| void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { |
| ASSERT(ToRegister(instr->context()).is(esi)); |
| ASSERT(ToRegister(instr->object()).is(edx)); |
| @@ -3818,8 +3826,7 @@ void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { |
| } |
| -void LCodeGen::DoStoreKeyedSpecializedArrayElement( |
| - LStoreKeyedSpecializedArrayElement* instr) { |
| +void LCodeGen::DoStoreKeyedExternal(LStoreKeyed* instr) { |
| ElementsKind elements_kind = instr->elements_kind(); |
| LOperand* key = instr->key(); |
| if (!key->IsConstantOperand() && |
| @@ -3828,7 +3835,7 @@ void LCodeGen::DoStoreKeyedSpecializedArrayElement( |
| __ SmiUntag(ToRegister(key)); |
| } |
| Operand operand(BuildFastArrayOperand( |
| - instr->external_pointer(), |
| + instr->object(), |
| key, |
| instr->hydrogen()->key()->representation(), |
| elements_kind, |
| @@ -3872,10 +3879,37 @@ void LCodeGen::DoStoreKeyedSpecializedArrayElement( |
| } |
| -void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { |
| +void LCodeGen::DoStoreKeyedDouble(LStoreKeyed* instr) { |
| + XMMRegister value = ToDoubleRegister(instr->value()); |
| + |
| + if (instr->NeedsCanonicalization()) { |
| + Label have_value; |
| + |
| + __ ucomisd(value, value); |
| + __ j(parity_odd, &have_value); // NaN. |
| + |
| + ExternalReference canonical_nan_reference = |
| + ExternalReference::address_of_canonical_non_hole_nan(); |
| + __ movdbl(value, Operand::StaticVariable(canonical_nan_reference)); |
| + __ bind(&have_value); |
| + } |
| + |
| + Operand double_store_operand = BuildFastArrayOperand( |
| + instr->object(), |
| + instr->key(), |
| + instr->hydrogen()->key()->representation(), |
| + FAST_DOUBLE_ELEMENTS, |
| + FixedDoubleArray::kHeaderSize - kHeapObjectTag, |
| + instr->additional_index()); |
| + __ movdbl(double_store_operand, value); |
| +} |
| + |
| + |
| +void LCodeGen::DoStoreKeyedFixed(LStoreKeyed* instr) { |
| Register value = ToRegister(instr->value()); |
| Register elements = ToRegister(instr->object()); |
| - Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg; |
| + Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) |
|
danno
2012/10/24 11:42:43
I think this still fits on one line?
mvstanton
2012/10/24 18:24:21
Done.
|
| + : no_reg; |
| Operand operand = BuildFastArrayOperand( |
| instr->object(), |
| @@ -3903,30 +3937,15 @@ void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { |
| } |
| -void LCodeGen::DoStoreKeyedFastDoubleElement( |
| - LStoreKeyedFastDoubleElement* instr) { |
| - XMMRegister value = ToDoubleRegister(instr->value()); |
| - |
| - if (instr->NeedsCanonicalization()) { |
| - Label have_value; |
| - |
| - __ ucomisd(value, value); |
| - __ j(parity_odd, &have_value); // NaN. |
| - |
| - ExternalReference canonical_nan_reference = |
| - ExternalReference::address_of_canonical_non_hole_nan(); |
| - __ movdbl(value, Operand::StaticVariable(canonical_nan_reference)); |
| - __ bind(&have_value); |
| +void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { |
| + // By cases...external, fast-double, fast |
| + if (instr->is_external()) { |
| + DoStoreKeyedExternal(instr); |
| + } else if (instr->hydrogen()->value()->representation().IsDouble()) { |
| + DoStoreKeyedDouble(instr); |
| + } else { |
| + DoStoreKeyedFixed(instr); |
| } |
| - |
| - Operand double_store_operand = BuildFastArrayOperand( |
| - instr->elements(), |
| - instr->key(), |
| - instr->hydrogen()->key()->representation(), |
| - FAST_DOUBLE_ELEMENTS, |
| - FixedDoubleArray::kHeaderSize - kHeapObjectTag, |
| - instr->additional_index()); |
| - __ movdbl(double_store_operand, value); |
| } |