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

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

Issue 2554323003: [promises] Don't allocate new array before filling up existing array (Closed)
Patch Set: 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 | « no previous file | no next file » | 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 e2888c3e1b403788e768362cd4e53d1948794778..b7a93a517f253422eeeaef9f0635e97b79141053 100644
--- a/src/builtins/builtins-promise.cc
+++ b/src/builtins/builtins-promise.cc
@@ -479,26 +479,25 @@ compiler::Node* InternalPerformPromiseThen(CodeStubAssembler* a,
a->Bind(&if_singlecallback);
{
- // Create new FixedArrays to store callbacks.
+ // Create new FixedArrays to store callbacks, and migrate
+ // existing callbacks.
Node* const deferreds =
a->AllocateFixedArray(FAST_ELEMENTS, a->Int32Constant(2));
+ a->StoreFixedArrayElement(deferreds, 0, existing_deferred);
+ a->StoreFixedArrayElement(deferreds, 1, deferred);
+
Node* const fulfill_reactions =
a->AllocateFixedArray(FAST_ELEMENTS, a->Int32Constant(2));
- Node* const reject_reactions =
- a->AllocateFixedArray(FAST_ELEMENTS, a->Int32Constant(2));
-
- // Store existing callbacks in FixedArrays.
- a->StoreFixedArrayElement(deferreds, 0, existing_deferred);
a->StoreFixedArrayElement(
fulfill_reactions, 0,
a->LoadObjectField(promise, JSPromise::kFulfillReactionsOffset));
+ a->StoreFixedArrayElement(fulfill_reactions, 1, var_on_resolve.value());
+
+ Node* const reject_reactions =
+ a->AllocateFixedArray(FAST_ELEMENTS, a->Int32Constant(2));
a->StoreFixedArrayElement(
reject_reactions, 0,
a->LoadObjectField(promise, JSPromise::kRejectReactionsOffset));
-
- // Store new callbacks in FixedArrays.
- a->StoreFixedArrayElement(deferreds, 1, deferred);
- a->StoreFixedArrayElement(fulfill_reactions, 1, var_on_resolve.value());
a->StoreFixedArrayElement(reject_reactions, 1, var_on_reject.value());
// Store new FixedArrays in promise.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698