Index: Source/bindings/v8/V8RecursionScope.h |
diff --git a/Source/bindings/v8/V8RecursionScope.h b/Source/bindings/v8/V8RecursionScope.h |
index 0a150c3b9fe6a96058f3519a0f6bcd5e2ea726aa..962375bec61189dabe8a993efc358400ec474f8c 100644 |
--- a/Source/bindings/v8/V8RecursionScope.h |
+++ b/Source/bindings/v8/V8RecursionScope.h |
@@ -31,6 +31,7 @@ |
#ifndef V8RecursionScope_h |
#define V8RecursionScope_h |
+#include "bindings/common/StackTrace.h" |
#include "bindings/v8/V8PerIsolateData.h" |
#include "core/dom/ExecutionContext.h" |
#include "core/dom/ScriptForbiddenScope.h" |
@@ -59,11 +60,16 @@ namespace WebCore { |
class V8RecursionScope { |
WTF_MAKE_NONCOPYABLE(V8RecursionScope); |
public: |
- V8RecursionScope(v8::Isolate* isolate, ExecutionContext* context) |
+ V8RecursionScope(v8::Isolate* isolate, ExecutionContext* context, bool shouldTrackStackDepth = true) |
: m_isolate(isolate) |
, m_executionContext(context) |
+ , m_shouldTrackStackDepth(shouldTrackStackDepth) |
{ |
- V8PerIsolateData::from(m_isolate)->incrementRecursionLevel(); |
+ V8PerIsolateData* isolateData = V8PerIsolateData::from(m_isolate); |
+ |
+ if (shouldTrackStackDepth) |
+ trackStackDepth(isolateData); |
+ isolateData->incrementRecursionLevel(); |
ASSERT(!ScriptForbiddenScope::isScriptForbidden()); |
// If you want V8 to autorun microtasks, this class needs to have a |
// v8::Isolate::SuppressMicrotaskExecutionScope member. |
@@ -72,7 +78,10 @@ public: |
~V8RecursionScope() |
{ |
- if (!V8PerIsolateData::from(m_isolate)->decrementRecursionLevel()) |
+ V8PerIsolateData* isolateData = V8PerIsolateData::from(m_isolate); |
+ if (m_shouldTrackStackDepth) |
+ isolateData->stackTraceTimestampTracker()->decrementRecursionLevel(); |
+ if (isolateData->decrementRecursionLevel()) |
didLeaveScriptContext(); |
} |
@@ -116,11 +125,13 @@ public: |
private: |
void didLeaveScriptContext(); |
+ void trackStackDepth(V8PerIsolateData*); |
v8::Isolate* m_isolate; |
// FIXME: This is a reference in upstream Blink. In Dartium, it can |
// be null when instantiated from a DartUtilities::V8Scope. |
ExecutionContext* m_executionContext; |
+ bool m_shouldTrackStackDepth; |
}; |
} // namespace WebCore |