Commit 6bcf57ef authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[builtins] Refactor reaction job allocation in PerformPromiseThen.

Reduce the code duplication overhead in the InternalPerformPromiseThen
helper, which saves quite a bit of space and makes code more concise and
readable.

Bug: v8:7253, v8:7310
Change-Id: I64d11661d7258ced32df564d2e83c5ea45955415
Reviewed-on: https://chromium-review.googlesource.com/880722Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50800}
parent 7900db4f
......@@ -487,36 +487,33 @@ Node* PromiseBuiltinsAssembler::InternalPerformPromiseThen(
BIND(&fulfilled_check);
{
Label reject(this);
Node* const result = LoadObjectField(promise, JSPromise::kResultOffset);
GotoIfNot(IsPromiseStatus(status, v8::Promise::kFulfilled), &reject);
Label fulfilled(this), rejected(this, Label::kDeferred), enqueue(this);
VARIABLE(var_tasks, MachineRepresentation::kTagged);
Branch(IsPromiseStatus(status, v8::Promise::kFulfilled), &fulfilled,
&rejected);
Node* info = AllocatePromiseReactionJobInfo(
result, var_on_resolve.value(), deferred_promise, deferred_on_resolve,
deferred_on_reject, context);
CallBuiltin(Builtins::kEnqueueMicrotask, NoContextConstant(), info);
Goto(&out);
BIND(&fulfilled);
{
var_tasks.Bind(var_on_resolve.value());
Goto(&enqueue);
}
BIND(&reject);
BIND(&rejected);
{
CSA_ASSERT(this, IsPromiseStatus(status, v8::Promise::kRejected));
Node* const has_handler = PromiseHasHandler(promise);
Label enqueue(this);
// TODO(gsathya): Fold these runtime calls and move to TF.
GotoIf(has_handler, &enqueue);
var_tasks.Bind(var_on_reject.value());
GotoIf(PromiseHasHandler(promise), &enqueue);
CallRuntime(Runtime::kPromiseRevokeReject, context, promise);
Goto(&enqueue);
BIND(&enqueue);
{
Node* info = AllocatePromiseReactionJobInfo(
result, var_on_reject.value(), deferred_promise,
deferred_on_resolve, deferred_on_reject, context);
CallBuiltin(Builtins::kEnqueueMicrotask, NoContextConstant(), info);
Goto(&out);
}
}
BIND(&enqueue);
Node* result = LoadObjectField(promise, JSPromise::kResultOffset);
Node* info = AllocatePromiseReactionJobInfo(
result, var_tasks.value(), deferred_promise, deferred_on_resolve,
deferred_on_reject, context);
CallBuiltin(Builtins::kEnqueueMicrotask, NoContextConstant(), info);
Goto(&out);
}
}
......
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