[csa][builtin] Port ArrayConstructor builtin to CSA.
Bug: v8:5269, v8:7703 Change-Id: If80923b767b6bf3533b4d53039b1b5125c670cf1 Reviewed-on: https://chromium-review.googlesource.com/1097486 Commit-Queue: Igor Sheludko <ishell@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#53693}
This commit is contained in:
parent
0909dbe3d6
commit
7745c73a82
@ -115,36 +115,6 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
|
||||
// ----------- S t a t e -------------
|
||||
// -- r0 : number of arguments
|
||||
// -- r1 : array function
|
||||
// -- lr : return address
|
||||
// -- sp[...]: constructor arguments
|
||||
// -----------------------------------
|
||||
Label generic_array_code, one_or_more_arguments, two_or_more_arguments;
|
||||
|
||||
if (FLAG_debug_code) {
|
||||
// Initial map for the builtin Array functions should be maps.
|
||||
__ ldr(r7, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset));
|
||||
__ SmiTst(r7);
|
||||
__ Assert(ne, AbortReason::kUnexpectedInitialMapForArrayFunction);
|
||||
__ CompareObjectType(r7, r8, r9, MAP_TYPE);
|
||||
__ Assert(eq, AbortReason::kUnexpectedInitialMapForArrayFunction);
|
||||
}
|
||||
|
||||
// r2 is the AllocationSite - here undefined.
|
||||
__ LoadRoot(r2, Heap::kUndefinedValueRootIndex);
|
||||
// If r3 (new target) is undefined, then this is the 'Call' case, so move
|
||||
// r1 (the constructor) to r3.
|
||||
__ cmp(r3, r2);
|
||||
__ mov(r3, r1, LeaveCC, eq);
|
||||
|
||||
// Run the native code for the Array function called as a normal function.
|
||||
Handle<Code> code = BUILTIN_CODE(masm->isolate(), ArrayConstructorImpl);
|
||||
__ Jump(code, RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
static void GenerateTailCallToReturnedCode(MacroAssembler* masm,
|
||||
Runtime::FunctionId function_id) {
|
||||
// ----------- S t a t e -------------
|
||||
|
@ -109,37 +109,6 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
|
||||
// ----------- S t a t e -------------
|
||||
// -- x0 : number of arguments
|
||||
// -- x1 : array function
|
||||
// -- lr : return address
|
||||
// -- sp[...]: constructor arguments
|
||||
// -----------------------------------
|
||||
ASM_LOCATION("Builtins::Generate_ArrayConstructor");
|
||||
Label generic_array_code, one_or_more_arguments, two_or_more_arguments;
|
||||
|
||||
if (FLAG_debug_code) {
|
||||
// Initial map for the builtin Array functions should be maps.
|
||||
__ Ldr(x10, FieldMemOperand(x1, JSFunction::kPrototypeOrInitialMapOffset));
|
||||
__ Tst(x10, kSmiTagMask);
|
||||
__ Assert(ne, AbortReason::kUnexpectedInitialMapForArrayFunction);
|
||||
__ CompareObjectType(x10, x11, x12, MAP_TYPE);
|
||||
__ Assert(eq, AbortReason::kUnexpectedInitialMapForArrayFunction);
|
||||
}
|
||||
|
||||
// x2 is the AllocationSite - here undefined.
|
||||
__ LoadRoot(x2, Heap::kUndefinedValueRootIndex);
|
||||
// If x3 (new target) is undefined, then this is the 'Call' case, so move
|
||||
// x1 (the constructor) to x3.
|
||||
__ Cmp(x3, x2);
|
||||
__ CmovX(x3, x1, eq);
|
||||
|
||||
// Run the native code for the Array function called as a normal function.
|
||||
Handle<Code> code = BUILTIN_CODE(masm->isolate(), ArrayConstructorImpl);
|
||||
__ Jump(code, RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
static void GenerateTailCallToReturnedCode(MacroAssembler* masm,
|
||||
Runtime::FunctionId function_id) {
|
||||
// ----------- S t a t e -------------
|
||||
|
@ -4011,6 +4011,30 @@ TF_BUILTIN(ArrayPrototypeFlatMap, CodeStubAssembler) {
|
||||
{ ThrowTypeError(context, MessageTemplate::kMapperFunctionNonCallable); }
|
||||
}
|
||||
|
||||
TF_BUILTIN(ArrayConstructor, ArrayBuiltinsAssembler) {
|
||||
// This is a trampoline to ArrayConstructorImpl which just adds
|
||||
// allocation_site parameter value and sets new_target if necessary.
|
||||
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
TNode<JSFunction> function = CAST(Parameter(Descriptor::kFunction));
|
||||
TNode<Object> new_target = CAST(Parameter(Descriptor::kNewTarget));
|
||||
TNode<Int32T> argc =
|
||||
UncheckedCast<Int32T>(Parameter(Descriptor::kActualArgumentsCount));
|
||||
|
||||
// If new_target is undefined, then this is the 'Call' case, so set new_target
|
||||
// to function.
|
||||
new_target =
|
||||
SelectConstant<Object>(IsUndefined(new_target), function, new_target);
|
||||
|
||||
// Run the native code for the Array function called as a normal function.
|
||||
TNode<Code> code =
|
||||
HeapConstant(BUILTIN_CODE(isolate(), ArrayConstructorImpl));
|
||||
ArrayConstructorDescriptor descriptor(isolate());
|
||||
TNode<Object> no_allocation_site = UndefinedConstant();
|
||||
// TODO(ishell): Use TailCallBuiltin once ArrayConstructorImpl is ported.
|
||||
TailCallStub(descriptor, code, context, function, new_target, argc,
|
||||
no_allocation_site);
|
||||
}
|
||||
|
||||
void ArrayBuiltinsAssembler::GenerateConstructor(
|
||||
Node* context, Node* array_function, Node* array_map, Node* array_size,
|
||||
Node* allocation_site, ElementsKind elements_kind,
|
||||
|
@ -235,7 +235,7 @@ namespace internal {
|
||||
TFJ(ReturnReceiver, 0) \
|
||||
\
|
||||
/* Array */ \
|
||||
ASM(ArrayConstructor) \
|
||||
TFC(ArrayConstructor, ConstructTrampoline, 1) \
|
||||
ASM(ArrayConstructorImpl) \
|
||||
TFC(ArrayNoArgumentConstructor_PackedSmi_DontOverride, \
|
||||
ArrayNoArgumentConstructor, 1) \
|
||||
|
@ -1718,40 +1718,6 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
|
||||
// ----------- S t a t e -------------
|
||||
// -- eax : argc
|
||||
// -- edi : array function
|
||||
// -- esp[0] : return address
|
||||
// -- esp[4] : last argument
|
||||
// -----------------------------------
|
||||
Label generic_array_code;
|
||||
|
||||
if (FLAG_debug_code) {
|
||||
// Initial map for the builtin Array function should be a map.
|
||||
__ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset));
|
||||
// Will both indicate a nullptr and a Smi.
|
||||
__ test(ebx, Immediate(kSmiTagMask));
|
||||
__ Assert(not_zero, AbortReason::kUnexpectedInitialMapForArrayFunction);
|
||||
__ CmpObjectType(ebx, MAP_TYPE, ecx);
|
||||
__ Assert(equal, AbortReason::kUnexpectedInitialMapForArrayFunction);
|
||||
}
|
||||
|
||||
// ebx is the AllocationSite - here undefined.
|
||||
__ mov(ebx, masm->isolate()->factory()->undefined_value());
|
||||
// If edx (new target) is undefined, then this is the 'Call' case, so move
|
||||
// edi (the constructor) to rdx.
|
||||
Label call;
|
||||
__ cmp(edx, ebx);
|
||||
__ j(not_equal, &call);
|
||||
__ mov(edx, edi);
|
||||
|
||||
// Run the native code for the Array function called as a normal function.
|
||||
__ bind(&call);
|
||||
Handle<Code> code = BUILTIN_CODE(masm->isolate(), ArrayConstructorImpl);
|
||||
__ Jump(code, RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
|
||||
__ push(ebp);
|
||||
__ mov(ebp, esp);
|
||||
|
@ -111,40 +111,6 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
|
||||
// ----------- S t a t e -------------
|
||||
// -- a0 : number of arguments
|
||||
// -- a1 : array function
|
||||
// -- ra : return address
|
||||
// -- sp[...]: constructor arguments
|
||||
// -----------------------------------
|
||||
Label generic_array_code;
|
||||
|
||||
if (FLAG_debug_code) {
|
||||
// Initial map for the builtin Array functions should be maps.
|
||||
__ lw(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset));
|
||||
__ SmiTst(a2, t0);
|
||||
__ Assert(ne, AbortReason::kUnexpectedInitialMapForArrayFunction1, t0,
|
||||
Operand(zero_reg));
|
||||
__ GetObjectType(a2, t1, t0);
|
||||
__ Assert(eq, AbortReason::kUnexpectedInitialMapForArrayFunction2, t0,
|
||||
Operand(MAP_TYPE));
|
||||
}
|
||||
|
||||
// a2 is the AllocationSite - here undefined.
|
||||
__ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
|
||||
// If a3 (new target) is undefined, then this is the 'Call' case, so move
|
||||
// a1 (the constructor) to a3.
|
||||
Label call;
|
||||
__ Branch(&call, ne, a3, Operand(a2));
|
||||
__ mov(a3, a1);
|
||||
|
||||
// Run the native code for the Array function called as a normal function.
|
||||
__ bind(&call);
|
||||
__ Jump(BUILTIN_CODE(masm->isolate(), ArrayConstructorImpl),
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
static void GenerateTailCallToReturnedCode(MacroAssembler* masm,
|
||||
Runtime::FunctionId function_id) {
|
||||
// ----------- S t a t e -------------
|
||||
|
@ -111,40 +111,6 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
|
||||
// ----------- S t a t e -------------
|
||||
// -- a0 : number of arguments
|
||||
// -- a1 : array function
|
||||
// -- ra : return address
|
||||
// -- sp[...]: constructor arguments
|
||||
// -----------------------------------
|
||||
Label generic_array_code;
|
||||
|
||||
if (FLAG_debug_code) {
|
||||
// Initial map for the builtin Array functions should be maps.
|
||||
__ Ld(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset));
|
||||
__ SmiTst(a2, a4);
|
||||
__ Assert(ne, AbortReason::kUnexpectedInitialMapForArrayFunction1, a4,
|
||||
Operand(zero_reg));
|
||||
__ GetObjectType(a2, t0, a4);
|
||||
__ Assert(eq, AbortReason::kUnexpectedInitialMapForArrayFunction2, a4,
|
||||
Operand(MAP_TYPE));
|
||||
}
|
||||
|
||||
// a2 is the AllocationSite - here undefined.
|
||||
__ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
|
||||
// If a3 (new target) is undefined, then this is the 'Call' case, so move
|
||||
// a1 (the constructor) to a3.
|
||||
Label call;
|
||||
__ Branch(&call, ne, a3, Operand(a2));
|
||||
__ mov(a3, a1);
|
||||
|
||||
// Run the native code for the Array function called as a normal function.
|
||||
__ bind(&call);
|
||||
__ Jump(BUILTIN_CODE(masm->isolate(), ArrayConstructorImpl),
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
static void GenerateTailCallToReturnedCode(MacroAssembler* masm,
|
||||
Runtime::FunctionId function_id) {
|
||||
// ----------- S t a t e -------------
|
||||
|
@ -109,39 +109,6 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
|
||||
// ----------- S t a t e -------------
|
||||
// -- r3 : number of arguments
|
||||
// -- r4 : array function
|
||||
// -- lr : return address
|
||||
// -- sp[...]: constructor arguments
|
||||
// -----------------------------------
|
||||
Label generic_array_code, one_or_more_arguments, two_or_more_arguments;
|
||||
|
||||
if (FLAG_debug_code) {
|
||||
// Initial map for the builtin Array functions should be maps.
|
||||
__ LoadP(r5, FieldMemOperand(r4, JSFunction::kPrototypeOrInitialMapOffset));
|
||||
__ TestIfSmi(r5, r0);
|
||||
__ Assert(ne, AbortReason::kUnexpectedInitialMapForArrayFunction, cr0);
|
||||
__ CompareObjectType(r5, r7, r8, MAP_TYPE);
|
||||
__ Assert(eq, AbortReason::kUnexpectedInitialMapForArrayFunction);
|
||||
}
|
||||
|
||||
// r5 is the AllocationSite - here undefined.
|
||||
__ LoadRoot(r5, Heap::kUndefinedValueRootIndex);
|
||||
// If r6 (new target) is undefined, then this is the 'Call' case, so move
|
||||
// r4 (the constructor) to r6.
|
||||
Label call;
|
||||
__ cmp(r6, r5);
|
||||
__ bne(&call);
|
||||
__ mr(r6, r4);
|
||||
__ bind(&call);
|
||||
|
||||
// Run the native code for the Array function called as a normal function.
|
||||
Handle<Code> code = BUILTIN_CODE(masm->isolate(), ArrayConstructorImpl);
|
||||
__ Jump(code, RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
static void GenerateTailCallToReturnedCode(MacroAssembler* masm,
|
||||
Runtime::FunctionId function_id) {
|
||||
// ----------- S t a t e -------------
|
||||
|
@ -115,42 +115,6 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
|
||||
// ----------- S t a t e -------------
|
||||
// -- r2 : number of arguments
|
||||
// -- r3 : array function
|
||||
// -- lr : return address
|
||||
// -- sp[...]: constructor arguments
|
||||
// -----------------------------------
|
||||
Label generic_array_code, one_or_more_arguments, two_or_more_arguments;
|
||||
|
||||
// Get the Array function.
|
||||
GenerateLoadArrayFunction(masm, r3);
|
||||
|
||||
if (FLAG_debug_code) {
|
||||
// Initial map for the builtin Array functions should be maps.
|
||||
__ LoadP(r4, FieldMemOperand(r3, JSFunction::kPrototypeOrInitialMapOffset));
|
||||
__ TestIfSmi(r4);
|
||||
__ Assert(ne, AbortReason::kUnexpectedInitialMapForArrayFunction, cr0);
|
||||
__ CompareObjectType(r4, r6, r7, MAP_TYPE);
|
||||
__ Assert(eq, AbortReason::kUnexpectedInitialMapForArrayFunction);
|
||||
}
|
||||
|
||||
// r4 is the AllocationSite - here undefined.
|
||||
__ LoadRoot(r4, Heap::kUndefinedValueRootIndex);
|
||||
// If r5 (new target) is undefined, then this is the 'Call' case, so move
|
||||
// r3 (the constructor) to r5.
|
||||
Label call;
|
||||
__ CmpP(r5, r4);
|
||||
__ bne(&call);
|
||||
__ LoadRR(r5, r3);
|
||||
__ bind(&call);
|
||||
|
||||
// Run the native code for the Array function called as a normal function.
|
||||
Handle<Code> code = BUILTIN_CODE(masm->isolate(), ArrayConstructorImpl);
|
||||
__ Jump(code, RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
static void GenerateTailCallToReturnedCode(MacroAssembler* masm,
|
||||
Runtime::FunctionId function_id) {
|
||||
// ----------- S t a t e -------------
|
||||
|
@ -1698,41 +1698,6 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
|
||||
// ----------- S t a t e -------------
|
||||
// -- rax : argc
|
||||
// -- rdi : array function
|
||||
// -- rsp[0] : return address
|
||||
// -- rsp[8] : last argument
|
||||
// -----------------------------------
|
||||
Label generic_array_code;
|
||||
|
||||
if (FLAG_debug_code) {
|
||||
// Initial map for the builtin Array functions should be maps.
|
||||
__ movp(rbx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset));
|
||||
// Will both indicate a nullptr and a Smi.
|
||||
STATIC_ASSERT(kSmiTag == 0);
|
||||
Condition not_smi = NegateCondition(masm->CheckSmi(rbx));
|
||||
__ Check(not_smi, AbortReason::kUnexpectedInitialMapForArrayFunction);
|
||||
__ CmpObjectType(rbx, MAP_TYPE, rcx);
|
||||
__ Check(equal, AbortReason::kUnexpectedInitialMapForArrayFunction);
|
||||
}
|
||||
|
||||
// rbx is the AllocationSite - here undefined.
|
||||
__ LoadRoot(rbx, Heap::kUndefinedValueRootIndex);
|
||||
// If rdx (new target) is undefined, then this is the 'Call' case, so move
|
||||
// rdi (the constructor) to rdx.
|
||||
Label call;
|
||||
__ cmpp(rdx, rbx);
|
||||
__ j(not_equal, &call);
|
||||
__ movp(rdx, rdi);
|
||||
|
||||
// Run the native code for the Array function called as a normal function.
|
||||
__ bind(&call);
|
||||
Handle<Code> code = BUILTIN_CODE(masm->isolate(), ArrayConstructorImpl);
|
||||
__ Jump(code, RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
|
||||
__ pushq(rbp);
|
||||
__ movp(rbp, rsp);
|
||||
|
Loading…
Reference in New Issue
Block a user