| 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 2972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2983 queue->set(num_tasks, *microtask); | 2983 queue->set(num_tasks, *microtask); |
| 2984 set_pending_microtask_count(num_tasks + 1); | 2984 set_pending_microtask_count(num_tasks + 1); |
| 2985 } | 2985 } |
| 2986 | 2986 |
| 2987 | 2987 |
| 2988 void Isolate::RunMicrotasks() { | 2988 void Isolate::RunMicrotasks() { |
| 2989 // Increase call depth to prevent recursive callbacks. | 2989 // Increase call depth to prevent recursive callbacks. |
| 2990 v8::Isolate::SuppressMicrotaskExecutionScope suppress( | 2990 v8::Isolate::SuppressMicrotaskExecutionScope suppress( |
| 2991 reinterpret_cast<v8::Isolate*>(this)); | 2991 reinterpret_cast<v8::Isolate*>(this)); |
| 2992 is_running_microtasks_ = true; | 2992 is_running_microtasks_ = true; |
| 2993 RunMicrotasksInternal(); | 2993 MaybeHandle<Object> maybe_exception; |
| 2994 MaybeHandle<Object> result = Execution::TryCall( |
| 2995 this, microtask_run(), factory()->undefined_value(), 0, NULL, |
| 2996 &maybe_exception); |
| 2997 //RunMicrotasksInternal(); |
| 2994 is_running_microtasks_ = false; | 2998 is_running_microtasks_ = false; |
| 2995 FireMicrotasksCompletedCallback(); | 2999 FireMicrotasksCompletedCallback(); |
| 2996 } | 3000 } |
| 2997 | 3001 |
| 2998 | 3002 |
| 2999 void Isolate::RunMicrotasksInternal() { | 3003 void Isolate::RunMicrotasksInternal() { |
| 3000 while (pending_microtask_count() > 0) { | 3004 while (pending_microtask_count() > 0) { |
| 3001 HandleScope scope(this); | 3005 HandleScope scope(this); |
| 3002 int num_tasks = pending_microtask_count(); | 3006 int num_tasks = pending_microtask_count(); |
| 3003 Handle<FixedArray> queue(heap()->microtask_queue(), this); | 3007 Handle<FixedArray> queue(heap()->microtask_queue(), this); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3014 SaveContext save(this); | 3018 SaveContext save(this); |
| 3015 set_context(microtask_function->context()->native_context()); | 3019 set_context(microtask_function->context()->native_context()); |
| 3016 handle_scope_implementer_->EnterMicrotaskContext( | 3020 handle_scope_implementer_->EnterMicrotaskContext( |
| 3017 handle(microtask_function->context(), this)); | 3021 handle(microtask_function->context(), this)); |
| 3018 MaybeHandle<Object> maybe_exception; | 3022 MaybeHandle<Object> maybe_exception; |
| 3019 MaybeHandle<Object> result = Execution::TryCall( | 3023 MaybeHandle<Object> result = Execution::TryCall( |
| 3020 this, microtask_function, factory()->undefined_value(), 0, NULL, | 3024 this, microtask_function, factory()->undefined_value(), 0, NULL, |
| 3021 &maybe_exception); | 3025 &maybe_exception); |
| 3022 handle_scope_implementer_->LeaveMicrotaskContext(); | 3026 handle_scope_implementer_->LeaveMicrotaskContext(); |
| 3023 // If execution is terminating, just bail out. | 3027 // If execution is terminating, just bail out. |
| 3024 Handle<Object> exception; | |
| 3025 if (result.is_null() && maybe_exception.is_null()) { | 3028 if (result.is_null() && maybe_exception.is_null()) { |
| 3026 // Clear out any remaining callbacks in the queue. | 3029 // Clear out any remaining callbacks in the queue. |
| 3027 heap()->set_microtask_queue(heap()->empty_fixed_array()); | 3030 heap()->set_microtask_queue(heap()->empty_fixed_array()); |
| 3028 set_pending_microtask_count(0); | 3031 set_pending_microtask_count(0); |
| 3029 return; | 3032 return; |
| 3030 } | 3033 } |
| 3031 } else { | 3034 } else { |
| 3032 Handle<CallHandlerInfo> callback_info = | 3035 Handle<CallHandlerInfo> callback_info = |
| 3033 Handle<CallHandlerInfo>::cast(microtask); | 3036 Handle<CallHandlerInfo>::cast(microtask); |
| 3034 v8::MicrotaskCallback callback = | 3037 v8::MicrotaskCallback callback = |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3205 // Then check whether this scope intercepts. | 3208 // Then check whether this scope intercepts. |
| 3206 if ((flag & intercept_mask_)) { | 3209 if ((flag & intercept_mask_)) { |
| 3207 intercepted_flags_ |= flag; | 3210 intercepted_flags_ |= flag; |
| 3208 return true; | 3211 return true; |
| 3209 } | 3212 } |
| 3210 return false; | 3213 return false; |
| 3211 } | 3214 } |
| 3212 | 3215 |
| 3213 } // namespace internal | 3216 } // namespace internal |
| 3214 } // namespace v8 | 3217 } // namespace v8 |
| OLD | NEW |