Chromium Code Reviews| Index: Source/platform/heap/StackFrameDepth.h |
| diff --git a/Source/platform/heap/StackFrameDepth.h b/Source/platform/heap/StackFrameDepth.h |
| index 09c41a469fe4548ca13541c6833983a18734da64..66c6c0266743fa99e6e43f670b2f919b0ebdf2bf 100644 |
| --- a/Source/platform/heap/StackFrameDepth.h |
| +++ b/Source/platform/heap/StackFrameDepth.h |
| @@ -18,7 +18,7 @@ class PLATFORM_EXPORT StackFrameDepth final { |
| public: |
| inline static bool isSafeToRecurse() |
| { |
| - ASSERT(s_stackFrameLimit); |
| + ASSERT(s_stackFrameLimit || !s_isActive); |
| // Asssume that the stack grows towards lower addresses, which |
| // all the ABIs currently supported do. |
| @@ -31,6 +31,18 @@ public: |
| static size_t getUnderestimatedStackSize(); |
| static void* getStackStart(); |
| + static void clearStackLimit() |
|
haraken
2015/05/04 23:11:32
configureStackLimit => enableStackLimit
clearStack
sof
2015/05/06 10:39:57
Renamed so.
|
| + { |
| + s_stackFrameLimit = 0; |
| +#if ENABLE(ASSERT) |
| + s_isActive = false; |
| +#endif |
| + } |
| + |
| +#if ENABLE(ASSERT) |
| + inline static bool isActive() { return s_isActive; } |
| +#endif |
| + |
| #if COMPILER(MSVC) |
| // Ignore C4172: returning address of local variable or temporary: dummy. This |
| // warning suppression has to go outside of the function to take effect. |
| @@ -58,6 +70,23 @@ private: |
| static const int kSafeStackFrameSize = 32 * 1024; |
| static uintptr_t s_stackFrameLimit; |
| +#if ENABLE(ASSERT) |
| + static bool s_isActive; |
| +#endif |
| +}; |
| + |
| +class StackFrameDepthScope { |
|
haraken
2015/05/04 23:11:32
Add STACK_ALLOCATED.
sof
2015/05/06 10:39:57
Not done, that would be an unnecessary restriction
|
| +public: |
| + StackFrameDepthScope() |
| + { |
| + StackFrameDepth::configureStackLimit(); |
| + ASSERT(StackFrameDepth::isSafeToRecurse()); |
| + } |
| + |
| + ~StackFrameDepthScope() |
| + { |
| + StackFrameDepth::clearStackLimit(); |
| + } |
| }; |
| } // namespace blink |