X87: [runtime] Rewrite Function.prototype.toString in C++.
port 4acca53e62cdfe6f3c495c87ca7d3c8fe1059f01(r32996) original commit message: There's actually no point trying to do Function.prototype.toString in JavaScript, as it always calls into C++ at least once, so it only complicates things (esp. once we start optimizing bound functions). Drive-by-fix: Rename FunctionApply and FunctionCall builtins to also reflect the fact that these are builtins in the Function.prototype and not on Function itself. BUG= Review URL: https://codereview.chromium.org/1548483003 Cr-Commit-Position: refs/heads/master@{#33017}
This commit is contained in:
parent
3f7e96df21
commit
a1c2e40276
95
src/x87/builtins-x87.cc
Normal file → Executable file
95
src/x87/builtins-x87.cc
Normal file → Executable file
@ -995,53 +995,7 @@ void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) {
|
|||||||
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void Builtins::Generate_FunctionCall(MacroAssembler* masm) {
|
void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) {
|
||||||
// Stack Layout:
|
|
||||||
// esp[0] : Return address
|
|
||||||
// esp[8] : Argument n
|
|
||||||
// esp[16] : Argument n-1
|
|
||||||
// ...
|
|
||||||
// esp[8 * n] : Argument 1
|
|
||||||
// esp[8 * (n + 1)] : Receiver (callable to call)
|
|
||||||
//
|
|
||||||
// eax contains the number of arguments, n, not counting the receiver.
|
|
||||||
//
|
|
||||||
// 1. Make sure we have at least one argument.
|
|
||||||
{
|
|
||||||
Label done;
|
|
||||||
__ test(eax, eax);
|
|
||||||
__ j(not_zero, &done, Label::kNear);
|
|
||||||
__ PopReturnAddressTo(ebx);
|
|
||||||
__ PushRoot(Heap::kUndefinedValueRootIndex);
|
|
||||||
__ PushReturnAddressFrom(ebx);
|
|
||||||
__ inc(eax);
|
|
||||||
__ bind(&done);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Get the callable to call (passed as receiver) from the stack.
|
|
||||||
__ mov(edi, Operand(esp, eax, times_pointer_size, kPointerSize));
|
|
||||||
|
|
||||||
// 3. Shift arguments and return address one slot down on the stack
|
|
||||||
// (overwriting the original receiver). Adjust argument count to make
|
|
||||||
// the original first argument the new receiver.
|
|
||||||
{
|
|
||||||
Label loop;
|
|
||||||
__ mov(ecx, eax);
|
|
||||||
__ bind(&loop);
|
|
||||||
__ mov(ebx, Operand(esp, ecx, times_pointer_size, 0));
|
|
||||||
__ mov(Operand(esp, ecx, times_pointer_size, kPointerSize), ebx);
|
|
||||||
__ dec(ecx);
|
|
||||||
__ j(not_sign, &loop); // While non-negative (to copy return address).
|
|
||||||
__ pop(ebx); // Discard copy of return address.
|
|
||||||
__ dec(eax); // One fewer argument (first argument is new receiver).
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. Call the callable.
|
|
||||||
__ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
|
|
||||||
// ----------- S t a t e -------------
|
// ----------- S t a t e -------------
|
||||||
// -- eax : argc
|
// -- eax : argc
|
||||||
// -- esp[0] : return address
|
// -- esp[0] : return address
|
||||||
@ -1117,6 +1071,53 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// static
|
||||||
|
void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) {
|
||||||
|
// Stack Layout:
|
||||||
|
// esp[0] : Return address
|
||||||
|
// esp[8] : Argument n
|
||||||
|
// esp[16] : Argument n-1
|
||||||
|
// ...
|
||||||
|
// esp[8 * n] : Argument 1
|
||||||
|
// esp[8 * (n + 1)] : Receiver (callable to call)
|
||||||
|
//
|
||||||
|
// eax contains the number of arguments, n, not counting the receiver.
|
||||||
|
//
|
||||||
|
// 1. Make sure we have at least one argument.
|
||||||
|
{
|
||||||
|
Label done;
|
||||||
|
__ test(eax, eax);
|
||||||
|
__ j(not_zero, &done, Label::kNear);
|
||||||
|
__ PopReturnAddressTo(ebx);
|
||||||
|
__ PushRoot(Heap::kUndefinedValueRootIndex);
|
||||||
|
__ PushReturnAddressFrom(ebx);
|
||||||
|
__ inc(eax);
|
||||||
|
__ bind(&done);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Get the callable to call (passed as receiver) from the stack.
|
||||||
|
__ mov(edi, Operand(esp, eax, times_pointer_size, kPointerSize));
|
||||||
|
|
||||||
|
// 3. Shift arguments and return address one slot down on the stack
|
||||||
|
// (overwriting the original receiver). Adjust argument count to make
|
||||||
|
// the original first argument the new receiver.
|
||||||
|
{
|
||||||
|
Label loop;
|
||||||
|
__ mov(ecx, eax);
|
||||||
|
__ bind(&loop);
|
||||||
|
__ mov(ebx, Operand(esp, ecx, times_pointer_size, 0));
|
||||||
|
__ mov(Operand(esp, ecx, times_pointer_size, kPointerSize), ebx);
|
||||||
|
__ dec(ecx);
|
||||||
|
__ j(not_sign, &loop); // While non-negative (to copy return address).
|
||||||
|
__ pop(ebx); // Discard copy of return address.
|
||||||
|
__ dec(eax); // One fewer argument (first argument is new receiver).
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Call the callable.
|
||||||
|
__ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Builtins::Generate_ReflectApply(MacroAssembler* masm) {
|
void Builtins::Generate_ReflectApply(MacroAssembler* masm) {
|
||||||
// ----------- S t a t e -------------
|
// ----------- S t a t e -------------
|
||||||
// -- eax : argc
|
// -- eax : argc
|
||||||
|
Loading…
Reference in New Issue
Block a user