Index: src/x64/stub-cache-x64.cc |
diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc |
index 54d2a113a73724fa39b79b10aad72b503ff9f356..92c82a3417c097347709b289f360ed77a36f888f 100644 |
--- a/src/x64/stub-cache-x64.cc |
+++ b/src/x64/stub-cache-x64.cc |
@@ -396,7 +396,7 @@ static void CompileCallLoadPropertyWithInterceptor( |
// Number of pointers to be reserved on stack for fast API call. |
-static const int kFastApiCallArguments = 4; |
+static const int kFastApiCallArguments = FunctionCallbackArguments::kArgsLength; |
// Reserves space for the extra arguments to API function in the |
@@ -447,10 +447,12 @@ static void GenerateFastApiCall(MacroAssembler* masm, |
// (first fast api call extra argument) |
// -- rsp[24] : api call data |
// -- rsp[32] : isolate |
- // -- rsp[40] : last argument |
+ // -- rsp[40] : ReturnValue |
+ // |
+ // -- rsp[48] : last argument |
// -- ... |
- // -- rsp[(argc + 4) * 8] : first argument |
- // -- rsp[(argc + 5) * 8] : receiver |
+ // -- rsp[(argc + 5) * 8] : first argument |
+ // -- rsp[(argc + 6) * 8] : receiver |
// ----------------------------------- |
// Get the function and setup the context. |
Handle<JSFunction> function = optimization.constant_function(); |
@@ -471,9 +473,12 @@ static void GenerateFastApiCall(MacroAssembler* masm, |
__ movq(kScratchRegister, |
ExternalReference::isolate_address(masm->isolate())); |
__ movq(Operand(rsp, 4 * kPointerSize), kScratchRegister); |
+ __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); |
+ __ movq(Operand(rsp, 5 * kPointerSize), kScratchRegister); |
// Prepare arguments. |
- __ lea(rbx, Operand(rsp, 4 * kPointerSize)); |
+ STATIC_ASSERT(kFastApiCallArguments == 5); |
+ __ lea(rbx, Operand(rsp, kFastApiCallArguments * kPointerSize)); |
#if defined(__MINGW64__) |
Register arguments_arg = rcx; |
@@ -503,7 +508,8 @@ static void GenerateFastApiCall(MacroAssembler* masm, |
// Function address is a foreign pointer outside V8's heap. |
Address function_address = v8::ToCData<Address>(api_call_info->callback()); |
__ CallApiFunctionAndReturn(function_address, |
- argc + kFastApiCallArguments + 1); |
+ argc + kFastApiCallArguments + 1, |
+ FunctionCallbackArguments::kReturnValueOffset); |
} |
@@ -1180,7 +1186,9 @@ void BaseLoadStubCompiler::GenerateLoadCallback( |
} else { |
__ Push(Handle<Object>(callback->data(), isolate())); |
} |
- __ PushAddress(ExternalReference::isolate_address(isolate())); // isolate |
+ __ PushAddress(ExternalReference::isolate_address(isolate())); |
+ __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); |
+ __ push(kScratchRegister); // return value |
__ push(name()); // name |
// Save a pointer to where we pushed the arguments pointer. This will be |
// passed as the const ExecutableAccessorInfo& to the C++ callback. |
@@ -1201,14 +1209,15 @@ void BaseLoadStubCompiler::GenerateLoadCallback( |
__ movq(name_arg, rsp); |
__ push(scratch2()); // Restore return address. |
- // 4 elements array for v8::Arguments::values_ and handler for name. |
- const int kStackSpace = 5; |
+ // v8::Arguments::values_ and handler for name. |
+ const int kStackSpace = PropertyCallbackArguments::kArgsLength + 1; |
// Allocate v8::AccessorInfo in non-GCed stack space. |
const int kArgStackSpace = 1; |
__ PrepareCallApiFunction(kArgStackSpace); |
- __ lea(rax, Operand(name_arg, 4 * kPointerSize)); |
+ STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 5); |
+ __ lea(rax, Operand(name_arg, 5 * kPointerSize)); |
// v8::AccessorInfo::args_. |
__ movq(StackSpaceOperand(0), rax); |
@@ -1218,7 +1227,9 @@ void BaseLoadStubCompiler::GenerateLoadCallback( |
__ lea(accessor_info_arg, StackSpaceOperand(0)); |
Address getter_address = v8::ToCData<Address>(callback->getter()); |
- __ CallApiFunctionAndReturn(getter_address, kStackSpace); |
+ __ CallApiFunctionAndReturn(getter_address, |
+ kStackSpace, |
+ PropertyCallbackArguments::kReturnValueOffset); |
} |
@@ -2163,7 +2174,7 @@ Handle<Code> CallStubCompiler::CompileFastApiCall( |
name, depth, &miss); |
// Move the return address on top of the stack. |
- __ movq(rax, Operand(rsp, 4 * kPointerSize)); |
+ __ movq(rax, Operand(rsp, kFastApiCallArguments * kPointerSize)); |
__ movq(Operand(rsp, 0 * kPointerSize), rax); |
GenerateFastApiCall(masm(), optimization, argc); |