Commit 18772548 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[x86] Use pushes to setup the FunctionCallbackArguments on the stack.

On Intel processors it seems to be generally beneficial to use pushes
instead of explicit stack massaging to allocate the function callback
arguments on the stack for the API callback.

This yields a 5% improvement on the API callback performance, and
recovers an earlier regression (which was probably due to changing this
code to use movs instead of pushes).

Bug: v8:8820, v8:8848, chromium:913553
Change-Id: I3a82cf9bd49498728cae579dd39a9a3cfef37cea
Reviewed-on: https://chromium-review.googlesource.com/c/1477745Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59724}
parent 1736ec6a
......@@ -3147,14 +3147,13 @@ void Builtins::Generate_CallApiCallback(MacroAssembler* masm) {
Register api_function_address = edx;
Register argc = ecx;
XMMRegister call_data = xmm0;
Register call_data = eax;
Register holder = edi;
Register scratch = eax;
// Park call_data in xmm0.
__ movd(call_data, eax);
// Park argc in xmm0.
__ movd(xmm0, argc);
DCHECK(!AreAliased(api_function_address, argc, holder, scratch));
DCHECK(!AreAliased(api_function_address, argc, holder));
typedef FunctionCallbackArguments FCA;
......@@ -3180,34 +3179,21 @@ void Builtins::Generate_CallApiCallback(MacroAssembler* masm) {
// esp[5 * kSystemPointerSize]: kData
// esp[6 * kSystemPointerSize]: undefined (kNewTarget)
// Reserve space on the stack.
__ sub(esp, Immediate(FCA::kArgsLength * kSystemPointerSize));
// Return address (the old stack location is overwritten later on).
__ mov(scratch, Operand(esp, FCA::kArgsLength * kSystemPointerSize));
__ mov(Operand(esp, 0 * kSystemPointerSize), scratch);
// kHolder.
__ mov(Operand(esp, 1 * kSystemPointerSize), holder);
// kIsolate.
__ Move(scratch,
Immediate(ExternalReference::isolate_address(masm->isolate())));
__ mov(Operand(esp, 2 * kSystemPointerSize), scratch);
// kReturnValueDefaultValue and kReturnValue.
__ LoadRoot(scratch, RootIndex::kUndefinedValue);
__ mov(Operand(esp, 3 * kSystemPointerSize), scratch);
__ mov(Operand(esp, 4 * kSystemPointerSize), scratch);
// kData.
__ movd(Operand(esp, 5 * kSystemPointerSize), call_data);
__ PopReturnAddressTo(ecx);
__ PushRoot(RootIndex::kUndefinedValue);
__ Push(call_data);
__ PushRoot(RootIndex::kUndefinedValue);
__ PushRoot(RootIndex::kUndefinedValue);
__ Push(Immediate(ExternalReference::isolate_address(masm->isolate())));
__ Push(holder);
__ PushReturnAddressFrom(ecx);
// kNewTarget.
__ mov(Operand(esp, 6 * kSystemPointerSize), scratch);
// Reload argc from xmm0.
__ movd(argc, xmm0);
// Keep a pointer to kHolder (= implicit_args) in a scratch register.
// We use it below to set up the FunctionCallbackInfo object.
Register scratch = eax;
__ lea(scratch, Operand(esp, 1 * kSystemPointerSize));
// The API function takes a reference to v8::Arguments. If the CPU profiler
......
......@@ -3129,32 +3129,15 @@ void Builtins::Generate_CallApiCallback(MacroAssembler* masm) {
// rsp[5 * kSystemPointerSize]: kData
// rsp[6 * kSystemPointerSize]: undefined (kNewTarget)
// Reserve space on the stack.
__ subq(rsp, Immediate(FCA::kArgsLength * kSystemPointerSize));
// Return address (the old stack location is overwritten later on).
__ movq(kScratchRegister,
Operand(rsp, FCA::kArgsLength * kSystemPointerSize));
__ movq(Operand(rsp, 0 * kSystemPointerSize), kScratchRegister);
// kHolder.
__ movq(Operand(rsp, 1 * kSystemPointerSize), holder);
// kIsolate.
__ Move(kScratchRegister,
ExternalReference::isolate_address(masm->isolate()));
__ movq(Operand(rsp, 2 * kSystemPointerSize), kScratchRegister);
// kReturnValueDefaultValue and kReturnValue.
__ PopReturnAddressTo(rax);
__ LoadRoot(kScratchRegister, RootIndex::kUndefinedValue);
__ movq(Operand(rsp, 3 * kSystemPointerSize), kScratchRegister);
__ movq(Operand(rsp, 4 * kSystemPointerSize), kScratchRegister);
// kData.
__ movq(Operand(rsp, 5 * kSystemPointerSize), call_data);
// kNewTarget.
__ movq(Operand(rsp, 6 * kSystemPointerSize), kScratchRegister);
__ Push(kScratchRegister);
__ Push(call_data);
__ Push(kScratchRegister);
__ Push(kScratchRegister);
__ PushAddress(ExternalReference::isolate_address(masm->isolate()));
__ Push(holder);
__ PushReturnAddressFrom(rax);
// Keep a pointer to kHolder (= implicit_args) in a scratch register.
// We use it below to set up the FunctionCallbackInfo object.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment