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

Unified Diff: src/api.h

Issue 1741893003: Introduce v8::MicrotasksScope. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Merged scopes 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
Index: src/api.h
diff --git a/src/api.h b/src/api.h
index 556765264ae4b1ba6989aba0ef7f3d3aeb4d42f6..21f6dacc872179e236ee031747299df4b8ac1f8d 100644
--- a/src/api.h
+++ b/src/api.h
@@ -434,6 +434,14 @@ class DeferredHandles {
};
+// Microtasks invocation policy. Keep in sync with v8::Isolate::MicrotasksPolicy
+enum MicrotasksPolicy {
jochen (gone - plz use gerrit) 2016/03/01 14:26:08 why not just use the public version?
dgozman 2016/03/03 01:22:06 Done.
+ kExplicitMicrotasksInvocation,
+ kScopedMicrotasksInvocation,
+ kAutoMicrotasksInvocation
+};
+
+
// This class is here in order to be able to declare it a friend of
// HandleScope. Moving these methods to be members of HandleScope would be
// neat in some ways, but it would expose internal implementation details in
@@ -452,6 +460,12 @@ class HandleScopeImplementer {
saved_contexts_(0),
spare_(NULL),
call_depth_(0),
+ microtasks_suppression_(0),
+#ifdef V8_ENABLE_CHECKS
+ debug_call_depth_(0),
+#endif
+ internal_call_depth_(0),
+ microtasks_policy_(kAutoMicrotasksInvocation),
last_handle_before_deferred_block_(NULL) { }
~HandleScopeImplementer() {
@@ -474,7 +488,24 @@ class HandleScopeImplementer {
inline void IncrementCallDepth() {call_depth_++;}
adamk 2016/03/01 19:10:34 Given the below new types of "call depth", I think
inline void DecrementCallDepth() {call_depth_--;}
- inline bool CallDepthIsZero() { return call_depth_ == 0; }
+ inline int GetCallDepth() { return call_depth_; }
+
+ inline void IncrementMicrotasksSuppression() {microtasks_suppression_++;}
adamk 2016/03/01 19:10:34 This could use a comment, what is this counter for
+ inline void DecrementMicrotasksSuppression() {microtasks_suppression_--;}
+ inline bool GetMicrotasksSuppression() { return microtasks_suppression_; }
+
+#ifdef V8_ENABLE_CHECKS
+ inline void IncrementDebugCallDepth() {debug_call_depth_++;}
adamk 2016/03/01 19:10:34 Please add comments, what's a "debug call depth"?
+ inline void DecrementDebugCallDepth() {debug_call_depth_--;}
+ inline bool GetDebugCallDepth() { return debug_call_depth_; }
+#endif
+
+ inline void IncrementInternalCallDepth() {internal_call_depth_++;}
adamk 2016/03/01 19:10:34 Same here, what's an "internal call depth"?
+ inline void DecrementInternalCallDepth() {internal_call_depth_--;}
+ inline bool GetInternalCallDepth() { return internal_call_depth_; }
+
+ inline void set_microtasks_policy(MicrotasksPolicy policy);
+ inline MicrotasksPolicy microtasks_policy() const;
inline void EnterContext(Handle<Context> context);
inline void LeaveContext();
@@ -532,6 +563,12 @@ class HandleScopeImplementer {
List<Context*> saved_contexts_;
Object** spare_;
int call_depth_;
+ int microtasks_suppression_;
+#ifdef V8_ENABLE_CHECKS
+ int debug_call_depth_;
+#endif
+ int internal_call_depth_;
+ MicrotasksPolicy microtasks_policy_;
Object** last_handle_before_deferred_block_;
// This is only used for threading support.
HandleScopeData handle_scope_data_;
@@ -550,6 +587,16 @@ class HandleScopeImplementer {
const int kHandleBlockSize = v8::internal::KB - 2; // fit in one page
+void HandleScopeImplementer::set_microtasks_policy(MicrotasksPolicy policy) {
+ microtasks_policy_ = policy;
+}
+
+
+MicrotasksPolicy HandleScopeImplementer::microtasks_policy() const {
+ return microtasks_policy_;
+}
+
+
void HandleScopeImplementer::SaveContext(Context* context) {
saved_contexts_.Add(context);
}

Powered by Google App Engine
This is Rietveld 408576698