| 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 3246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3257 stack_trace = GetDetailedStackTrace(Handle<JSObject>::cast(value)); | 3257 stack_trace = GetDetailedStackTrace(Handle<JSObject>::cast(value)); |
| 3258 } | 3258 } |
| 3259 promise_reject_callback_(v8::PromiseRejectMessage( | 3259 promise_reject_callback_(v8::PromiseRejectMessage( |
| 3260 v8::Utils::PromiseToLocal(promise), event, v8::Utils::ToLocal(value), | 3260 v8::Utils::PromiseToLocal(promise), event, v8::Utils::ToLocal(value), |
| 3261 v8::Utils::StackTraceToLocal(stack_trace))); | 3261 v8::Utils::StackTraceToLocal(stack_trace))); |
| 3262 } | 3262 } |
| 3263 | 3263 |
| 3264 namespace { | 3264 namespace { |
| 3265 class PromiseDebugEventScope { | 3265 class PromiseDebugEventScope { |
| 3266 public: | 3266 public: |
| 3267 PromiseDebugEventScope(Isolate* isolate, int id, int name) | 3267 PromiseDebugEventScope(Isolate* isolate, int id) |
| 3268 : isolate_(isolate), | 3268 : isolate_(isolate), id_(id) { |
| 3269 id_(id), | 3269 if (isolate_->debug()->is_active() && id_ != kDebugPromiseNoID) { |
| 3270 name_(static_cast<PromiseDebugActionName>(name)), | 3270 isolate_->debug()->OnAsyncTaskEvent(debug::kDebugWillHandle, id_); |
| 3271 is_debug_active_(isolate_->debug()->is_active() && | |
| 3272 id != kDebugPromiseNoID && name_ != kDebugNotActive) { | |
| 3273 if (is_debug_active_) { | |
| 3274 isolate_->debug()->OnAsyncTaskEvent(debug::kDebugWillHandle, id_, name_); | |
| 3275 } | 3271 } |
| 3276 } | 3272 } |
| 3277 | 3273 |
| 3278 ~PromiseDebugEventScope() { | 3274 ~PromiseDebugEventScope() { |
| 3279 if (is_debug_active_) { | 3275 if (isolate_->debug()->is_active() && id_ != kDebugPromiseNoID) { |
| 3280 isolate_->debug()->OnAsyncTaskEvent(debug::kDebugDidHandle, id_, name_); | 3276 isolate_->debug()->OnAsyncTaskEvent(debug::kDebugDidHandle, id_); |
| 3281 } | 3277 } |
| 3282 } | 3278 } |
| 3283 | 3279 |
| 3284 private: | 3280 private: |
| 3285 Isolate* isolate_; | 3281 Isolate* isolate_; |
| 3286 int id_; | 3282 int id_; |
| 3287 PromiseDebugActionName name_; | |
| 3288 bool is_debug_active_; | |
| 3289 }; | 3283 }; |
| 3290 } // namespace | 3284 } // namespace |
| 3291 | 3285 |
| 3292 void Isolate::PromiseReactionJob(Handle<PromiseReactionJobInfo> info, | 3286 void Isolate::PromiseReactionJob(Handle<PromiseReactionJobInfo> info, |
| 3293 MaybeHandle<Object>* result, | 3287 MaybeHandle<Object>* result, |
| 3294 MaybeHandle<Object>* maybe_exception) { | 3288 MaybeHandle<Object>* maybe_exception) { |
| 3295 PromiseDebugEventScope helper(this, info->debug_id(), info->debug_name()); | 3289 PromiseDebugEventScope helper(this, info->debug_id()); |
| 3296 | 3290 |
| 3297 Handle<Object> value(info->value(), this); | 3291 Handle<Object> value(info->value(), this); |
| 3298 Handle<Object> tasks(info->tasks(), this); | 3292 Handle<Object> tasks(info->tasks(), this); |
| 3299 Handle<JSFunction> promise_handle_fn = promise_handle(); | 3293 Handle<JSFunction> promise_handle_fn = promise_handle(); |
| 3300 Handle<Object> undefined = factory()->undefined_value(); | 3294 Handle<Object> undefined = factory()->undefined_value(); |
| 3301 Handle<Object> deferred_promise(info->deferred_promise(), this); | 3295 Handle<Object> deferred_promise(info->deferred_promise(), this); |
| 3302 | 3296 |
| 3303 if (deferred_promise->IsFixedArray()) { | 3297 if (deferred_promise->IsFixedArray()) { |
| 3304 DCHECK(tasks->IsFixedArray()); | 3298 DCHECK(tasks->IsFixedArray()); |
| 3305 Handle<FixedArray> deferred_promise_arr = | 3299 Handle<FixedArray> deferred_promise_arr = |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3326 handle(info->deferred_on_resolve(), this), | 3320 handle(info->deferred_on_resolve(), this), |
| 3327 handle(info->deferred_on_reject(), this)}; | 3321 handle(info->deferred_on_reject(), this)}; |
| 3328 *result = Execution::TryCall(this, promise_handle_fn, undefined, | 3322 *result = Execution::TryCall(this, promise_handle_fn, undefined, |
| 3329 arraysize(argv), argv, maybe_exception); | 3323 arraysize(argv), argv, maybe_exception); |
| 3330 } | 3324 } |
| 3331 } | 3325 } |
| 3332 | 3326 |
| 3333 void Isolate::PromiseResolveThenableJob( | 3327 void Isolate::PromiseResolveThenableJob( |
| 3334 Handle<PromiseResolveThenableJobInfo> info, MaybeHandle<Object>* result, | 3328 Handle<PromiseResolveThenableJobInfo> info, MaybeHandle<Object>* result, |
| 3335 MaybeHandle<Object>* maybe_exception) { | 3329 MaybeHandle<Object>* maybe_exception) { |
| 3336 PromiseDebugEventScope helper(this, info->debug_id(), info->debug_name()); | 3330 PromiseDebugEventScope helper(this, info->debug_id()); |
| 3337 | 3331 |
| 3338 Handle<JSReceiver> thenable(info->thenable(), this); | 3332 Handle<JSReceiver> thenable(info->thenable(), this); |
| 3339 Handle<JSFunction> resolve(info->resolve(), this); | 3333 Handle<JSFunction> resolve(info->resolve(), this); |
| 3340 Handle<JSFunction> reject(info->reject(), this); | 3334 Handle<JSFunction> reject(info->reject(), this); |
| 3341 Handle<JSReceiver> then(info->then(), this); | 3335 Handle<JSReceiver> then(info->then(), this); |
| 3342 Handle<Object> argv[] = {resolve, reject}; | 3336 Handle<Object> argv[] = {resolve, reject}; |
| 3343 *result = Execution::TryCall(this, then, thenable, arraysize(argv), argv, | 3337 *result = Execution::TryCall(this, then, thenable, arraysize(argv), argv, |
| 3344 maybe_exception); | 3338 maybe_exception); |
| 3345 | 3339 |
| 3346 Handle<Object> reason; | 3340 Handle<Object> reason; |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3657 // Then check whether this scope intercepts. | 3651 // Then check whether this scope intercepts. |
| 3658 if ((flag & intercept_mask_)) { | 3652 if ((flag & intercept_mask_)) { |
| 3659 intercepted_flags_ |= flag; | 3653 intercepted_flags_ |= flag; |
| 3660 return true; | 3654 return true; |
| 3661 } | 3655 } |
| 3662 return false; | 3656 return false; |
| 3663 } | 3657 } |
| 3664 | 3658 |
| 3665 } // namespace internal | 3659 } // namespace internal |
| 3666 } // namespace v8 | 3660 } // namespace v8 |
| OLD | NEW |