Commit 7ebbda48 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[csa][builtins] Port ArrayNArgumentsConstructor builtin to CSA.

Bug: v8:5269, v8:7703
Change-Id: Ib9934e1c3685f731ba588f12e253fce24c03b151
Reviewed-on: https://chromium-review.googlesource.com/1097485Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53688}
parent e0dc3d29
......@@ -2960,15 +2960,6 @@ void Builtins::Generate_InternalArrayConstructorImpl(MacroAssembler* masm) {
GenerateInternalArrayConstructorCase(masm, PACKED_ELEMENTS);
}
void Builtins::Generate_ArrayNArgumentsConstructor(MacroAssembler* masm) {
__ lsl(r5, r0, Operand(kPointerSizeLog2));
__ str(r1, MemOperand(sp, r5));
__ Push(r1);
__ Push(r2);
__ add(r0, r0, Operand(3));
__ TailCallRuntime(Runtime::kNewArray);
}
#undef __
} // namespace internal
......
......@@ -3510,14 +3510,6 @@ void Builtins::Generate_InternalArrayConstructorImpl(MacroAssembler* masm) {
GenerateInternalArrayConstructorCase(masm, PACKED_ELEMENTS);
}
void Builtins::Generate_ArrayNArgumentsConstructor(MacroAssembler* masm) {
__ Mov(x5, Operand(x0, LSL, kPointerSizeLog2));
__ Poke(x1, Operand(x5));
__ Push(x1, x2);
__ Add(x0, x0, Operand(3));
__ TailCallRuntime(Runtime::kNewArray);
}
#undef __
} // namespace internal
......
......@@ -4096,6 +4096,34 @@ void ArrayBuiltinsAssembler::GenerateArraySingleArgumentConstructor(
kind, allocation_site_mode);
}
void ArrayBuiltinsAssembler::GenerateArrayNArgumentsConstructor(
TNode<Context> context, TNode<JSFunction> target, TNode<Object> new_target,
TNode<Int32T> argc, TNode<HeapObject> maybe_allocation_site) {
// Replace incoming JS receiver argument with the target.
// TODO(ishell): Avoid replacing the target on the stack and just add it
// as another additional parameter for Runtime::kNewArray.
CodeStubArguments args(this, ChangeInt32ToIntPtr(argc));
args.SetReceiver(target);
// Adjust arguments count for the runtime call: +1 for implicit receiver
// and +2 for new_target and maybe_allocation_site.
argc = Int32Add(argc, Int32Constant(3));
TailCallRuntime(Runtime::kNewArray, argc, context, new_target,
maybe_allocation_site);
}
TF_BUILTIN(ArrayNArgumentsConstructor, ArrayBuiltinsAssembler) {
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<JSFunction> target = CAST(Parameter(Descriptor::kFunction));
TNode<Int32T> argc =
UncheckedCast<Int32T>(Parameter(Descriptor::kActualArgumentsCount));
TNode<HeapObject> maybe_allocation_site =
CAST(Parameter(Descriptor::kAllocationSite));
GenerateArrayNArgumentsConstructor(context, target, target, argc,
maybe_allocation_site);
}
void ArrayBuiltinsAssembler::GenerateInternalArrayNoArgumentConstructor(
ElementsKind kind) {
typedef ArrayNoArgumentConstructorDescriptor Descriptor;
......
......@@ -122,6 +122,11 @@ class ArrayBuiltinsAssembler : public BaseBuiltinsFromDSLAssembler {
AllocationSiteOverrideMode mode);
void GenerateArraySingleArgumentConstructor(ElementsKind kind,
AllocationSiteOverrideMode mode);
void GenerateArrayNArgumentsConstructor(
TNode<Context> context, TNode<JSFunction> target,
TNode<Object> new_target, TNode<Int32T> argc,
TNode<HeapObject> maybe_allocation_site);
void GenerateInternalArrayNoArgumentConstructor(ElementsKind kind);
void GenerateInternalArraySingleArgumentConstructor(ElementsKind kind);
......
......@@ -269,7 +269,7 @@ namespace internal {
ArraySingleArgumentConstructor, 1) \
TFC(ArraySingleArgumentConstructor_HoleyDouble_DisableAllocationSites, \
ArraySingleArgumentConstructor, 1) \
ASM(ArrayNArgumentsConstructor) \
TFC(ArrayNArgumentsConstructor, ArrayNArgumentsConstructor, 1) \
ASM(InternalArrayConstructor) \
ASM(InternalArrayConstructorImpl) \
TFC(InternalArrayNoArgumentConstructor_Packed, ArrayNoArgumentConstructor, \
......
......@@ -3225,16 +3225,6 @@ void Builtins::Generate_InternalArrayConstructorImpl(MacroAssembler* masm) {
GenerateInternalArrayConstructorCase(masm, PACKED_ELEMENTS);
}
void Builtins::Generate_ArrayNArgumentsConstructor(MacroAssembler* masm) {
__ pop(ecx);
__ mov(MemOperand(esp, eax, times_4, 0), edi);
__ push(edi);
__ push(ebx);
__ push(ecx);
__ add(eax, Immediate(3));
__ TailCallRuntime(Runtime::kNewArray);
}
#undef __
} // namespace internal
......
......@@ -3089,16 +3089,6 @@ void Builtins::Generate_InternalArrayConstructorImpl(MacroAssembler* masm) {
GenerateInternalArrayConstructorCase(masm, PACKED_ELEMENTS);
}
void Builtins::Generate_ArrayNArgumentsConstructor(MacroAssembler* masm) {
__ sll(t9, a0, kPointerSizeLog2);
__ Addu(t9, sp, t9);
__ sw(a1, MemOperand(t9, 0));
__ Push(a1);
__ Push(a2);
__ Addu(a0, a0, Operand(3));
__ TailCallRuntime(Runtime::kNewArray);
}
#undef __
} // namespace internal
......
......@@ -3108,16 +3108,6 @@ void Builtins::Generate_InternalArrayConstructorImpl(MacroAssembler* masm) {
GenerateInternalArrayConstructorCase(masm, PACKED_ELEMENTS);
}
void Builtins::Generate_ArrayNArgumentsConstructor(MacroAssembler* masm) {
__ dsll(t9, a0, kPointerSizeLog2);
__ Daddu(t9, sp, t9);
__ Sd(a1, MemOperand(t9, 0));
__ Push(a1);
__ Push(a2);
__ Daddu(a0, a0, 3);
__ TailCallRuntime(Runtime::kNewArray);
}
#undef __
} // namespace internal
......
......@@ -3116,15 +3116,6 @@ void Builtins::Generate_InternalArrayConstructorImpl(MacroAssembler* masm) {
GenerateInternalArrayConstructorCase(masm, PACKED_ELEMENTS);
}
void Builtins::Generate_ArrayNArgumentsConstructor(MacroAssembler* masm) {
__ ShiftLeftImm(r0, r3, Operand(kPointerSizeLog2));
__ StorePX(r4, MemOperand(sp, r0));
__ push(r4);
__ push(r5);
__ addi(r3, r3, Operand(3));
__ TailCallRuntime(Runtime::kNewArray);
}
#undef __
} // namespace internal
} // namespace v8
......
......@@ -2857,15 +2857,6 @@ void Builtins::Generate_MathPowInternal(MacroAssembler* masm) {
__ Ret();
}
void Builtins::Generate_ArrayNArgumentsConstructor(MacroAssembler* masm) {
__ ShiftLeftP(r1, r2, Operand(kPointerSizeLog2));
__ StoreP(r3, MemOperand(sp, r1));
__ push(r3);
__ push(r4);
__ AddP(r2, r2, Operand(3));
__ TailCallRuntime(Runtime::kNewArray);
}
namespace {
void CreateArrayDispatchNoArgument(MacroAssembler* masm,
......
......@@ -3175,16 +3175,6 @@ void Builtins::Generate_InternalArrayConstructorImpl(MacroAssembler* masm) {
GenerateInternalArrayConstructorCase(masm, PACKED_ELEMENTS);
}
void Builtins::Generate_ArrayNArgumentsConstructor(MacroAssembler* masm) {
__ popq(rcx);
__ movq(MemOperand(rsp, rax, times_8, 0), rdi);
__ pushq(rdi);
__ pushq(rbx);
__ pushq(rcx);
__ addq(rax, Immediate(3));
__ TailCallRuntime(Runtime::kNewArray);
}
#undef __
} // namespace internal
......
......@@ -11480,6 +11480,13 @@ TNode<Object> CodeStubArguments::GetReceiver() const {
assembler_->IntPtrConstant(kPointerSize)));
}
void CodeStubArguments::SetReceiver(TNode<Object> object) const {
DCHECK_EQ(receiver_mode_, ReceiverMode::kHasReceiver);
assembler_->StoreNoWriteBarrier(MachineRepresentation::kTagged, arguments_,
assembler_->IntPtrConstant(kPointerSize),
object);
}
TNode<RawPtr<Object>> CodeStubArguments::AtIndexPtr(
Node* index, CodeStubAssembler::ParameterMode mode) const {
typedef compiler::Node Node;
......
......@@ -2753,6 +2753,10 @@ class CodeStubArguments {
ReceiverMode receiver_mode = ReceiverMode::kHasReceiver);
TNode<Object> GetReceiver() const;
// Replaces receiver argument on the expression stack. Should be used only
// for manipulating arguments in trampoline builtins before tail calling
// further with passing all the JS arguments as is.
void SetReceiver(TNode<Object> object) const;
TNode<RawPtr<Object>> AtIndexPtr(
Node* index, CodeStubAssembler::ParameterMode mode =
......
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