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 2950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2961 v8::Isolate::SuppressMicrotaskExecutionScope suppress( | 2961 v8::Isolate::SuppressMicrotaskExecutionScope suppress( |
2962 reinterpret_cast<v8::Isolate*>(this)); | 2962 reinterpret_cast<v8::Isolate*>(this)); |
2963 is_running_microtasks_ = true; | 2963 is_running_microtasks_ = true; |
2964 RunMicrotasksInternal(); | 2964 RunMicrotasksInternal(); |
2965 is_running_microtasks_ = false; | 2965 is_running_microtasks_ = false; |
2966 FireMicrotasksCompletedCallback(); | 2966 FireMicrotasksCompletedCallback(); |
2967 } | 2967 } |
2968 | 2968 |
2969 | 2969 |
2970 void Isolate::RunMicrotasksInternal() { | 2970 void Isolate::RunMicrotasksInternal() { |
| 2971 if (!pending_microtask_count()) return; |
| 2972 TRACE_EVENT0("v8.execute", "RunMicrotasks"); |
2971 while (pending_microtask_count() > 0) { | 2973 while (pending_microtask_count() > 0) { |
2972 HandleScope scope(this); | 2974 HandleScope scope(this); |
2973 int num_tasks = pending_microtask_count(); | 2975 int num_tasks = pending_microtask_count(); |
2974 Handle<FixedArray> queue(heap()->microtask_queue(), this); | 2976 Handle<FixedArray> queue(heap()->microtask_queue(), this); |
2975 DCHECK(num_tasks <= queue->length()); | 2977 DCHECK(num_tasks <= queue->length()); |
2976 set_pending_microtask_count(0); | 2978 set_pending_microtask_count(0); |
2977 heap()->set_microtask_queue(heap()->empty_fixed_array()); | 2979 heap()->set_microtask_queue(heap()->empty_fixed_array()); |
2978 | 2980 |
2979 Isolate* isolate = this; | 2981 Isolate* isolate = this; |
2980 FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < num_tasks, i++, { | 2982 FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < num_tasks, i++, { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3175 // Then check whether this scope intercepts. | 3177 // Then check whether this scope intercepts. |
3176 if ((flag & intercept_mask_)) { | 3178 if ((flag & intercept_mask_)) { |
3177 intercepted_flags_ |= flag; | 3179 intercepted_flags_ |= flag; |
3178 return true; | 3180 return true; |
3179 } | 3181 } |
3180 return false; | 3182 return false; |
3181 } | 3183 } |
3182 | 3184 |
3183 } // namespace internal | 3185 } // namespace internal |
3184 } // namespace v8 | 3186 } // namespace v8 |
OLD | NEW |