From 2b476800e19f3455672002acdfe3299689df4d3f Mon Sep 17 00:00:00 2001 From: "chunyang.dai" Date: Tue, 15 Sep 2015 05:24:48 -0700 Subject: [PATCH] X87: [Interpreter] Add support for JS calls. port e7fb233946b990ecbbbd76cc6529f62bd5da64e3 (r30710). original commit message: Adds support for JS calls to the interpreter. In order to support calls from the interpreter, the PushArgsAndCall builtin is added which pushes a sequence of arguments onto the stack and calls builtin::Call. Adds the Call bytecode. BUG= Review URL: https://codereview.chromium.org/1334153004 Cr-Commit-Position: refs/heads/master@{#30745} --- src/x87/builtins-x87.cc | 35 ++++++++++++++++++++++++++++ src/x87/interface-descriptors-x87.cc | 12 ++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/x87/builtins-x87.cc b/src/x87/builtins-x87.cc index 82998d58c6..be973c8995 100644 --- a/src/x87/builtins-x87.cc +++ b/src/x87/builtins-x87.cc @@ -1534,6 +1534,41 @@ void Builtins::Generate_Call(MacroAssembler* masm) { } +// static +void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { + // ----------- S t a t e ------------- + // -- eax : the number of arguments (not including the receiver) + // -- ebx : the address of the first argument to be pushed. Subsequent + // arguments should be consecutive above this, in the same order as + // they are to be pushed onto the stack. + // -- edi : the target to call (can be any Object). + + // Pop return address to allow tail-call after pushing arguments. + __ Pop(edx); + + // Find the address of the last argument. + __ mov(ecx, eax); + __ add(ecx, Immediate(1)); // Add one for receiver. + __ shl(ecx, kPointerSizeLog2); + __ neg(ecx); + __ add(ecx, ebx); + + // Push the arguments. + Label loop_header, loop_check; + __ jmp(&loop_check); + __ bind(&loop_header); + __ Push(Operand(ebx, 0)); + __ sub(ebx, Immediate(kPointerSize)); + __ bind(&loop_check); + __ cmp(ebx, ecx); + __ j(greater, &loop_header, Label::kNear); + + // Call the target. + __ Push(edx); // Re-push return address. + __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); +} + + void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { // ----------- S t a t e ------------- // -- eax : actual number of arguments diff --git a/src/x87/interface-descriptors-x87.cc b/src/x87/interface-descriptors-x87.cc index 23119d6ea5..fc5b4be2f7 100644 --- a/src/x87/interface-descriptors-x87.cc +++ b/src/x87/interface-descriptors-x87.cc @@ -389,6 +389,18 @@ void MathRoundVariantCallFromOptimizedCodeDescriptor:: }; data->InitializePlatformSpecific(arraysize(registers), registers); } + + +void PushArgsAndCallDescriptor::InitializePlatformSpecific( + CallInterfaceDescriptorData* data) { + Register registers[] = { + eax, // argument count (including receiver) + ebx, // address of first argument + edi // the target callable to be call + }; + data->InitializePlatformSpecific(arraysize(registers), registers); +} + } // namespace internal } // namespace v8