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..8ca7bc0aa047ef50f67c0e8ae65f0dd0c25ae785 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() && |
@@ -2901,6 +2813,93 @@ void LCodeGen::DoLoadKeyedSpecializedArrayElement( |
} |
+void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) { |
+ if (instr->is_external()) { |
+ DoLoadKeyedExternal(instr); |
+ } else if (instr->hydrogen()->representation().IsDouble()) { |
+ 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); |
+ } else { |
+ 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()); |
+ } |
+ } |
+ } |
+} |
+ |
+ |
+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 +3817,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() && |
@@ -3872,61 +3870,63 @@ void LCodeGen::DoStoreKeyedSpecializedArrayElement( |
} |
-void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { |
- Register value = ToRegister(instr->value()); |
- Register elements = ToRegister(instr->object()); |
- Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg; |
- |
- Operand operand = BuildFastArrayOperand( |
- instr->object(), |
- instr->key(), |
- instr->hydrogen()->key()->representation(), |
- FAST_ELEMENTS, |
- FixedArray::kHeaderSize - kHeapObjectTag, |
- instr->additional_index()); |
- __ mov(operand, 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()) { |
+ XMMRegister value = ToDoubleRegister(instr->value()); |
- if (instr->hydrogen()->NeedsWriteBarrier()) { |
- ASSERT(!instr->key()->IsConstantOperand()); |
- HType type = instr->hydrogen()->value()->type(); |
- SmiCheck check_needed = |
- type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; |
- // Compute address of modified element and store it into key register. |
- __ lea(key, operand); |
- __ RecordWrite(elements, |
- key, |
- value, |
- kSaveFPRegs, |
- EMIT_REMEMBERED_SET, |
- check_needed); |
- } |
-} |
+ if (instr->NeedsCanonicalization()) { |
+ Label have_value; |
+ __ ucomisd(value, value); |
+ __ j(parity_odd, &have_value); // NaN. |
-void LCodeGen::DoStoreKeyedFastDoubleElement( |
- LStoreKeyedFastDoubleElement* instr) { |
- XMMRegister value = ToDoubleRegister(instr->value()); |
+ ExternalReference canonical_nan_reference = |
+ ExternalReference::address_of_canonical_non_hole_nan(); |
+ __ movdbl(value, Operand::StaticVariable(canonical_nan_reference)); |
+ __ bind(&have_value); |
+ } |
- if (instr->NeedsCanonicalization()) { |
- Label 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); |
+ } else { |
+ Register value = ToRegister(instr->value()); |
+ Register elements = ToRegister(instr->object()); |
+ Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) |
+ : no_reg; |
- __ ucomisd(value, value); |
- __ j(parity_odd, &have_value); // NaN. |
+ Operand operand = BuildFastArrayOperand( |
+ instr->object(), |
+ instr->key(), |
+ instr->hydrogen()->key()->representation(), |
+ FAST_ELEMENTS, |
+ FixedArray::kHeaderSize - kHeapObjectTag, |
+ instr->additional_index()); |
+ __ mov(operand, value); |
- ExternalReference canonical_nan_reference = |
- ExternalReference::address_of_canonical_non_hole_nan(); |
- __ movdbl(value, Operand::StaticVariable(canonical_nan_reference)); |
- __ bind(&have_value); |
+ if (instr->hydrogen()->NeedsWriteBarrier()) { |
+ ASSERT(!instr->key()->IsConstantOperand()); |
+ HType type = instr->hydrogen()->value()->type(); |
+ SmiCheck check_needed = |
+ type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; |
+ // Compute address of modified element and store it into key register. |
+ __ lea(key, operand); |
+ __ RecordWrite(elements, |
+ key, |
+ value, |
+ kSaveFPRegs, |
+ EMIT_REMEMBERED_SET, |
+ check_needed); |
+ } |
} |
- |
- 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); |
} |