Index: src/x64/lithium-codegen-x64.cc |
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc |
index 4596aca2f7628e78bdd4bcc0d84bd5129abd348a..2bcf943ab6cb3963fe9c8b53f0a3679355c9048e 100644 |
--- a/src/x64/lithium-codegen-x64.cc |
+++ b/src/x64/lithium-codegen-x64.cc |
@@ -2624,30 +2624,24 @@ void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) { |
} |
-template <class T> |
-inline void LCodeGen::PrepareKeyForKeyedOp(T* hydrogen_instr, LOperand* key) { |
- if (ArrayOpClobbersKey<T>(hydrogen_instr)) { |
+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/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. |
- Register key_reg = ToRegister(key); |
- if (hydrogen_instr->key()->representation().IsTagged()) { |
+ if (instr->hydrogen()->key()->representation().IsTagged()) { |
__ SmiToInteger64(key_reg, key_reg); |
- } else if (hydrogen_instr->IsDehoisted()) { |
+ } 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); |
} |
} |
-} |
- |
- |
-void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { |
- ElementsKind elements_kind = instr->elements_kind(); |
- LOperand* key = instr->key(); |
- PrepareKeyForKeyedOp(instr->hydrogen(), key); |
Operand operand(BuildFastArrayOperand( |
instr->elements(), |
key, |
@@ -2707,7 +2701,21 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { |
void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) { |
XMMRegister result(ToDoubleRegister(instr->result())); |
LOperand* key = instr->key(); |
- PrepareKeyForKeyedOp<HLoadKeyed>(instr->hydrogen(), key); |
+ if (!key->IsConstantOperand()) { |
+ Register key_reg = ToRegister(key); |
+ // 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 (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); |
+ } |
+ } |
+ |
if (instr->hydrogen()->RequiresHoleCheck()) { |
int offset = FixedDoubleArray::kHeaderSize - kHeapObjectTag + |
sizeof(kHoleNanLower32); |
@@ -2734,7 +2742,21 @@ void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) { |
void LCodeGen::DoLoadKeyedFixedArray(LLoadKeyed* instr) { |
Register result = ToRegister(instr->result()); |
LOperand* key = instr->key(); |
- PrepareKeyForKeyedOp<HLoadKeyed>(instr->hydrogen(), 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, |
@@ -3729,7 +3751,21 @@ void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { |
void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { |
ElementsKind elements_kind = instr->elements_kind(); |
LOperand* key = instr->key(); |
- PrepareKeyForKeyedOp<HStoreKeyed>(instr->hydrogen(), 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, |
@@ -3779,7 +3815,22 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { |
void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) { |
XMMRegister value = ToDoubleRegister(instr->value()); |
LOperand* key = instr->key(); |
- PrepareKeyForKeyedOp<HStoreKeyed>(instr->hydrogen(), 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); |
+ } |
+ } |
+ |
if (instr->NeedsCanonicalization()) { |
Label have_value; |
@@ -3808,7 +3859,21 @@ void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) { |
Register value = ToRegister(instr->value()); |
Register elements = ToRegister(instr->elements()); |
LOperand* key = instr->key(); |
- PrepareKeyForKeyedOp<HStoreKeyed>(instr->hydrogen(), 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(), |