Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef StackFrameDepth_h | 5 #ifndef StackFrameDepth_h |
| 6 #define StackFrameDepth_h | 6 #define StackFrameDepth_h |
| 7 | 7 |
| 8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "wtf/Allocator.h" | 9 #include "wtf/Allocator.h" |
| 10 #include "wtf/Assertions.h" | 10 #include "wtf/Assertions.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 // all the ABIs currently supported do. | 27 // all the ABIs currently supported do. |
| 28 // | 28 // |
| 29 // A unit test checks that the assumption holds for a target | 29 // A unit test checks that the assumption holds for a target |
| 30 // (HeapTest.StackGrowthDirection.) | 30 // (HeapTest.StackGrowthDirection.) |
| 31 return currentStackFrame() > s_stackFrameLimit; | 31 return currentStackFrame() > s_stackFrameLimit; |
| 32 } | 32 } |
| 33 | 33 |
| 34 static void enableStackLimit(); | 34 static void enableStackLimit(); |
| 35 static void disableStackLimit() | 35 static void disableStackLimit() |
| 36 { | 36 { |
| 37 s_stackFrameLimit = 0; | 37 s_stackFrameLimit = 0; |
|
sof
2016/03/10 13:43:13
Using 0 as the disabled limit value is strictly sp
| |
| 38 #if ENABLE(ASSERT) | 38 #if ENABLE(ASSERT) |
| 39 s_isEnabled = false; | 39 s_isEnabled = false; |
| 40 #endif | 40 #endif |
| 41 } | 41 } |
| 42 | 42 |
| 43 #if ENABLE(ASSERT) | 43 #if ENABLE(ASSERT) |
| 44 inline static bool isEnabled() { return s_isEnabled; } | 44 inline static bool isEnabled() { return s_isEnabled; } |
| 45 inline static bool isAcceptableStackUse() | 45 inline static bool isAcceptableStackUse() |
| 46 { | 46 { |
| 47 // ASan adds extra stack usage leading to too noisy asserts. | 47 // ASan adds extra stack usage leading to too noisy asserts. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 #endif | 97 #endif |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 class StackFrameDepthScope { | 100 class StackFrameDepthScope { |
| 101 STACK_ALLOCATED(); | 101 STACK_ALLOCATED(); |
| 102 WTF_MAKE_NONCOPYABLE(StackFrameDepthScope); | 102 WTF_MAKE_NONCOPYABLE(StackFrameDepthScope); |
| 103 public: | 103 public: |
| 104 StackFrameDepthScope() | 104 StackFrameDepthScope() |
| 105 { | 105 { |
| 106 StackFrameDepth::enableStackLimit(); | 106 StackFrameDepth::enableStackLimit(); |
| 107 ASSERT(StackFrameDepth::isSafeToRecurse()); | 107 // Enabled unless under stack pressure. |
| 108 ASSERT(StackFrameDepth::isSafeToRecurse() || !StackFrameDepth::isEnabled ()); | |
| 108 } | 109 } |
| 109 | 110 |
| 110 ~StackFrameDepthScope() | 111 ~StackFrameDepthScope() |
| 111 { | 112 { |
| 112 StackFrameDepth::disableStackLimit(); | 113 StackFrameDepth::disableStackLimit(); |
| 113 } | 114 } |
| 114 }; | 115 }; |
| 115 | 116 |
| 116 } // namespace blink | 117 } // namespace blink |
| 117 | 118 |
| 118 #endif // StackFrameDepth_h | 119 #endif // StackFrameDepth_h |
| OLD | NEW |