Commit 1a70805a authored by Georgia Kouveli's avatar Georgia Kouveli Committed by Commit Bot

[arm64] Update FunctionPrototypeApply, ReflectApply, ReflectConstruct for jssp removal.

Bug: v8:6644
Change-Id: I47482fa15fa89b1d9cd6c943e89dcc543596de5d
Reviewed-on: https://chromium-review.googlesource.com/738093Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Georgia Kouveli <georgia.kouveli@arm.com>
Cr-Commit-Position: refs/heads/master@{#48917}
parent 5442e8b2
...@@ -1713,24 +1713,35 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { ...@@ -1713,24 +1713,35 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) {
// arguments from the stack (including the receiver), and push thisArg (if // arguments from the stack (including the receiver), and push thisArg (if
// present) instead. // present) instead.
{ {
// Claim (2 - argc) dummy arguments from the stack, to put the stack in a Register saved_argc = x10;
// consistent state for a simple pop operation. Register scratch = x11;
__ Claim(2);
__ Drop(argc); // Push two undefined values on the stack, to put it in a consistent state
// so that we can always read three arguments from it.
// ----------- S t a t e ------------- __ Push(undefined_value, undefined_value);
// -- x0 : argc
// -- jssp[0] : argArray (dummy value if argc <= 1) // The state of the stack (with arrows pointing to the slots we will read)
// -- jssp[8] : thisArg (dummy value if argc == 0) // is as follows:
// -- jssp[16] : receiver //
// ----------------------------------- // argc = 0 argc = 1 argc = 2
__ Cmp(argc, 1); // -> sp[16]: receiver -> sp[24]: receiver -> sp[32]: receiver
__ Pop(arg_array, this_arg); // Overwrites argc. // -> sp[8]: undefined -> sp[16]: this_arg -> sp[24]: this_arg
__ CmovX(this_arg, undefined_value, lo); // undefined if argc == 0. // -> sp[0]: undefined -> sp[8]: undefined -> sp[16]: arg_array
__ CmovX(arg_array, undefined_value, ls); // undefined if argc <= 1. // sp[0]: undefined sp[8]: undefined
// sp[0]: undefined
__ Peek(receiver, 0); //
__ Poke(this_arg, 0); // There are now always three arguments to read, in the slots starting from
// slot argc.
__ SlotAddress(scratch, argc);
__ Mov(saved_argc, argc);
__ Ldp(arg_array, this_arg, MemOperand(scratch)); // Overwrites argc.
__ Ldr(receiver, MemOperand(scratch, 2 * kPointerSize));
__ Drop(2); // Drop the undefined values we pushed above.
__ DropArguments(saved_argc, TurboAssembler::kCountExcludesReceiver);
__ PushArgument(this_arg);
} }
// ----------- S t a t e ------------- // ----------- S t a t e -------------
...@@ -1831,26 +1842,44 @@ void Builtins::Generate_ReflectApply(MacroAssembler* masm) { ...@@ -1831,26 +1842,44 @@ void Builtins::Generate_ReflectApply(MacroAssembler* masm) {
// remove all arguments from the stack (including the receiver), and push // remove all arguments from the stack (including the receiver), and push
// thisArgument (if present) instead. // thisArgument (if present) instead.
{ {
// Claim (3 - argc) dummy arguments from the stack, to put the stack in a // Push four undefined values on the stack, to put it in a consistent state
// consistent state for a simple pop operation. // so that we can always read the three arguments we need from it. The
__ Claim(3); // fourth value is used for stack alignment.
__ Drop(argc); __ Push(undefined_value, undefined_value, undefined_value, undefined_value);
// ----------- S t a t e ------------- // The state of the stack (with arrows pointing to the slots we will read)
// -- x0 : argc // is as follows:
// -- jssp[0] : argumentsList (dummy value if argc <= 2) //
// -- jssp[8] : thisArgument (dummy value if argc <= 1) // argc = 0 argc = 1 argc = 2
// -- jssp[16] : target (dummy value if argc == 0) // sp[32]: receiver sp[40]: receiver sp[48]: receiver
// -- jssp[24] : receiver // -> sp[24]: undefined -> sp[32]: target -> sp[40]: target
// ----------------------------------- // -> sp[16]: undefined -> sp[24]: undefined -> sp[32]: this_argument
__ Adds(x10, argc, 0); // Preserve argc, and set the Z flag if it is zero. // -> sp[8]: undefined -> sp[16]: undefined -> sp[24]: undefined
__ Pop(arguments_list, this_argument, target); // Overwrites argc. // sp[0]: undefined sp[8]: undefined sp[16]: undefined
__ CmovX(target, undefined_value, eq); // undefined if argc == 0. // sp[0]: undefined sp[8]: undefined
__ Cmp(x10, 2); // sp[0]: undefined
__ CmovX(this_argument, undefined_value, lo); // undefined if argc <= 1. // argc = 3
__ CmovX(arguments_list, undefined_value, ls); // undefined if argc <= 2. // sp[56]: receiver
// -> sp[48]: target
__ Poke(this_argument, 0); // Overwrite receiver. // -> sp[40]: this_argument
// -> sp[32]: arguments_list
// sp[24]: undefined
// sp[16]: undefined
// sp[8]: undefined
// sp[0]: undefined
//
// There are now always three arguments to read, in the slots starting from
// slot (argc + 1).
Register scratch = x10;
__ SlotAddress(scratch, argc);
__ Ldp(arguments_list, this_argument,
MemOperand(scratch, 1 * kPointerSize));
__ Ldr(target, MemOperand(scratch, 3 * kPointerSize));
__ Drop(4); // Drop the undefined values we pushed above.
__ DropArguments(argc, TurboAssembler::kCountExcludesReceiver);
__ PushArgument(this_argument);
} }
// ----------- S t a t e ------------- // ----------- S t a t e -------------
...@@ -1891,26 +1920,47 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { ...@@ -1891,26 +1920,47 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
// arguments from the stack (including the receiver), and push thisArgument // arguments from the stack (including the receiver), and push thisArgument
// (if present) instead. // (if present) instead.
{ {
// Claim (3 - argc) dummy arguments from the stack, to put the stack in a // Push four undefined values on the stack, to put it in a consistent state
// consistent state for a simple pop operation. // so that we can always read the three arguments we need from it. The
__ Claim(3); // fourth value is used for stack alignment.
__ Drop(argc); __ Push(undefined_value, undefined_value, undefined_value, undefined_value);
// ----------- S t a t e ------------- // The state of the stack (with arrows pointing to the slots we will read)
// -- x0 : argc // is as follows:
// -- jssp[0] : new.target (dummy value if argc <= 2) //
// -- jssp[8] : argumentsList (dummy value if argc <= 1) // argc = 0 argc = 1 argc = 2
// -- jssp[16] : target (dummy value if argc == 0) // sp[32]: receiver sp[40]: receiver sp[48]: receiver
// -- jssp[24] : receiver // -> sp[24]: undefined -> sp[32]: target -> sp[40]: target
// ----------------------------------- // -> sp[16]: undefined -> sp[24]: undefined -> sp[32]: arguments_list
__ Adds(x10, argc, 0); // Preserve argc, and set the Z flag if it is zero. // -> sp[8]: undefined -> sp[16]: undefined -> sp[24]: undefined
__ Pop(new_target, arguments_list, target); // Overwrites argc. // sp[0]: undefined sp[8]: undefined sp[16]: undefined
__ CmovX(target, undefined_value, eq); // undefined if argc == 0. // sp[0]: undefined sp[8]: undefined
__ Cmp(x10, 2); // sp[0]: undefined
__ CmovX(arguments_list, undefined_value, lo); // undefined if argc <= 1. // argc = 3
__ CmovX(new_target, target, ls); // target if argc <= 2. // sp[56]: receiver
// -> sp[48]: target
__ Poke(undefined_value, 0); // Overwrite receiver. // -> sp[40]: arguments_list
// -> sp[32]: new_target
// sp[24]: undefined
// sp[16]: undefined
// sp[8]: undefined
// sp[0]: undefined
//
// There are now always three arguments to read, in the slots starting from
// slot (argc + 1).
Register scratch = x10;
__ SlotAddress(scratch, argc);
__ Ldp(new_target, arguments_list, MemOperand(scratch, 1 * kPointerSize));
__ Ldr(target, MemOperand(scratch, 3 * kPointerSize));
__ Cmp(argc, 2);
__ CmovX(new_target, target, ls); // target if argc <= 2.
__ Drop(4); // Drop the undefined values we pushed above.
__ DropArguments(argc, TurboAssembler::kCountExcludesReceiver);
// Push receiver (undefined).
__ PushArgument(undefined_value);
} }
// ----------- S t a t e ------------- // ----------- S t a t e -------------
......
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