Commit fab59bbb authored by tzik's avatar tzik Committed by Commit Bot

Support non-default MicrotaskQueue on RunMicrotasks builtin

The previous implementation of MicrotaskQueue::RunMicrotasks() didn't
support non-default MicrotaskQueue as RunMicrotasks builtin couldn't
take a parameter.

This CL updates the entry trampoline for RunMicrotasks builtin to pass
a MicrotaskQueue parameter to support non-default one.

Bug: v8:8124
Change-Id: I817238cd9a1fd6c20dcd58022274736c5e86229a
Reviewed-on: https://chromium-review.googlesource.com/c/1369906Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58872}
parent 314da8ee
...@@ -537,19 +537,27 @@ constexpr int kPushedStackSpace = kNumCalleeSaved * kPointerSize + ...@@ -537,19 +537,27 @@ constexpr int kPushedStackSpace = kNumCalleeSaved * kPointerSize +
EntryFrameConstants::kCallerFPOffset; 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 either:
// //
// using JSEntryFunction = GeneratedCode<Address( // using JSEntryFunction = GeneratedCode<Address(
// Address root_register_value, Address new_target, Address target, // Address root_register_value, Address new_target, Address target,
// Address receiver, intptr_t argc, Address** args)>; // Address receiver, intptr_t argc, Address** argv)>;
// or
// using JSEntryFunction = GeneratedCode<Address(
// Address root_register_value, MicrotaskQueue* microtask_queue)>;
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: root_register_value // The register state is either:
// r1: code entry // r0: root_register_value
// r2: function // r1: code entry
// r3: receiver // r2: function
// [sp + 0 * kSystemPointerSize]: argc // r3: receiver
// [sp + 1 * kSystemPointerSize]: argv // [sp + 0 * kSystemPointerSize]: argc
// [sp + 1 * kSystemPointerSize]: argv
// or
// r0: root_register_value
// r1: microtask_queue
// Preserve all but r0 and pass them to entry_trampoline.
Label invoke, handler_entry, exit; Label invoke, handler_entry, exit;
// Update |pushed_stack_space| when we manipulate the stack. // Update |pushed_stack_space| when we manipulate the stack.
...@@ -578,9 +586,6 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, ...@@ -578,9 +586,6 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
// 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: root_register_value // r0: root_register_value
// r1: code entry
// r2: function
// r3: receiver
__ 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,
...@@ -654,13 +659,6 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, ...@@ -654,13 +659,6 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
// restores all kCalleeSaved registers (including cp and fp) to their // restores all kCalleeSaved registers (including cp and fp) to their
// saved values before returning a failure to C. // saved values before returning a failure to C.
// //
// Expected registers by Builtins::JSEntryTrampoline
// r0: code entry
// r1: function
// r2: receiver
// r3: argc
// r4: 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.
Handle<Code> trampoline_code = Handle<Code> trampoline_code =
...@@ -717,7 +715,8 @@ void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) { ...@@ -717,7 +715,8 @@ void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) {
} }
void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) { void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) {
Generate_JSEntryVariant(masm, StackFrame::ENTRY, Builtins::kRunMicrotasks); Generate_JSEntryVariant(masm, StackFrame::ENTRY,
Builtins::kRunMicrotasksTrampoline);
} }
static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
...@@ -825,6 +824,16 @@ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { ...@@ -825,6 +824,16 @@ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
Generate_JSEntryTrampolineHelper(masm, true); Generate_JSEntryTrampolineHelper(masm, true);
} }
void Builtins::Generate_RunMicrotasksTrampoline(MacroAssembler* masm) {
// This expects two C++ function parameters passed by Invoke() in
// execution.cc.
// r0: root_register_value
// r1: microtask_queue
__ mov(RunMicrotasksDescriptor::MicrotaskQueueRegister(), r1);
__ Jump(BUILTIN_CODE(masm->isolate(), RunMicrotasks), RelocInfo::CODE_TARGET);
}
static void ReplaceClosureCodeWithOptimizedCode( static void ReplaceClosureCodeWithOptimizedCode(
MacroAssembler* masm, Register optimized_code, Register closure, MacroAssembler* masm, Register optimized_code, Register closure,
Register scratch1, Register scratch2, Register scratch3) { Register scratch1, Register scratch2, Register scratch3) {
......
...@@ -594,19 +594,25 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { ...@@ -594,19 +594,25 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) {
namespace { namespace {
// Called with the native C calling convention. The corresponding function // Called with the native C calling convention. The corresponding function
// signature is: // signature is either:
// //
// using JSEntryFunction = GeneratedCode<Address( // using JSEntryFunction = GeneratedCode<Address(
// Address root_register_value, Address new_target, Address target, // Address root_register_value, Address new_target, Address target,
// Address receiver, intptr_t argc, Address** argv)>; // Address receiver, intptr_t argc, Address** argv)>;
// or
// using JSEntryFunction = GeneratedCode<Address(
// Address root_register_value, MicrotaskQueue* microtask_queue)>;
// //
// Input: // Input is either:
// x0: root_register_value. // x0: root_register_value.
// x1: new_target. // x1: new_target.
// x2: target. // x2: target.
// x3: receiver. // x3: receiver.
// x4: argc. // x4: argc.
// x5: argv. // x5: argv.
// or
// x0: root_register_value.
// x1: microtask_queue.
// Output: // Output:
// x0: result. // x0: result.
void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
...@@ -727,13 +733,6 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, ...@@ -727,13 +733,6 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
// restores all callee-saved registers (including cp and fp) to their // restores all callee-saved registers (including cp and fp) to their
// saved values before returning a failure to C. // saved values before returning a failure to C.
// //
// Expected registers by Builtins::JSEntryTrampoline
// x1: new_target.
// x2: target.
// x3: receiver.
// x4: argc.
// 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.
Handle<Code> trampoline_code = Handle<Code> trampoline_code =
...@@ -799,7 +798,8 @@ void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) { ...@@ -799,7 +798,8 @@ void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) {
} }
void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) { void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) {
Generate_JSEntryVariant(masm, StackFrame::ENTRY, Builtins::kRunMicrotasks); Generate_JSEntryVariant(masm, StackFrame::ENTRY,
Builtins::kRunMicrotasksTrampoline);
} }
// Input: // Input:
...@@ -922,6 +922,16 @@ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { ...@@ -922,6 +922,16 @@ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
Generate_JSEntryTrampolineHelper(masm, true); Generate_JSEntryTrampolineHelper(masm, true);
} }
void Builtins::Generate_RunMicrotasksTrampoline(MacroAssembler* masm) {
// This expects two C++ function parameters passed by Invoke() in
// execution.cc.
// x0: root_register_value
// x1: microtask_queue
__ Mov(RunMicrotasksDescriptor::MicrotaskQueueRegister(), x1);
__ Jump(BUILTIN_CODE(masm->isolate(), RunMicrotasks), RelocInfo::CODE_TARGET);
}
static void ReplaceClosureCodeWithOptimizedCode( static void ReplaceClosureCodeWithOptimizedCode(
MacroAssembler* masm, Register optimized_code, Register closure, MacroAssembler* masm, Register optimized_code, Register closure,
Register scratch1, Register scratch2, Register scratch3) { Register scratch1, Register scratch2, Register scratch3) {
......
...@@ -252,6 +252,7 @@ namespace internal { ...@@ -252,6 +252,7 @@ namespace internal {
\ \
/* Microtask helpers */ \ /* Microtask helpers */ \
TFS(EnqueueMicrotask, kMicrotask) \ TFS(EnqueueMicrotask, kMicrotask) \
ASM(RunMicrotasksTrampoline, Dummy) \
TFC(RunMicrotasks, RunMicrotasks, 1) \ TFC(RunMicrotasks, RunMicrotasks, 1) \
\ \
/* Object property helpers */ \ /* Object property helpers */ \
......
...@@ -21,7 +21,6 @@ class MicrotaskQueueBuiltinsAssembler : public CodeStubAssembler { ...@@ -21,7 +21,6 @@ class MicrotaskQueueBuiltinsAssembler : public CodeStubAssembler {
explicit MicrotaskQueueBuiltinsAssembler(compiler::CodeAssemblerState* state) explicit MicrotaskQueueBuiltinsAssembler(compiler::CodeAssemblerState* state)
: CodeStubAssembler(state) {} : CodeStubAssembler(state) {}
TNode<RawPtrT> GetDefaultMicrotaskQueue();
TNode<RawPtrT> GetMicrotaskQueue(TNode<Context> context); TNode<RawPtrT> GetMicrotaskQueue(TNode<Context> context);
TNode<RawPtrT> GetMicrotaskRingBuffer(TNode<RawPtrT> microtask_queue); TNode<RawPtrT> GetMicrotaskRingBuffer(TNode<RawPtrT> microtask_queue);
TNode<IntPtrT> GetMicrotaskQueueCapacity(TNode<RawPtrT> microtask_queue); TNode<IntPtrT> GetMicrotaskQueueCapacity(TNode<RawPtrT> microtask_queue);
...@@ -48,12 +47,6 @@ class MicrotaskQueueBuiltinsAssembler : public CodeStubAssembler { ...@@ -48,12 +47,6 @@ class MicrotaskQueueBuiltinsAssembler : public CodeStubAssembler {
SloppyTNode<HeapObject> promise_or_capability); SloppyTNode<HeapObject> promise_or_capability);
}; };
TNode<RawPtrT> MicrotaskQueueBuiltinsAssembler::GetDefaultMicrotaskQueue() {
auto ref = ExternalReference::default_microtask_queue_address(isolate());
return UncheckedCast<RawPtrT>(
Load(MachineType::Pointer(), ExternalConstant(ref)));
}
TNode<RawPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskQueue( TNode<RawPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskQueue(
TNode<Context> native_context) { TNode<Context> native_context) {
CSA_ASSERT(this, IsNativeContext(native_context)); CSA_ASSERT(this, IsNativeContext(native_context));
...@@ -506,8 +499,8 @@ TF_BUILTIN(RunMicrotasks, MicrotaskQueueBuiltinsAssembler) { ...@@ -506,8 +499,8 @@ TF_BUILTIN(RunMicrotasks, MicrotaskQueueBuiltinsAssembler) {
// Load the current context from the isolate. // Load the current context from the isolate.
TNode<Context> current_context = GetCurrentContext(); TNode<Context> current_context = GetCurrentContext();
// TODO(tzik): Take a MicrotaskQueue parameter to support non-default queue. TNode<RawPtrT> microtask_queue =
TNode<RawPtrT> microtask_queue = GetDefaultMicrotaskQueue(); UncheckedCast<RawPtrT>(Parameter(Descriptor::kMicrotaskQueue));
Label loop(this), done(this); Label loop(this), done(this);
Goto(&loop); Goto(&loop);
......
...@@ -371,11 +371,14 @@ void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { ...@@ -371,11 +371,14 @@ void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) {
namespace { namespace {
// Called with the native C calling convention. The corresponding function // Called with the native C calling convention. The corresponding function
// signature is: // signature is either:
// //
// using JSEntryFunction = GeneratedCode<Address( // using JSEntryFunction = GeneratedCode<Address(
// Address root_register_value, Address new_target, Address target, // Address root_register_value, Address new_target, Address target,
// Address receiver, intptr_t argc, Address** args)>; // Address receiver, intptr_t argc, Address** argv)>;
// or
// using JSEntryFunction = GeneratedCode<Address(
// Address root_register_value, MicrotaskQueue* microtask_queue)>;
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;
...@@ -493,7 +496,8 @@ void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) { ...@@ -493,7 +496,8 @@ void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) {
} }
void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) { void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) {
Generate_JSEntryVariant(masm, StackFrame::ENTRY, Builtins::kRunMicrotasks); Generate_JSEntryVariant(masm, StackFrame::ENTRY,
Builtins::kRunMicrotasksTrampoline);
} }
static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
...@@ -574,6 +578,15 @@ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { ...@@ -574,6 +578,15 @@ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
Generate_JSEntryTrampolineHelper(masm, true); Generate_JSEntryTrampolineHelper(masm, true);
} }
void Builtins::Generate_RunMicrotasksTrampoline(MacroAssembler* masm) {
// This expects two C++ function parameters passed by Invoke() in
// execution.cc.
// r1: microtask_queue
__ mov(RunMicrotasksDescriptor::MicrotaskQueueRegister(),
Operand(ebp, EntryFrameConstants::kMicrotaskQueueArgOffset));
__ Jump(BUILTIN_CODE(masm->isolate(), RunMicrotasks), RelocInfo::CODE_TARGET);
}
static void GetSharedFunctionInfoBytecode(MacroAssembler* masm, static void GetSharedFunctionInfoBytecode(MacroAssembler* masm,
Register sfi_data, Register sfi_data,
Register scratch1) { Register scratch1) {
......
...@@ -568,7 +568,8 @@ void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) { ...@@ -568,7 +568,8 @@ void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) {
} }
void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) { void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) {
Generate_JSEntryVariant(masm, StackFrame::ENTRY, Builtins::kRunMicrotasks); Generate_JSEntryVariant(masm, StackFrame::ENTRY,
Builtins::kRunMicrotasksTrampoline);
} }
static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
...@@ -665,6 +666,12 @@ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { ...@@ -665,6 +666,12 @@ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
Generate_JSEntryTrampolineHelper(masm, true); Generate_JSEntryTrampolineHelper(masm, true);
} }
void Builtins::Generate_RunMicrotasksTrampoline(MacroAssembler* masm) {
// a1: microtask_queue
__ mov(RunMicrotasksDescriptor::MicrotaskQueueRegister(), a1);
__ Jump(BUILTIN_CODE(masm->isolate(), RunMicrotasks), RelocInfo::CODE_TARGET);
}
static void GetSharedFunctionInfoBytecode(MacroAssembler* masm, static void GetSharedFunctionInfoBytecode(MacroAssembler* masm,
Register sfi_data, Register sfi_data,
Register scratch1) { Register scratch1) {
......
...@@ -557,12 +557,16 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, ...@@ -557,12 +557,16 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
// TODO(plind): unify the ABI description here. // TODO(plind): unify the ABI description here.
// Registers: // Registers:
// a0: root register value // either
// a1: entry address // a0: root register value
// a2: function // a1: entry address
// a3: receiver // a2: function
// a4: argc // a3: receiver
// a5: argv // a4: argc
// a5: argv
// or
// a0: root register value
// a1: microtask_queue
// //
// Stack: // Stack:
// 0 arg slots on mips64 (4 args slots on mips) // 0 arg slots on mips64 (4 args slots on mips)
...@@ -599,11 +603,14 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, ...@@ -599,11 +603,14 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
__ daddiu(fp, sp, -EntryFrameConstants::kCallerFPOffset); __ daddiu(fp, sp, -EntryFrameConstants::kCallerFPOffset);
// Registers: // Registers:
// a1: entry_address // either
// a2: function // a1: entry address
// a3: receiver_pointer // a2: function
// a4: argc // a3: receiver
// a5: argv // a4: argc
// a5: argv
// or
// a1: microtask_queue
// //
// Stack: // Stack:
// caller fp | // caller fp |
...@@ -660,11 +667,16 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, ...@@ -660,11 +667,16 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
// saved values before returning a failure to C. // saved values before returning a failure to C.
// //
// Registers: // Registers:
// a1: entry_address // either
// a2: function // a0: root register value
// a3: receiver_pointer // a1: entry address
// a4: argc // a2: function
// a5: argv // a3: receiver
// a4: argc
// a5: argv
// or
// a0: root register value
// a1: microtask_queue
// //
// Stack: // Stack:
// handler frame // handler frame
...@@ -724,7 +736,8 @@ void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) { ...@@ -724,7 +736,8 @@ void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) {
} }
void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) { void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) {
Generate_JSEntryVariant(masm, StackFrame::ENTRY, Builtins::kRunMicrotasks); Generate_JSEntryVariant(masm, StackFrame::ENTRY,
Builtins::kRunMicrotasksTrampoline);
} }
static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
...@@ -815,6 +828,12 @@ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { ...@@ -815,6 +828,12 @@ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
Generate_JSEntryTrampolineHelper(masm, true); Generate_JSEntryTrampolineHelper(masm, true);
} }
void Builtins::Generate_RunMicrotasksTrampoline(MacroAssembler* masm) {
// a1: microtask_queue
__ mov(RunMicrotasksDescriptor::MicrotaskQueueRegister(), a1);
__ Jump(BUILTIN_CODE(masm->isolate(), RunMicrotasks), RelocInfo::CODE_TARGET);
}
static void ReplaceClosureCodeWithOptimizedCode( static void ReplaceClosureCodeWithOptimizedCode(
MacroAssembler* masm, Register optimized_code, Register closure, MacroAssembler* masm, Register optimized_code, Register closure,
Register scratch1, Register scratch2, Register scratch3) { Register scratch1, Register scratch2, Register scratch3) {
......
...@@ -720,7 +720,8 @@ void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) { ...@@ -720,7 +720,8 @@ void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) {
} }
void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) { void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) {
Generate_JSEntryVariant(masm, StackFrame::ENTRY, Builtins::kRunMicrotasks); Generate_JSEntryVariant(masm, StackFrame::ENTRY,
Builtins::kRunMicrotasksTrampoline);
} }
// Clobbers scratch1 and scratch2; preserves all other registers. // Clobbers scratch1 and scratch2; preserves all other registers.
...@@ -841,6 +842,12 @@ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { ...@@ -841,6 +842,12 @@ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
Generate_JSEntryTrampolineHelper(masm, true); Generate_JSEntryTrampolineHelper(masm, true);
} }
void Builtins::Generate_RunMicrotasksTrampoline(MacroAssembler* masm) {
// r4: microtask_queue
__ mr(RunMicrotasksDescriptor::MicrotaskQueueRegister(), r4);
__ Jump(BUILTIN_CODE(masm->isolate(), RunMicrotasks), RelocInfo::CODE_TARGET);
}
static void ReplaceClosureCodeWithOptimizedCode( static void ReplaceClosureCodeWithOptimizedCode(
MacroAssembler* masm, Register optimized_code, Register closure, MacroAssembler* masm, Register optimized_code, Register closure,
Register scratch1, Register scratch2, Register scratch3) { Register scratch1, Register scratch2, Register scratch3) {
......
...@@ -756,7 +756,8 @@ void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) { ...@@ -756,7 +756,8 @@ void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) {
} }
void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) { void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) {
Generate_JSEntryVariant(masm, StackFrame::ENTRY, Builtins::kRunMicrotasks); Generate_JSEntryVariant(masm, StackFrame::ENTRY,
Builtins::kRunMicrotasksTrampoline);
} }
// Clobbers scratch1 and scratch2; preserves all other registers. // Clobbers scratch1 and scratch2; preserves all other registers.
...@@ -891,6 +892,12 @@ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { ...@@ -891,6 +892,12 @@ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
Generate_JSEntryTrampolineHelper(masm, true); Generate_JSEntryTrampolineHelper(masm, true);
} }
void Builtins::Generate_RunMicrotasksTrampoline(MacroAssembler* masm) {
// r3: microtask_queue
__ mov(RunMicrotasksDescriptor::MicrotaskQueueRegister(), Operand(r3));
__ Jump(BUILTIN_CODE(masm->isolate(), RunMicrotasks), RelocInfo::CODE_TARGET);
}
static void ReplaceClosureCodeWithOptimizedCode( static void ReplaceClosureCodeWithOptimizedCode(
MacroAssembler* masm, Register optimized_code, Register closure, MacroAssembler* masm, Register optimized_code, Register closure,
Register scratch1, Register scratch2, Register scratch3) { Register scratch1, Register scratch2, Register scratch3) {
......
...@@ -365,11 +365,13 @@ void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { ...@@ -365,11 +365,13 @@ void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) {
namespace { namespace {
// Called with the native C calling convention. The corresponding function // Called with the native C calling convention. The corresponding function
// signature is: // signature is either:
// // using JSEntryFunction = GeneratedCode<Address(
// using JSEntryFunction = GeneratedCode<Address( // Address root_register_value, Address new_target, Address target,
// Address root_register_value, Address new_target, Address target, // Address receiver, intptr_t argc, Address** argv)>;
// Address receiver, intptr_t argc, Address** args)>; // or
// using JSEntryFunction = GeneratedCode<Address(
// Address root_register_value, MicrotaskQueue* microtask_queue)>;
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;
...@@ -542,12 +544,13 @@ void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) { ...@@ -542,12 +544,13 @@ void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) {
} }
void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) { void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) {
Generate_JSEntryVariant(masm, StackFrame::ENTRY, Builtins::kRunMicrotasks); Generate_JSEntryVariant(masm, StackFrame::ENTRY,
Builtins::kRunMicrotasksTrampoline);
} }
static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
bool is_construct) { bool is_construct) {
// Expects five C++ function parameters. // Expects six C++ function parameters.
// - Address root_register_value // - 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)
...@@ -672,6 +675,12 @@ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { ...@@ -672,6 +675,12 @@ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
Generate_JSEntryTrampolineHelper(masm, true); Generate_JSEntryTrampolineHelper(masm, true);
} }
void Builtins::Generate_RunMicrotasksTrampoline(MacroAssembler* masm) {
// arg_reg_2: microtask_queue
__ movp(RunMicrotasksDescriptor::MicrotaskQueueRegister(), arg_reg_2);
__ Jump(BUILTIN_CODE(masm->isolate(), RunMicrotasks), RelocInfo::CODE_TARGET);
}
static void GetSharedFunctionInfoBytecode(MacroAssembler* masm, static void GetSharedFunctionInfoBytecode(MacroAssembler* masm,
Register sfi_data, Register sfi_data,
Register scratch1) { Register scratch1) {
......
...@@ -269,29 +269,46 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate, ...@@ -269,29 +269,46 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate,
// allocation of handles without explicit handle scopes. // allocation of handles without explicit handle scopes.
SaveContext save(isolate); SaveContext save(isolate);
SealHandleScope shs(isolate); SealHandleScope shs(isolate);
// clang-format off
// {new_target}, {target}, {receiver}, return value: tagged pointers
// {argv}: pointer to array of tagged pointers
using JSEntryFunction = GeneratedCode<Address(
Address root_register_value, Address new_target, Address target,
Address receiver, intptr_t argc, Address** argv)>;
// clang-format on
JSEntryFunction stub_entry =
JSEntryFunction::FromAddress(isolate, code->InstructionStart());
if (FLAG_clear_exceptions_on_js_entry) isolate->clear_pending_exception(); if (FLAG_clear_exceptions_on_js_entry) isolate->clear_pending_exception();
// Call the function through the right JS entry stub. if (params.execution_target == Execution::Target::kCallable) {
Address orig_func = params.new_target->ptr(); // clang-format off
Address func = params.target->ptr(); // {new_target}, {target}, {receiver}, return value: tagged pointers
Address recv = params.receiver->ptr(); // {argv}: pointer to array of tagged pointers
Address** argv = reinterpret_cast<Address**>(params.argv); using JSEntryFunction = GeneratedCode<Address(
if (FLAG_profile_deserialization && params.target->IsJSFunction()) { Address root_register_value, Address new_target, Address target,
PrintDeserializedCodeInfo(Handle<JSFunction>::cast(params.target)); Address receiver, intptr_t argc, Address** argv)>;
// clang-format on
JSEntryFunction stub_entry =
JSEntryFunction::FromAddress(isolate, code->InstructionStart());
Address orig_func = params.new_target->ptr();
Address func = params.target->ptr();
Address recv = params.receiver->ptr();
Address** argv = reinterpret_cast<Address**>(params.argv);
if (FLAG_profile_deserialization && params.target->IsJSFunction()) {
PrintDeserializedCodeInfo(Handle<JSFunction>::cast(params.target));
}
RuntimeCallTimerScope timer(isolate, RuntimeCallCounterId::kJS_Execution);
value = Object(stub_entry.Call(isolate->isolate_data()->isolate_root(),
orig_func, func, recv, params.argc, argv));
} else {
DCHECK_EQ(Execution::Target::kRunMicrotasks, params.execution_target);
// clang-format off
// return value: tagged pointers
// {microtask_queue}: pointer to a C++ object
using JSEntryFunction = GeneratedCode<Address(
Address root_register_value, MicrotaskQueue* microtask_queue)>;
// clang-format on
JSEntryFunction stub_entry =
JSEntryFunction::FromAddress(isolate, code->InstructionStart());
RuntimeCallTimerScope timer(isolate, RuntimeCallCounterId::kJS_Execution);
value = Object(stub_entry.Call(isolate->isolate_data()->isolate_root(),
params.microtask_queue));
} }
RuntimeCallTimerScope timer(isolate, RuntimeCallCounterId::kJS_Execution);
value = Object(stub_entry.Call(isolate->isolate_data()->isolate_root(),
orig_func, func, recv, params.argc, argv));
} }
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
......
...@@ -17,12 +17,19 @@ class EntryFrameConstants : public AllStatic { ...@@ -17,12 +17,19 @@ 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;
// EntryFrame is used by JSEntry, JSConstructEntry and JSRunMicrotasksEntry.
// All of them take |root_register_value| as the first parameter.
static constexpr int kRootRegisterValueOffset = +2 * kPointerSize; static constexpr int kRootRegisterValueOffset = +2 * kPointerSize;
// Rest of parameters passed to JSEntry and JSConstructEntry.
static constexpr int kNewTargetArgOffset = +3 * kPointerSize; static constexpr int kNewTargetArgOffset = +3 * kPointerSize;
static constexpr int kFunctionArgOffset = +4 * kPointerSize; static constexpr int kFunctionArgOffset = +4 * kPointerSize;
static constexpr int kReceiverArgOffset = +5 * kPointerSize; static constexpr int kReceiverArgOffset = +5 * kPointerSize;
static constexpr int kArgcOffset = +6 * kPointerSize; static constexpr int kArgcOffset = +6 * kPointerSize;
static constexpr int kArgvOffset = +7 * kPointerSize; static constexpr int kArgvOffset = +7 * kPointerSize;
// Rest of parameters passed to JSRunMicrotasksEntry.
static constexpr int kMicrotaskQueueArgOffset = +3 * kPointerSize;
}; };
class ExitFrameConstants : public TypedFrameConstants { class ExitFrameConstants : public TypedFrameConstants {
......
...@@ -386,6 +386,17 @@ void CloneObjectWithVectorDescriptor::InitializePlatformSpecific( ...@@ -386,6 +386,17 @@ void CloneObjectWithVectorDescriptor::InitializePlatformSpecific(
DefaultInitializePlatformSpecific(data, kParameterCount); DefaultInitializePlatformSpecific(data, kParameterCount);
} }
// static
Register RunMicrotasksDescriptor::MicrotaskQueueRegister() {
return CallDescriptors::call_descriptor_data(CallDescriptors::RunMicrotasks)
->register_param(0);
}
void RunMicrotasksDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
DefaultInitializePlatformSpecific(data, kParameterCount);
}
void BigIntToWasmI64Descriptor::InitializePlatformSpecific( void BigIntToWasmI64Descriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
DefaultInitializePlatformSpecific(data, kParameterCount); DefaultInitializePlatformSpecific(data, kParameterCount);
......
...@@ -1107,8 +1107,11 @@ class FrameDropperTrampolineDescriptor final : public CallInterfaceDescriptor { ...@@ -1107,8 +1107,11 @@ class FrameDropperTrampolineDescriptor final : public CallInterfaceDescriptor {
class RunMicrotasksDescriptor final : public CallInterfaceDescriptor { class RunMicrotasksDescriptor final : public CallInterfaceDescriptor {
public: public:
DEFINE_PARAMETERS() DEFINE_PARAMETERS(kMicrotaskQueue)
DECLARE_DEFAULT_DESCRIPTOR(RunMicrotasksDescriptor, CallInterfaceDescriptor) DEFINE_PARAMETER_TYPES(MachineType::Pointer())
DECLARE_DESCRIPTOR(RunMicrotasksDescriptor, CallInterfaceDescriptor)
static Register MicrotaskQueueRegister();
}; };
class WasmMemoryGrowDescriptor final : public CallInterfaceDescriptor { class WasmMemoryGrowDescriptor final : public CallInterfaceDescriptor {
......
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