Index: src/arm64/code-stubs-arm64.cc |
diff --git a/src/arm64/code-stubs-arm64.cc b/src/arm64/code-stubs-arm64.cc |
index 810f3aa7c831c3d4693653f0d9d7626f19904e81..e86135294f70c947c34e7f8ae214376de0fb95b0 100644 |
--- a/src/arm64/code-stubs-arm64.cc |
+++ b/src/arm64/code-stubs-arm64.cc |
@@ -2941,6 +2941,7 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) { |
// -- ... |
// -- sp[(argc - 1) * 8] : first argument |
// -- sp[argc * 8] : receiver |
+ // -- sp[(argc + 1) * 8] : accessor_holder |
// ----------------------------------- |
Register callee = x0; |
@@ -2969,18 +2970,29 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) { |
// context, callee and call data. |
__ Push(context, callee, call_data); |
- if (!is_lazy()) { |
- // Load context from callee |
- __ Ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset)); |
- } |
- |
- __ LoadRoot(call_data, Heap::kUndefinedValueRootIndex); |
+ Register scratch = call_data; |
+ __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); |
Register isolate_reg = x5; |
__ Mov(isolate_reg, ExternalReference::isolate_address(masm->isolate())); |
// FunctionCallbackArguments: |
// return value, return value default, isolate, holder. |
- __ Push(call_data, call_data, isolate_reg, holder); |
+ __ Push(scratch, scratch, isolate_reg, holder); |
+ |
+ // Enter a new context |
+ if (is_lazy()) { |
+ // Load context from accessor_holder |
+ Register accessor_holder = context; |
+ __ Ldr(accessor_holder, |
+ MemOperand(__ StackPointer(), |
+ (FCA::kArgsLength + 1 + argc()) * kPointerSize)); |
+ __ Ldr(scratch, FieldMemOperand(accessor_holder, HeapObject::kMapOffset)); |
+ __ GetMapConstructor(scratch, scratch, context, callee); |
+ __ Ldr(context, FieldMemOperand(scratch, JSFunction::kContextOffset)); |
+ } else { |
+ // Load context from callee |
+ __ Ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset)); |
+ } |
// Prepare arguments. |
Register args = x6; |
@@ -3022,12 +3034,8 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) { |
return_value_offset = 2 + FCA::kReturnValueOffset; |
} |
MemOperand return_value_operand(fp, return_value_offset * kPointerSize); |
- int stack_space = 0; |
- MemOperand length_operand = |
- MemOperand(masm->StackPointer(), 3 * kPointerSize); |
- MemOperand* stack_space_operand = &length_operand; |
- stack_space = argc() + FCA::kArgsLength + 1; |
- stack_space_operand = NULL; |
+ const int stack_space = argc() + FCA::kArgsLength + 2; |
+ MemOperand* stack_space_operand = nullptr; |
const int spill_offset = 1 + kApiStackSpace; |
CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space, |