Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Unified Diff: src/builtins/builtins-promise.cc

Issue 2614603003: [promises] Move PromiseFulfill to TF (Closed)
Patch Set: rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/builtins/builtins-promise.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-promise.cc
diff --git a/src/builtins/builtins-promise.cc b/src/builtins/builtins-promise.cc
index d07598661e3da2269fa4469ff5c84309b62125c6..564fbaf54ccbcb1017a812c14ad80dad3875a6d6 100644
--- a/src/builtins/builtins-promise.cc
+++ b/src/builtins/builtins-promise.cc
@@ -685,8 +685,8 @@ void PromiseBuiltinsAssembler::InternalResolvePromise(Node* context,
Bind(&if_fulfilled);
{
- CallRuntime(Runtime::kPromiseFulfill, context, promise,
- SmiConstant(v8::Promise::kFulfilled), thenable_value);
+ PromiseFulfill(context, promise, thenable_value,
+ v8::Promise::kFulfilled);
PromiseSetHasHandler(promise);
Goto(&out);
}
@@ -757,8 +757,7 @@ void PromiseBuiltinsAssembler::InternalResolvePromise(Node* context,
// 7.b Return FulfillPromise(promise, resolution).
Bind(&fulfill);
{
- CallRuntime(Runtime::kPromiseFulfill, context, promise,
- SmiConstant(v8::Promise::kFulfilled), result);
+ PromiseFulfill(context, promise, result, v8::Promise::kFulfilled);
Goto(&out);
}
@@ -785,6 +784,50 @@ void PromiseBuiltinsAssembler::InternalResolvePromise(Node* context,
Bind(&out);
}
+void PromiseBuiltinsAssembler::PromiseFulfill(
+ Node* context, Node* promise, Node* result,
+ v8::Promise::PromiseState status) {
+ Label do_promisereset(this);
+
+ Node* const status_smi = SmiConstant(static_cast<int>(status));
+ Node* const deferred_promise =
+ LoadObjectField(promise, JSPromise::kDeferredPromiseOffset);
+
+ GotoIf(IsUndefined(deferred_promise), &do_promisereset);
+
+ Node* const tasks =
+ status == v8::Promise::kFulfilled
+ ? LoadObjectField(promise, JSPromise::kFulfillReactionsOffset)
+ : LoadObjectField(promise, JSPromise::kRejectReactionsOffset);
+
+ Node* const deferred_on_resolve =
+ LoadObjectField(promise, JSPromise::kDeferredOnResolveOffset);
+ Node* const deferred_on_reject =
+ LoadObjectField(promise, JSPromise::kDeferredOnRejectOffset);
+
+ Node* const info = AllocatePromiseReactionJobInfo(
+ promise, result, tasks, deferred_promise, deferred_on_resolve,
+ deferred_on_reject, context);
+ CallRuntime(Runtime::kEnqueuePromiseReactionJob, context, info, status_smi);
+ Goto(&do_promisereset);
+
+ Bind(&do_promisereset);
+ {
+ StoreObjectField(promise, JSPromise::kStatusOffset, status_smi);
+ StoreObjectField(promise, JSPromise::kResultOffset, result);
+ StoreObjectFieldRoot(promise, JSPromise::kDeferredPromiseOffset,
+ Heap::kUndefinedValueRootIndex);
+ StoreObjectFieldRoot(promise, JSPromise::kDeferredOnResolveOffset,
+ Heap::kUndefinedValueRootIndex);
+ StoreObjectFieldRoot(promise, JSPromise::kDeferredOnRejectOffset,
+ Heap::kUndefinedValueRootIndex);
+ StoreObjectFieldRoot(promise, JSPromise::kFulfillReactionsOffset,
+ Heap::kUndefinedValueRootIndex);
+ StoreObjectFieldRoot(promise, JSPromise::kRejectReactionsOffset,
+ Heap::kUndefinedValueRootIndex);
+ }
+}
+
// ES#sec-promise-reject-functions
// Promise Reject Functions
BUILTIN(PromiseRejectClosure) {
« no previous file with comments | « src/builtins/builtins-promise.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698