OLD | NEW |
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 3277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3288 PromiseDebugActionName name_; | 3288 PromiseDebugActionName name_; |
3289 bool is_debug_active_; | 3289 bool is_debug_active_; |
3290 }; | 3290 }; |
3291 } // namespace | 3291 } // namespace |
3292 | 3292 |
3293 void Isolate::PromiseReactionJob(Handle<PromiseReactionJobInfo> info, | 3293 void Isolate::PromiseReactionJob(Handle<PromiseReactionJobInfo> info, |
3294 MaybeHandle<Object>* result, | 3294 MaybeHandle<Object>* result, |
3295 MaybeHandle<Object>* maybe_exception) { | 3295 MaybeHandle<Object>* maybe_exception) { |
3296 PromiseDebugEventScope helper(this, info->debug_id(), info->debug_name()); | 3296 PromiseDebugEventScope helper(this, info->debug_id(), info->debug_name()); |
3297 | 3297 |
3298 Handle<JSPromise> promise(info->promise(), this); | |
3299 Handle<Object> value(info->value(), this); | 3298 Handle<Object> value(info->value(), this); |
3300 Handle<Object> tasks(info->tasks(), this); | 3299 Handle<Object> tasks(info->tasks(), this); |
3301 Handle<JSFunction> promise_handle_fn = promise_handle(); | 3300 Handle<JSFunction> promise_handle_fn = promise_handle(); |
3302 Handle<Object> undefined = factory()->undefined_value(); | 3301 Handle<Object> undefined = factory()->undefined_value(); |
3303 Handle<Object> deferred_promise(info->deferred_promise(), this); | 3302 Handle<Object> deferred_promise(info->deferred_promise(), this); |
3304 | 3303 |
3305 if (deferred_promise->IsFixedArray()) { | 3304 if (deferred_promise->IsFixedArray()) { |
3306 DCHECK(tasks->IsFixedArray()); | 3305 DCHECK(tasks->IsFixedArray()); |
3307 Handle<FixedArray> deferred_promise_arr = | 3306 Handle<FixedArray> deferred_promise_arr = |
3308 Handle<FixedArray>::cast(deferred_promise); | 3307 Handle<FixedArray>::cast(deferred_promise); |
3309 Handle<FixedArray> deferred_on_resolve_arr( | 3308 Handle<FixedArray> deferred_on_resolve_arr( |
3310 FixedArray::cast(info->deferred_on_resolve()), this); | 3309 FixedArray::cast(info->deferred_on_resolve()), this); |
3311 Handle<FixedArray> deferred_on_reject_arr( | 3310 Handle<FixedArray> deferred_on_reject_arr( |
3312 FixedArray::cast(info->deferred_on_reject()), this); | 3311 FixedArray::cast(info->deferred_on_reject()), this); |
3313 Handle<FixedArray> tasks_arr = Handle<FixedArray>::cast(tasks); | 3312 Handle<FixedArray> tasks_arr = Handle<FixedArray>::cast(tasks); |
3314 for (int i = 0; i < deferred_promise_arr->length(); i++) { | 3313 for (int i = 0; i < deferred_promise_arr->length(); i++) { |
3315 Handle<Object> argv[] = {promise, | 3314 Handle<Object> argv[] = {value, handle(tasks_arr->get(i), this), |
3316 value, | |
3317 handle(tasks_arr->get(i), this), | |
3318 handle(deferred_promise_arr->get(i), this), | 3315 handle(deferred_promise_arr->get(i), this), |
3319 handle(deferred_on_resolve_arr->get(i), this), | 3316 handle(deferred_on_resolve_arr->get(i), this), |
3320 handle(deferred_on_reject_arr->get(i), this)}; | 3317 handle(deferred_on_reject_arr->get(i), this)}; |
3321 *result = Execution::TryCall(this, promise_handle_fn, undefined, | 3318 *result = Execution::TryCall(this, promise_handle_fn, undefined, |
3322 arraysize(argv), argv, maybe_exception); | 3319 arraysize(argv), argv, maybe_exception); |
3323 // If execution is terminating, just bail out. | 3320 // If execution is terminating, just bail out. |
3324 if (result->is_null() && maybe_exception->is_null()) { | 3321 if (result->is_null() && maybe_exception->is_null()) { |
3325 return; | 3322 return; |
3326 } | 3323 } |
3327 } | 3324 } |
3328 } else { | 3325 } else { |
3329 Handle<Object> argv[] = {promise, | 3326 Handle<Object> argv[] = {value, tasks, deferred_promise, |
3330 value, | |
3331 tasks, | |
3332 deferred_promise, | |
3333 handle(info->deferred_on_resolve(), this), | 3327 handle(info->deferred_on_resolve(), this), |
3334 handle(info->deferred_on_reject(), this)}; | 3328 handle(info->deferred_on_reject(), this)}; |
3335 *result = Execution::TryCall(this, promise_handle_fn, undefined, | 3329 *result = Execution::TryCall(this, promise_handle_fn, undefined, |
3336 arraysize(argv), argv, maybe_exception); | 3330 arraysize(argv), argv, maybe_exception); |
3337 } | 3331 } |
3338 } | 3332 } |
3339 | 3333 |
3340 void Isolate::PromiseResolveThenableJob( | 3334 void Isolate::PromiseResolveThenableJob( |
3341 Handle<PromiseResolveThenableJobInfo> info, MaybeHandle<Object>* result, | 3335 Handle<PromiseResolveThenableJobInfo> info, MaybeHandle<Object>* result, |
3342 MaybeHandle<Object>* maybe_exception) { | 3336 MaybeHandle<Object>* maybe_exception) { |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3663 // Then check whether this scope intercepts. | 3657 // Then check whether this scope intercepts. |
3664 if ((flag & intercept_mask_)) { | 3658 if ((flag & intercept_mask_)) { |
3665 intercepted_flags_ |= flag; | 3659 intercepted_flags_ |= flag; |
3666 return true; | 3660 return true; |
3667 } | 3661 } |
3668 return false; | 3662 return false; |
3669 } | 3663 } |
3670 | 3664 |
3671 } // namespace internal | 3665 } // namespace internal |
3672 } // namespace v8 | 3666 } // namespace v8 |
OLD | NEW |