Index: src/x64/code-stubs-x64.cc |
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc |
index 9c70fe6c8d8c833422ea5d9f7435fe9ddf537e45..1d7ee71cafcc3ded90039e69f07026a167e5da1e 100644 |
--- a/src/x64/code-stubs-x64.cc |
+++ b/src/x64/code-stubs-x64.cc |
@@ -2711,6 +2711,7 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) { |
// -- ... |
// -- rsp[argc * 8] : first argument |
// -- rsp[(argc + 1) * 8] : receiver |
+ // -- rsp[(argc + 2) * 8] : accessor_holder |
// ----------------------------------- |
Register callee = rdi; |
@@ -2757,15 +2758,25 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) { |
// holder |
__ Push(holder); |
- __ movp(scratch, rsp); |
- // Push return address back on stack. |
- __ PushReturnAddressFrom(return_address); |
- |
- if (!this->is_lazy()) { |
+ // enter a new context |
+ int argc = this->argc(); |
+ if (this->is_lazy()) { |
+ // load context from accessor_holder |
+ Register accessor_holder = context; |
+ __ movp(accessor_holder, |
+ MemOperand(rsp, (argc + FCA::kArgsLength + 1) * kPointerSize)); |
+ __ movp(scratch, FieldOperand(accessor_holder, HeapObject::kMapOffset)); |
+ __ GetMapConstructor(scratch, scratch, context); |
+ __ movp(context, FieldOperand(scratch, JSFunction::kContextOffset)); |
+ } else { |
// load context from callee |
__ movp(context, FieldOperand(callee, JSFunction::kContextOffset)); |
} |
+ __ movp(scratch, rsp); |
+ // Push return address back on stack. |
+ __ PushReturnAddressFrom(return_address); |
+ |
// Allocate the v8::Arguments structure in the arguments' space since |
// it's not controlled by GC. |
const int kApiStackSpace = 3; |
@@ -2773,7 +2784,6 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) { |
PrepareCallApiFunction(masm, kApiStackSpace); |
// FunctionCallbackInfo::implicit_args_. |
- int argc = this->argc(); |
__ movp(StackSpaceOperand(0), scratch); |
__ addp(scratch, Immediate((argc + FCA::kArgsLength - 1) * kPointerSize)); |
// FunctionCallbackInfo::values_. |