Index: src/arm/lithium-arm.cc |
diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc |
index 714c12a3fb2e3bd5956282663f49a994dd21624e..7a4de9f4ccad29a23d8605c4738d86492276bb96 100644 |
--- a/src/arm/lithium-arm.cc |
+++ b/src/arm/lithium-arm.cc |
@@ -2279,6 +2279,8 @@ LInstruction* LChunkBuilder::DoTrapAllocationMemento( |
LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { |
bool is_in_object = instr->access().IsInobject(); |
bool needs_write_barrier = instr->NeedsWriteBarrier(); |
+ bool needs_write_barrier_for_map = instr->has_transition() && |
+ instr->NeedsWriteBarrierForMap(); |
LOperand* obj; |
if (needs_write_barrier) { |
@@ -2286,7 +2288,9 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { |
? UseRegister(instr->object()) |
: UseTempRegister(instr->object()); |
} else { |
- obj = UseRegisterAtStart(instr->object()); |
+ obj = needs_write_barrier_for_map |
+ ? UseRegister(instr->object()) |
+ : UseRegisterAtStart(instr->object()); |
} |
LOperand* val; |
@@ -2298,7 +2302,10 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { |
val = UseRegister(instr->value()); |
} |
- LInstruction* result = new(zone()) LStoreNamedField(obj, val); |
+ // We need a temporary register for write barrier of the map field. |
+ LOperand* temp = needs_write_barrier_for_map ? TempRegister() : NULL; |
+ |
+ LInstruction* result = new(zone()) LStoreNamedField(obj, val, temp); |
if (!instr->access().IsExternalMemory() && |
instr->field_representation().IsHeapObject() && |
!instr->value()->type().IsHeapObject()) { |