Index: src/ia32/macro-assembler-ia32.cc |
diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc |
index a4c9b11879725be6330c1cca5b5301ed24abe4a8..ee4e3d9cd64aa0b10492709f9c2f7e09334bd108 100644 |
--- a/src/ia32/macro-assembler-ia32.cc |
+++ b/src/ia32/macro-assembler-ia32.cc |
@@ -1523,11 +1523,21 @@ void MacroAssembler::LoadContext(Register dst, int context_chain_length) { |
mov(dst, Operand(dst, Context::SlotOffset(Context::CLOSURE_INDEX))); |
mov(dst, FieldOperand(dst, JSFunction::kContextOffset)); |
} |
- // The context may be an intermediate context, not a function context. |
- mov(dst, Operand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX))); |
- } else { // Slot is in the current function context. |
- // The context may be an intermediate context, not a function context. |
- mov(dst, Operand(esi, Context::SlotOffset(Context::FCONTEXT_INDEX))); |
+ } else { |
+ // Slot is in the current function context. Move it into the |
+ // destination register in case we store into it (the write barrier |
+ // cannot be allowed to destroy the context in esi). |
+ mov(dst, esi); |
+ } |
+ |
+ // We should not have found a 'with' context by walking the context chain |
+ // (i.e., the static scope chain and runtime context chain do not agree). |
+ // A variable occurring in such a scope should have slot type LOOKUP and |
+ // not CONTEXT. |
+ if (FLAG_debug_code) { |
+ cmp(dst, Operand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX))); |
+ Check(equal, "Yo dawg, I heard you liked function contexts " |
+ "so I put function contexts in all your contexts"); |
} |
} |