Index: src/ia32/macro-assembler-ia32.cc |
diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc |
index 8ed7f55a059575386c547354c4b5c10b20e0b718..e3be800554a4d35acec8e74651d96913a70b6fa4 100644 |
--- a/src/ia32/macro-assembler-ia32.cc |
+++ b/src/ia32/macro-assembler-ia32.cc |
@@ -1192,6 +1192,26 @@ Handle<Code> MacroAssembler::ResolveBuiltin(Builtins::JavaScript id, |
} |
+void MacroAssembler::LoadContext(Register dst, int context_chain_length) { |
+ if (context_chain_length > 0) { |
+ // Move up the chain of contexts to the context containing the slot. |
+ mov(dst, Operand(esi, Context::SlotOffset(Context::CLOSURE_INDEX))); |
+ // Load the function context (which is the incoming, outer context). |
+ mov(dst, FieldOperand(dst, JSFunction::kContextOffset)); |
+ for (int i = 1; i < context_chain_length; i++) { |
+ 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))); |
+ } |
+} |
+ |
+ |
+ |
void MacroAssembler::Ret() { |
ret(0); |
} |