[builtins] Move ArrayNArgumentsConstructorStub to builtin
Calls from embedded builtins to stubs are expensive due to the indirection through the builtins constants table. This moves the ArrayNArgumentsConstructorStub to a builtin. Bug: v8:6666 Change-Id: Ied303334874251415a9057abf612d76dd8330aa6 Reviewed-on: https://chromium-review.googlesource.com/1071450 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#53356}
This commit is contained in:
parent
70cede3916
commit
0094defac4
@ -30,15 +30,6 @@ namespace internal {
|
||||
|
||||
#define __ ACCESS_MASM(masm)
|
||||
|
||||
void ArrayNArgumentsConstructorStub::Generate(MacroAssembler* masm) {
|
||||
__ lsl(r5, r0, Operand(kPointerSizeLog2));
|
||||
__ str(r1, MemOperand(sp, r5));
|
||||
__ Push(r1);
|
||||
__ Push(r2);
|
||||
__ add(r0, r0, Operand(3));
|
||||
__ TailCallRuntime(Runtime::kNewArray);
|
||||
}
|
||||
|
||||
void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) {
|
||||
CommonArrayConstructorStub::GenerateStubsAheadOfTime(isolate);
|
||||
StoreFastElementStub::GenerateAheadOfTime(isolate);
|
||||
@ -438,8 +429,6 @@ void CommonArrayConstructorStub::GenerateStubsAheadOfTime(Isolate* isolate) {
|
||||
isolate);
|
||||
ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>(
|
||||
isolate);
|
||||
ArrayNArgumentsConstructorStub stub(isolate);
|
||||
stub.GetCode();
|
||||
ElementsKind kinds[2] = {PACKED_ELEMENTS, HOLEY_ELEMENTS};
|
||||
for (int i = 0; i < 2; i++) {
|
||||
// For internal arrays we only need a few things
|
||||
@ -465,8 +454,8 @@ void ArrayConstructorStub::GenerateDispatchToArrayStub(
|
||||
CreateArrayDispatchOneArgument(masm, mode);
|
||||
|
||||
__ bind(¬_one_case);
|
||||
ArrayNArgumentsConstructorStub stub(masm->isolate());
|
||||
__ TailCallStub(&stub);
|
||||
__ Jump(BUILTIN_CODE(masm->isolate(), ArrayNArgumentsConstructor),
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
|
||||
@ -533,8 +522,8 @@ void InternalArrayConstructorStub::GenerateCase(
|
||||
InternalArrayNoArgumentConstructorStub stub0(isolate(), kind);
|
||||
__ TailCallStub(&stub0, lo);
|
||||
|
||||
ArrayNArgumentsConstructorStub stubN(isolate());
|
||||
__ TailCallStub(&stubN, hi);
|
||||
__ Jump(BUILTIN_CODE(masm->isolate(), ArrayNArgumentsConstructor),
|
||||
RelocInfo::CODE_TARGET, hi);
|
||||
|
||||
if (IsFastPackedElementsKind(kind)) {
|
||||
// We might need to create a holey array
|
||||
|
@ -29,14 +29,6 @@ namespace internal {
|
||||
|
||||
#define __ ACCESS_MASM(masm)
|
||||
|
||||
void ArrayNArgumentsConstructorStub::Generate(MacroAssembler* masm) {
|
||||
__ Mov(x5, Operand(x0, LSL, kPointerSizeLog2));
|
||||
__ Poke(x1, Operand(x5));
|
||||
__ Push(x1, x2);
|
||||
__ Add(x0, x0, Operand(3));
|
||||
__ TailCallRuntime(Runtime::kNewArray);
|
||||
}
|
||||
|
||||
void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) {
|
||||
// It is important that the following stubs are generated in this order
|
||||
// because pregenerated stubs can only call other pregenerated stubs.
|
||||
@ -453,8 +445,6 @@ void CommonArrayConstructorStub::GenerateStubsAheadOfTime(Isolate* isolate) {
|
||||
isolate);
|
||||
ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>(
|
||||
isolate);
|
||||
ArrayNArgumentsConstructorStub stub(isolate);
|
||||
stub.GetCode();
|
||||
ElementsKind kinds[2] = {PACKED_ELEMENTS, HOLEY_ELEMENTS};
|
||||
for (int i = 0; i < 2; i++) {
|
||||
// For internal arrays we only need a few things
|
||||
@ -484,8 +474,8 @@ void ArrayConstructorStub::GenerateDispatchToArrayStub(
|
||||
|
||||
__ Bind(&n_case);
|
||||
// N arguments.
|
||||
ArrayNArgumentsConstructorStub stub(masm->isolate());
|
||||
__ TailCallStub(&stub);
|
||||
__ Jump(BUILTIN_CODE(masm->isolate(), ArrayNArgumentsConstructor),
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
|
||||
@ -584,8 +574,8 @@ void InternalArrayConstructorStub::GenerateCase(
|
||||
|
||||
__ Bind(&n_case);
|
||||
// N arguments.
|
||||
ArrayNArgumentsConstructorStub stubN(isolate());
|
||||
__ TailCallStub(&stubN);
|
||||
__ Jump(BUILTIN_CODE(masm->isolate(), ArrayNArgumentsConstructor),
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2913,6 +2913,15 @@ void Builtins::Generate_MathPowInternal(MacroAssembler* masm) {
|
||||
__ Ret();
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -3444,6 +3444,14 @@ void Builtins::Generate_MathPowInternal(MacroAssembler* masm) {
|
||||
__ Ret();
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -236,6 +236,7 @@ namespace internal {
|
||||
\
|
||||
/* Array */ \
|
||||
ASM(ArrayConstructor) \
|
||||
ASM(ArrayNArgumentsConstructor) \
|
||||
ASM(InternalArrayConstructor) \
|
||||
CPP(ArrayConcat) \
|
||||
/* ES6 #sec-array.isarray */ \
|
||||
|
@ -3149,6 +3149,16 @@ void Builtins::Generate_MathPowInternal(MacroAssembler* masm) {
|
||||
__ ret(0);
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -3037,6 +3037,16 @@ void Builtins::Generate_MathPowInternal(MacroAssembler* masm) {
|
||||
__ Ret();
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -3059,6 +3059,16 @@ void Builtins::Generate_MathPowInternal(MacroAssembler* masm) {
|
||||
__ Ret();
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -3096,6 +3096,16 @@ void Builtins::Generate_MathPowInternal(MacroAssembler* masm) {
|
||||
__ ret(0);
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -39,7 +39,6 @@ class Node;
|
||||
V(StoreInArrayLiteralSlow) \
|
||||
V(ArrayNoArgumentConstructor) \
|
||||
V(ArraySingleArgumentConstructor) \
|
||||
V(ArrayNArgumentsConstructor) \
|
||||
V(InternalArrayNoArgumentConstructor) \
|
||||
V(InternalArraySingleArgumentConstructor) \
|
||||
V(ElementsTransitionAndStore) \
|
||||
@ -760,20 +759,6 @@ class InternalArraySingleArgumentConstructorStub
|
||||
CommonArrayConstructorStub);
|
||||
};
|
||||
|
||||
// TODO(jgruber): Convert this stub into a builtin.
|
||||
class ArrayNArgumentsConstructorStub : public PlatformCodeStub {
|
||||
public:
|
||||
explicit ArrayNArgumentsConstructorStub(Isolate* isolate)
|
||||
: PlatformCodeStub(isolate) {}
|
||||
|
||||
CallInterfaceDescriptor GetCallInterfaceDescriptor() const override {
|
||||
return ArrayNArgumentsConstructorDescriptor(isolate());
|
||||
}
|
||||
|
||||
private:
|
||||
DEFINE_PLATFORM_CODE_STUB(ArrayNArgumentsConstructor, PlatformCodeStub);
|
||||
};
|
||||
|
||||
class StoreSlowElementStub : public TurboFanCodeStub {
|
||||
public:
|
||||
StoreSlowElementStub(Isolate* isolate, KeyedAccessStoreMode mode)
|
||||
|
@ -751,11 +751,12 @@ Reduction JSCreateLowering::ReduceNewArrayToStubCall(
|
||||
NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
|
||||
} else {
|
||||
DCHECK_GT(arity, 1);
|
||||
ArrayNArgumentsConstructorStub stub(isolate());
|
||||
Handle<Code> code = BUILTIN_CODE(isolate(), ArrayNArgumentsConstructor);
|
||||
auto call_descriptor = Linkage::GetStubCallDescriptor(
|
||||
isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(),
|
||||
arity + 1, CallDescriptor::kNeedsFrameState);
|
||||
node->ReplaceInput(0, jsgraph()->HeapConstant(stub.GetCode()));
|
||||
isolate(), graph()->zone(),
|
||||
ArrayNArgumentsConstructorDescriptor(isolate()), arity + 1,
|
||||
CallDescriptor::kNeedsFrameState);
|
||||
node->ReplaceInput(0, jsgraph()->HeapConstant(code));
|
||||
node->InsertInput(graph()->zone(), 2, type_info);
|
||||
node->InsertInput(graph()->zone(), 3, jsgraph()->Constant(arity));
|
||||
node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant());
|
||||
|
@ -25,16 +25,6 @@ namespace internal {
|
||||
|
||||
#define __ ACCESS_MASM(masm)
|
||||
|
||||
void ArrayNArgumentsConstructorStub::Generate(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);
|
||||
}
|
||||
|
||||
void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) {
|
||||
// It is important that the store buffer overflow stubs are generated first.
|
||||
CommonArrayConstructorStub::GenerateStubsAheadOfTime(isolate);
|
||||
@ -292,8 +282,6 @@ void CommonArrayConstructorStub::GenerateStubsAheadOfTime(Isolate* isolate) {
|
||||
isolate);
|
||||
ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>(
|
||||
isolate);
|
||||
ArrayNArgumentsConstructorStub stub(isolate);
|
||||
stub.GetCode();
|
||||
|
||||
ElementsKind kinds[2] = {PACKED_ELEMENTS, HOLEY_ELEMENTS};
|
||||
for (int i = 0; i < 2; i++) {
|
||||
@ -318,8 +306,8 @@ void ArrayConstructorStub::GenerateDispatchToArrayStub(
|
||||
CreateArrayDispatchOneArgument(masm, mode);
|
||||
|
||||
__ bind(¬_one_case);
|
||||
ArrayNArgumentsConstructorStub stub(masm->isolate());
|
||||
__ TailCallStub(&stub);
|
||||
__ Jump(BUILTIN_CODE(masm->isolate(), ArrayNArgumentsConstructor),
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
void ArrayConstructorStub::Generate(MacroAssembler* masm) {
|
||||
@ -415,8 +403,8 @@ void InternalArrayConstructorStub::GenerateCase(
|
||||
__ TailCallStub(&stub1);
|
||||
|
||||
__ bind(¬_one_case);
|
||||
ArrayNArgumentsConstructorStub stubN(isolate());
|
||||
__ TailCallStub(&stubN);
|
||||
__ Jump(BUILTIN_CODE(masm->isolate(), ArrayNArgumentsConstructor),
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,16 +26,6 @@ namespace internal {
|
||||
|
||||
#define __ ACCESS_MASM(masm)
|
||||
|
||||
void ArrayNArgumentsConstructorStub::Generate(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);
|
||||
}
|
||||
|
||||
void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) {
|
||||
CommonArrayConstructorStub::GenerateStubsAheadOfTime(isolate);
|
||||
StoreFastElementStub::GenerateAheadOfTime(isolate);
|
||||
@ -432,8 +422,6 @@ void CommonArrayConstructorStub::GenerateStubsAheadOfTime(Isolate* isolate) {
|
||||
isolate);
|
||||
ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>(
|
||||
isolate);
|
||||
ArrayNArgumentsConstructorStub stub(isolate);
|
||||
stub.GetCode();
|
||||
ElementsKind kinds[2] = {PACKED_ELEMENTS, HOLEY_ELEMENTS};
|
||||
for (int i = 0; i < 2; i++) {
|
||||
// For internal arrays we only need a few things.
|
||||
@ -458,8 +446,8 @@ void ArrayConstructorStub::GenerateDispatchToArrayStub(
|
||||
CreateArrayDispatchOneArgument(masm, mode);
|
||||
|
||||
__ bind(¬_one_case);
|
||||
ArrayNArgumentsConstructorStub stub(masm->isolate());
|
||||
__ TailCallStub(&stub);
|
||||
__ Jump(BUILTIN_CODE(masm->isolate(), ArrayNArgumentsConstructor),
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
|
||||
@ -528,8 +516,8 @@ void InternalArrayConstructorStub::GenerateCase(
|
||||
InternalArrayNoArgumentConstructorStub stub0(isolate(), kind);
|
||||
__ TailCallStub(&stub0, lo, a0, Operand(1));
|
||||
|
||||
ArrayNArgumentsConstructorStub stubN(isolate());
|
||||
__ TailCallStub(&stubN, hi, a0, Operand(1));
|
||||
__ Jump(BUILTIN_CODE(masm->isolate(), ArrayNArgumentsConstructor),
|
||||
RelocInfo::CODE_TARGET, hi, a0, Operand(1));
|
||||
|
||||
if (IsFastPackedElementsKind(kind)) {
|
||||
// We might need to create a holey array
|
||||
|
@ -25,16 +25,6 @@ namespace internal {
|
||||
|
||||
#define __ ACCESS_MASM(masm)
|
||||
|
||||
void ArrayNArgumentsConstructorStub::Generate(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);
|
||||
}
|
||||
|
||||
void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) {
|
||||
CommonArrayConstructorStub::GenerateStubsAheadOfTime(isolate);
|
||||
StoreFastElementStub::GenerateAheadOfTime(isolate);
|
||||
@ -434,8 +424,6 @@ void CommonArrayConstructorStub::GenerateStubsAheadOfTime(Isolate* isolate) {
|
||||
isolate);
|
||||
ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>(
|
||||
isolate);
|
||||
ArrayNArgumentsConstructorStub stub(isolate);
|
||||
stub.GetCode();
|
||||
ElementsKind kinds[2] = {PACKED_ELEMENTS, HOLEY_ELEMENTS};
|
||||
for (int i = 0; i < 2; i++) {
|
||||
// For internal arrays we only need a few things.
|
||||
@ -460,8 +448,8 @@ void ArrayConstructorStub::GenerateDispatchToArrayStub(
|
||||
CreateArrayDispatchOneArgument(masm, mode);
|
||||
|
||||
__ bind(¬_one_case);
|
||||
ArrayNArgumentsConstructorStub stub(masm->isolate());
|
||||
__ TailCallStub(&stub);
|
||||
__ Jump(BUILTIN_CODE(masm->isolate(), ArrayNArgumentsConstructor),
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
|
||||
@ -530,8 +518,8 @@ void InternalArrayConstructorStub::GenerateCase(
|
||||
InternalArrayNoArgumentConstructorStub stub0(isolate(), kind);
|
||||
__ TailCallStub(&stub0, lo, a0, Operand(1));
|
||||
|
||||
ArrayNArgumentsConstructorStub stubN(isolate());
|
||||
__ TailCallStub(&stubN, hi, a0, Operand(1));
|
||||
__ Jump(BUILTIN_CODE(masm->isolate(), ArrayNArgumentsConstructor),
|
||||
RelocInfo::CODE_TARGET, hi, a0, Operand(1));
|
||||
|
||||
if (IsFastPackedElementsKind(kind)) {
|
||||
// We might need to create a holey array
|
||||
|
@ -27,16 +27,6 @@ namespace internal {
|
||||
|
||||
#define __ ACCESS_MASM(masm)
|
||||
|
||||
void ArrayNArgumentsConstructorStub::Generate(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);
|
||||
}
|
||||
|
||||
void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) {
|
||||
// It is important that the store buffer overflow stubs are generated first.
|
||||
CommonArrayConstructorStub::GenerateStubsAheadOfTime(isolate);
|
||||
@ -357,8 +347,6 @@ void CommonArrayConstructorStub::GenerateStubsAheadOfTime(Isolate* isolate) {
|
||||
isolate);
|
||||
ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>(
|
||||
isolate);
|
||||
ArrayNArgumentsConstructorStub stub(isolate);
|
||||
stub.GetCode();
|
||||
|
||||
ElementsKind kinds[2] = {PACKED_ELEMENTS, HOLEY_ELEMENTS};
|
||||
for (int i = 0; i < 2; i++) {
|
||||
@ -383,8 +371,8 @@ void ArrayConstructorStub::GenerateDispatchToArrayStub(
|
||||
CreateArrayDispatchOneArgument(masm, mode);
|
||||
|
||||
__ bind(¬_one_case);
|
||||
ArrayNArgumentsConstructorStub stub(masm->isolate());
|
||||
__ TailCallStub(&stub);
|
||||
__ Jump(BUILTIN_CODE(masm->isolate(), ArrayNArgumentsConstructor),
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
void ArrayConstructorStub::Generate(MacroAssembler* masm) {
|
||||
@ -482,8 +470,8 @@ void InternalArrayConstructorStub::GenerateCase(
|
||||
__ TailCallStub(&stub1);
|
||||
|
||||
__ bind(¬_one_case);
|
||||
ArrayNArgumentsConstructorStub stubN(isolate());
|
||||
__ TailCallStub(&stubN);
|
||||
__ Jump(BUILTIN_CODE(masm->isolate(), ArrayNArgumentsConstructor),
|
||||
RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user