Index: src/x64/stub-cache-x64.cc |
diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc |
index f0b362b947d046184bfd592ee381b9a938933394..a1e916866123da156710646ecdc75b262f54efe0 100644 |
--- a/src/x64/stub-cache-x64.cc |
+++ b/src/x64/stub-cache-x64.cc |
@@ -398,7 +398,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 |
@@ -449,10 +449,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(); |
@@ -473,9 +475,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; |
@@ -505,7 +510,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); |
} |
@@ -1288,7 +1294,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. |
@@ -1309,14 +1317,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); |
@@ -1326,7 +1335,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); |
} |
@@ -2272,7 +2283,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); |