Chromium Code Reviews| 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 3052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3063 stack_trace = GetDetailedStackTrace(Handle<JSObject>::cast(value)); | 3063 stack_trace = GetDetailedStackTrace(Handle<JSObject>::cast(value)); |
| 3064 } | 3064 } |
| 3065 promise_reject_callback_(v8::PromiseRejectMessage( | 3065 promise_reject_callback_(v8::PromiseRejectMessage( |
| 3066 v8::Utils::PromiseToLocal(promise), event, v8::Utils::ToLocal(value), | 3066 v8::Utils::PromiseToLocal(promise), event, v8::Utils::ToLocal(value), |
| 3067 v8::Utils::StackTraceToLocal(stack_trace))); | 3067 v8::Utils::StackTraceToLocal(stack_trace))); |
| 3068 } | 3068 } |
| 3069 | 3069 |
| 3070 namespace { | 3070 namespace { |
| 3071 class PromiseDebugEventScope { | 3071 class PromiseDebugEventScope { |
| 3072 public: | 3072 public: |
| 3073 PromiseDebugEventScope(Isolate* isolate, Object* before, Object* after) | 3073 PromiseDebugEventScope(Isolate* isolate, Object* id, Object* name) |
| 3074 : isolate_(isolate), | 3074 : isolate_(isolate), |
| 3075 after_(after, isolate_), | 3075 id_(id, isolate_), |
| 3076 name_(name, isolate_), | |
| 3076 is_debug_active_(isolate_->debug()->is_active() && | 3077 is_debug_active_(isolate_->debug()->is_active() && |
| 3077 before->IsJSObject() && after->IsJSObject()) { | 3078 !id_->IsUndefined(isolate_) && |
| 3079 !name_->IsUndefined(isolate_)) { | |
|
gsathya
2016/10/13 21:27:30
I wonder if it'd be better to do a id_->IsNumber()
adamk
2016/10/14 20:34:51
Yeah, that seems better to me.
gsathya
2016/10/14 22:21:27
Done.
| |
| 3078 if (is_debug_active_) { | 3080 if (is_debug_active_) { |
| 3079 isolate_->debug()->OnAsyncTaskEvent( | 3081 isolate_->debug()->OnAsyncTaskEvent( |
| 3080 handle(JSObject::cast(before), isolate_)); | 3082 isolate_->factory()->will_handle_string(), id_, |
| 3083 Handle<String>::cast(name_)); | |
| 3081 } | 3084 } |
| 3082 } | 3085 } |
| 3083 | 3086 |
| 3084 ~PromiseDebugEventScope() { | 3087 ~PromiseDebugEventScope() { |
| 3085 if (is_debug_active_) { | 3088 if (is_debug_active_) { |
| 3086 isolate_->debug()->OnAsyncTaskEvent(Handle<JSObject>::cast(after_)); | 3089 isolate_->debug()->OnAsyncTaskEvent( |
| 3090 isolate_->factory()->did_handle_string(), id_, | |
| 3091 Handle<String>::cast(name_)); | |
| 3087 } | 3092 } |
| 3088 } | 3093 } |
| 3089 | 3094 |
| 3090 private: | 3095 private: |
| 3091 Isolate* isolate_; | 3096 Isolate* isolate_; |
| 3092 Handle<Object> after_; | 3097 Handle<Object> id_; |
| 3098 Handle<Object> name_; | |
| 3093 bool is_debug_active_; | 3099 bool is_debug_active_; |
| 3094 }; | 3100 }; |
| 3095 } // namespace | 3101 } // namespace |
| 3096 | 3102 |
| 3097 void Isolate::PromiseReactionJob(Handle<PromiseReactionJobInfo> info, | 3103 void Isolate::PromiseReactionJob(Handle<PromiseReactionJobInfo> info, |
| 3098 MaybeHandle<Object>* result, | 3104 MaybeHandle<Object>* result, |
| 3099 MaybeHandle<Object>* maybe_exception) { | 3105 MaybeHandle<Object>* maybe_exception) { |
| 3100 PromiseDebugEventScope helper(this, info->before_debug_event(), | 3106 PromiseDebugEventScope helper(this, info->debug_id(), info->debug_name()); |
| 3101 info->after_debug_event()); | |
| 3102 | 3107 |
| 3103 Handle<Object> value(info->value(), this); | 3108 Handle<Object> value(info->value(), this); |
| 3104 Handle<Object> tasks(info->tasks(), this); | 3109 Handle<Object> tasks(info->tasks(), this); |
| 3105 Handle<JSFunction> promise_handle_fn = promise_handle(); | 3110 Handle<JSFunction> promise_handle_fn = promise_handle(); |
| 3106 Handle<Object> undefined = factory()->undefined_value(); | 3111 Handle<Object> undefined = factory()->undefined_value(); |
| 3107 | 3112 |
| 3108 // If tasks is an array we have multiple onFulfilled/onRejected callbacks | 3113 // If tasks is an array we have multiple onFulfilled/onRejected callbacks |
| 3109 // associated with the promise. The deferred object for each callback | 3114 // associated with the promise. The deferred object for each callback |
| 3110 // is attached to this array as well. | 3115 // is attached to this array as well. |
| 3111 // Otherwise, there is a single callback and the deferred object is attached | 3116 // Otherwise, there is a single callback and the deferred object is attached |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 3132 Handle<Object> deferred(info->deferred(), this); | 3137 Handle<Object> deferred(info->deferred(), this); |
| 3133 Handle<Object> argv[] = {value, tasks, deferred}; | 3138 Handle<Object> argv[] = {value, tasks, deferred}; |
| 3134 *result = Execution::TryCall(this, promise_handle_fn, undefined, | 3139 *result = Execution::TryCall(this, promise_handle_fn, undefined, |
| 3135 arraysize(argv), argv, maybe_exception); | 3140 arraysize(argv), argv, maybe_exception); |
| 3136 } | 3141 } |
| 3137 } | 3142 } |
| 3138 | 3143 |
| 3139 void Isolate::PromiseResolveThenableJob( | 3144 void Isolate::PromiseResolveThenableJob( |
| 3140 Handle<PromiseResolveThenableJobInfo> info, MaybeHandle<Object>* result, | 3145 Handle<PromiseResolveThenableJobInfo> info, MaybeHandle<Object>* result, |
| 3141 MaybeHandle<Object>* maybe_exception) { | 3146 MaybeHandle<Object>* maybe_exception) { |
| 3142 PromiseDebugEventScope helper(this, info->before_debug_event(), | 3147 PromiseDebugEventScope helper(this, info->debug_id(), info->debug_name()); |
| 3143 info->after_debug_event()); | |
| 3144 | 3148 |
| 3145 Handle<JSReceiver> thenable(info->thenable(), this); | 3149 Handle<JSReceiver> thenable(info->thenable(), this); |
| 3146 Handle<JSFunction> resolve(info->resolve(), this); | 3150 Handle<JSFunction> resolve(info->resolve(), this); |
| 3147 Handle<JSFunction> reject(info->reject(), this); | 3151 Handle<JSFunction> reject(info->reject(), this); |
| 3148 Handle<JSReceiver> then(info->then(), this); | 3152 Handle<JSReceiver> then(info->then(), this); |
| 3149 Handle<Object> argv[] = {resolve, reject}; | 3153 Handle<Object> argv[] = {resolve, reject}; |
| 3150 *result = Execution::TryCall(this, then, thenable, arraysize(argv), argv, | 3154 *result = Execution::TryCall(this, then, thenable, arraysize(argv), argv, |
| 3151 maybe_exception); | 3155 maybe_exception); |
| 3152 | 3156 |
| 3153 Handle<Object> reason; | 3157 Handle<Object> reason; |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3451 // Then check whether this scope intercepts. | 3455 // Then check whether this scope intercepts. |
| 3452 if ((flag & intercept_mask_)) { | 3456 if ((flag & intercept_mask_)) { |
| 3453 intercepted_flags_ |= flag; | 3457 intercepted_flags_ |= flag; |
| 3454 return true; | 3458 return true; |
| 3455 } | 3459 } |
| 3456 return false; | 3460 return false; |
| 3457 } | 3461 } |
| 3458 | 3462 |
| 3459 } // namespace internal | 3463 } // namespace internal |
| 3460 } // namespace v8 | 3464 } // namespace v8 |
| OLD | NEW |