| 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..1e6a6eee8083eae0b8a1e0fd5dee12fb333a6d52 100644
|
| --- a/third_party/WebKit/Source/platform/heap/StackFrameDepth.h
|
| +++ b/third_party/WebKit/Source/platform/heap/StackFrameDepth.h
|
| @@ -19,28 +19,16 @@ 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);
|
| +class PLATFORM_EXPORT StackFrameDepth {
|
| public:
|
| - inline static bool isSafeToRecurse()
|
| + void enableStackLimit();
|
| + void disableStackLimit()
|
| {
|
| - // 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;
|
| + m_stackFrameLimit = kMinimumStackLimit;
|
| }
|
|
|
| - static void enableStackLimit();
|
| - static void disableStackLimit()
|
| - {
|
| - s_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 +37,6 @@ public:
|
| return !isEnabled() || isSafeToRecurse();
|
| #endif
|
| }
|
| -#endif
|
|
|
| static size_t getUnderestimatedStackSize();
|
| static void* getStackStart();
|
| @@ -75,7 +62,20 @@ public:
|
| #pragma warning(pop)
|
| #endif
|
|
|
| +protected:
|
| + StackFrameDepth() : m_stackFrameLimit(kMinimumStackLimit) {}
|
| +
|
| private:
|
| + 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() > m_stackFrameLimit;
|
| + }
|
| +
|
| // The maximum depth of eager, unrolled trace() calls that is
|
| // considered safe and allowed for targets with an unknown
|
| // thread stack size.
|
| @@ -89,24 +89,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
|
|
|