Commit 7efa02a3 authored by tzik's avatar tzik Committed by Commit Bot

Shuffle the parameter ordering of JSEntry

This moves |root_register_value| parameter of JSEntryFunction to the
first. I.e. the type of entry function will be changed from
 Object*(Object* new_target, Object* target, Object* receiver,
         int argc, Object*** args,
         Address root_register_value)
to
 Object*(Address root_register_value,
         Object* new_target, Object* target, Object* receiver,
         int argc, Object*** args),
and moves all parameter handling except for |root_register_value| from
JSEntryVariant to JSEntryTrampolineHelper.

This is a preparation to add another JS entry point for RunMicrotasks,
whose type will be
 Object*(Address root_register_value, MicrotaskQueue*).
The new entry point requires |root_register_value| to be the first to
share the implementation of the EntryFrame setup with existing ones.

Bug: v8:8124
Change-Id: I675376a2ccd240f61cf04eea6fe9a91031e06ede
Reviewed-on: https://chromium-review.googlesource.com/c/1372857
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58683}
parent d286fe3d
...@@ -19,8 +19,8 @@ class EntryFrameConstants : public AllStatic { ...@@ -19,8 +19,8 @@ class EntryFrameConstants : public AllStatic {
-(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize); -(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize);
// Stack offsets for arguments passed to JSEntry. // Stack offsets for arguments passed to JSEntry.
static constexpr int kArgvOffset = +0 * kSystemPointerSize; static constexpr int kArgcOffset = +0 * kSystemPointerSize;
static constexpr int kRootRegisterValueOffset = +1 * kSystemPointerSize; static constexpr int kArgvOffset = +1 * kSystemPointerSize;
}; };
class ExitFrameConstants : public TypedFrameConstants { class ExitFrameConstants : public TypedFrameConstants {
......
...@@ -527,27 +527,33 @@ void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { ...@@ -527,27 +527,33 @@ void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) {
namespace { namespace {
// Total size of the stack space pushed by JSEntryVariant.
// JSEntryTrampoline uses this to access on stack arguments passed to
// JSEntryVariant.
constexpr int kPushedStackSpace = kNumCalleeSaved * kPointerSize +
kPointerSize /* LR */ +
kNumDoubleCalleeSaved * kDoubleSize +
4 * kPointerSize /* r5, r6, r7, scratch */ +
EntryFrameConstants::kCallerFPOffset;
// Called with the native C calling convention. The corresponding function // Called with the native C calling convention. The corresponding function
// signature is: // signature is:
// //
// using JSEntryFunction = GeneratedCode<Address( // using JSEntryFunction = GeneratedCode<Address(
// Address new_target, Address target, Address receiver, intptr_t argc, // Address root_register_value, Address new_target, Address target,
// Address** args, Address root_register_value)>; // Address receiver, intptr_t argc, Address** args)>;
void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
Builtins::Name entry_trampoline) { Builtins::Name entry_trampoline) {
// r0: code entry // r0: root_register_value
// r1: function // r1: code entry
// r2: receiver // r2: function
// r3: argc // r3: receiver
// [sp + 0 * kSystemPointerSize]: argv // [sp + 0 * kSystemPointerSize]: argc
// [sp + 1 * kSystemPointerSize]: root register value // [sp + 1 * kSystemPointerSize]: argv
Label invoke, handler_entry, exit; Label invoke, handler_entry, exit;
static constexpr int kPushedStackSpace = // Update |pushed_stack_space| when we manipulate the stack.
(kNumCalleeSaved + 1) * kPointerSize + int pushed_stack_space = EntryFrameConstants::kCallerFPOffset;
kNumDoubleCalleeSaved * kDoubleSize;
{ {
NoRootArrayScope no_root_array(masm); NoRootArrayScope no_root_array(masm);
...@@ -555,36 +561,26 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, ...@@ -555,36 +561,26 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
// No need to save register-passed args // No need to save register-passed args
// Save callee-saved registers (incl. cp and fp), sp, and lr // Save callee-saved registers (incl. cp and fp), sp, and lr
__ stm(db_w, sp, kCalleeSaved | lr.bit()); __ stm(db_w, sp, kCalleeSaved | lr.bit());
pushed_stack_space +=
kNumCalleeSaved * kPointerSize + kPointerSize /* LR */;
// Save callee-saved vfp registers. // Save callee-saved vfp registers.
__ vstm(db_w, sp, kFirstCalleeSavedDoubleReg, kLastCalleeSavedDoubleReg); __ vstm(db_w, sp, kFirstCalleeSavedDoubleReg, kLastCalleeSavedDoubleReg);
pushed_stack_space += kNumDoubleCalleeSaved * kDoubleSize;
// Set up the reserved register for 0.0. // Set up the reserved register for 0.0.
__ vmov(kDoubleRegZero, Double(0.0)); __ vmov(kDoubleRegZero, Double(0.0));
// Initialize the root register. // Initialize the root register.
// C calling convention. The sixth argument is passed on the stack. // C calling convention. The first argument is passed in r0.
static constexpr int kOffsetToRootRegisterValue = __ mov(kRootRegister, r0);
kPushedStackSpace + EntryFrameConstants::kRootRegisterValueOffset;
__ ldr(kRootRegister, MemOperand(sp, kOffsetToRootRegisterValue));
} }
// Get address of argv, see stm above.
// r0: code entry
// r1: function
// r2: receiver
// r3: argc
// Set up argv in r4.
static constexpr int kOffsetToArgv =
kPushedStackSpace + EntryFrameConstants::kArgvOffset;
__ ldr(r4, MemOperand(sp, kOffsetToArgv));
// Push a frame with special values setup to mark it as an entry frame. // Push a frame with special values setup to mark it as an entry frame.
// r0: code entry // r0: root_register_value
// r1: function // r1: code entry
// r2: receiver // r2: function
// r3: argc // r3: receiver
// r4: argv
__ mov(r7, Operand(StackFrame::TypeToMarker(type))); __ mov(r7, Operand(StackFrame::TypeToMarker(type)));
__ mov(r6, Operand(StackFrame::TypeToMarker(type))); __ mov(r6, Operand(StackFrame::TypeToMarker(type)));
__ Move(r5, ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, __ Move(r5, ExternalReference::Create(IsolateAddressId::kCEntryFPAddress,
...@@ -597,6 +593,7 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, ...@@ -597,6 +593,7 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
// Push a bad frame pointer to fail if it is used. // Push a bad frame pointer to fail if it is used.
__ mov(scratch, Operand(-1)); __ mov(scratch, Operand(-1));
__ stm(db_w, sp, r5.bit() | r6.bit() | r7.bit() | scratch.bit()); __ stm(db_w, sp, r5.bit() | r6.bit() | r7.bit() | scratch.bit());
pushed_stack_space += 4 * kPointerSize /* r5, r6, r7, scratch */;
} }
Register scratch = r6; Register scratch = r6;
...@@ -668,6 +665,7 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, ...@@ -668,6 +665,7 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
// pop the faked function when we return. // pop the faked function when we return.
Handle<Code> trampoline_code = Handle<Code> trampoline_code =
masm->isolate()->builtins()->builtin_handle(entry_trampoline); masm->isolate()->builtins()->builtin_handle(entry_trampoline);
DCHECK_EQ(kPushedStackSpace, pushed_stack_space);
__ Call(trampoline_code, RelocInfo::CODE_TARGET); __ Call(trampoline_code, RelocInfo::CODE_TARGET);
// Unlink this frame from the handler chain. // Unlink this frame from the handler chain.
...@@ -725,13 +723,25 @@ void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) { ...@@ -725,13 +723,25 @@ void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) {
static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
bool is_construct) { bool is_construct) {
// Called from Generate_JS_Entry // Called from Generate_JS_Entry
// r0: new.target // r0: root_register_value
// r1: function // r1: new.target
// r2: receiver // r2: function
// r3: argc // r3: receiver
// r4: argv // [fp + kPushedStackSpace + 0 * kSystemPointerSize]: argc
// [fp + kPushedStackSpace + 1 * kSystemPointerSize]: argv
// r5-r6, r8 and cp may be clobbered // r5-r6, r8 and cp may be clobbered
__ ldr(r0,
MemOperand(fp, kPushedStackSpace + EntryFrameConstants::kArgcOffset));
__ ldr(r4,
MemOperand(fp, kPushedStackSpace + EntryFrameConstants::kArgvOffset));
// r1: new.target
// r2: function
// r3: receiver
// r0: argc
// r4: argv
// Enter an internal frame. // Enter an internal frame.
{ {
FrameScope scope(masm, StackFrame::INTERNAL); FrameScope scope(masm, StackFrame::INTERNAL);
...@@ -743,12 +753,12 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, ...@@ -743,12 +753,12 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
__ ldr(cp, MemOperand(cp)); __ ldr(cp, MemOperand(cp));
// Push the function and the receiver onto the stack. // Push the function and the receiver onto the stack.
__ Push(r1, r2); __ Push(r2, r3);
// Check if we have enough stack space to push all arguments. // Check if we have enough stack space to push all arguments.
// Clobbers r2. // Clobbers r3.
Label enough_stack_space, stack_overflow; Label enough_stack_space, stack_overflow;
Generate_StackOverflowCheck(masm, r3, r2, &stack_overflow); Generate_StackOverflowCheck(masm, r0, r3, &stack_overflow);
__ b(&enough_stack_space); __ b(&enough_stack_space);
__ bind(&stack_overflow); __ bind(&stack_overflow);
__ CallRuntime(Runtime::kThrowStackOverflow); __ CallRuntime(Runtime::kThrowStackOverflow);
...@@ -757,37 +767,39 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, ...@@ -757,37 +767,39 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
__ bind(&enough_stack_space); __ bind(&enough_stack_space);
// Remember new.target.
__ mov(r5, r0);
// Copy arguments to the stack in a loop. // Copy arguments to the stack in a loop.
// r1: function // r1: new.target
// r3: argc // r2: function
// r0: argc
// r4: argv, i.e. points to first arg // r4: argv, i.e. points to first arg
Label loop, entry; Label loop, entry;
__ add(r2, r4, Operand(r3, LSL, kPointerSizeLog2)); __ add(r3, r4, Operand(r0, LSL, kPointerSizeLog2));
// r2 points past last arg. // r1 points past last arg.
__ b(&entry); __ b(&entry);
__ bind(&loop); __ bind(&loop);
__ ldr(r0, MemOperand(r4, kPointerSize, PostIndex)); // read next parameter __ ldr(r5, MemOperand(r4, kPointerSize, PostIndex)); // read next parameter
__ ldr(r0, MemOperand(r0)); // dereference handle __ ldr(r5, MemOperand(r5)); // dereference handle
__ push(r0); // push parameter __ push(r5); // push parameter
__ bind(&entry); __ bind(&entry);
__ cmp(r4, r2); __ cmp(r4, r3);
__ b(ne, &loop); __ b(ne, &loop);
// Setup new.target and argc. // Setup new.target and function.
__ mov(r0, Operand(r3)); __ mov(r3, r1);
__ mov(r3, Operand(r5)); __ mov(r1, r2);
// r0: argc
// r1: function
// r3: new.target
// Initialize all JavaScript callee-saved registers, since they will be seen // Initialize all JavaScript callee-saved registers, since they will be seen
// by the garbage collector as part of handlers. // by the garbage collector as part of handlers.
__ LoadRoot(r4, RootIndex::kUndefinedValue); __ LoadRoot(r4, RootIndex::kUndefinedValue);
__ mov(r5, Operand(r4)); __ mov(r2, r4);
__ mov(r6, Operand(r4)); __ mov(r5, r4);
__ mov(r8, Operand(r4)); __ mov(r6, r4);
__ mov(r8, r4);
if (kR9Available == 1) { if (kR9Available == 1) {
__ mov(r9, Operand(r4)); __ mov(r9, r4);
} }
// Invoke the code. // Invoke the code.
......
...@@ -597,24 +597,22 @@ namespace { ...@@ -597,24 +597,22 @@ namespace {
// signature is: // signature is:
// //
// using JSEntryFunction = GeneratedCode<Address( // using JSEntryFunction = GeneratedCode<Address(
// Address new_target, Address target, Address receiver, intptr_t argc, // Address root_register_value, Address new_target, Address target,
// Address** args, Address root_register_value)>; // Address receiver, intptr_t argc, Address** argv)>;
// //
// Input: // Input:
// x0: code entry. // x0: root_register_value.
// x1: function. // x1: new_target.
// x2: receiver. // x2: target.
// x3: argc. // x3: receiver.
// x4: argv. // x4: argc.
// x5: root register value. // x5: argv.
// Output: // Output:
// x0: result. // x0: result.
void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
Builtins::Name entry_trampoline) { Builtins::Name entry_trampoline) {
Label invoke, handler_entry, exit; Label invoke, handler_entry, exit;
Register code_entry = x0;
{ {
NoRootArrayScope no_root_array(masm); NoRootArrayScope no_root_array(masm);
...@@ -628,8 +626,8 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, ...@@ -628,8 +626,8 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
__ Fmov(fp_zero, 0.0); __ Fmov(fp_zero, 0.0);
// Initialize the root register. // Initialize the root register.
// C calling convention. The sixth argument is passed in x5. // C calling convention. The first argument is passed in x0.
__ Mov(kRootRegister, x5); __ Mov(kRootRegister, x0);
} }
// Build an entry frame (see layout below). // Build an entry frame (see layout below).
...@@ -697,7 +695,7 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, ...@@ -697,7 +695,7 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
ExternalReference::Create(IsolateAddressId::kPendingExceptionAddress, ExternalReference::Create(IsolateAddressId::kPendingExceptionAddress,
masm->isolate())); masm->isolate()));
} }
__ Str(code_entry, MemOperand(x10)); __ Str(x0, MemOperand(x10));
__ LoadRoot(x0, RootIndex::kException); __ LoadRoot(x0, RootIndex::kException);
__ B(&exit); __ B(&exit);
...@@ -730,11 +728,11 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, ...@@ -730,11 +728,11 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
// saved values before returning a failure to C. // saved values before returning a failure to C.
// //
// Expected registers by Builtins::JSEntryTrampoline // Expected registers by Builtins::JSEntryTrampoline
// x0: code entry. // x1: new_target.
// x1: function. // x2: target.
// x2: receiver. // x3: receiver.
// x3: argc. // x4: argc.
// x4: argv. // x5: argv.
// //
// Invoke the function by calling through JS entry trampoline builtin and // Invoke the function by calling through JS entry trampoline builtin and
// pop the faked function when we return. // pop the faked function when we return.
...@@ -805,20 +803,20 @@ void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) { ...@@ -805,20 +803,20 @@ void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) {
} }
// Input: // Input:
// x0: new.target. // x1: new.target.
// x1: function. // x2: function.
// x2: receiver. // x3: receiver.
// x3: argc. // x4: argc.
// x4: argv. // x5: argv.
// Output: // Output:
// x0: result. // x0: result.
static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
bool is_construct) { bool is_construct) {
Register new_target = x0; Register new_target = x1;
Register function = x1; Register function = x2;
Register receiver = x2; Register receiver = x3;
Register argc = x3; Register argc = x4;
Register argv = x4; Register argv = x5;
Register scratch = x10; Register scratch = x10;
Register slots_to_claim = x11; Register slots_to_claim = x11;
...@@ -857,8 +855,8 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, ...@@ -857,8 +855,8 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
__ Stp(receiver, function, MemOperand(scratch)); __ Stp(receiver, function, MemOperand(scratch));
// Copy arguments to the stack in a loop, in reverse order. // Copy arguments to the stack in a loop, in reverse order.
// x3: argc. // x4: argc.
// x4: argv. // x5: argv.
Label loop, done; Label loop, done;
// Skip the argument set up if we have no arguments. // Skip the argument set up if we have no arguments.
...@@ -880,10 +878,11 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, ...@@ -880,10 +878,11 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
__ Bind(&done); __ Bind(&done);
__ Mov(scratch, argc); __ Mov(x0, argc);
__ Mov(argc, new_target); __ Mov(x3, new_target);
__ Mov(new_target, scratch); __ Mov(x1, function);
// x0: argc. // x0: argc.
// x1: function.
// x3: new.target. // x3: new.target.
// Initialize all JavaScript callee-saved registers, since they will be seen // Initialize all JavaScript callee-saved registers, since they will be seen
......
...@@ -374,8 +374,8 @@ namespace { ...@@ -374,8 +374,8 @@ namespace {
// signature is: // signature is:
// //
// using JSEntryFunction = GeneratedCode<Address( // using JSEntryFunction = GeneratedCode<Address(
// Address new_target, Address target, Address receiver, intptr_t argc, // Address root_register_value, Address new_target, Address target,
// Address** args, Address root_register_value)>; // Address receiver, intptr_t argc, Address** args)>;
void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
Builtins::Name entry_trampoline) { Builtins::Name entry_trampoline) {
Label invoke, handler_entry, exit; Label invoke, handler_entry, exit;
...@@ -399,7 +399,7 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, ...@@ -399,7 +399,7 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
__ push(ebx); __ push(ebx);
// Initialize the root register based on the given Isolate* argument. // Initialize the root register based on the given Isolate* argument.
// C calling convention. The sixth argument is passed on the stack. // C calling convention. The first argument is passed on the stack.
__ mov(kRootRegister, __ mov(kRootRegister,
Operand(ebp, EntryFrameConstants::kRootRegisterValueOffset)); Operand(ebp, EntryFrameConstants::kRootRegisterValueOffset));
} }
......
...@@ -397,10 +397,13 @@ namespace { ...@@ -397,10 +397,13 @@ namespace {
// signature is: // signature is:
// //
// using JSEntryFunction = GeneratedCode<Address( // using JSEntryFunction = GeneratedCode<Address(
// Address new_target, Address target, Address receiver, intptr_t argc, // Address root_register_value, Address new_target, Address target,
// Address** args, Address root_register_value)>; // Address receiver, intptr_t argc, Address** args)>;
void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
Builtins::Name entry_trampoline) { Builtins::Name entry_trampoline) {
// TODO(tzik): |root_register_value| is moved from sixth to first. Update
// JSEntryVariant and JSEntryTrampoline for it.
Label invoke, handler_entry, exit; Label invoke, handler_entry, exit;
static constexpr int kPushedStackSpace = static constexpr int kPushedStackSpace =
......
...@@ -542,10 +542,13 @@ namespace { ...@@ -542,10 +542,13 @@ namespace {
// signature is: // signature is:
// //
// using JSEntryFunction = GeneratedCode<Address( // using JSEntryFunction = GeneratedCode<Address(
// Address new_target, Address target, Address receiver, intptr_t argc, // Address root_register_value, Address new_target, Address target,
// Address** args, Address root_register_value)>; // Address receiver, intptr_t argc, Address** args)>;
void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
Builtins::Name entry_trampoline) { Builtins::Name entry_trampoline) {
// TODO(tzik): |root_register_value| is moved from sixth to first. Update
// JSEntryVariant and JSEntryTrampoline for it.
Label invoke, handler_entry, exit; Label invoke, handler_entry, exit;
{ {
......
...@@ -536,15 +536,19 @@ namespace { ...@@ -536,15 +536,19 @@ namespace {
// signature is: // signature is:
// //
// using JSEntryFunction = GeneratedCode<Address( // using JSEntryFunction = GeneratedCode<Address(
// Address new_target, Address target, Address receiver, intptr_t argc, // Address root_register_value, Address new_target, Address target,
// Address** args, Address root_register_value)>; // Address receiver, intptr_t argc, Address** args)>;
void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
Builtins::Name entry_trampoline) { Builtins::Name entry_trampoline) {
// TODO(tzik): |root_register_value| is moved from sixth to first. Update
// JSEntryVariant and JSEntryTrampoline for it.
//
// r3: code entry // r3: code entry
// r4: function // r4: function
// r5: receiver // r5: receiver
// r6: argc // r6: argc
// [sp+0]: argv // r7: argv
// r8: root_register_value
Label invoke, handler_entry, exit; Label invoke, handler_entry, exit;
......
...@@ -536,10 +536,13 @@ namespace { ...@@ -536,10 +536,13 @@ namespace {
// signature is: // signature is:
// //
// using JSEntryFunction = GeneratedCode<Address( // using JSEntryFunction = GeneratedCode<Address(
// Address new_target, Address target, Address receiver, intptr_t argc, // Address root_register_value, Address new_target, Address target,
// Address** args, Address root_register_value)>; // Address receiver, intptr_t argc, Address** args)>;
void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
Builtins::Name entry_trampoline) { Builtins::Name entry_trampoline) {
// TODO(tzik): |root_register_value| is moved from sixth to first. Update
// JSEntryVariant and JSEntryTrampoline for it.
//
// r2: code entry // r2: code entry
// r3: function // r3: function
// r4: receiver // r4: receiver
......
...@@ -368,8 +368,8 @@ namespace { ...@@ -368,8 +368,8 @@ namespace {
// signature is: // signature is:
// //
// using JSEntryFunction = GeneratedCode<Address( // using JSEntryFunction = GeneratedCode<Address(
// Address new_target, Address target, Address receiver, intptr_t argc, // Address root_register_value, Address new_target, Address target,
// Address** args, Address root_register_value)>; // Address receiver, intptr_t argc, Address** args)>;
void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
Builtins::Name entry_trampoline) { Builtins::Name entry_trampoline) {
Label invoke, handler_entry, exit; Label invoke, handler_entry, exit;
...@@ -416,16 +416,9 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, ...@@ -416,16 +416,9 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
EntryFrameConstants::kCalleeSaveXMMRegisters); EntryFrameConstants::kCalleeSaveXMMRegisters);
#endif #endif
#ifdef _WIN64
// Initialize the root register.
// C calling convention. The sixth argument is passed on the stack.
__ movp(kRootRegister,
Operand(rbp, EntryFrameConstants::kRootRegisterValueOffset));
#else
// Initialize the root register. // Initialize the root register.
// C calling convention. The sixth argument is passed in r9. // C calling convention. The first argument is passed in arg_reg_1.
__ movp(kRootRegister, r9); __ movp(kRootRegister, arg_reg_1);
#endif
} }
// Save copies of the top frame descriptor on the stack. // Save copies of the top frame descriptor on the stack.
...@@ -555,6 +548,7 @@ void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) { ...@@ -555,6 +548,7 @@ void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) {
static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
bool is_construct) { bool is_construct) {
// Expects five C++ function parameters. // Expects five C++ function parameters.
// - Address root_register_value
// - Address new_target (tagged Object pointer) // - Address new_target (tagged Object pointer)
// - Address function (tagged JSFunction pointer) // - Address function (tagged JSFunction pointer)
// - Address receiver (tagged Object pointer) // - Address receiver (tagged Object pointer)
...@@ -564,19 +558,25 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, ...@@ -564,19 +558,25 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
// Open a C++ scope for the FrameScope. // Open a C++ scope for the FrameScope.
{ {
// Platform specific argument handling. After this, the stack contains // Platform specific argument handling. After this, the stack contains
// an internal frame and the pushed function and receiver, and // an internal frame and the pushed function and receiver, and
// register rax and rbx holds the argument count and argument array, // register rax and rbx holds the argument count and argument array,
// while rdi holds the function pointer, rsi the context, and rdx the // while rdi holds the function pointer, rsi the context, and rdx the
// new.target. // new.target.
#ifdef _WIN64 #ifdef _WIN64
// MSVC parameters in: // MSVC parameters in:
// rcx : new_target // rcx : root_register_value
// rdx : function // rdx : new_target
// r8 : receiver // r8 : function
// r9 : argc // r9 : receiver
// [rsp+0x20] : argv // [rsp+0x20] : argc
// [rsp+0x28] : argv
__ movp(rdi, r8);
// Clear the context before we push it when entering the internal frame.
__ Set(rsi, 0);
// Enter an internal frame. // Enter an internal frame.
FrameScope scope(masm, StackFrame::INTERNAL); FrameScope scope(masm, StackFrame::INTERNAL);
...@@ -587,30 +587,27 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, ...@@ -587,30 +587,27 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
__ movp(rsi, masm->ExternalReferenceAsOperand(context_address)); __ movp(rsi, masm->ExternalReferenceAsOperand(context_address));
// Push the function and the receiver onto the stack. // Push the function and the receiver onto the stack.
__ Push(rdx);
__ Push(r8); __ Push(r8);
__ Push(r9);
// Load the number of arguments and setup pointer to the arguments. // Load the previous frame pointer to access C arguments on stack
__ movp(rax, r9);
// Load the previous frame pointer to access C argument on stack
__ movp(kScratchRegister, Operand(rbp, 0)); __ movp(kScratchRegister, Operand(rbp, 0));
// Load the number of arguments and setup pointer to the arguments.
__ movp(rax, Operand(kScratchRegister, EntryFrameConstants::kArgcOffset));
__ movp(rbx, Operand(kScratchRegister, EntryFrameConstants::kArgvOffset)); __ movp(rbx, Operand(kScratchRegister, EntryFrameConstants::kArgvOffset));
// Load the function pointer into rdi.
__ movp(rdi, rdx);
// Load the new.target into rdx.
__ movp(rdx, rcx);
#else // _WIN64 #else // _WIN64
// GCC parameters in: // GCC parameters in:
// rdi : new_target // rdi : root_register_value
// rsi : function // rsi : new_target
// rdx : receiver // rdx : function
// rcx : argc // rcx : receiver
// r8 : argv // r8 : argc
// r9 : argv
__ movp(r11, rdi);
__ movp(rdi, rsi); __ movp(rdi, rdx);
__ movp(rdx, rsi);
// rdi : function // rdi : function
// r11 : new_target // rdx : new_target
// Clear the context before we push it when entering the internal frame. // Clear the context before we push it when entering the internal frame.
__ Set(rsi, 0); __ Set(rsi, 0);
...@@ -625,14 +622,11 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, ...@@ -625,14 +622,11 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
// Push the function and receiver onto the stack. // Push the function and receiver onto the stack.
__ Push(rdi); __ Push(rdi);
__ Push(rdx); __ Push(rcx);
// Load the number of arguments and setup pointer to the arguments. // Load the number of arguments and setup pointer to the arguments.
__ movp(rax, rcx); __ movp(rax, r8);
__ movp(rbx, r8); __ movp(rbx, r9);
// Load the new.target into rdx.
__ movp(rdx, r11);
#endif // _WIN64 #endif // _WIN64
// Current stack contents: // Current stack contents:
......
...@@ -273,8 +273,8 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate, ...@@ -273,8 +273,8 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate,
// {new_target}, {target}, {receiver}, return value: tagged pointers // {new_target}, {target}, {receiver}, return value: tagged pointers
// {argv}: pointer to array of tagged pointers // {argv}: pointer to array of tagged pointers
using JSEntryFunction = GeneratedCode<Address( using JSEntryFunction = GeneratedCode<Address(
Address new_target, Address target, Address receiver, intptr_t argc, Address root_register_value, Address new_target, Address target,
Address** argv, Address root_register_value)>; Address receiver, intptr_t argc, Address** argv)>;
// clang-format on // clang-format on
JSEntryFunction stub_entry = JSEntryFunction stub_entry =
JSEntryFunction::FromAddress(isolate, code->InstructionStart()); JSEntryFunction::FromAddress(isolate, code->InstructionStart());
...@@ -290,8 +290,8 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate, ...@@ -290,8 +290,8 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate,
PrintDeserializedCodeInfo(Handle<JSFunction>::cast(params.target)); PrintDeserializedCodeInfo(Handle<JSFunction>::cast(params.target));
} }
RuntimeCallTimerScope timer(isolate, RuntimeCallCounterId::kJS_Execution); RuntimeCallTimerScope timer(isolate, RuntimeCallCounterId::kJS_Execution);
value = Object(stub_entry.Call(orig_func, func, recv, params.argc, argv, value = Object(stub_entry.Call(isolate->isolate_data()->isolate_root(),
isolate->isolate_data()->isolate_root())); orig_func, func, recv, params.argc, argv));
} }
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
......
...@@ -17,12 +17,12 @@ class EntryFrameConstants : public AllStatic { ...@@ -17,12 +17,12 @@ class EntryFrameConstants : public AllStatic {
// Isolate::c_entry_fp onto the stack. // Isolate::c_entry_fp onto the stack.
static constexpr int kCallerFPOffset = -6 * kPointerSize; static constexpr int kCallerFPOffset = -6 * kPointerSize;
static constexpr int kNewTargetArgOffset = +2 * kPointerSize; static constexpr int kRootRegisterValueOffset = +2 * kPointerSize;
static constexpr int kFunctionArgOffset = +3 * kPointerSize; static constexpr int kNewTargetArgOffset = +3 * kPointerSize;
static constexpr int kReceiverArgOffset = +4 * kPointerSize; static constexpr int kFunctionArgOffset = +4 * kPointerSize;
static constexpr int kArgcOffset = +5 * kPointerSize; static constexpr int kReceiverArgOffset = +5 * kPointerSize;
static constexpr int kArgvOffset = +6 * kPointerSize; static constexpr int kArgcOffset = +6 * kPointerSize;
static constexpr int kRootRegisterValueOffset = +7 * kPointerSize; static constexpr int kArgvOffset = +7 * kPointerSize;
}; };
class ExitFrameConstants : public TypedFrameConstants { class ExitFrameConstants : public TypedFrameConstants {
......
...@@ -28,8 +28,8 @@ class EntryFrameConstants : public AllStatic { ...@@ -28,8 +28,8 @@ class EntryFrameConstants : public AllStatic {
-3 * kSystemPointerSize + -7 * kRegisterSize - kXMMRegistersBlockSize; -3 * kSystemPointerSize + -7 * kRegisterSize - kXMMRegistersBlockSize;
// Stack offsets for arguments passed to JSEntry. // Stack offsets for arguments passed to JSEntry.
static constexpr int kArgvOffset = 6 * kSystemPointerSize; static constexpr int kArgcOffset = 6 * kSystemPointerSize;
static constexpr int kRootRegisterValueOffset = 7 * kSystemPointerSize; static constexpr int kArgvOffset = 7 * kSystemPointerSize;
#else #else
// This is the offset to where JSEntry pushes the current value of // This is the offset to where JSEntry pushes the current value of
// Isolate::c_entry_fp onto the stack. // Isolate::c_entry_fp onto the stack.
......
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