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 2197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2208 global_handles_(NULL), | 2208 global_handles_(NULL), |
2209 eternal_handles_(NULL), | 2209 eternal_handles_(NULL), |
2210 thread_manager_(NULL), | 2210 thread_manager_(NULL), |
2211 regexp_stack_(NULL), | 2211 regexp_stack_(NULL), |
2212 date_cache_(NULL), | 2212 date_cache_(NULL), |
2213 call_descriptor_data_(NULL), | 2213 call_descriptor_data_(NULL), |
2214 // TODO(bmeurer) Initialized lazily because it depends on flags; can | 2214 // TODO(bmeurer) Initialized lazily because it depends on flags; can |
2215 // be fixed once the default isolate cleanup is done. | 2215 // be fixed once the default isolate cleanup is done. |
2216 random_number_generator_(NULL), | 2216 random_number_generator_(NULL), |
2217 rail_mode_(PERFORMANCE_ANIMATION), | 2217 rail_mode_(PERFORMANCE_ANIMATION), |
| 2218 promise_hook_or_debug_is_active_(false), |
2218 promise_hook_(NULL), | 2219 promise_hook_(NULL), |
2219 load_start_time_ms_(0), | 2220 load_start_time_ms_(0), |
2220 serializer_enabled_(enable_serializer), | 2221 serializer_enabled_(enable_serializer), |
2221 has_fatal_error_(false), | 2222 has_fatal_error_(false), |
2222 initialized_from_snapshot_(false), | 2223 initialized_from_snapshot_(false), |
2223 is_tail_call_elimination_enabled_(true), | 2224 is_tail_call_elimination_enabled_(true), |
2224 is_isolate_in_background_(false), | 2225 is_isolate_in_background_(false), |
2225 cpu_profiler_(NULL), | 2226 cpu_profiler_(NULL), |
2226 heap_profiler_(NULL), | 2227 heap_profiler_(NULL), |
2227 code_event_dispatcher_(new CodeEventDispatcher()), | 2228 code_event_dispatcher_(new CodeEventDispatcher()), |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3238 | 3239 |
3239 if (call_completed_callbacks_.is_empty()) return; | 3240 if (call_completed_callbacks_.is_empty()) return; |
3240 // Fire callbacks. Increase call depth to prevent recursive callbacks. | 3241 // Fire callbacks. Increase call depth to prevent recursive callbacks. |
3241 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this); | 3242 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this); |
3242 v8::Isolate::SuppressMicrotaskExecutionScope suppress(isolate); | 3243 v8::Isolate::SuppressMicrotaskExecutionScope suppress(isolate); |
3243 for (int i = 0; i < call_completed_callbacks_.length(); i++) { | 3244 for (int i = 0; i < call_completed_callbacks_.length(); i++) { |
3244 call_completed_callbacks_.at(i)(isolate); | 3245 call_completed_callbacks_.at(i)(isolate); |
3245 } | 3246 } |
3246 } | 3247 } |
3247 | 3248 |
3248 void Isolate::SetPromiseHook(PromiseHook hook) { promise_hook_ = hook; } | 3249 void Isolate::DebugStateChanged() { |
| 3250 promise_hook_or_debug_is_active_ = promise_hook_ || debug()->is_active(); |
| 3251 } |
| 3252 |
| 3253 void Isolate::SetPromiseHook(PromiseHook hook) { |
| 3254 promise_hook_ = hook; |
| 3255 DebugStateChanged(); |
| 3256 } |
3249 | 3257 |
3250 void Isolate::RunPromiseHook(PromiseHookType type, Handle<JSPromise> promise, | 3258 void Isolate::RunPromiseHook(PromiseHookType type, Handle<JSPromise> promise, |
3251 Handle<Object> parent) { | 3259 Handle<Object> parent) { |
3252 if (promise_hook_ == nullptr) return; | 3260 if (promise_hook_ == nullptr) return; |
3253 promise_hook_(type, v8::Utils::PromiseToLocal(promise), | 3261 promise_hook_(type, v8::Utils::PromiseToLocal(promise), |
3254 v8::Utils::ToLocal(parent)); | 3262 v8::Utils::ToLocal(parent)); |
3255 } | 3263 } |
3256 | 3264 |
3257 void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) { | 3265 void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) { |
3258 promise_reject_callback_ = callback; | 3266 promise_reject_callback_ = callback; |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3665 // Then check whether this scope intercepts. | 3673 // Then check whether this scope intercepts. |
3666 if ((flag & intercept_mask_)) { | 3674 if ((flag & intercept_mask_)) { |
3667 intercepted_flags_ |= flag; | 3675 intercepted_flags_ |= flag; |
3668 return true; | 3676 return true; |
3669 } | 3677 } |
3670 return false; | 3678 return false; |
3671 } | 3679 } |
3672 | 3680 |
3673 } // namespace internal | 3681 } // namespace internal |
3674 } // namespace v8 | 3682 } // namespace v8 |
OLD | NEW |