Index: src/arm/lithium-codegen-arm.cc |
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc |
index d2e665e58cbb8a22218235ce1ac45594b225055b..b417c801d58f9b31cb0956cba3df95fd0ca58098 100644 |
--- a/src/arm/lithium-codegen-arm.cc |
+++ b/src/arm/lithium-codegen-arm.cc |
@@ -179,10 +179,13 @@ bool LCodeGen::GeneratePrologue() { |
int heap_slots = info()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
if (heap_slots > 0) { |
Comment(";;; Allocate local context"); |
+ bool need_write_barrier = true; |
// Argument to NewContext is the function, which is in r1. |
if (heap_slots <= FastNewContextStub::kMaximumSlots) { |
FastNewContextStub stub(isolate(), heap_slots); |
__ CallStub(&stub); |
+ // Result of FastNewContextStub is always in new space. |
+ need_write_barrier = false; |
} else { |
__ push(r1); |
__ CallRuntime(Runtime::kHiddenNewFunctionContext, 1); |
@@ -205,13 +208,20 @@ bool LCodeGen::GeneratePrologue() { |
MemOperand target = ContextOperand(cp, var->index()); |
__ str(r0, target); |
// Update the write barrier. This clobbers r3 and r0. |
- __ RecordWriteContextSlot( |
- cp, |
- target.offset(), |
- r0, |
- r3, |
- GetLinkRegisterState(), |
- kSaveFPRegs); |
+ if (need_write_barrier) { |
+ __ RecordWriteContextSlot( |
+ cp, |
+ target.offset(), |
+ r0, |
+ r3, |
+ GetLinkRegisterState(), |
+ kSaveFPRegs); |
+ } else if (FLAG_debug_code) { |
+ Label done; |
+ __ JumpIfInNewSpace(cp, r0, &done); |
+ __ Abort(kExpectedNewSpaceObject); |
+ __ bind(&done); |
+ } |
} |
} |
Comment(";;; End allocate local context"); |