Index: src/a64/lithium-codegen-a64.cc |
diff --git a/src/a64/lithium-codegen-a64.cc b/src/a64/lithium-codegen-a64.cc |
index ad8d742abac2cc894d292e026d7005b67933e834..d7dd832a8593385765f39f2107deb17f77b3e94a 100644 |
--- a/src/a64/lithium-codegen-a64.cc |
+++ b/src/a64/lithium-codegen-a64.cc |
@@ -5059,7 +5059,7 @@ void LCodeGen::DoStoreKeyedExternal(LStoreKeyedExternal* instr) { |
void LCodeGen::DoStoreKeyedFixedDouble(LStoreKeyedFixedDouble* instr) { |
Register elements = ToRegister(instr->elements()); |
DoubleRegister value = ToDoubleRegister(instr->value()); |
- Register store_base = ToRegister(instr->temp()); |
+ Register store_base = no_reg; |
int offset = 0; |
if (instr->key()->IsConstantOperand()) { |
@@ -5071,6 +5071,7 @@ void LCodeGen::DoStoreKeyedFixedDouble(LStoreKeyedFixedDouble* instr) { |
instr->additional_index()); |
store_base = elements; |
} else { |
+ store_base = ToRegister(instr->temp()); |
Register key = ToRegister(instr->key()); |
bool key_is_tagged = instr->hydrogen()->key()->representation().IsSmi(); |
CalcKeyedArrayBaseRegister(store_base, elements, key, key_is_tagged, |
@@ -5093,17 +5094,23 @@ void LCodeGen::DoStoreKeyedFixedDouble(LStoreKeyedFixedDouble* instr) { |
void LCodeGen::DoStoreKeyedFixed(LStoreKeyedFixed* instr) { |
Register value = ToRegister(instr->value()); |
Register elements = ToRegister(instr->elements()); |
- Register store_base = ToRegister(instr->temp()); |
+ Register scratch = no_reg; |
+ Register store_base = no_reg; |
Register key = no_reg; |
int offset = 0; |
+ if (!instr->key()->IsConstantOperand() || |
+ instr->hydrogen()->NeedsWriteBarrier()) { |
+ scratch = ToRegister(instr->temp()); |
+ } |
+ |
if (instr->key()->IsConstantOperand()) { |
- ASSERT(!instr->hydrogen()->NeedsWriteBarrier()); |
LConstantOperand* const_operand = LConstantOperand::cast(instr->key()); |
offset = FixedArray::OffsetOfElementAt(ToInteger32(const_operand) + |
instr->additional_index()); |
store_base = elements; |
} else { |
+ store_base = scratch; |
key = ToRegister(instr->key()); |
bool key_is_tagged = instr->hydrogen()->key()->representation().IsSmi(); |
CalcKeyedArrayBaseRegister(store_base, elements, key, key_is_tagged, |
@@ -5122,13 +5129,16 @@ void LCodeGen::DoStoreKeyedFixed(LStoreKeyedFixed* instr) { |
} |
if (instr->hydrogen()->NeedsWriteBarrier()) { |
+ ASSERT(representation.IsTagged()); |
+ // This assignment may cause element_addr to alias store_base. |
+ Register element_addr = scratch; |
SmiCheck check_needed = |
instr->hydrogen()->value()->IsHeapObject() |
? OMIT_SMI_CHECK : INLINE_SMI_CHECK; |
// Compute address of modified element and store it into key register. |
- __ Add(key, store_base, offset - kHeapObjectTag); |
- __ RecordWrite(elements, key, value, GetLinkRegisterState(), kSaveFPRegs, |
- EMIT_REMEMBERED_SET, check_needed); |
+ __ Add(element_addr, store_base, offset - kHeapObjectTag); |
+ __ RecordWrite(elements, element_addr, value, GetLinkRegisterState(), |
+ kSaveFPRegs, EMIT_REMEMBERED_SET, check_needed); |
} |
} |