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

Unified Diff: src/api.h

Issue 1741893003: Introduce v8::MicrotasksScope. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: SetAutorunMicrotasks fix Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.h
diff --git a/src/api.h b/src/api.h
index 556765264ae4b1ba6989aba0ef7f3d3aeb4d42f6..d2981c34b3232ee35dc06ac16f281a794d406f1e 100644
--- a/src/api.h
+++ b/src/api.h
@@ -452,6 +452,12 @@ class HandleScopeImplementer {
saved_contexts_(0),
spare_(NULL),
call_depth_(0),
+ microtasks_depth_(0),
+ microtasks_suppressions_(0),
+#ifdef V8_ENABLE_CHECKS
+ debug_microtasks_depth_(0),
+#endif
+ microtasks_policy_(v8::MicrotasksPolicy::kAuto),
last_handle_before_deferred_block_(NULL) { }
~HandleScopeImplementer() {
@@ -472,10 +478,36 @@ class HandleScopeImplementer {
inline internal::Object** GetSpareOrNewBlock();
inline void DeleteExtensions(internal::Object** prev_limit);
+ // Call depth represents nested v8 api calls.
inline void IncrementCallDepth() {call_depth_++;}
inline void DecrementCallDepth() {call_depth_--;}
inline bool CallDepthIsZero() { return call_depth_ == 0; }
+ // Microtasks scope depth represents nested scopes controlling microtasks
+ // invocation, which happens when depth reaches zero.
+ inline void IncrementMicrotasksScopeDepth() {microtasks_depth_++;}
+ inline void DecrementMicrotasksScopeDepth() {microtasks_depth_--;}
+ inline int GetMicrotasksScopeDepth() { return microtasks_depth_; }
+
+ // Possibly nested microtasks suppression scopes prevent microtasks
+ // from running.
+ inline void IncrementMicrotasksSuppressions() {microtasks_suppressions_++;}
+ inline void DecrementMicrotasksSuppressions() {microtasks_suppressions_--;}
+ inline bool HasMicrotasksSuppressions() { return !!microtasks_suppressions_; }
+
+#ifdef V8_ENABLE_CHECKS
+ // In debug we check that calls not intended to invoke microtasks are
+ // still correctly wrapped with microtask scopes.
+ inline void IncrementDebugMicrotasksScopeDepth() {debug_microtasks_depth_++;}
+ inline void DecrementDebugMicrotasksScopeDepth() {debug_microtasks_depth_--;}
+ inline bool DebugMicrotasksScopeDepthIsZero() {
+ return debug_microtasks_depth_ == 0;
+ }
+#endif
+
+ inline void set_microtasks_policy(v8::MicrotasksPolicy policy);
+ inline v8::MicrotasksPolicy microtasks_policy() const;
+
inline void EnterContext(Handle<Context> context);
inline void LeaveContext();
inline bool LastEnteredContextWas(Handle<Context> context);
@@ -532,6 +564,12 @@ class HandleScopeImplementer {
List<Context*> saved_contexts_;
Object** spare_;
int call_depth_;
+ int microtasks_depth_;
+ int microtasks_suppressions_;
+#ifdef V8_ENABLE_CHECKS
+ int debug_microtasks_depth_;
+#endif
+ v8::MicrotasksPolicy microtasks_policy_;
Object** last_handle_before_deferred_block_;
// This is only used for threading support.
HandleScopeData handle_scope_data_;
@@ -550,6 +588,17 @@ class HandleScopeImplementer {
const int kHandleBlockSize = v8::internal::KB - 2; // fit in one page
+void HandleScopeImplementer::set_microtasks_policy(
+ v8::MicrotasksPolicy policy) {
+ microtasks_policy_ = policy;
+}
+
+
+v8::MicrotasksPolicy HandleScopeImplementer::microtasks_policy() const {
+ return microtasks_policy_;
+}
+
+
void HandleScopeImplementer::SaveContext(Context* context) {
saved_contexts_.Add(context);
}
« no previous file with comments | « include/v8.h ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698