 Chromium Code Reviews
 Chromium Code Reviews Issue 11365084:
  Some improvements in register usage in lithium compilation of LoadKeyed/StoreKeyed operations.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 11365084:
  Some improvements in register usage in lithium compilation of LoadKeyed/StoreKeyed operations.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| Index: src/x64/lithium-codegen-x64.cc | 
| diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc | 
| index 98e9aadedcffa0cc7f57d5208cc1f0756446b49e..2509ea951573ba01d187ec4f0141ce415d4f02dd 100644 | 
| --- a/src/x64/lithium-codegen-x64.cc | 
| +++ b/src/x64/lithium-codegen-x64.cc | 
| @@ -2612,24 +2612,30 @@ void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) { | 
| } | 
| -void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { | 
| - ElementsKind elements_kind = instr->elements_kind(); | 
| - LOperand* key = instr->key(); | 
| - if (!key->IsConstantOperand()) { | 
| - Register key_reg = ToRegister(key); | 
| +template <class T> | 
| +inline void LCodeGen::HandleKeyedAlterations(T* hydrogen_instr, LOperand* key) { | 
| 
danno
2012/11/07 22:34:38
How about "PrepareKeyForKeyedOp" or "PrepareKeyFor
 
mvstanton
2012/11/09 09:43:13
Done.
 | 
| + if (ArrayOpClobbersKey<T>(hydrogen_instr)) { | 
| // 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()) { | 
| + Register key_reg = ToRegister(key); | 
| + if (hydrogen_instr->key()->representation().IsTagged()) { | 
| __ SmiToInteger64(key_reg, key_reg); | 
| - } else if (instr->hydrogen()->IsDehoisted()) { | 
| + } else if (hydrogen_instr->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(); | 
| + HandleKeyedAlterations(instr->hydrogen(), key); | 
| Operand operand(BuildFastArrayOperand( | 
| instr->elements(), | 
| key, | 
| @@ -2689,21 +2695,7 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* 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/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); | 
| - } | 
| - } | 
| - | 
| + HandleKeyedAlterations<HLoadKeyed>(instr->hydrogen(), key); | 
| if (instr->hydrogen()->RequiresHoleCheck()) { | 
| int offset = FixedDoubleArray::kHeaderSize - kHeapObjectTag + | 
| sizeof(kHoleNanLower32); | 
| @@ -2730,21 +2722,7 @@ void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) { | 
| 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); | 
| - } | 
| - } | 
| + HandleKeyedAlterations<HLoadKeyed>(instr->hydrogen(), key); | 
| // Load the result. | 
| __ movq(result, | 
| @@ -3739,21 +3717,7 @@ void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { | 
| 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. | 
| - 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); | 
| - } | 
| - } | 
| + HandleKeyedAlterations<HStoreKeyed>(instr->hydrogen(), key); | 
| Operand operand(BuildFastArrayOperand( | 
| instr->elements(), | 
| key, | 
| @@ -3803,22 +3767,7 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* 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. | 
| - 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); | 
| - } | 
| - } | 
| - | 
| + HandleKeyedAlterations<HStoreKeyed>(instr->hydrogen(), key); | 
| if (instr->NeedsCanonicalization()) { | 
| Label have_value; | 
| @@ -3847,21 +3796,7 @@ 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); | 
| - } | 
| - } | 
| + HandleKeyedAlterations<HStoreKeyed>(instr->hydrogen(), key); | 
| Operand operand = | 
| BuildFastArrayOperand(instr->elements(), |