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

Unified Diff: src/code-stub-assembler.cc

Issue 2571663002: [promises] Refactor CreatePromise (Closed)
Patch Set: rename to allocatejspromise Created 4 years 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/code-stub-assembler.h ('k') | test/cctest/test-code-stub-assembler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stub-assembler.cc
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc
index c6d79716a57a827279d3700c7c26e6ea72e8cafa..11568bf29b8f7a22c02b60af568d12fcee9f2975 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -8245,5 +8245,29 @@ Node* CodeStubAssembler::IsPromiseHookEnabled() {
return WordNotEqual(is_promisehook_enabled, Int32Constant(0));
}
+Node* CodeStubAssembler::AllocateJSPromise(Node* context) {
+ Node* const native_context = LoadNativeContext(context);
+ Node* const promise_fun =
+ LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX);
+ Node* const initial_map =
+ LoadObjectField(promise_fun, JSFunction::kPrototypeOrInitialMapOffset);
+ Node* const instance = AllocateJSObjectFromMap(initial_map);
+
+ return instance;
+}
+
+void CodeStubAssembler::PromiseInit(Node* promise) {
+ StoreObjectField(promise, JSPromise::kStatusOffset,
+ SmiConstant(kPromisePending));
+ StoreObjectField(promise, JSPromise::kFlagsOffset, SmiConstant(0));
+}
+
+void CodeStubAssembler::PromiseSet(Node* promise, Node* status, Node* result) {
+ CSA_ASSERT(this, TaggedIsSmi(status));
+ StoreObjectField(promise, JSPromise::kStatusOffset, status);
+ StoreObjectField(promise, JSPromise::kResultOffset, result);
+ StoreObjectField(promise, JSPromise::kFlagsOffset, SmiConstant(0));
+}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/code-stub-assembler.h ('k') | test/cctest/test-code-stub-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698