Index: src/x87/full-codegen-x87.cc |
diff --git a/src/x87/full-codegen-x87.cc b/src/x87/full-codegen-x87.cc |
index 06eaa21f311b8e4ab839e56a0976ca1d1d4ac457..006383d4d1974087dbbd62f8d2cd11a2b48395ad 100644 |
--- a/src/x87/full-codegen-x87.cc |
+++ b/src/x87/full-codegen-x87.cc |
@@ -198,6 +198,7 @@ void FullCodeGenerator::Generate() { |
int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
if (heap_slots > 0) { |
Comment cmnt(masm_, "[ Allocate context"); |
+ bool need_write_barrier = true; |
// Argument to NewContext is the function, which is still in edi. |
if (FLAG_harmony_scoping && info->scope()->is_global_scope()) { |
__ push(edi); |
@@ -206,6 +207,8 @@ void FullCodeGenerator::Generate() { |
} else 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(edi); |
__ CallRuntime(Runtime::kHiddenNewFunctionContext, 1); |
@@ -229,10 +232,17 @@ void FullCodeGenerator::Generate() { |
int context_offset = Context::SlotOffset(var->index()); |
__ mov(Operand(esi, context_offset), eax); |
// Update the write barrier. This clobbers eax and ebx. |
- __ RecordWriteContextSlot(esi, |
- context_offset, |
- eax, |
- ebx); |
+ if (need_write_barrier) { |
+ __ RecordWriteContextSlot(esi, |
+ context_offset, |
+ eax, |
+ ebx); |
+ } else if (FLAG_debug_code) { |
+ Label done; |
+ __ JumpIfInNewSpace(esi, eax, &done, Label::kNear); |
+ __ Abort(kExpectedNewSpaceObject); |
+ __ bind(&done); |
+ } |
} |
} |
} |