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

Unified Diff: third_party/WebKit/Source/platform/heap/StackFrameDepth.h

Issue 2304023003: StackFrameDepth should be managed per ThreadHeap (Closed)
Patch Set: revert to PS1 Created 4 years, 3 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/platform/heap/StackFrameDepth.h
diff --git a/third_party/WebKit/Source/platform/heap/StackFrameDepth.h b/third_party/WebKit/Source/platform/heap/StackFrameDepth.h
index 94379aa71692505ddc0cfdd4a82680c1f28216cf..4ae894c12c8b14c9a2eac198bcd27efe44dc4c01 100644
--- a/third_party/WebKit/Source/platform/heap/StackFrameDepth.h
+++ b/third_party/WebKit/Source/platform/heap/StackFrameDepth.h
@@ -20,27 +20,26 @@ namespace blink {
// Use isSafeToRecurse() to determine if it is safe to consume
// more stack by invoking another recursive call.
class PLATFORM_EXPORT StackFrameDepth final {
- STATIC_ONLY(StackFrameDepth);
+ DISALLOW_NEW();
public:
- inline static bool isSafeToRecurse()
+ bool isSafeToRecurse()
{
// Asssume that the stack grows towards lower addresses, which
// all the ABIs currently supported do.
//
// A unit test checks that the assumption holds for a target
// (HeapTest.StackGrowthDirection.)
- return currentStackFrame() > s_stackFrameLimit;
+ return currentStackFrame() > m_stackFrameLimit;
}
- static void enableStackLimit();
- static void disableStackLimit()
+ void enableStackLimit();
+ void disableStackLimit()
{
- s_stackFrameLimit = kMinimumStackLimit;
+ m_stackFrameLimit = kMinimumStackLimit;
}
-#if ENABLE(ASSERT)
- inline static bool isEnabled() { return s_stackFrameLimit != kMinimumStackLimit; }
- inline static bool isAcceptableStackUse()
+ bool isEnabled() { return m_stackFrameLimit != kMinimumStackLimit; }
+ bool isAcceptableStackUse()
{
#if defined(ADDRESS_SANITIZER)
// ASan adds extra stack usage leading to too noisy asserts.
@@ -49,7 +48,6 @@ public:
return !isEnabled() || isSafeToRecurse();
#endif
}
-#endif
static size_t getUnderestimatedStackSize();
static void* getStackStart();
@@ -89,24 +87,27 @@ private:
static uintptr_t getFallbackStackLimit();
// The (pointer-valued) stack limit.
- static uintptr_t s_stackFrameLimit;
+ uintptr_t m_stackFrameLimit;
};
class StackFrameDepthScope {
STACK_ALLOCATED();
WTF_MAKE_NONCOPYABLE(StackFrameDepthScope);
public:
- StackFrameDepthScope()
+ explicit StackFrameDepthScope(StackFrameDepth* depth): m_depth(depth)
{
- StackFrameDepth::enableStackLimit();
+ m_depth->enableStackLimit();
// Enabled unless under stack pressure.
- ASSERT(StackFrameDepth::isSafeToRecurse() || !StackFrameDepth::isEnabled());
+ DCHECK(m_depth->isSafeToRecurse() || !m_depth->isEnabled());
}
~StackFrameDepthScope()
{
- StackFrameDepth::disableStackLimit();
+ m_depth->disableStackLimit();
}
+
+private:
+ StackFrameDepth* m_depth;
};
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapTest.cpp ('k') | third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698