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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.h

Issue 1765423004: Revert of Use v8::MicrotasksScope internally in V8RecursionScope. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8rs-2-endofscope
Patch Set: Created 4 years, 9 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: third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.h b/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.h
index 8bbd26cd3dfbc9b2144110a0f174bbe484cd7a28..dd9a51fb354f2ce33937587882c6ff849a61cb30 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.h
+++ b/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.h
@@ -59,39 +59,63 @@
STACK_ALLOCATED();
public:
explicit V8RecursionScope(v8::Isolate* isolate)
- : m_scope(isolate, v8::MicrotasksScope::kRunMicrotasks)
+ : m_isolate(isolate)
{
- ASSERT(isolate->GetMicrotasksPolicy() == v8::MicrotasksPolicy::kScoped);
+ V8PerIsolateData::from(m_isolate)->incrementRecursionLevel();
+ // If you want V8 to autorun microtasks, this class needs to have a
+ // v8::Isolate::SuppressMicrotaskExecutionScope member.
+ ASSERT(!isolate->WillAutorunMicrotasks());
}
~V8RecursionScope()
{
+ if (!V8PerIsolateData::from(m_isolate)->decrementRecursionLevel())
+ didLeaveScriptContext();
}
static int recursionLevel(v8::Isolate* isolate)
{
- return v8::MicrotasksScope::GetCurrentDepth(isolate);
+ return V8PerIsolateData::from(isolate)->recursionLevel();
}
+
+#if ENABLE(ASSERT)
+ static bool properlyUsed(v8::Isolate* isolate)
+ {
+ return recursionLevel(isolate) > 0 || V8PerIsolateData::from(isolate)->internalScriptRecursionLevel() > 0;
+ }
+#endif
class MicrotaskSuppression {
USING_FAST_MALLOC(MicrotaskSuppression);
WTF_MAKE_NONCOPYABLE(MicrotaskSuppression);
public:
- explicit MicrotaskSuppression(v8::Isolate* isolate)
- : m_scope(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks)
+ MicrotaskSuppression(v8::Isolate* isolate)
+#if ENABLE(ASSERT)
+ : m_isolate(isolate)
+#endif
{
+#if ENABLE(ASSERT)
+ V8PerIsolateData::from(m_isolate)->incrementInternalScriptRecursionLevel();
+#endif
}
~MicrotaskSuppression()
{
+#if ENABLE(ASSERT)
+ V8PerIsolateData::from(m_isolate)->decrementInternalScriptRecursionLevel();
+#endif
}
private:
- v8::MicrotasksScope m_scope;
+#if ENABLE(ASSERT)
+ v8::Isolate* m_isolate;
+#endif
};
private:
- v8::MicrotasksScope m_scope;
+ void didLeaveScriptContext();
+
+ v8::Isolate* m_isolate;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698