Commit 5a36af3c authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[promises] Fix fast path in Promise.resolve

The receiver in the case of Promise.resolve is the promise
constructor, not an instance of Promise.

BUG=chromium:691875

Change-Id: I43e914aac51077b28c7954c8023780b9174df825
Reviewed-on: https://chromium-review.googlesource.com/450884Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43648}
parent 7c0f3f06
......@@ -1393,6 +1393,10 @@ TF_BUILTIN(PromiseResolve, PromiseBuiltinsAssembler) {
ThrowIfNotJSReceiver(context, receiver, MessageTemplate::kCalledOnNonObject,
"PromiseResolve");
Node* const native_context = LoadNativeContext(context);
Node* const promise_fun =
LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX);
Label if_valueisnativepromise(this), if_valueisnotnativepromise(this),
if_valueisnotpromise(this);
......@@ -1404,9 +1408,6 @@ TF_BUILTIN(PromiseResolve, PromiseBuiltinsAssembler) {
// This adds a fast path as non-subclassed native promises don't have
// an observable constructor lookup.
Node* const native_context = LoadNativeContext(context);
Node* const promise_fun =
LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX);
BranchIfFastPath(native_context, promise_fun, value, &if_valueisnativepromise,
&if_valueisnotnativepromise);
......@@ -1437,15 +1438,13 @@ TF_BUILTIN(PromiseResolve, PromiseBuiltinsAssembler) {
Bind(&if_valueisnotpromise);
{
Label if_nativepromise(this), if_notnativepromise(this);
BranchIfFastPath(context, receiver, &if_nativepromise,
&if_notnativepromise);
Branch(WordEqual(promise_fun, receiver), &if_nativepromise,
&if_notnativepromise);
// This adds a fast path for native promises that don't need to
// create NewPromiseCapability.
Bind(&if_nativepromise);
{
Label do_resolve(this);
Node* const result = AllocateAndInitJSPromise(context);
InternalResolvePromise(context, result, value);
Return(result);
......
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