Commit 849a3790 authored by tzik's avatar tzik Committed by Commit Bot

Consolidate preparation of Microtask to a function

This CL factors out the preparation of Microtask to a function, so that
we don't miss the common set up for new types of Microtasks.

Bug: v8:8124
Change-Id: I5e1e46b368dfc3d28a5d0a97d0f47e0479d600f4
Reviewed-on: https://chromium-review.googlesource.com/c/1423981Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59151}
parent 50ac6264
......@@ -33,6 +33,8 @@ class MicrotaskQueueBuiltinsAssembler : public CodeStubAssembler {
TNode<IntPtrT> CalculateRingBufferOffset(TNode<IntPtrT> capacity,
TNode<IntPtrT> start,
TNode<IntPtrT> index);
void PrepareForContext(TNode<Context> microtask_context);
void RunSingleMicrotask(TNode<Context> current_context,
TNode<Microtask> microtask);
void IncrementFinishedMicrotaskCount(TNode<RawPtrT> microtask_queue);
......@@ -101,6 +103,13 @@ TNode<IntPtrT> MicrotaskQueueBuiltinsAssembler::CalculateRingBufferOffset(
WordAnd(IntPtrAdd(start, index), IntPtrSub(capacity, IntPtrConstant(1))));
}
void MicrotaskQueueBuiltinsAssembler::PrepareForContext(
TNode<Context> native_context) {
CSA_ASSERT(this, IsNativeContext(native_context));
EnterMicrotaskContext(native_context);
SetCurrentContext(native_context);
}
void MicrotaskQueueBuiltinsAssembler::RunSingleMicrotask(
TNode<Context> current_context, TNode<Microtask> microtask) {
CSA_ASSERT(this, TaggedIsNotSmi(microtask));
......@@ -140,10 +149,7 @@ void MicrotaskQueueBuiltinsAssembler::RunSingleMicrotask(
TNode<Context> microtask_context =
LoadObjectField<Context>(microtask, CallableTask::kContextOffset);
TNode<Context> native_context = LoadNativeContext(microtask_context);
CSA_ASSERT(this, IsNativeContext(native_context));
EnterMicrotaskContext(native_context);
SetCurrentContext(native_context);
PrepareForContext(native_context);
TNode<JSReceiver> callable =
LoadObjectField<JSReceiver>(microtask, CallableTask::kCallableOffset);
......@@ -186,9 +192,7 @@ void MicrotaskQueueBuiltinsAssembler::RunSingleMicrotask(
TNode<Context> microtask_context = LoadObjectField<Context>(
microtask, PromiseResolveThenableJobTask::kContextOffset);
TNode<Context> native_context = LoadNativeContext(microtask_context);
CSA_ASSERT(this, IsNativeContext(native_context));
EnterMicrotaskContext(native_context);
SetCurrentContext(native_context);
PrepareForContext(native_context);
Node* const promise_to_resolve = LoadObjectField(
microtask, PromiseResolveThenableJobTask::kPromiseToResolveOffset);
......@@ -212,9 +216,7 @@ void MicrotaskQueueBuiltinsAssembler::RunSingleMicrotask(
TNode<Context> microtask_context = LoadObjectField<Context>(
microtask, PromiseReactionJobTask::kContextOffset);
TNode<Context> native_context = LoadNativeContext(microtask_context);
CSA_ASSERT(this, IsNativeContext(native_context));
EnterMicrotaskContext(native_context);
SetCurrentContext(native_context);
PrepareForContext(native_context);
Node* const argument =
LoadObjectField(microtask, PromiseReactionJobTask::kArgumentOffset);
......@@ -247,9 +249,7 @@ void MicrotaskQueueBuiltinsAssembler::RunSingleMicrotask(
TNode<Context> microtask_context = LoadObjectField<Context>(
microtask, PromiseReactionJobTask::kContextOffset);
TNode<Context> native_context = LoadNativeContext(microtask_context);
CSA_ASSERT(this, IsNativeContext(native_context));
EnterMicrotaskContext(native_context);
SetCurrentContext(native_context);
PrepareForContext(native_context);
Node* const argument =
LoadObjectField(microtask, PromiseReactionJobTask::kArgumentOffset);
......@@ -283,9 +283,7 @@ void MicrotaskQueueBuiltinsAssembler::RunSingleMicrotask(
microtask, WeakFactoryCleanupJobTask::kFactoryOffset);
TNode<Context> native_context = LoadObjectField<Context>(
weak_factory, JSWeakFactory::kNativeContextOffset);
CSA_ASSERT(this, IsNativeContext(native_context));
EnterMicrotaskContext(native_context);
SetCurrentContext(native_context);
PrepareForContext(native_context);
Node* const result = CallRuntime(Runtime::kWeakFactoryCleanupJob,
native_context, weak_factory);
......
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