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

Side by Side Diff: src/isolate.cc

Issue 2590563003: [promises] Remove deferred object (Closed)
Patch Set: add comments Created 3 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/isolate.h" 5 #include "src/isolate.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <fstream> // NOLINT(readability/streams) 9 #include <fstream> // NOLINT(readability/streams)
10 #include <sstream> 10 #include <sstream>
(...skipping 3218 matching lines...) Expand 10 before | Expand all | Expand 10 after
3229 void Isolate::PromiseReactionJob(Handle<PromiseReactionJobInfo> info, 3229 void Isolate::PromiseReactionJob(Handle<PromiseReactionJobInfo> info,
3230 MaybeHandle<Object>* result, 3230 MaybeHandle<Object>* result,
3231 MaybeHandle<Object>* maybe_exception) { 3231 MaybeHandle<Object>* maybe_exception) {
3232 PromiseDebugEventScope helper(this, info->debug_id(), info->debug_name()); 3232 PromiseDebugEventScope helper(this, info->debug_id(), info->debug_name());
3233 3233
3234 Handle<JSPromise> promise(info->promise(), this); 3234 Handle<JSPromise> promise(info->promise(), this);
3235 Handle<Object> value(info->value(), this); 3235 Handle<Object> value(info->value(), this);
3236 Handle<Object> tasks(info->tasks(), this); 3236 Handle<Object> tasks(info->tasks(), this);
3237 Handle<JSFunction> promise_handle_fn = promise_handle(); 3237 Handle<JSFunction> promise_handle_fn = promise_handle();
3238 Handle<Object> undefined = factory()->undefined_value(); 3238 Handle<Object> undefined = factory()->undefined_value();
3239 Handle<Object> deferred(info->deferred(), this); 3239 Handle<Object> deferred_promise(info->deferred_promise(), this);
3240 3240
3241 if (deferred->IsFixedArray()) { 3241 if (deferred_promise->IsFixedArray()) {
3242 DCHECK(tasks->IsFixedArray()); 3242 DCHECK(tasks->IsFixedArray());
3243 Handle<FixedArray> deferred_arr = Handle<FixedArray>::cast(deferred); 3243 Handle<FixedArray> deferred_promise_arr =
3244 Handle<FixedArray>::cast(deferred_promise);
3245 Handle<FixedArray> deferred_on_resolve_arr(
3246 FixedArray::cast(info->deferred_on_resolve()), this);
3247 Handle<FixedArray> deferred_on_reject_arr(
3248 FixedArray::cast(info->deferred_on_reject()), this);
3244 Handle<FixedArray> tasks_arr = Handle<FixedArray>::cast(tasks); 3249 Handle<FixedArray> tasks_arr = Handle<FixedArray>::cast(tasks);
3245 for (int i = 0; i < deferred_arr->length(); i++) { 3250 for (int i = 0; i < deferred_promise_arr->length(); i++) {
3246 Handle<Object> argv[] = {promise, value, handle(tasks_arr->get(i), this), 3251 Handle<Object> argv[] = {promise,
3247 handle(deferred_arr->get(i), this)}; 3252 value,
3253 handle(tasks_arr->get(i), this),
3254 handle(deferred_promise_arr->get(i), this),
3255 handle(deferred_on_resolve_arr->get(i), this),
3256 handle(deferred_on_reject_arr->get(i), this)};
3248 *result = Execution::TryCall(this, promise_handle_fn, undefined, 3257 *result = Execution::TryCall(this, promise_handle_fn, undefined,
3249 arraysize(argv), argv, maybe_exception); 3258 arraysize(argv), argv, maybe_exception);
3250 // If execution is terminating, just bail out. 3259 // If execution is terminating, just bail out.
3251 if (result->is_null() && maybe_exception->is_null()) { 3260 if (result->is_null() && maybe_exception->is_null()) {
3252 return; 3261 return;
3253 } 3262 }
3254 } 3263 }
3255 } else { 3264 } else {
3256 Handle<Object> argv[] = {promise, value, tasks, deferred}; 3265 Handle<Object> argv[] = {promise,
3266 value,
3267 tasks,
3268 deferred_promise,
3269 handle(info->deferred_on_resolve(), this),
3270 handle(info->deferred_on_reject(), this)};
3257 *result = Execution::TryCall(this, promise_handle_fn, undefined, 3271 *result = Execution::TryCall(this, promise_handle_fn, undefined,
3258 arraysize(argv), argv, maybe_exception); 3272 arraysize(argv), argv, maybe_exception);
3259 } 3273 }
3260 } 3274 }
3261 3275
3262 void Isolate::PromiseResolveThenableJob( 3276 void Isolate::PromiseResolveThenableJob(
3263 Handle<PromiseResolveThenableJobInfo> info, MaybeHandle<Object>* result, 3277 Handle<PromiseResolveThenableJobInfo> info, MaybeHandle<Object>* result,
3264 MaybeHandle<Object>* maybe_exception) { 3278 MaybeHandle<Object>* maybe_exception) {
3265 PromiseDebugEventScope helper(this, info->debug_id(), info->debug_name()); 3279 PromiseDebugEventScope helper(this, info->debug_id(), info->debug_name());
3266 3280
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
3585 // Then check whether this scope intercepts. 3599 // Then check whether this scope intercepts.
3586 if ((flag & intercept_mask_)) { 3600 if ((flag & intercept_mask_)) {
3587 intercepted_flags_ |= flag; 3601 intercepted_flags_ |= flag;
3588 return true; 3602 return true;
3589 } 3603 }
3590 return false; 3604 return false;
3591 } 3605 }
3592 3606
3593 } // namespace internal 3607 } // namespace internal
3594 } // namespace v8 3608 } // namespace v8
OLDNEW
« src/builtins/builtins-promise.cc ('K') | « src/factory.cc ('k') | src/js/async-await.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698