Index: src/x64/lithium-codegen-x64.cc |
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc |
index b461e6290376d4b842640115cea9ec1bd7da2d90..98e9aadedcffa0cc7f57d5208cc1f0756446b49e 100644 |
--- a/src/x64/lithium-codegen-x64.cc |
+++ b/src/x64/lithium-codegen-x64.cc |
@@ -2612,15 +2612,16 @@ void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) { |
} |
-void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { |
- Register result = ToRegister(instr->result()); |
+void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { |
+ ElementsKind elements_kind = instr->elements_kind(); |
LOperand* key = instr->key(); |
if (!key->IsConstantOperand()) { |
Register key_reg = ToRegister(key); |
- // 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. |
+ // Even though the HLoad/StoreKeyed (in this case) 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 (instr->hydrogen()->key()->representation().IsTagged()) { |
__ SmiToInteger64(key_reg, key_reg); |
} else if (instr->hydrogen()->IsDehoisted()) { |
@@ -2629,35 +2630,68 @@ void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { |
__ movsxlq(key_reg, key_reg); |
} |
} |
+ Operand operand(BuildFastArrayOperand( |
+ instr->elements(), |
+ key, |
+ elements_kind, |
+ 0, |
+ instr->additional_index())); |
- // Load the result. |
- __ movq(result, |
- BuildFastArrayOperand(instr->elements(), |
- key, |
- FAST_ELEMENTS, |
- FixedArray::kHeaderSize - kHeapObjectTag, |
- instr->additional_index())); |
- |
- // Check for the hole value. |
- if (instr->hydrogen()->RequiresHoleCheck()) { |
- if (IsFastSmiElementsKind(instr->hydrogen()->elements_kind())) { |
- Condition smi = __ CheckSmi(result); |
- DeoptimizeIf(NegateCondition(smi), instr->environment()); |
- } else { |
- __ CompareRoot(result, Heap::kTheHoleValueRootIndex); |
- DeoptimizeIf(equal, instr->environment()); |
+ if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { |
+ XMMRegister result(ToDoubleRegister(instr->result())); |
+ __ movss(result, operand); |
+ __ cvtss2sd(result, result); |
+ } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { |
+ __ movsd(ToDoubleRegister(instr->result()), operand); |
+ } else { |
+ Register result(ToRegister(instr->result())); |
+ switch (elements_kind) { |
+ case EXTERNAL_BYTE_ELEMENTS: |
+ __ movsxbq(result, operand); |
+ break; |
+ case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
+ case EXTERNAL_PIXEL_ELEMENTS: |
+ __ movzxbq(result, operand); |
+ break; |
+ case EXTERNAL_SHORT_ELEMENTS: |
+ __ movsxwq(result, operand); |
+ break; |
+ case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
+ __ movzxwq(result, operand); |
+ break; |
+ case EXTERNAL_INT_ELEMENTS: |
+ __ movsxlq(result, operand); |
+ break; |
+ case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
+ __ movl(result, operand); |
+ if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { |
+ __ testl(result, result); |
+ DeoptimizeIf(negative, instr->environment()); |
+ } |
+ break; |
+ case EXTERNAL_FLOAT_ELEMENTS: |
+ case EXTERNAL_DOUBLE_ELEMENTS: |
+ case FAST_ELEMENTS: |
+ case FAST_SMI_ELEMENTS: |
+ case FAST_DOUBLE_ELEMENTS: |
+ case FAST_HOLEY_ELEMENTS: |
+ case FAST_HOLEY_SMI_ELEMENTS: |
+ case FAST_HOLEY_DOUBLE_ELEMENTS: |
+ case DICTIONARY_ELEMENTS: |
+ case NON_STRICT_ARGUMENTS_ELEMENTS: |
+ UNREACHABLE(); |
+ break; |
} |
} |
} |
-void LCodeGen::DoLoadKeyedFastDoubleElement( |
- LLoadKeyedFastDoubleElement* instr) { |
+void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) { |
XMMRegister result(ToDoubleRegister(instr->result())); |
LOperand* key = instr->key(); |
if (!key->IsConstantOperand()) { |
Register key_reg = ToRegister(key); |
- // Even though the HLoad/StoreKeyedFastElement instructions force the input |
+ // 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. |
@@ -2693,6 +2727,57 @@ void LCodeGen::DoLoadKeyedFastDoubleElement( |
} |
+void LCodeGen::DoLoadKeyedFixedArray(LLoadKeyed* instr) { |
+ Register result = ToRegister(instr->result()); |
+ LOperand* key = instr->key(); |
+ if (!key->IsConstantOperand()) { |
+ Register key_reg = ToRegister(key); |
+ // 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 (instr->hydrogen()->key()->representation().IsTagged()) { |
+ __ SmiToInteger64(key_reg, key_reg); |
+ } else if (instr->hydrogen()->IsDehoisted()) { |
+ // Sign extend key because it could be a 32 bit negative value |
+ // and the dehoisted address computation happens in 64 bits |
+ __ movsxlq(key_reg, key_reg); |
+ } |
+ } |
+ |
+ // Load the result. |
+ __ movq(result, |
+ BuildFastArrayOperand(instr->elements(), |
+ key, |
+ FAST_ELEMENTS, |
+ FixedArray::kHeaderSize - kHeapObjectTag, |
+ instr->additional_index())); |
+ |
+ // Check for the hole value. |
+ if (instr->hydrogen()->RequiresHoleCheck()) { |
+ if (IsFastSmiElementsKind(instr->hydrogen()->elements_kind())) { |
+ Condition smi = __ CheckSmi(result); |
+ DeoptimizeIf(NegateCondition(smi), instr->environment()); |
+ } else { |
+ __ CompareRoot(result, Heap::kTheHoleValueRootIndex); |
+ DeoptimizeIf(equal, instr->environment()); |
+ } |
+ } |
+} |
+ |
+ |
+void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) { |
+ if (instr->is_external()) { |
+ DoLoadKeyedExternalArray(instr); |
+ } else if (instr->hydrogen()->representation().IsDouble()) { |
+ DoLoadKeyedFixedDoubleArray(instr); |
+ } else { |
+ DoLoadKeyedFixedArray(instr); |
+ } |
+} |
+ |
+ |
Operand LCodeGen::BuildFastArrayOperand( |
LOperand* elements_pointer, |
LOperand* key, |
@@ -2719,80 +2804,6 @@ Operand LCodeGen::BuildFastArrayOperand( |
} |
-void LCodeGen::DoLoadKeyedSpecializedArrayElement( |
- LLoadKeyedSpecializedArrayElement* instr) { |
- ElementsKind elements_kind = instr->elements_kind(); |
- LOperand* key = instr->key(); |
- if (!key->IsConstantOperand()) { |
- Register key_reg = ToRegister(key); |
- // 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 (instr->hydrogen()->key()->representation().IsTagged()) { |
- __ SmiToInteger64(key_reg, key_reg); |
- } else if (instr->hydrogen()->IsDehoisted()) { |
- // Sign extend key because it could be a 32 bit negative value |
- // and the dehoisted address computation happens in 64 bits |
- __ movsxlq(key_reg, key_reg); |
- } |
- } |
- Operand operand(BuildFastArrayOperand( |
- instr->external_pointer(), |
- key, |
- elements_kind, |
- 0, |
- instr->additional_index())); |
- |
- if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { |
- XMMRegister result(ToDoubleRegister(instr->result())); |
- __ movss(result, operand); |
- __ cvtss2sd(result, result); |
- } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { |
- __ movsd(ToDoubleRegister(instr->result()), operand); |
- } else { |
- Register result(ToRegister(instr->result())); |
- switch (elements_kind) { |
- case EXTERNAL_BYTE_ELEMENTS: |
- __ movsxbq(result, operand); |
- break; |
- case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
- case EXTERNAL_PIXEL_ELEMENTS: |
- __ movzxbq(result, operand); |
- break; |
- case EXTERNAL_SHORT_ELEMENTS: |
- __ movsxwq(result, operand); |
- break; |
- case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
- __ movzxwq(result, operand); |
- break; |
- case EXTERNAL_INT_ELEMENTS: |
- __ movsxlq(result, operand); |
- break; |
- case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
- __ movl(result, operand); |
- if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { |
- __ testl(result, result); |
- DeoptimizeIf(negative, instr->environment()); |
- } |
- break; |
- case EXTERNAL_FLOAT_ELEMENTS: |
- case EXTERNAL_DOUBLE_ELEMENTS: |
- case FAST_ELEMENTS: |
- case FAST_SMI_ELEMENTS: |
- case FAST_DOUBLE_ELEMENTS: |
- case FAST_HOLEY_ELEMENTS: |
- case FAST_HOLEY_SMI_ELEMENTS: |
- case FAST_HOLEY_DOUBLE_ELEMENTS: |
- case DICTIONARY_ELEMENTS: |
- case NON_STRICT_ARGUMENTS_ELEMENTS: |
- UNREACHABLE(); |
- break; |
- } |
- } |
-} |
- |
- |
void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { |
ASSERT(ToRegister(instr->object()).is(rdx)); |
ASSERT(ToRegister(instr->key()).is(rax)); |
@@ -3665,70 +3676,6 @@ void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { |
} |
-void LCodeGen::DoStoreKeyedSpecializedArrayElement( |
- LStoreKeyedSpecializedArrayElement* instr) { |
- ElementsKind elements_kind = instr->elements_kind(); |
- LOperand* key = instr->key(); |
- if (!key->IsConstantOperand()) { |
- Register key_reg = ToRegister(key); |
- // 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 (instr->hydrogen()->key()->representation().IsTagged()) { |
- __ SmiToInteger64(key_reg, key_reg); |
- } else if (instr->hydrogen()->IsDehoisted()) { |
- // Sign extend key because it could be a 32 bit negative value |
- // and the dehoisted address computation happens in 64 bits |
- __ movsxlq(key_reg, key_reg); |
- } |
- } |
- Operand operand(BuildFastArrayOperand( |
- instr->external_pointer(), |
- key, |
- elements_kind, |
- 0, |
- instr->additional_index())); |
- |
- if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { |
- XMMRegister value(ToDoubleRegister(instr->value())); |
- __ cvtsd2ss(value, value); |
- __ movss(operand, value); |
- } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { |
- __ movsd(operand, ToDoubleRegister(instr->value())); |
- } else { |
- Register value(ToRegister(instr->value())); |
- switch (elements_kind) { |
- case EXTERNAL_PIXEL_ELEMENTS: |
- case EXTERNAL_BYTE_ELEMENTS: |
- case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
- __ movb(operand, value); |
- break; |
- case EXTERNAL_SHORT_ELEMENTS: |
- case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
- __ movw(operand, value); |
- break; |
- case EXTERNAL_INT_ELEMENTS: |
- case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
- __ movl(operand, value); |
- break; |
- case EXTERNAL_FLOAT_ELEMENTS: |
- case EXTERNAL_DOUBLE_ELEMENTS: |
- case FAST_ELEMENTS: |
- case FAST_SMI_ELEMENTS: |
- case FAST_DOUBLE_ELEMENTS: |
- case FAST_HOLEY_ELEMENTS: |
- case FAST_HOLEY_SMI_ELEMENTS: |
- case FAST_HOLEY_DOUBLE_ELEMENTS: |
- case DICTIONARY_ELEMENTS: |
- case NON_STRICT_ARGUMENTS_ELEMENTS: |
- UNREACHABLE(); |
- break; |
- } |
- } |
-} |
- |
- |
void LCodeGen::DeoptIfTaggedButNotSmi(LEnvironment* environment, |
HValue* value, |
LOperand* operand) { |
@@ -3789,16 +3736,16 @@ void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { |
} |
-void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { |
- Register value = ToRegister(instr->value()); |
- Register elements = ToRegister(instr->object()); |
+void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { |
+ ElementsKind elements_kind = instr->elements_kind(); |
LOperand* key = instr->key(); |
if (!key->IsConstantOperand()) { |
Register key_reg = ToRegister(key); |
- // 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. |
+ // 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 (instr->hydrogen()->key()->representation().IsTagged()) { |
__ SmiToInteger64(key_reg, key_reg); |
} else if (instr->hydrogen()->IsDehoisted()) { |
@@ -3807,45 +3754,62 @@ void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { |
__ movsxlq(key_reg, key_reg); |
} |
} |
+ Operand operand(BuildFastArrayOperand( |
+ instr->elements(), |
+ key, |
+ elements_kind, |
+ 0, |
+ instr->additional_index())); |
- Operand operand = |
- BuildFastArrayOperand(instr->object(), |
- key, |
- FAST_ELEMENTS, |
- FixedArray::kHeaderSize - kHeapObjectTag, |
- instr->additional_index()); |
- |
- 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. |
- Register key_reg(ToRegister(key)); |
- __ lea(key_reg, operand); |
- __ movq(Operand(key_reg, 0), value); |
- __ RecordWrite(elements, |
- key_reg, |
- value, |
- kSaveFPRegs, |
- EMIT_REMEMBERED_SET, |
- check_needed); |
+ if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { |
+ XMMRegister value(ToDoubleRegister(instr->value())); |
+ __ cvtsd2ss(value, value); |
+ __ movss(operand, value); |
+ } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { |
+ __ movsd(operand, ToDoubleRegister(instr->value())); |
} else { |
- __ movq(operand, value); |
+ Register value(ToRegister(instr->value())); |
+ switch (elements_kind) { |
+ case EXTERNAL_PIXEL_ELEMENTS: |
+ case EXTERNAL_BYTE_ELEMENTS: |
+ case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
+ __ movb(operand, value); |
+ break; |
+ case EXTERNAL_SHORT_ELEMENTS: |
+ case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
+ __ movw(operand, value); |
+ break; |
+ case EXTERNAL_INT_ELEMENTS: |
+ case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
+ __ movl(operand, value); |
+ break; |
+ case EXTERNAL_FLOAT_ELEMENTS: |
+ case EXTERNAL_DOUBLE_ELEMENTS: |
+ case FAST_ELEMENTS: |
+ case FAST_SMI_ELEMENTS: |
+ case FAST_DOUBLE_ELEMENTS: |
+ case FAST_HOLEY_ELEMENTS: |
+ case FAST_HOLEY_SMI_ELEMENTS: |
+ case FAST_HOLEY_DOUBLE_ELEMENTS: |
+ case DICTIONARY_ELEMENTS: |
+ case NON_STRICT_ARGUMENTS_ELEMENTS: |
+ UNREACHABLE(); |
+ break; |
+ } |
} |
} |
-void LCodeGen::DoStoreKeyedFastDoubleElement( |
- LStoreKeyedFastDoubleElement* instr) { |
+void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) { |
XMMRegister value = ToDoubleRegister(instr->value()); |
LOperand* key = instr->key(); |
if (!key->IsConstantOperand()) { |
Register key_reg = ToRegister(key); |
- // 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. |
+ // 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 (instr->hydrogen()->key()->representation().IsTagged()) { |
__ SmiToInteger64(key_reg, key_reg); |
} else if (instr->hydrogen()->IsDehoisted()) { |
@@ -3878,6 +3842,66 @@ void LCodeGen::DoStoreKeyedFastDoubleElement( |
__ movsd(double_store_operand, value); |
} |
+ |
+void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) { |
+ Register value = ToRegister(instr->value()); |
+ Register elements = ToRegister(instr->elements()); |
+ LOperand* key = instr->key(); |
+ if (!key->IsConstantOperand()) { |
+ Register key_reg = ToRegister(key); |
+ // 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 (instr->hydrogen()->key()->representation().IsTagged()) { |
+ __ SmiToInteger64(key_reg, key_reg); |
+ } else if (instr->hydrogen()->IsDehoisted()) { |
+ // Sign extend key because it could be a 32 bit negative value |
+ // and the dehoisted address computation happens in 64 bits |
+ __ movsxlq(key_reg, key_reg); |
+ } |
+ } |
+ |
+ Operand operand = |
+ BuildFastArrayOperand(instr->elements(), |
+ key, |
+ FAST_ELEMENTS, |
+ FixedArray::kHeaderSize - kHeapObjectTag, |
+ instr->additional_index()); |
+ |
+ 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. |
+ Register key_reg(ToRegister(key)); |
+ __ lea(key_reg, operand); |
+ __ movq(Operand(key_reg, 0), value); |
+ __ RecordWrite(elements, |
+ key_reg, |
+ value, |
+ kSaveFPRegs, |
+ EMIT_REMEMBERED_SET, |
+ check_needed); |
+ } else { |
+ __ movq(operand, value); |
+ } |
+} |
+ |
+ |
+void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { |
+ if (instr->is_external()) { |
+ DoStoreKeyedExternalArray(instr); |
+ } else if (instr->hydrogen()->value()->representation().IsDouble()) { |
+ DoStoreKeyedFixedDoubleArray(instr); |
+ } else { |
+ DoStoreKeyedFixedArray(instr); |
+ } |
+} |
+ |
+ |
void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { |
ASSERT(ToRegister(instr->object()).is(rdx)); |
ASSERT(ToRegister(instr->key()).is(rcx)); |