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 2763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2774 void Isolate::RemoveCallCompletedCallback(CallCompletedCallback callback) { | 2774 void Isolate::RemoveCallCompletedCallback(CallCompletedCallback callback) { |
2775 for (int i = 0; i < call_completed_callbacks_.length(); i++) { | 2775 for (int i = 0; i < call_completed_callbacks_.length(); i++) { |
2776 if (callback == call_completed_callbacks_.at(i)) { | 2776 if (callback == call_completed_callbacks_.at(i)) { |
2777 call_completed_callbacks_.Remove(i); | 2777 call_completed_callbacks_.Remove(i); |
2778 } | 2778 } |
2779 } | 2779 } |
2780 } | 2780 } |
2781 | 2781 |
2782 | 2782 |
2783 void Isolate::FireCallCompletedCallback() { | 2783 void Isolate::FireCallCompletedCallback() { |
2784 bool has_call_completed_callbacks = !call_completed_callbacks_.is_empty(); | 2784 if (!handle_scope_implementer()->CallDepthIsZero()) return; |
| 2785 |
2785 bool run_microtasks = | 2786 bool run_microtasks = |
2786 pending_microtask_count() && | 2787 pending_microtask_count() && |
2787 !handle_scope_implementer()->HasMicrotasksSuppressions() && | 2788 !handle_scope_implementer()->HasMicrotasksSuppressions() && |
2788 handle_scope_implementer()->microtasks_policy() == | 2789 handle_scope_implementer()->microtasks_policy() == |
2789 v8::MicrotasksPolicy::kAuto; | 2790 v8::MicrotasksPolicy::kAuto; |
2790 if (!has_call_completed_callbacks && !run_microtasks) return; | |
2791 | 2791 |
2792 if (!handle_scope_implementer()->CallDepthIsZero()) return; | |
2793 if (run_microtasks) RunMicrotasks(); | 2792 if (run_microtasks) RunMicrotasks(); |
| 2793 // Prevent stepping from spilling into the next call made by the embedder. |
| 2794 if (debug()->is_active()) debug()->ClearStepping(); |
| 2795 |
| 2796 if (call_completed_callbacks_.is_empty()) return; |
2794 // Fire callbacks. Increase call depth to prevent recursive callbacks. | 2797 // Fire callbacks. Increase call depth to prevent recursive callbacks. |
2795 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this); | 2798 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this); |
2796 v8::Isolate::SuppressMicrotaskExecutionScope suppress(isolate); | 2799 v8::Isolate::SuppressMicrotaskExecutionScope suppress(isolate); |
2797 for (int i = 0; i < call_completed_callbacks_.length(); i++) { | 2800 for (int i = 0; i < call_completed_callbacks_.length(); i++) { |
2798 call_completed_callbacks_.at(i)(isolate); | 2801 call_completed_callbacks_.at(i)(isolate); |
2799 } | 2802 } |
2800 } | 2803 } |
2801 | 2804 |
2802 | 2805 |
2803 void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) { | 2806 void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) { |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3063 // Then check whether this scope intercepts. | 3066 // Then check whether this scope intercepts. |
3064 if ((flag & intercept_mask_)) { | 3067 if ((flag & intercept_mask_)) { |
3065 intercepted_flags_ |= flag; | 3068 intercepted_flags_ |= flag; |
3066 return true; | 3069 return true; |
3067 } | 3070 } |
3068 return false; | 3071 return false; |
3069 } | 3072 } |
3070 | 3073 |
3071 } // namespace internal | 3074 } // namespace internal |
3072 } // namespace v8 | 3075 } // namespace v8 |
OLD | NEW |