Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/isolate.cc

Issue 1920813002: [api] Introduce MicrotasksScope::IsRunningMicrotasks (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/isolate.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1851 deferred_handles_head_(NULL), 1851 deferred_handles_head_(NULL),
1852 optimizing_compile_dispatcher_(NULL), 1852 optimizing_compile_dispatcher_(NULL),
1853 stress_deopt_count_(0), 1853 stress_deopt_count_(0),
1854 virtual_handler_register_(NULL), 1854 virtual_handler_register_(NULL),
1855 virtual_slot_register_(NULL), 1855 virtual_slot_register_(NULL),
1856 next_optimization_id_(0), 1856 next_optimization_id_(0),
1857 js_calls_from_api_counter_(0), 1857 js_calls_from_api_counter_(0),
1858 #if TRACE_MAPS 1858 #if TRACE_MAPS
1859 next_unique_sfi_id_(0), 1859 next_unique_sfi_id_(0),
1860 #endif 1860 #endif
1861 is_running_microtasks_(false),
1861 use_counter_callback_(NULL), 1862 use_counter_callback_(NULL),
1862 basic_block_profiler_(NULL), 1863 basic_block_profiler_(NULL),
1863 cancelable_task_manager_(new CancelableTaskManager()), 1864 cancelable_task_manager_(new CancelableTaskManager()),
1864 abort_on_uncaught_exception_callback_(NULL) { 1865 abort_on_uncaught_exception_callback_(NULL) {
1865 { 1866 {
1866 base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); 1867 base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer());
1867 CHECK(thread_data_table_); 1868 CHECK(thread_data_table_);
1868 } 1869 }
1869 id_ = base::NoBarrier_AtomicIncrement(&isolate_counter_, 1); 1870 id_ = base::NoBarrier_AtomicIncrement(&isolate_counter_, 1);
1870 TRACE_ISOLATE(constructor); 1871 TRACE_ISOLATE(constructor);
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
2773 DCHECK(queue->get(num_tasks)->IsUndefined()); 2774 DCHECK(queue->get(num_tasks)->IsUndefined());
2774 queue->set(num_tasks, *microtask); 2775 queue->set(num_tasks, *microtask);
2775 set_pending_microtask_count(num_tasks + 1); 2776 set_pending_microtask_count(num_tasks + 1);
2776 } 2777 }
2777 2778
2778 2779
2779 void Isolate::RunMicrotasks() { 2780 void Isolate::RunMicrotasks() {
2780 // Increase call depth to prevent recursive callbacks. 2781 // Increase call depth to prevent recursive callbacks.
2781 v8::Isolate::SuppressMicrotaskExecutionScope suppress( 2782 v8::Isolate::SuppressMicrotaskExecutionScope suppress(
2782 reinterpret_cast<v8::Isolate*>(this)); 2783 reinterpret_cast<v8::Isolate*>(this));
2784 is_running_microtasks_ = true;
2783 RunMicrotasksInternal(); 2785 RunMicrotasksInternal();
2786 is_running_microtasks_ = false;
2784 FireMicrotasksCompletedCallback(); 2787 FireMicrotasksCompletedCallback();
2785 } 2788 }
2786 2789
2787 2790
2788 void Isolate::RunMicrotasksInternal() { 2791 void Isolate::RunMicrotasksInternal() {
2789 while (pending_microtask_count() > 0) { 2792 while (pending_microtask_count() > 0) {
2790 HandleScope scope(this); 2793 HandleScope scope(this);
2791 int num_tasks = pending_microtask_count(); 2794 int num_tasks = pending_microtask_count();
2792 Handle<FixedArray> queue(heap()->microtask_queue(), this); 2795 Handle<FixedArray> queue(heap()->microtask_queue(), this);
2793 DCHECK(num_tasks <= queue->length()); 2796 DCHECK(num_tasks <= queue->length());
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2994 // Then check whether this scope intercepts. 2997 // Then check whether this scope intercepts.
2995 if ((flag & intercept_mask_)) { 2998 if ((flag & intercept_mask_)) {
2996 intercepted_flags_ |= flag; 2999 intercepted_flags_ |= flag;
2997 return true; 3000 return true;
2998 } 3001 }
2999 return false; 3002 return false;
3000 } 3003 }
3001 3004
3002 } // namespace internal 3005 } // namespace internal
3003 } // namespace v8 3006 } // namespace v8
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698