Chromium Code Reviews| Index: src/x64/lithium-codegen-x64.cc |
| diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc |
| index 75ba04e48170f0ed94975dc180d28f5cd9625ae3..41f16bc2830aa5b39d1bf8697011ab7905d0d33e 100644 |
| --- a/src/x64/lithium-codegen-x64.cc |
| +++ b/src/x64/lithium-codegen-x64.cc |
| @@ -264,6 +264,37 @@ void LCodeGen::GenerateBodyInstructionPre(LInstruction* instr) { |
| if (!instr->IsLazyBailout() && !instr->IsGap()) { |
| safepoints_.BumpLastLazySafepointIndex(); |
| } |
| + if (kPointerSize == kInt32Size) { |
| + if (instr->IsLoadKeyed() || instr->IsStoreKeyed()) { |
|
Toon Verwaest
2014/06/12 08:54:25
Given that this code is only relevant for Load/Sto
haitao.feng
2014/06/12 09:34:56
Done.
|
| + ElementsKind elements_kind = INT8_ELEMENTS; // Bogus initialization. |
| + LOperand* key = NULL; |
| + Representation key_representation = Representation::None(); |
| + bool is_dehoisted = false; |
| + if (instr->IsLoadKeyed()) { |
| + LLoadKeyed* load = LLoadKeyed::cast(instr); |
| + elements_kind = load->elements_kind(); |
| + key = load->key(); |
| + key_representation = load->hydrogen()->key()->representation(); |
| + is_dehoisted = load->hydrogen()->IsDehoisted(); |
| + } else { |
| + LStoreKeyed* store = LStoreKeyed::cast(instr); |
| + elements_kind = store->elements_kind(); |
| + key = store->key(); |
| + key_representation = store->hydrogen()->key()->representation(); |
| + is_dehoisted = store->hydrogen()->IsDehoisted(); |
| + } |
| + if (!key->IsConstantOperand()) { |
| + Register key_reg = ToRegister(key); |
| + if (KeyedLoadOrStoreRequiresTemp(key_representation, elements_kind)) { |
| + __ SmiToInteger64(key_reg, key_reg); |
| + } else if (is_dehoisted) { |
| + // 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); |
| + } |
| + } |
| + } |
| + } |
| } |
| @@ -3037,6 +3068,7 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { |
| Operand operand(BuildFastArrayOperand( |
| instr->elements(), |
| key, |
| + instr->hydrogen()->key()->representation(), |
| elements_kind, |
| instr->base_offset())); |
| @@ -3107,6 +3139,7 @@ void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) { |
| Operand hole_check_operand = BuildFastArrayOperand( |
| instr->elements(), |
| key, |
| + instr->hydrogen()->key()->representation(), |
| FAST_DOUBLE_ELEMENTS, |
| instr->base_offset() + sizeof(kHoleNanLower32)); |
| __ cmpl(hole_check_operand, Immediate(kHoleNanUpper32)); |
| @@ -3116,6 +3149,7 @@ void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) { |
| Operand double_load_operand = BuildFastArrayOperand( |
| instr->elements(), |
| key, |
| + instr->hydrogen()->key()->representation(), |
| FAST_DOUBLE_ELEMENTS, |
| instr->base_offset()); |
| __ movsd(result, double_load_operand); |
| @@ -3138,6 +3172,7 @@ void LCodeGen::DoLoadKeyedFixedArray(LLoadKeyed* instr) { |
| __ Load(scratch, |
| BuildFastArrayOperand(instr->elements(), |
| key, |
| + instr->hydrogen()->key()->representation(), |
| FAST_ELEMENTS, |
| offset), |
| Representation::Smi()); |
| @@ -3152,6 +3187,7 @@ void LCodeGen::DoLoadKeyedFixedArray(LLoadKeyed* instr) { |
| __ Load(result, |
| BuildFastArrayOperand(instr->elements(), |
| key, |
| + instr->hydrogen()->key()->representation(), |
| FAST_ELEMENTS, |
| offset), |
| representation); |
| @@ -3183,6 +3219,7 @@ void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) { |
| Operand LCodeGen::BuildFastArrayOperand( |
| LOperand* elements_pointer, |
| LOperand* key, |
| + Representation key_representation, |
| ElementsKind elements_kind, |
| uint32_t offset) { |
| Register elements_pointer_reg = ToRegister(elements_pointer); |
| @@ -3195,6 +3232,11 @@ Operand LCodeGen::BuildFastArrayOperand( |
| return Operand(elements_pointer_reg, |
| (constant_value << shift_size) + offset); |
| } else { |
| + // Take the tag bit into account while computing the shift size. |
| + if (key_representation.IsSmi() && (shift_size >= 1)) { |
| + ASSERT(SmiValuesAre31Bits()); |
| + shift_size -= kSmiTagSize; |
| + } |
| ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size); |
| return Operand(elements_pointer_reg, |
| ToRegister(key), |
| @@ -4171,6 +4213,7 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { |
| Operand operand(BuildFastArrayOperand( |
| instr->elements(), |
| key, |
| + instr->hydrogen()->key()->representation(), |
| elements_kind, |
| instr->base_offset())); |
| @@ -4243,6 +4286,7 @@ void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) { |
| Operand double_store_operand = BuildFastArrayOperand( |
| instr->elements(), |
| key, |
| + instr->hydrogen()->key()->representation(), |
| FAST_DOUBLE_ELEMENTS, |
| instr->base_offset()); |
| @@ -4264,6 +4308,7 @@ void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) { |
| __ Load(scratch, |
| BuildFastArrayOperand(instr->elements(), |
| key, |
| + instr->hydrogen()->key()->representation(), |
| FAST_ELEMENTS, |
| offset), |
| Representation::Smi()); |
| @@ -4278,6 +4323,7 @@ void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) { |
| Operand operand = |
| BuildFastArrayOperand(instr->elements(), |
| key, |
| + instr->hydrogen()->key()->representation(), |
| FAST_ELEMENTS, |
| offset); |
| if (instr->value()->IsRegister()) { |