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

Unified Diff: src/isolate.cc

Issue 2554943002: Reland Create JSPromise (patchset #16 id:300001 of https://codereview.chromium.org/2536463002/ )" (Closed)
Patch Set: fix test 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/heap-symbols.h ('k') | src/js/async-await.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index 77e8c6a02aa3401c15fe62b56759691a17ed4e6e..14b9df7b10832feabe95bb2cc10a3dfcd470ef91 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -3182,23 +3182,15 @@ void Isolate::PromiseReactionJob(Handle<PromiseReactionJobInfo> info,
Handle<Object> tasks(info->tasks(), this);
Handle<JSFunction> promise_handle_fn = promise_handle();
Handle<Object> undefined = factory()->undefined_value();
-
- // If tasks is an array we have multiple onFulfilled/onRejected callbacks
- // associated with the promise. The deferred object for each callback
- // is attached to this array as well.
- // Otherwise, there is a single callback and the deferred object is attached
- // directly to PromiseReactionJobInfo.
- if (tasks->IsJSArray()) {
- Handle<JSArray> array = Handle<JSArray>::cast(tasks);
- DCHECK(array->length()->IsSmi());
- int length = Smi::cast(array->length())->value();
- ElementsAccessor* accessor = array->GetElementsAccessor();
- DCHECK(length % 2 == 0);
- for (int i = 0; i < length; i += 2) {
- DCHECK(accessor->HasElement(array, i));
- DCHECK(accessor->HasElement(array, i + 1));
- Handle<Object> argv[] = {value, accessor->Get(array, i),
- accessor->Get(array, i + 1)};
+ Handle<Object> deferred(info->deferred(), this);
+
+ if (deferred->IsFixedArray()) {
+ DCHECK(tasks->IsFixedArray());
+ Handle<FixedArray> deferred_arr = Handle<FixedArray>::cast(deferred);
+ Handle<FixedArray> tasks_arr = Handle<FixedArray>::cast(tasks);
+ for (int i = 0; i < deferred_arr->length(); i++) {
+ Handle<Object> argv[] = {value, handle(tasks_arr->get(i), this),
+ handle(deferred_arr->get(i), this)};
*result = Execution::TryCall(this, promise_handle_fn, undefined,
arraysize(argv), argv, maybe_exception);
// If execution is terminating, just bail out.
@@ -3207,7 +3199,6 @@ void Isolate::PromiseReactionJob(Handle<PromiseReactionJobInfo> info,
}
}
} else {
- Handle<Object> deferred(info->deferred(), this);
Handle<Object> argv[] = {value, tasks, deferred};
*result = Execution::TryCall(this, promise_handle_fn, undefined,
arraysize(argv), argv, maybe_exception);
« no previous file with comments | « src/heap-symbols.h ('k') | src/js/async-await.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698