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

[csa][builtins] Port AdaptorWith[Builtin]ExitFrame builtins to CSA.

Bug: v8:5269, v8:7754
Change-Id: Iadbf7e1174e4cfe9f53310e7e499cc90ed27843b
Reviewed-on: https://chromium-review.googlesource.com/1110372
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53964}
parent 3e41a47c
...@@ -28,7 +28,7 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address, ...@@ -28,7 +28,7 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
ExternalReference::Create(address).address()) & ExternalReference::Create(address).address()) &
1); 1);
#endif #endif
__ Move(r5, ExternalReference::Create(address)); __ Move(kJavaScriptCallExtraArg1Register, ExternalReference::Create(address));
if (exit_frame_type == BUILTIN_EXIT) { if (exit_frame_type == BUILTIN_EXIT) {
__ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame), __ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame),
RelocInfo::CODE_TARGET); RelocInfo::CODE_TARGET);
...@@ -39,57 +39,6 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address, ...@@ -39,57 +39,6 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
} }
} }
namespace {
void AdaptorWithExitFrameType(MacroAssembler* masm,
Builtins::ExitFrameType exit_frame_type) {
// ----------- S t a t e -------------
// -- r0 : number of arguments excluding receiver
// -- r1 : target
// -- r3 : new.target
// -- r5 : entry point
// -- sp[0] : last argument
// -- ...
// -- sp[4 * (argc - 1)] : first argument
// -- sp[4 * argc] : receiver
// -----------------------------------
__ AssertFunction(r1);
// Make sure we operate in the context of the called function (for example
// ConstructStubs implemented in C++ will be run in the context of the caller
// instead of the callee, due to the way that [[Construct]] is defined for
// ordinary functions).
__ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset));
// CEntry expects r0 to contain the number of arguments including the
// receiver and the extra arguments.
__ add(r0, r0, Operand(BuiltinExitFrameConstants::kNumExtraArgsWithReceiver));
// Insert extra arguments.
__ PushRoot(Heap::kTheHoleValueRootIndex); // Padding.
__ SmiTag(r0);
__ Push(r0, r1, r3);
__ SmiUntag(r0);
// Jump to the C entry runtime stub directly here instead of using
// JumpToExternalReference. We have already loaded entry point to r5
// in Generate_adaptor.
__ mov(r1, r5);
Handle<Code> code =
CodeFactory::CEntry(masm->isolate(), 1, kDontSaveFPRegs, kArgvOnStack,
exit_frame_type == Builtins::BUILTIN_EXIT);
__ Jump(code, RelocInfo::CODE_TARGET);
}
} // namespace
void Builtins::Generate_AdaptorWithExitFrame(MacroAssembler* masm) {
AdaptorWithExitFrameType(masm, EXIT);
}
void Builtins::Generate_AdaptorWithBuiltinExitFrame(MacroAssembler* masm) {
AdaptorWithExitFrameType(masm, BUILTIN_EXIT);
}
void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) { void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- r0 : number of arguments // -- r0 : number of arguments
......
...@@ -22,7 +22,7 @@ namespace internal { ...@@ -22,7 +22,7 @@ namespace internal {
void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address, void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
ExitFrameType exit_frame_type) { ExitFrameType exit_frame_type) {
__ Mov(x5, ExternalReference::Create(address)); __ Mov(kJavaScriptCallExtraArg1Register, ExternalReference::Create(address));
if (exit_frame_type == BUILTIN_EXIT) { if (exit_frame_type == BUILTIN_EXIT) {
__ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame), __ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame),
RelocInfo::CODE_TARGET); RelocInfo::CODE_TARGET);
...@@ -33,57 +33,6 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address, ...@@ -33,57 +33,6 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
} }
} }
namespace {
void AdaptorWithExitFrameType(MacroAssembler* masm,
Builtins::ExitFrameType exit_frame_type) {
// ----------- S t a t e -------------
// -- x0 : number of arguments excluding receiver
// -- x1 : target
// -- x3 : new target
// -- x5 : entry point
// -- sp[0] : last argument
// -- ...
// -- sp[4 * (argc - 1)] : first argument
// -- sp[4 * argc] : receiver
// -----------------------------------
__ AssertFunction(x1);
// Make sure we operate in the context of the called function (for example
// ConstructStubs implemented in C++ will be run in the context of the caller
// instead of the callee, due to the way that [[Construct]] is defined for
// ordinary functions).
__ Ldr(cp, FieldMemOperand(x1, JSFunction::kContextOffset));
// CEntry expects x0 to contain the number of arguments including the
// receiver and the extra arguments.
__ Add(x0, x0, BuiltinExitFrameConstants::kNumExtraArgsWithReceiver);
// Insert extra arguments.
Register padding = x10;
__ LoadRoot(padding, Heap::kTheHoleValueRootIndex);
__ SmiTag(x11, x0);
__ Push(padding, x11, x1, x3);
// Jump to the C entry runtime stub directly here instead of using
// JumpToExternalReference. We have already loaded entry point to x5
// in Generate_adaptor.
__ Mov(x1, x5);
Handle<Code> code =
CodeFactory::CEntry(masm->isolate(), 1, kDontSaveFPRegs, kArgvOnStack,
exit_frame_type == Builtins::BUILTIN_EXIT);
__ Jump(code, RelocInfo::CODE_TARGET);
}
} // namespace
void Builtins::Generate_AdaptorWithExitFrame(MacroAssembler* masm) {
AdaptorWithExitFrameType(masm, EXIT);
}
void Builtins::Generate_AdaptorWithBuiltinExitFrame(MacroAssembler* masm) {
AdaptorWithExitFrameType(masm, BUILTIN_EXIT);
}
void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) { void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- x0 : number of arguments // -- x0 : number of arguments
......
...@@ -31,8 +31,8 @@ namespace internal { ...@@ -31,8 +31,8 @@ namespace internal {
TFC(RecordWrite, RecordWrite, 1) \ TFC(RecordWrite, RecordWrite, 1) \
\ \
/* Adaptors for CPP/API builtin */ \ /* Adaptors for CPP/API builtin */ \
ASM(AdaptorWithExitFrame) \ TFC(AdaptorWithExitFrame, CppBuiltinAdaptor, 1) \
ASM(AdaptorWithBuiltinExitFrame) \ TFC(AdaptorWithBuiltinExitFrame, CppBuiltinAdaptor, 1) \
\ \
/* Calls */ \ /* Calls */ \
ASM(ArgumentsAdaptorTrampoline) \ ASM(ArgumentsAdaptorTrampoline) \
......
...@@ -688,8 +688,61 @@ class InternalBuiltinsAssembler : public CodeStubAssembler { ...@@ -688,8 +688,61 @@ class InternalBuiltinsAssembler : public CodeStubAssembler {
StoreNoWriteBarrier(MachineRepresentation::kTagged, ExternalConstant(ref), StoreNoWriteBarrier(MachineRepresentation::kTagged, ExternalConstant(ref),
TheHoleConstant()); TheHoleConstant());
} }
template <typename Descriptor>
void GenerateAdaptorWithExitFrameType(
Builtins::ExitFrameType exit_frame_type);
}; };
template <typename Descriptor>
void InternalBuiltinsAssembler::GenerateAdaptorWithExitFrameType(
Builtins::ExitFrameType exit_frame_type) {
TNode<JSFunction> target = CAST(Parameter(Descriptor::kTarget));
TNode<Object> new_target = CAST(Parameter(Descriptor::kNewTarget));
TNode<WordT> c_function =
UncheckedCast<WordT>(Parameter(Descriptor::kCFunction));
// The logic contained here is mirrored for TurboFan inlining in
// JSTypedLowering::ReduceJSCall{Function,Construct}. Keep these in sync.
// Make sure we operate in the context of the called function (for example
// ConstructStubs implemented in C++ will be run in the context of the caller
// instead of the callee, due to the way that [[Construct]] is defined for
// ordinary functions).
TNode<Context> context =
CAST(LoadObjectField(target, JSFunction::kContextOffset));
// Update arguments count for CEntry to contain the number of arguments
// including the receiver and the extra arguments.
TNode<Int32T> argc =
UncheckedCast<Int32T>(Parameter(Descriptor::kActualArgumentsCount));
argc = Int32Add(
argc,
Int32Constant(BuiltinExitFrameConstants::kNumExtraArgsWithReceiver));
TNode<Code> code = HeapConstant(
CodeFactory::CEntry(isolate(), 1, kDontSaveFPRegs, kArgvOnStack,
exit_frame_type == Builtins::BUILTIN_EXIT));
// Unconditionally push argc, target and new target as extra stack arguments.
// They will be used by stack frame iterators when constructing stack trace.
TailCallStub(CEntry1ArgvOnStackDescriptor{}, // descriptor
code, context, // standard arguments for TailCallStub
argc, c_function, // register arguments
TheHoleConstant(), // additional stack argument 1 (padding)
SmiFromInt32(argc), // additional stack argument 2
target, // additional stack argument 3
new_target); // additional stack argument 4
}
TF_BUILTIN(AdaptorWithExitFrame, InternalBuiltinsAssembler) {
GenerateAdaptorWithExitFrameType<Descriptor>(Builtins::EXIT);
}
TF_BUILTIN(AdaptorWithBuiltinExitFrame, InternalBuiltinsAssembler) {
GenerateAdaptorWithExitFrameType<Descriptor>(Builtins::BUILTIN_EXIT);
}
TNode<IntPtrT> InternalBuiltinsAssembler::GetPendingMicrotaskCount() { TNode<IntPtrT> InternalBuiltinsAssembler::GetPendingMicrotaskCount() {
auto ref = ExternalReference::pending_microtask_count_address(isolate()); auto ref = ExternalReference::pending_microtask_count_address(isolate());
if (kIntSize == 8) { if (kIntSize == 8) {
......
...@@ -20,7 +20,8 @@ namespace internal { ...@@ -20,7 +20,8 @@ namespace internal {
void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address, void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
ExitFrameType exit_frame_type) { ExitFrameType exit_frame_type) {
__ mov(ebx, Immediate(ExternalReference::Create(address))); __ mov(kJavaScriptCallExtraArg1Register,
Immediate(ExternalReference::Create(address)));
if (exit_frame_type == BUILTIN_EXIT) { if (exit_frame_type == BUILTIN_EXIT) {
__ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame), __ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame),
RelocInfo::CODE_TARGET); RelocInfo::CODE_TARGET);
...@@ -31,60 +32,6 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address, ...@@ -31,60 +32,6 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
} }
} }
namespace {
void AdaptorWithExitFrameType(MacroAssembler* masm,
Builtins::ExitFrameType exit_frame_type) {
// ----------- S t a t e -------------
// -- eax : number of arguments excluding receiver
// -- ebx : entry point
// -- edi : target
// -- edx : new.target
// -- esp[0] : return address
// -- esp[4] : last argument
// -- ...
// -- esp[4 * argc] : first argument
// -- esp[4 * (argc +1)] : receiver
// -----------------------------------
__ AssertFunction(edi);
// Make sure we operate in the context of the called function (for example
// ConstructStubs implemented in C++ will be run in the context of the caller
// instead of the callee, due to the way that [[Construct]] is defined for
// ordinary functions).
__ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
// CEntry expects eax to contain the number of arguments including the
// receiver and the extra arguments.
__ add(eax, Immediate(BuiltinExitFrameConstants::kNumExtraArgsWithReceiver));
// Insert extra arguments.
__ PopReturnAddressTo(ecx);
__ SmiTag(eax);
__ PushRoot(Heap::kTheHoleValueRootIndex); // Padding.
__ Push(eax);
__ SmiUntag(eax);
__ Push(edi);
__ Push(edx);
__ PushReturnAddressFrom(ecx);
// Jump to the C entry runtime stub directly here instead of using
// JumpToExternalReference because ebx is loaded by Generate_adaptor.
Handle<Code> code =
CodeFactory::CEntry(masm->isolate(), 1, kDontSaveFPRegs, kArgvOnStack,
exit_frame_type == Builtins::BUILTIN_EXIT);
__ Jump(code, RelocInfo::CODE_TARGET);
}
} // namespace
void Builtins::Generate_AdaptorWithExitFrame(MacroAssembler* masm) {
AdaptorWithExitFrameType(masm, EXIT);
}
void Builtins::Generate_AdaptorWithBuiltinExitFrame(MacroAssembler* masm) {
AdaptorWithExitFrameType(masm, BUILTIN_EXIT);
}
static void GenerateTailCallToReturnedCode(MacroAssembler* masm, static void GenerateTailCallToReturnedCode(MacroAssembler* masm,
Runtime::FunctionId function_id) { Runtime::FunctionId function_id) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
......
...@@ -22,7 +22,7 @@ namespace internal { ...@@ -22,7 +22,7 @@ namespace internal {
void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address, void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
ExitFrameType exit_frame_type) { ExitFrameType exit_frame_type) {
__ li(s2, ExternalReference::Create(address)); __ li(kJavaScriptCallExtraArg1Register, ExternalReference::Create(address));
if (exit_frame_type == BUILTIN_EXIT) { if (exit_frame_type == BUILTIN_EXIT) {
__ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame), __ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame),
RelocInfo::CODE_TARGET); RelocInfo::CODE_TARGET);
...@@ -33,58 +33,6 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address, ...@@ -33,58 +33,6 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
} }
} }
namespace {
void AdaptorWithExitFrameType(MacroAssembler* masm,
Builtins::ExitFrameType exit_frame_type) {
// ----------- S t a t e -------------
// -- a0 : number of arguments excluding receiver
// -- a1 : target
// -- a3 : new.target
// -- s2 : entry point
// -- sp[0] : last argument
// -- ...
// -- sp[4 * (argc - 1)] : first argument
// -- sp[4 * agrc] : receiver
// -----------------------------------
__ AssertFunction(a1);
// Make sure we operate in the context of the called function (for example
// ConstructStubs implemented in C++ will be run in the context of the caller
// instead of the callee, due to the way that [[Construct]] is defined for
// ordinary functions).
__ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset));
// CEntry expects a0 to contain the number of arguments including the
// receiver and the extra arguments.
__ Addu(a0, a0, BuiltinExitFrameConstants::kNumExtraArgsWithReceiver);
// Insert extra arguments.
__ PushRoot(Heap::kTheHoleValueRootIndex); // Padding.
__ SmiTag(a0);
__ Push(a0, a1, a3);
__ SmiUntag(a0);
// Jump to the C entry runtime stub directly here instead of using
// JumpToExternalReference. We have already loaded entry point to s2
// in Generate_adaptor.
__ mov(a1, s2);
Handle<Code> code =
CodeFactory::CEntry(masm->isolate(), 1, kDontSaveFPRegs, kArgvOnStack,
exit_frame_type == Builtins::BUILTIN_EXIT);
__ Jump(code, RelocInfo::CODE_TARGET, al, zero_reg, Operand(zero_reg),
PROTECT);
}
} // namespace
void Builtins::Generate_AdaptorWithExitFrame(MacroAssembler* masm) {
AdaptorWithExitFrameType(masm, EXIT);
}
void Builtins::Generate_AdaptorWithBuiltinExitFrame(MacroAssembler* masm) {
AdaptorWithExitFrameType(masm, BUILTIN_EXIT);
}
void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) { void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- a0 : number of arguments // -- a0 : number of arguments
......
...@@ -22,7 +22,7 @@ namespace internal { ...@@ -22,7 +22,7 @@ namespace internal {
void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address, void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
ExitFrameType exit_frame_type) { ExitFrameType exit_frame_type) {
__ li(s2, ExternalReference::Create(address)); __ li(kJavaScriptCallExtraArg1Register, ExternalReference::Create(address));
if (exit_frame_type == BUILTIN_EXIT) { if (exit_frame_type == BUILTIN_EXIT) {
__ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame), __ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame),
RelocInfo::CODE_TARGET); RelocInfo::CODE_TARGET);
...@@ -33,58 +33,6 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address, ...@@ -33,58 +33,6 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
} }
} }
namespace {
void AdaptorWithExitFrameType(MacroAssembler* masm,
Builtins::ExitFrameType exit_frame_type) {
// ----------- S t a t e -------------
// -- a0 : number of arguments excluding receiver
// -- a1 : target
// -- a3 : new.target
// -- s2 : entry point
// -- sp[0] : last argument
// -- ...
// -- sp[8 * (argc - 1)] : first argument
// -- sp[8 * agrc] : receiver
// -----------------------------------
__ AssertFunction(a1);
// Make sure we operate in the context of the called function (for example
// ConstructStubs implemented in C++ will be run in the context of the caller
// instead of the callee, due to the way that [[Construct]] is defined for
// ordinary functions).
__ Ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset));
// CEntry expects a0 to contain the number of arguments including the
// receiver and the extra arguments.
__ Daddu(a0, a0, BuiltinExitFrameConstants::kNumExtraArgsWithReceiver);
// Insert extra arguments.
__ PushRoot(Heap::kTheHoleValueRootIndex); // Padding.
__ SmiTag(a0);
__ Push(a0, a1, a3);
__ SmiUntag(a0);
// Jump to the C entry runtime stub directly here instead of using
// JumpToExternalReference. We have already loaded entry point to s2
// in Generate_adaptor.
__ mov(a1, s2);
Handle<Code> code =
CodeFactory::CEntry(masm->isolate(), 1, kDontSaveFPRegs, kArgvOnStack,
exit_frame_type == Builtins::BUILTIN_EXIT);
__ Jump(code, RelocInfo::CODE_TARGET, al, zero_reg, Operand(zero_reg),
PROTECT);
}
} // namespace
void Builtins::Generate_AdaptorWithExitFrame(MacroAssembler* masm) {
AdaptorWithExitFrameType(masm, EXIT);
}
void Builtins::Generate_AdaptorWithBuiltinExitFrame(MacroAssembler* masm) {
AdaptorWithExitFrameType(masm, BUILTIN_EXIT);
}
void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) { void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- a0 : number of arguments // -- a0 : number of arguments
......
...@@ -20,7 +20,7 @@ namespace internal { ...@@ -20,7 +20,7 @@ namespace internal {
void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address, void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
ExitFrameType exit_frame_type) { ExitFrameType exit_frame_type) {
__ Move(r15, ExternalReference::Create(address)); __ Move(kJavaScriptCallExtraArg1Register, ExternalReference::Create(address));
if (exit_frame_type == BUILTIN_EXIT) { if (exit_frame_type == BUILTIN_EXIT) {
__ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame), __ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame),
RelocInfo::CODE_TARGET); RelocInfo::CODE_TARGET);
...@@ -31,58 +31,6 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address, ...@@ -31,58 +31,6 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
} }
} }
namespace {
void AdaptorWithExitFrameType(MacroAssembler* masm,
Builtins::ExitFrameType exit_frame_type) {
// ----------- S t a t e -------------
// -- r3 : number of arguments excluding receiver
// -- r4 : target
// -- r6 : new.target
// -- r15 : entry point
// -- sp[0] : last argument
// -- ...
// -- sp[4 * (argc - 1)] : first argument
// -- sp[4 * argc] : receiver
// -----------------------------------
__ AssertFunction(r4);
// Make sure we operate in the context of the called function (for example
// ConstructStubs implemented in C++ will be run in the context of the caller
// instead of the callee, due to the way that [[Construct]] is defined for
// ordinary functions).
__ LoadP(cp, FieldMemOperand(r4, JSFunction::kContextOffset));
// CEntry expects r3 to contain the number of arguments including the
// receiver and the extra arguments.
__ addi(r3, r3,
Operand(BuiltinExitFrameConstants::kNumExtraArgsWithReceiver));
// Insert extra arguments.
__ PushRoot(Heap::kTheHoleValueRootIndex); // Padding.
__ SmiTag(r3);
__ Push(r3, r4, r6);
__ SmiUntag(r3);
// Jump to the C entry runtime stub directly here instead of using
// JumpToExternalReference. We have already loaded entry point to r15
// in Generate_adaptor.
__ mr(r4, r15);
Handle<Code> code =
CodeFactory::CEntry(masm->isolate(), 1, kDontSaveFPRegs, kArgvOnStack,
exit_frame_type == Builtins::BUILTIN_EXIT);
__ Jump(code, RelocInfo::CODE_TARGET);
}
} // namespace
void Builtins::Generate_AdaptorWithExitFrame(MacroAssembler* masm) {
AdaptorWithExitFrameType(masm, EXIT);
}
void Builtins::Generate_AdaptorWithBuiltinExitFrame(MacroAssembler* masm) {
AdaptorWithExitFrameType(masm, BUILTIN_EXIT);
}
void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) { void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- r3 : number of arguments // -- r3 : number of arguments
......
...@@ -20,7 +20,7 @@ namespace internal { ...@@ -20,7 +20,7 @@ namespace internal {
void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address, void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
ExitFrameType exit_frame_type) { ExitFrameType exit_frame_type) {
__ Move(r7, ExternalReference::Create(address)); __ Move(kJavaScriptCallExtraArg1Register, ExternalReference::Create(address));
if (exit_frame_type == BUILTIN_EXIT) { if (exit_frame_type == BUILTIN_EXIT) {
__ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame), __ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame),
RelocInfo::CODE_TARGET); RelocInfo::CODE_TARGET);
...@@ -31,58 +31,6 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address, ...@@ -31,58 +31,6 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
} }
} }
namespace {
void AdaptorWithExitFrameType(MacroAssembler* masm,
Builtins::ExitFrameType exit_frame_type) {
// ----------- S t a t e -------------
// -- r2 : number of arguments excluding receiver
// -- r3 : target
// -- r5 : new.target
// -- r7 : entry point
// -- sp[0] : last argument
// -- ...
// -- sp[4 * (argc - 1)] : first argument
// -- sp[4 * argc] : receiver
// -----------------------------------
__ AssertFunction(r3);
// Make sure we operate in the context of the called function (for example
// ConstructStubs implemented in C++ will be run in the context of the caller
// instead of the callee, due to the way that [[Construct]] is defined for
// ordinary functions).
__ LoadP(cp, FieldMemOperand(r3, JSFunction::kContextOffset));
// CEntry expects r2 to contain the number of arguments including the
// receiver and the extra arguments.
__ AddP(r2, r2,
Operand(BuiltinExitFrameConstants::kNumExtraArgsWithReceiver));
// Insert extra arguments.
__ PushRoot(Heap::kTheHoleValueRootIndex); // Padding.
__ SmiTag(r2);
__ Push(r2, r3, r5);
__ SmiUntag(r2);
// Jump to the C entry runtime stub directly here instead of using
// JumpToExternalReference. We have already loaded entry point to r7
// in Generate_adaptor.
__ LoadRR(r3, r7);
Handle<Code> code =
CodeFactory::CEntry(masm->isolate(), 1, kDontSaveFPRegs, kArgvOnStack,
exit_frame_type == Builtins::BUILTIN_EXIT);
__ Jump(code, RelocInfo::CODE_TARGET);
}
} // namespace
void Builtins::Generate_AdaptorWithExitFrame(MacroAssembler* masm) {
AdaptorWithExitFrameType(masm, EXIT);
}
void Builtins::Generate_AdaptorWithBuiltinExitFrame(MacroAssembler* masm) {
AdaptorWithExitFrameType(masm, BUILTIN_EXIT);
}
void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) { void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- r2 : number of arguments // -- r2 : number of arguments
......
...@@ -21,7 +21,8 @@ namespace internal { ...@@ -21,7 +21,8 @@ namespace internal {
void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address, void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
ExitFrameType exit_frame_type) { ExitFrameType exit_frame_type) {
__ LoadAddress(rbx, ExternalReference::Create(address)); __ LoadAddress(kJavaScriptCallExtraArg1Register,
ExternalReference::Create(address));
if (exit_frame_type == BUILTIN_EXIT) { if (exit_frame_type == BUILTIN_EXIT) {
__ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame), __ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame),
RelocInfo::CODE_TARGET); RelocInfo::CODE_TARGET);
...@@ -32,64 +33,6 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address, ...@@ -32,64 +33,6 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
} }
} }
namespace {
void AdaptorWithExitFrameType(MacroAssembler* masm,
Builtins::ExitFrameType exit_frame_type) {
// ----------- S t a t e -------------
// -- rax : number of arguments excluding receiver
// -- rbx : entry point
// -- rdi : target
// -- rdx : new.target
// -- rsp[0] : return address
// -- rsp[8] : last argument
// -- ...
// -- rsp[8 * argc] : first argument
// -- rsp[8 * (argc + 1)] : receiver
// -----------------------------------
__ AssertFunction(rdi);
// The logic contained here is mirrored for TurboFan inlining in
// JSTypedLowering::ReduceJSCall{Function,Construct}. Keep these in sync.
// Make sure we operate in the context of the called function (for example
// ConstructStubs implemented in C++ will be run in the context of the caller
// instead of the callee, due to the way that [[Construct]] is defined for
// ordinary functions).
__ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
// CEntry expects rax to contain the number of arguments including the
// receiver and the extra arguments.
__ addp(rax, Immediate(BuiltinExitFrameConstants::kNumExtraArgsWithReceiver));
// Unconditionally insert argc, target and new target as extra arguments. They
// will be used by stack frame iterators when constructing the stack trace.
__ PopReturnAddressTo(kScratchRegister);
__ SmiTag(rax, rax);
__ PushRoot(Heap::kTheHoleValueRootIndex); // Padding.
__ Push(rax);
__ SmiUntag(rax, rax);
__ Push(rdi);
__ Push(rdx);
__ PushReturnAddressFrom(kScratchRegister);
// Jump to the C entry runtime stub directly here instead of using
// JumpToExternalReference because rbx is loaded by Generate_adaptor.
Handle<Code> code =
CodeFactory::CEntry(masm->isolate(), 1, kDontSaveFPRegs, kArgvOnStack,
exit_frame_type == Builtins::BUILTIN_EXIT);
__ Jump(code, RelocInfo::CODE_TARGET);
}
} // namespace
void Builtins::Generate_AdaptorWithExitFrame(MacroAssembler* masm) {
AdaptorWithExitFrameType(masm, EXIT);
}
void Builtins::Generate_AdaptorWithBuiltinExitFrame(MacroAssembler* masm) {
AdaptorWithExitFrameType(masm, BUILTIN_EXIT);
}
static void GenerateTailCallToReturnedCode(MacroAssembler* masm, static void GenerateTailCallToReturnedCode(MacroAssembler* masm,
Runtime::FunctionId function_id) { Runtime::FunctionId function_id) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
......
...@@ -112,6 +112,13 @@ void AllocateDescriptor::InitializePlatformSpecific( ...@@ -112,6 +112,13 @@ void AllocateDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void CEntry1ArgvOnStackDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {kRuntimeCallArgCountRegister,
kRuntimeCallFunctionRegister};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastNewFunctionContextDescriptor::InitializePlatformSpecific( void FastNewFunctionContextDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
Register registers[] = {ScopeInfoRegister(), SlotsRegister()}; Register registers[] = {ScopeInfoRegister(), SlotsRegister()};
......
...@@ -16,6 +16,8 @@ namespace v8 { ...@@ -16,6 +16,8 @@ namespace v8 {
namespace internal { namespace internal {
#define INTERFACE_DESCRIPTOR_LIST(V) \ #define INTERFACE_DESCRIPTOR_LIST(V) \
V(CppBuiltinAdaptor) \
V(CEntry1ArgvOnStack) \
V(Allocate) \ V(Allocate) \
V(Void) \ V(Void) \
V(ContextOnly) \ V(ContextOnly) \
...@@ -861,6 +863,31 @@ class ArgumentAdaptorDescriptor : public CallInterfaceDescriptor { ...@@ -861,6 +863,31 @@ class ArgumentAdaptorDescriptor : public CallInterfaceDescriptor {
DECLARE_DESCRIPTOR(ArgumentAdaptorDescriptor, CallInterfaceDescriptor) DECLARE_DESCRIPTOR(ArgumentAdaptorDescriptor, CallInterfaceDescriptor)
}; };
class CppBuiltinAdaptorDescriptor : public CallInterfaceDescriptor {
public:
DEFINE_JS_PARAMETERS(kCFunction)
DEFINE_JS_PARAMETER_TYPES(MachineType::Pointer())
DECLARE_JS_COMPATIBLE_DESCRIPTOR(CppBuiltinAdaptorDescriptor,
CallInterfaceDescriptor, 1)
};
class CEntry1ArgvOnStackDescriptor : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS(kArity, // register argument
kCFunction, // register argument
kPadding, // stack argument 1 (just padding)
kArgcSmi, // stack argument 2
kTargetCopy, // stack argument 3
kNewTargetCopy) // stack argument 4
DEFINE_PARAMETER_TYPES(MachineType::Int32(), // kArity
MachineType::Pointer(), // kCFunction
MachineType::AnyTagged(), // kPadding
MachineType::AnyTagged(), // kArgcSmi
MachineType::AnyTagged(), // kTargetCopy
MachineType::AnyTagged()) // kNewTargetCopy
DECLARE_DESCRIPTOR(CEntry1ArgvOnStackDescriptor, CallInterfaceDescriptor)
};
class ApiCallbackDescriptor : public CallInterfaceDescriptor { class ApiCallbackDescriptor : public CallInterfaceDescriptor {
public: public:
DEFINE_PARAMETERS_NO_CONTEXT(kTargetContext, kCallData, kHolder, DEFINE_PARAMETERS_NO_CONTEXT(kTargetContext, kCallData, kHolder,
......
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