fix performance regression on intel call api stubs
additionally, make the interface match the JSFunction interface BUG=451405 LOG=N Review URL: https://codereview.chromium.org/883613003 Cr-Commit-Position: refs/heads/master@{#26291}
This commit is contained in:
parent
2a567faa3e
commit
b18ad51079
@ -4888,12 +4888,12 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm,
|
||||
bool return_first_arg,
|
||||
bool call_data_undefined) {
|
||||
// ----------- S t a t e -------------
|
||||
// -- eax : callee
|
||||
// -- edi : callee
|
||||
// -- ebx : call_data
|
||||
// -- ecx : holder
|
||||
// -- edx : api_function_address
|
||||
// -- esi : context
|
||||
// -- edi : number of arguments if argc is a register
|
||||
// -- eax : number of arguments if argc is a register
|
||||
// --
|
||||
// -- esp[0] : return address
|
||||
// -- esp[4] : last argument
|
||||
@ -4902,11 +4902,12 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm,
|
||||
// -- esp[(argc + 1) * 4] : receiver
|
||||
// -----------------------------------
|
||||
|
||||
Register callee = eax;
|
||||
Register callee = edi;
|
||||
Register call_data = ebx;
|
||||
Register holder = ecx;
|
||||
Register api_function_address = edx;
|
||||
Register context = esi;
|
||||
Register return_address = eax;
|
||||
|
||||
typedef FunctionCallbackArguments FCA;
|
||||
|
||||
@ -4919,10 +4920,17 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm,
|
||||
STATIC_ASSERT(FCA::kHolderIndex == 0);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 7);
|
||||
|
||||
DCHECK(argc.is_immediate() || edi.is(argc.reg()));
|
||||
DCHECK(argc.is_immediate() || eax.is(argc.reg()));
|
||||
|
||||
// pop return address and save context
|
||||
__ xchg(context, Operand(esp, 0));
|
||||
if (argc.is_immediate()) {
|
||||
__ pop(return_address);
|
||||
// context save.
|
||||
__ push(context);
|
||||
} else {
|
||||
// pop return address and save context
|
||||
__ xchg(context, Operand(esp, 0));
|
||||
return_address = context;
|
||||
}
|
||||
|
||||
// callee
|
||||
__ push(callee);
|
||||
@ -4950,7 +4958,7 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm,
|
||||
__ mov(scratch, esp);
|
||||
|
||||
// push return address
|
||||
__ push(context);
|
||||
__ push(return_address);
|
||||
|
||||
// load context from callee
|
||||
__ mov(context, FieldOperand(callee, JSFunction::kContextOffset));
|
||||
@ -5023,9 +5031,8 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm,
|
||||
|
||||
|
||||
void CallApiFunctionStub::Generate(MacroAssembler* masm) {
|
||||
// TODO(dcarney): make eax contain the function address.
|
||||
bool call_data_undefined = this->call_data_undefined();
|
||||
CallApiFunctionStubHelper(masm, ParameterCount(edi), false,
|
||||
CallApiFunctionStubHelper(masm, ParameterCount(eax), false,
|
||||
call_data_undefined);
|
||||
}
|
||||
|
||||
|
@ -306,11 +306,11 @@ void ArgumentAdaptorDescriptor::Initialize(CallInterfaceDescriptorData* data) {
|
||||
void ApiFunctionDescriptor::Initialize(CallInterfaceDescriptorData* data) {
|
||||
Register registers[] = {
|
||||
esi, // context
|
||||
eax, // callee
|
||||
edi, // callee
|
||||
ebx, // call_data
|
||||
ecx, // holder
|
||||
edx, // api_function_address
|
||||
edi, // actual number of arguments
|
||||
eax, // actual number of arguments
|
||||
};
|
||||
Representation representations[] = {
|
||||
Representation::Tagged(), // context
|
||||
@ -327,7 +327,7 @@ void ApiFunctionDescriptor::Initialize(CallInterfaceDescriptorData* data) {
|
||||
void ApiAccessorDescriptor::Initialize(CallInterfaceDescriptorData* data) {
|
||||
Register registers[] = {
|
||||
esi, // context
|
||||
eax, // callee
|
||||
edi, // callee
|
||||
ebx, // call_data
|
||||
ecx, // holder
|
||||
edx, // api_function_address
|
||||
|
@ -162,11 +162,11 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
|
||||
DCHECK(optimization.is_simple_api_call());
|
||||
|
||||
// Abi for CallApiFunctionStub.
|
||||
Register callee = eax;
|
||||
Register callee = edi;
|
||||
Register call_data = ebx;
|
||||
Register holder = ecx;
|
||||
Register api_function_address = edx;
|
||||
Register scratch = edi; // scratch_in is no longer valid.
|
||||
Register scratch = eax; // scratch_in is no longer valid.
|
||||
|
||||
// Put holder in place.
|
||||
CallOptimization::HolderLookup holder_lookup;
|
||||
|
@ -147,11 +147,11 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
|
||||
// Stack now matches JSFunction abi.
|
||||
|
||||
// Abi for CallApiFunctionStub.
|
||||
Register callee = rax;
|
||||
Register callee = rdi;
|
||||
Register call_data = rbx;
|
||||
Register holder = rcx;
|
||||
Register api_function_address = rdx;
|
||||
Register scratch = rdi; // scratch_in is no longer valid.
|
||||
Register scratch = rax; // scratch_in is no longer valid.
|
||||
|
||||
// Put holder in place.
|
||||
CallOptimization::HolderLookup holder_lookup;
|
||||
|
@ -4830,12 +4830,12 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm,
|
||||
bool return_first_arg,
|
||||
bool call_data_undefined) {
|
||||
// ----------- S t a t e -------------
|
||||
// -- rax : callee
|
||||
// -- rdi : callee
|
||||
// -- rbx : call_data
|
||||
// -- rcx : holder
|
||||
// -- rdx : api_function_address
|
||||
// -- rsi : context
|
||||
// -- rdi : number of arguments if argc is a register
|
||||
// -- rax : number of arguments if argc is a register
|
||||
// -- rsp[0] : return address
|
||||
// -- rsp[8] : last argument
|
||||
// -- ...
|
||||
@ -4843,11 +4843,12 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm,
|
||||
// -- rsp[(argc + 1) * 8] : receiver
|
||||
// -----------------------------------
|
||||
|
||||
Register callee = rax;
|
||||
Register callee = rdi;
|
||||
Register call_data = rbx;
|
||||
Register holder = rcx;
|
||||
Register api_function_address = rdx;
|
||||
Register context = rsi;
|
||||
Register return_address = r8;
|
||||
|
||||
typedef FunctionCallbackArguments FCA;
|
||||
|
||||
@ -4860,17 +4861,12 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm,
|
||||
STATIC_ASSERT(FCA::kHolderIndex == 0);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 7);
|
||||
|
||||
DCHECK(argc.is_immediate() || rdi.is(argc.reg()));
|
||||
DCHECK(argc.is_immediate() || rax.is(argc.reg()));
|
||||
|
||||
if (kPointerSize == kInt64Size) {
|
||||
// pop return address and save context
|
||||
__ xchgq(context, Operand(rsp, 0));
|
||||
} else {
|
||||
// x32 handling.
|
||||
__ PopReturnAddressTo(kScratchRegister);
|
||||
__ Push(context);
|
||||
__ movq(context, kScratchRegister);
|
||||
}
|
||||
__ PopReturnAddressTo(return_address);
|
||||
|
||||
// context save
|
||||
__ Push(context);
|
||||
|
||||
// callee
|
||||
__ Push(callee);
|
||||
@ -4893,7 +4889,7 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm,
|
||||
|
||||
__ movp(scratch, rsp);
|
||||
// Push return address back on stack.
|
||||
__ PushReturnAddressFrom(context);
|
||||
__ PushReturnAddressFrom(return_address);
|
||||
|
||||
// load context from callee
|
||||
__ movp(context, FieldOperand(callee, JSFunction::kContextOffset));
|
||||
@ -4967,9 +4963,8 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm,
|
||||
|
||||
|
||||
void CallApiFunctionStub::Generate(MacroAssembler* masm) {
|
||||
// TODO(dcarney): make rax contain the function address.
|
||||
bool call_data_undefined = this->call_data_undefined();
|
||||
CallApiFunctionStubHelper(masm, ParameterCount(rdi), false,
|
||||
CallApiFunctionStubHelper(masm, ParameterCount(rax), false,
|
||||
call_data_undefined);
|
||||
}
|
||||
|
||||
|
@ -307,11 +307,11 @@ void ArgumentAdaptorDescriptor::Initialize(CallInterfaceDescriptorData* data) {
|
||||
void ApiFunctionDescriptor::Initialize(CallInterfaceDescriptorData* data) {
|
||||
Register registers[] = {
|
||||
rsi, // context
|
||||
rax, // callee
|
||||
rdi, // callee
|
||||
rbx, // call_data
|
||||
rcx, // holder
|
||||
rdx, // api_function_address
|
||||
rdi, // actual number of arguments
|
||||
rax, // actual number of arguments
|
||||
};
|
||||
Representation representations[] = {
|
||||
Representation::Tagged(), // context
|
||||
@ -328,7 +328,7 @@ void ApiFunctionDescriptor::Initialize(CallInterfaceDescriptorData* data) {
|
||||
void ApiAccessorDescriptor::Initialize(CallInterfaceDescriptorData* data) {
|
||||
Register registers[] = {
|
||||
rsi, // context
|
||||
rax, // callee
|
||||
rdi, // callee
|
||||
rbx, // call_data
|
||||
rcx, // holder
|
||||
rdx, // api_function_address
|
||||
|
Loading…
Reference in New Issue
Block a user