Reland [arm64] Improve some new builtins.
- Simplify the variable-length pop sequence on entry. (It now uses smaller code with no branches.) - Use conditional compare to merge branches where appropriate. - Make use of Ldrsw + UntagSmiFieldMemOperand to load smis more efficiently. - Only load 'undefined' and 'null' once per builtin. - A few other small improvements. BUG= Review URL: https://codereview.chromium.org/1576403002 Cr-Commit-Position: refs/heads/master@{#33235}
This commit is contained in:
parent
9ce5162fd2
commit
a1103a117c
@ -1403,54 +1403,71 @@ void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm,
|
||||
// static
|
||||
void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) {
|
||||
// ----------- S t a t e -------------
|
||||
// -- r0 : argc
|
||||
// -- sp[0] : argArray
|
||||
// -- sp[8] : thisArg
|
||||
// -- sp[16] : receiver
|
||||
// -- x0 : argc
|
||||
// -- jssp[0] : argArray (if argc == 2)
|
||||
// -- jssp[8] : thisArg (if argc >= 1)
|
||||
// -- jssp[16] : receiver
|
||||
// -----------------------------------
|
||||
ASM_LOCATION("Builtins::Generate_FunctionPrototypeApply");
|
||||
|
||||
Register argc = x0;
|
||||
Register arg_array = x0;
|
||||
Register receiver = x1;
|
||||
Register this_arg = x2;
|
||||
Register undefined_value = x3;
|
||||
Register null_value = x4;
|
||||
|
||||
__ LoadRoot(undefined_value, Heap::kUndefinedValueRootIndex);
|
||||
__ LoadRoot(null_value, Heap::kNullValueRootIndex);
|
||||
|
||||
// 1. Load receiver into x1, argArray into x0 (if present), remove all
|
||||
// arguments from the stack (including the receiver), and push thisArg (if
|
||||
// present) instead.
|
||||
{
|
||||
Label done;
|
||||
__ LoadRoot(x2, Heap::kUndefinedValueRootIndex);
|
||||
__ Mov(x3, x2);
|
||||
__ Peek(x1, Operand(x0, LSL, kPointerSizeLog2)); // receiver
|
||||
__ Subs(x4, x0, 1);
|
||||
__ B(lt, &done);
|
||||
__ Peek(x2, Operand(x4, LSL, kPointerSizeLog2)); // thisArg
|
||||
__ Subs(x4, x4, 1);
|
||||
__ B(lt, &done);
|
||||
__ Peek(x3, Operand(x4, LSL, kPointerSizeLog2)); // argArray
|
||||
__ Bind(&done);
|
||||
__ Drop(x0);
|
||||
__ Poke(x2, 0);
|
||||
__ Mov(x0, x3);
|
||||
// Claim (2 - argc) dummy arguments from the stack, to put the stack in a
|
||||
// consistent state for a simple pop operation.
|
||||
__ Claim(2);
|
||||
__ Drop(argc);
|
||||
|
||||
// ----------- S t a t e -------------
|
||||
// -- x0 : argc
|
||||
// -- jssp[0] : argArray (dummy value if argc <= 1)
|
||||
// -- jssp[8] : thisArg (dummy value if argc == 0)
|
||||
// -- jssp[16] : receiver
|
||||
// -----------------------------------
|
||||
__ Cmp(argc, 1);
|
||||
__ Pop(arg_array, this_arg); // Overwrites argc.
|
||||
__ CmovX(this_arg, undefined_value, lo); // undefined if argc == 0.
|
||||
__ CmovX(arg_array, undefined_value, ls); // undefined if argc <= 1.
|
||||
|
||||
__ Peek(receiver, 0);
|
||||
__ Poke(this_arg, 0);
|
||||
}
|
||||
|
||||
// ----------- S t a t e -------------
|
||||
// -- x0 : argArray
|
||||
// -- x1 : receiver
|
||||
// -- sp[0] : thisArg
|
||||
// -- x0 : argArray
|
||||
// -- x1 : receiver
|
||||
// -- x3 : undefined root value
|
||||
// -- jssp[0] : thisArg
|
||||
// -----------------------------------
|
||||
|
||||
// 2. Make sure the receiver is actually callable.
|
||||
Label receiver_not_callable;
|
||||
__ JumpIfSmi(x1, &receiver_not_callable);
|
||||
__ Ldr(x4, FieldMemOperand(x1, HeapObject::kMapOffset));
|
||||
__ Ldrb(x4, FieldMemOperand(x4, Map::kBitFieldOffset));
|
||||
__ TestAndBranchIfAllClear(x4, 1 << Map::kIsCallable, &receiver_not_callable);
|
||||
__ JumpIfSmi(receiver, &receiver_not_callable);
|
||||
__ Ldr(x10, FieldMemOperand(receiver, HeapObject::kMapOffset));
|
||||
__ Ldrb(w10, FieldMemOperand(x10, Map::kBitFieldOffset));
|
||||
__ TestAndBranchIfAllClear(x10, 1 << Map::kIsCallable,
|
||||
&receiver_not_callable);
|
||||
|
||||
// 3. Tail call with no arguments if argArray is null or undefined.
|
||||
Label no_arguments;
|
||||
__ JumpIfRoot(x0, Heap::kNullValueRootIndex, &no_arguments);
|
||||
__ JumpIfRoot(x0, Heap::kUndefinedValueRootIndex, &no_arguments);
|
||||
__ Cmp(arg_array, null_value);
|
||||
__ Ccmp(arg_array, undefined_value, ZFlag, ne);
|
||||
__ B(eq, &no_arguments);
|
||||
|
||||
// 4a. Apply the receiver to the given argArray (passing undefined for
|
||||
// new.target).
|
||||
__ LoadRoot(x3, Heap::kUndefinedValueRootIndex);
|
||||
// new.target in x3).
|
||||
DCHECK(undefined_value.Is(x3));
|
||||
__ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET);
|
||||
|
||||
// 4b. The argArray is either null or undefined, so we tail call without any
|
||||
@ -1458,13 +1475,14 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) {
|
||||
__ Bind(&no_arguments);
|
||||
{
|
||||
__ Mov(x0, 0);
|
||||
DCHECK(receiver.Is(x1));
|
||||
__ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
// 4c. The receiver is not callable, throw an appropriate TypeError.
|
||||
__ Bind(&receiver_not_callable);
|
||||
{
|
||||
__ Poke(x1, 0);
|
||||
__ Poke(receiver, 0);
|
||||
__ TailCallRuntime(Runtime::kThrowApplyNonFunction);
|
||||
}
|
||||
}
|
||||
@ -1519,59 +1537,70 @@ void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) {
|
||||
|
||||
void Builtins::Generate_ReflectApply(MacroAssembler* masm) {
|
||||
// ----------- S t a t e -------------
|
||||
// -- x0 : argc
|
||||
// -- sp[0] : argumentsList
|
||||
// -- sp[8] : thisArgument
|
||||
// -- sp[16] : target
|
||||
// -- sp[24] : receiver
|
||||
// -- x0 : argc
|
||||
// -- jssp[0] : argumentsList (if argc == 3)
|
||||
// -- jssp[8] : thisArgument (if argc >= 2)
|
||||
// -- jssp[16] : target (if argc >= 1)
|
||||
// -- jssp[24] : receiver
|
||||
// -----------------------------------
|
||||
ASM_LOCATION("Builtins::Generate_ReflectApply");
|
||||
|
||||
Register argc = x0;
|
||||
Register arguments_list = x0;
|
||||
Register target = x1;
|
||||
Register this_argument = x2;
|
||||
Register undefined_value = x3;
|
||||
|
||||
__ LoadRoot(undefined_value, Heap::kUndefinedValueRootIndex);
|
||||
|
||||
// 1. Load target into x1 (if present), argumentsList into x0 (if present),
|
||||
// remove all arguments from the stack (including the receiver), and push
|
||||
// thisArgument (if present) instead.
|
||||
{
|
||||
Label done;
|
||||
__ LoadRoot(x1, Heap::kUndefinedValueRootIndex);
|
||||
__ Mov(x2, x1);
|
||||
__ Mov(x3, x1);
|
||||
__ Subs(x4, x0, 1);
|
||||
__ B(lt, &done);
|
||||
__ Peek(x1, Operand(x4, LSL, kPointerSizeLog2)); // target
|
||||
__ Subs(x4, x4, 1);
|
||||
__ B(lt, &done);
|
||||
__ Peek(x2, Operand(x4, LSL, kPointerSizeLog2)); // thisArgument
|
||||
__ Subs(x4, x4, 1);
|
||||
__ B(lt, &done);
|
||||
__ Peek(x3, Operand(x4, LSL, kPointerSizeLog2)); // argumentsList
|
||||
__ Bind(&done);
|
||||
__ Drop(x0);
|
||||
__ Poke(x2, 0);
|
||||
__ Mov(x0, x3);
|
||||
// Claim (3 - argc) dummy arguments from the stack, to put the stack in a
|
||||
// consistent state for a simple pop operation.
|
||||
__ Claim(3);
|
||||
__ Drop(argc);
|
||||
|
||||
// ----------- S t a t e -------------
|
||||
// -- x0 : argc
|
||||
// -- jssp[0] : argumentsList (dummy value if argc <= 2)
|
||||
// -- jssp[8] : thisArgument (dummy value if argc <= 1)
|
||||
// -- jssp[16] : target (dummy value if argc == 0)
|
||||
// -- jssp[24] : receiver
|
||||
// -----------------------------------
|
||||
__ Adds(x10, argc, 0); // Preserve argc, and set the Z flag if it is zero.
|
||||
__ Pop(arguments_list, this_argument, target); // Overwrites argc.
|
||||
__ CmovX(target, undefined_value, eq); // undefined if argc == 0.
|
||||
__ Cmp(x10, 2);
|
||||
__ CmovX(this_argument, undefined_value, lo); // undefined if argc <= 1.
|
||||
__ CmovX(arguments_list, undefined_value, ls); // undefined if argc <= 2.
|
||||
|
||||
__ Poke(this_argument, 0); // Overwrite receiver.
|
||||
}
|
||||
|
||||
// ----------- S t a t e -------------
|
||||
// -- x0 : argumentsList
|
||||
// -- x1 : target
|
||||
// -- sp[0] : thisArgument
|
||||
// -- x0 : argumentsList
|
||||
// -- x1 : target
|
||||
// -- jssp[0] : thisArgument
|
||||
// -----------------------------------
|
||||
|
||||
// 2. Make sure the target is actually callable.
|
||||
Label target_not_callable;
|
||||
__ JumpIfSmi(x1, &target_not_callable);
|
||||
__ Ldr(x4, FieldMemOperand(x1, HeapObject::kMapOffset));
|
||||
__ Ldrb(x4, FieldMemOperand(x4, Map::kBitFieldOffset));
|
||||
__ TestAndBranchIfAllClear(x4, 1 << Map::kIsCallable, &target_not_callable);
|
||||
__ JumpIfSmi(target, &target_not_callable);
|
||||
__ Ldr(x10, FieldMemOperand(target, HeapObject::kMapOffset));
|
||||
__ Ldr(x10, FieldMemOperand(x10, Map::kBitFieldOffset));
|
||||
__ TestAndBranchIfAllClear(x10, 1 << Map::kIsCallable, &target_not_callable);
|
||||
|
||||
// 3a. Apply the target to the given argumentsList (passing undefined for
|
||||
// new.target).
|
||||
__ LoadRoot(x3, Heap::kUndefinedValueRootIndex);
|
||||
// new.target in x3).
|
||||
DCHECK(undefined_value.Is(x3));
|
||||
__ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET);
|
||||
|
||||
// 3b. The target is not callable, throw an appropriate TypeError.
|
||||
__ Bind(&target_not_callable);
|
||||
{
|
||||
__ Poke(x1, 0);
|
||||
__ Poke(target, 0);
|
||||
__ TailCallRuntime(Runtime::kThrowApplyNonFunction);
|
||||
}
|
||||
}
|
||||
@ -1579,59 +1608,70 @@ void Builtins::Generate_ReflectApply(MacroAssembler* masm) {
|
||||
|
||||
void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
|
||||
// ----------- S t a t e -------------
|
||||
// -- x0 : argc
|
||||
// -- sp[0] : new.target (optional)
|
||||
// -- sp[8] : argumentsList
|
||||
// -- sp[16] : target
|
||||
// -- sp[24] : receiver
|
||||
// -- x0 : argc
|
||||
// -- jssp[0] : new.target (optional)
|
||||
// -- jssp[8] : argumentsList
|
||||
// -- jssp[16] : target
|
||||
// -- jssp[24] : receiver
|
||||
// -----------------------------------
|
||||
ASM_LOCATION("Builtins::Generate_ReflectConstruct");
|
||||
|
||||
Register argc = x0;
|
||||
Register arguments_list = x0;
|
||||
Register target = x1;
|
||||
Register new_target = x3;
|
||||
Register undefined_value = x4;
|
||||
|
||||
__ LoadRoot(undefined_value, Heap::kUndefinedValueRootIndex);
|
||||
|
||||
// 1. Load target into x1 (if present), argumentsList into x0 (if present),
|
||||
// new.target into x3 (if present, otherwise use target), remove all
|
||||
// arguments from the stack (including the receiver), and push thisArgument
|
||||
// (if present) instead.
|
||||
{
|
||||
Label done;
|
||||
__ LoadRoot(x1, Heap::kUndefinedValueRootIndex);
|
||||
__ Mov(x2, x1);
|
||||
__ Poke(x2, Operand(x0, LSL, kPointerSizeLog2)); // receiver
|
||||
__ Subs(x4, x0, 1);
|
||||
__ B(lt, &done);
|
||||
__ Peek(x1, Operand(x4, LSL, kPointerSizeLog2)); // target
|
||||
__ Mov(x3, x1); // new.target defaults to target
|
||||
__ Subs(x4, x4, 1);
|
||||
__ B(lt, &done);
|
||||
__ Peek(x2, Operand(x4, LSL, kPointerSizeLog2)); // argumentsList
|
||||
__ Subs(x4, x4, 1);
|
||||
__ B(lt, &done);
|
||||
__ Peek(x3, Operand(x4, LSL, kPointerSizeLog2)); // new.target
|
||||
__ Bind(&done);
|
||||
__ Drop(x0);
|
||||
__ Mov(x0, x2);
|
||||
// Claim (3 - argc) dummy arguments from the stack, to put the stack in a
|
||||
// consistent state for a simple pop operation.
|
||||
__ Claim(3);
|
||||
__ Drop(argc);
|
||||
|
||||
// ----------- S t a t e -------------
|
||||
// -- x0 : argc
|
||||
// -- jssp[0] : new.target (dummy value if argc <= 2)
|
||||
// -- jssp[8] : argumentsList (dummy value if argc <= 1)
|
||||
// -- jssp[16] : target (dummy value if argc == 0)
|
||||
// -- jssp[24] : receiver
|
||||
// -----------------------------------
|
||||
__ Adds(x10, argc, 0); // Preserve argc, and set the Z flag if it is zero.
|
||||
__ Pop(new_target, arguments_list, target); // Overwrites argc.
|
||||
__ CmovX(target, undefined_value, eq); // undefined if argc == 0.
|
||||
__ Cmp(x10, 2);
|
||||
__ CmovX(arguments_list, undefined_value, lo); // undefined if argc <= 1.
|
||||
__ CmovX(new_target, target, ls); // target if argc <= 2.
|
||||
|
||||
__ Poke(undefined_value, 0); // Overwrite receiver.
|
||||
}
|
||||
|
||||
// ----------- S t a t e -------------
|
||||
// -- x0 : argumentsList
|
||||
// -- x3 : new.target
|
||||
// -- x1 : target
|
||||
// -- sp[0] : receiver (undefined)
|
||||
// -- x0 : argumentsList
|
||||
// -- x1 : target
|
||||
// -- x3 : new.target
|
||||
// -- jssp[0] : receiver (undefined)
|
||||
// -----------------------------------
|
||||
|
||||
// 2. Make sure the target is actually a constructor.
|
||||
Label target_not_constructor;
|
||||
__ JumpIfSmi(x1, &target_not_constructor);
|
||||
__ Ldr(x4, FieldMemOperand(x1, HeapObject::kMapOffset));
|
||||
__ Ldrb(x4, FieldMemOperand(x4, Map::kBitFieldOffset));
|
||||
__ TestAndBranchIfAllClear(x4, 1 << Map::kIsConstructor,
|
||||
__ JumpIfSmi(target, &target_not_constructor);
|
||||
__ Ldr(x10, FieldMemOperand(target, HeapObject::kMapOffset));
|
||||
__ Ldrb(x10, FieldMemOperand(x10, Map::kBitFieldOffset));
|
||||
__ TestAndBranchIfAllClear(x10, 1 << Map::kIsConstructor,
|
||||
&target_not_constructor);
|
||||
|
||||
// 3. Make sure the target is actually a constructor.
|
||||
// 3. Make sure the new.target is actually a constructor.
|
||||
Label new_target_not_constructor;
|
||||
__ JumpIfSmi(x3, &new_target_not_constructor);
|
||||
__ Ldr(x4, FieldMemOperand(x3, HeapObject::kMapOffset));
|
||||
__ Ldrb(x4, FieldMemOperand(x4, Map::kBitFieldOffset));
|
||||
__ TestAndBranchIfAllClear(x4, 1 << Map::kIsConstructor,
|
||||
__ JumpIfSmi(new_target, &new_target_not_constructor);
|
||||
__ Ldr(x10, FieldMemOperand(new_target, HeapObject::kMapOffset));
|
||||
__ Ldrb(x10, FieldMemOperand(x10, Map::kBitFieldOffset));
|
||||
__ TestAndBranchIfAllClear(x10, 1 << Map::kIsConstructor,
|
||||
&new_target_not_constructor);
|
||||
|
||||
// 4a. Construct the target with the given new.target and argumentsList.
|
||||
@ -1640,14 +1680,14 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
|
||||
// 4b. The target is not a constructor, throw an appropriate TypeError.
|
||||
__ Bind(&target_not_constructor);
|
||||
{
|
||||
__ Poke(x1, 0);
|
||||
__ Poke(target, 0);
|
||||
__ TailCallRuntime(Runtime::kThrowCalledNonCallable);
|
||||
}
|
||||
|
||||
// 4c. The new.target is not a constructor, throw an appropriate TypeError.
|
||||
__ Bind(&new_target_not_constructor);
|
||||
{
|
||||
__ Poke(x3, 0);
|
||||
__ Poke(new_target, 0);
|
||||
__ TailCallRuntime(Runtime::kThrowCalledNonCallable);
|
||||
}
|
||||
}
|
||||
@ -1703,72 +1743,81 @@ static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) {
|
||||
// static
|
||||
void Builtins::Generate_Apply(MacroAssembler* masm) {
|
||||
// ----------- S t a t e -------------
|
||||
// -- x0 : argumentsList
|
||||
// -- x1 : target
|
||||
// -- x3 : new.target (checked to be constructor or undefined)
|
||||
// -- sp[0] : thisArgument
|
||||
// -- x0 : argumentsList
|
||||
// -- x1 : target
|
||||
// -- x3 : new.target (checked to be constructor or undefined)
|
||||
// -- jssp[0] : thisArgument
|
||||
// -----------------------------------
|
||||
|
||||
Register arguments_list = x0;
|
||||
Register target = x1;
|
||||
Register new_target = x3;
|
||||
|
||||
Register args = x0;
|
||||
Register len = x2;
|
||||
|
||||
// Create the list of arguments from the array-like argumentsList.
|
||||
{
|
||||
Label create_arguments, create_array, create_runtime, done_create;
|
||||
__ JumpIfSmi(x0, &create_runtime);
|
||||
__ JumpIfSmi(arguments_list, &create_runtime);
|
||||
|
||||
// Load the map of argumentsList into x2.
|
||||
__ Ldr(x2, FieldMemOperand(x0, HeapObject::kMapOffset));
|
||||
// Load native context.
|
||||
Register native_context = x4;
|
||||
__ Ldr(native_context, NativeContextMemOperand());
|
||||
|
||||
// Load native context into x4.
|
||||
__ Ldr(x4, NativeContextMemOperand());
|
||||
// Load the map of argumentsList.
|
||||
Register arguments_list_map = x2;
|
||||
__ Ldr(arguments_list_map,
|
||||
FieldMemOperand(arguments_list, HeapObject::kMapOffset));
|
||||
|
||||
// Check if argumentsList is an (unmodified) arguments object.
|
||||
__ Ldr(x5, ContextMemOperand(x4, Context::SLOPPY_ARGUMENTS_MAP_INDEX));
|
||||
__ Cmp(x5, x2);
|
||||
__ B(eq, &create_arguments);
|
||||
__ Ldr(x5, ContextMemOperand(x4, Context::STRICT_ARGUMENTS_MAP_INDEX));
|
||||
__ Cmp(x5, x2);
|
||||
__ Ldr(x10, ContextMemOperand(native_context,
|
||||
Context::SLOPPY_ARGUMENTS_MAP_INDEX));
|
||||
__ Ldr(x11, ContextMemOperand(native_context,
|
||||
Context::STRICT_ARGUMENTS_MAP_INDEX));
|
||||
__ Cmp(arguments_list_map, x10);
|
||||
__ Ccmp(arguments_list_map, x11, ZFlag, ne);
|
||||
__ B(eq, &create_arguments);
|
||||
|
||||
// Check if argumentsList is a fast JSArray.
|
||||
__ CompareInstanceType(x2, x4, JS_ARRAY_TYPE);
|
||||
__ CompareInstanceType(arguments_list_map, native_context, JS_ARRAY_TYPE);
|
||||
__ B(eq, &create_array);
|
||||
|
||||
// Ask the runtime to create the list (actually a FixedArray).
|
||||
__ Bind(&create_runtime);
|
||||
{
|
||||
FrameScope scope(masm, StackFrame::INTERNAL);
|
||||
__ Push(x1, x3, x0);
|
||||
__ Push(target, new_target, arguments_list);
|
||||
__ CallRuntime(Runtime::kCreateListFromArrayLike);
|
||||
__ Pop(x3, x1);
|
||||
__ Ldrsw(x2, UntagSmiFieldMemOperand(x0, FixedArray::kLengthOffset));
|
||||
__ Pop(new_target, target);
|
||||
__ Ldrsw(len, UntagSmiFieldMemOperand(arguments_list,
|
||||
FixedArray::kLengthOffset));
|
||||
}
|
||||
__ B(&done_create);
|
||||
|
||||
// Try to create the list from an arguments object.
|
||||
__ Bind(&create_arguments);
|
||||
__ Ldr(x2,
|
||||
FieldMemOperand(x0, JSObject::kHeaderSize +
|
||||
Heap::kArgumentsLengthIndex * kPointerSize));
|
||||
__ Ldr(x4, FieldMemOperand(x0, JSObject::kElementsOffset));
|
||||
__ Ldr(x5, FieldMemOperand(x4, FixedArray::kLengthOffset));
|
||||
__ Cmp(x2, x4);
|
||||
__ B(ne, &create_runtime);
|
||||
__ SmiUntag(x2);
|
||||
__ Mov(x0, x4);
|
||||
__ Ldrsw(len, UntagSmiFieldMemOperand(
|
||||
arguments_list,
|
||||
JSObject::kHeaderSize +
|
||||
Heap::kArgumentsLengthIndex * kPointerSize));
|
||||
__ Ldr(x10, FieldMemOperand(arguments_list, JSObject::kElementsOffset));
|
||||
__ Ldrsw(x11, UntagSmiFieldMemOperand(x10, FixedArray::kLengthOffset));
|
||||
__ CompareAndBranch(len, x11, ne, &create_runtime);
|
||||
__ Mov(args, x10);
|
||||
__ B(&done_create);
|
||||
|
||||
// Try to create the list from a JSArray object.
|
||||
__ Bind(&create_array);
|
||||
__ Ldr(x2, FieldMemOperand(x2, Map::kBitField2Offset));
|
||||
__ DecodeField<Map::ElementsKindBits>(x2);
|
||||
__ Ldr(x10, FieldMemOperand(arguments_list_map, Map::kBitField2Offset));
|
||||
__ DecodeField<Map::ElementsKindBits>(x10);
|
||||
STATIC_ASSERT(FAST_SMI_ELEMENTS == 0);
|
||||
STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1);
|
||||
STATIC_ASSERT(FAST_ELEMENTS == 2);
|
||||
__ Cmp(x2, FAST_ELEMENTS);
|
||||
__ B(hi, &create_runtime);
|
||||
__ Cmp(x2, FAST_HOLEY_SMI_ELEMENTS);
|
||||
__ B(eq, &create_runtime);
|
||||
__ Ldrsw(x2, UntagSmiFieldMemOperand(x0, JSArray::kLengthOffset));
|
||||
__ Ldr(x0, FieldMemOperand(x0, JSArray::kElementsOffset));
|
||||
// Branch for anything that's not FAST_{SMI_}ELEMENTS.
|
||||
__ TestAndBranchIfAnySet(x10, ~FAST_ELEMENTS, &create_runtime);
|
||||
__ Ldrsw(len,
|
||||
UntagSmiFieldMemOperand(arguments_list, JSArray::kLengthOffset));
|
||||
__ Ldr(args, FieldMemOperand(arguments_list, JSArray::kElementsOffset));
|
||||
|
||||
__ Bind(&done_create);
|
||||
}
|
||||
@ -1781,41 +1830,53 @@ void Builtins::Generate_Apply(MacroAssembler* masm) {
|
||||
__ LoadRoot(x10, Heap::kRealStackLimitRootIndex);
|
||||
// Make x10 the space we have left. The stack might already be overflowed
|
||||
// here which will cause x10 to become negative.
|
||||
__ Sub(x10, jssp, x10);
|
||||
__ Sub(x10, masm->StackPointer(), x10);
|
||||
// Check if the arguments will overflow the stack.
|
||||
__ Cmp(x10, Operand(x2, LSL, kPointerSizeLog2));
|
||||
__ Cmp(x10, Operand(len, LSL, kPointerSizeLog2));
|
||||
__ B(gt, &done); // Signed comparison.
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
__ Bind(&done);
|
||||
}
|
||||
|
||||
// ----------- S t a t e -------------
|
||||
// -- x1 : target
|
||||
// -- x0 : args (a FixedArray built from argumentsList)
|
||||
// -- x2 : len (number of elements to push from args)
|
||||
// -- x3 : new.target (checked to be constructor or undefined)
|
||||
// -- sp[0] : thisArgument
|
||||
// -- x0 : args (a FixedArray built from argumentsList)
|
||||
// -- x1 : target
|
||||
// -- x2 : len (number of elements to push from args)
|
||||
// -- x3 : new.target (checked to be constructor or undefined)
|
||||
// -- jssp[0] : thisArgument
|
||||
// -----------------------------------
|
||||
|
||||
// Push arguments onto the stack (thisArgument is already on the stack).
|
||||
{
|
||||
__ Mov(x4, 0);
|
||||
Label done, loop;
|
||||
Register src = x4;
|
||||
|
||||
__ Add(src, args, FixedArray::kHeaderSize - kHeapObjectTag);
|
||||
__ Mov(x0, len); // The 'len' argument for Call() or Construct().
|
||||
__ Cbz(len, &done);
|
||||
__ Claim(len);
|
||||
__ Bind(&loop);
|
||||
__ Cmp(x4, x2);
|
||||
__ B(eq, &done);
|
||||
__ Add(x10, x0, Operand(x4, LSL, kPointerSizeLog2));
|
||||
__ Ldr(x10, FieldMemOperand(x10, FixedArray::kHeaderSize));
|
||||
__ Push(x10);
|
||||
__ Add(x4, x4, 1);
|
||||
__ B(&loop);
|
||||
__ Sub(len, len, 1);
|
||||
__ Ldr(x10, MemOperand(src, kPointerSize, PostIndex));
|
||||
__ Poke(x10, Operand(len, LSL, kPointerSizeLog2));
|
||||
__ Cbnz(len, &loop);
|
||||
__ Bind(&done);
|
||||
__ Mov(x0, x4);
|
||||
}
|
||||
|
||||
// ----------- S t a t e -------------
|
||||
// -- x0 : argument count (len)
|
||||
// -- x1 : target
|
||||
// -- x3 : new.target (checked to be constructor or undefined)
|
||||
// -- jssp[0] : args[len-1]
|
||||
// -- jssp[8] : args[len-2]
|
||||
// ... : ...
|
||||
// -- jssp[8*(len-2)] : args[1]
|
||||
// -- jssp[8*(len-1)] : args[0]
|
||||
// -----------------------------------
|
||||
|
||||
// Dispatch to Call or Construct depending on whether new.target is undefined.
|
||||
{
|
||||
__ CompareRoot(x3, Heap::kUndefinedValueRootIndex);
|
||||
__ CompareRoot(new_target, Heap::kUndefinedValueRootIndex);
|
||||
__ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET, eq);
|
||||
__ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
|
||||
}
|
||||
@ -1825,6 +1886,7 @@ void Builtins::Generate_Apply(MacroAssembler* masm) {
|
||||
// static
|
||||
void Builtins::Generate_CallFunction(MacroAssembler* masm,
|
||||
ConvertReceiverMode mode) {
|
||||
ASM_LOCATION("Builtins::Generate_CallFunction");
|
||||
// ----------- S t a t e -------------
|
||||
// -- x0 : the number of arguments (not including the receiver)
|
||||
// -- x1 : the function to call (checked to be a JSFunction)
|
||||
|
@ -2440,6 +2440,7 @@ void FullCodeGenerator::CallIC(Handle<Code> code,
|
||||
|
||||
// Code common for calls using the IC.
|
||||
void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) {
|
||||
ASM_LOCATION("FullCodeGenerator::EmitCallWithLoadIC");
|
||||
Expression* callee = expr->expression();
|
||||
|
||||
// Get the target function.
|
||||
@ -2476,6 +2477,7 @@ void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) {
|
||||
|
||||
|
||||
void FullCodeGenerator::EmitSuperCallWithLoadIC(Call* expr) {
|
||||
ASM_LOCATION("FullCodeGenerator::EmitSuperCallWithLoadIC");
|
||||
Expression* callee = expr->expression();
|
||||
DCHECK(callee->IsProperty());
|
||||
Property* prop = callee->AsProperty();
|
||||
@ -2518,6 +2520,7 @@ void FullCodeGenerator::EmitSuperCallWithLoadIC(Call* expr) {
|
||||
// Code common for calls using the IC.
|
||||
void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr,
|
||||
Expression* key) {
|
||||
ASM_LOCATION("FullCodeGenerator::EmitKeyedCallWithLoadIC");
|
||||
// Load the key.
|
||||
VisitForAccumulatorValue(key);
|
||||
|
||||
@ -2539,6 +2542,7 @@ void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr,
|
||||
|
||||
|
||||
void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) {
|
||||
ASM_LOCATION("FullCodeGenerator::EmitKeyedSuperCallWithLoadIC");
|
||||
Expression* callee = expr->expression();
|
||||
DCHECK(callee->IsProperty());
|
||||
Property* prop = callee->AsProperty();
|
||||
@ -2577,6 +2581,7 @@ void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) {
|
||||
|
||||
|
||||
void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) {
|
||||
ASM_LOCATION("FullCodeGenerator::EmitCall");
|
||||
// Load the arguments.
|
||||
ZoneList<Expression*>* args = expr->arguments();
|
||||
int arg_count = args->length();
|
||||
@ -2669,6 +2674,7 @@ void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) {
|
||||
|
||||
|
||||
void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
|
||||
ASM_LOCATION("FullCodeGenerator::EmitPossiblyEvalCall");
|
||||
// In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval
|
||||
// to resolve the function we need to call. Then we call the resolved
|
||||
// function using the given arguments.
|
||||
@ -2748,6 +2754,7 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) {
|
||||
|
||||
|
||||
void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
|
||||
ASM_LOCATION("FullCodeGenerator::EmitSuperConstructorCall");
|
||||
SuperCallReference* super_call_ref =
|
||||
expr->expression()->AsSuperCallReference();
|
||||
DCHECK_NOT_NULL(super_call_ref);
|
||||
|
Loading…
Reference in New Issue
Block a user