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" |
11 #include <cstddef> | 11 #include <cstddef> |
12 #include <stdint.h> | 12 #include <stdint.h> |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 // StackFrameDepth keeps track of current call stack frame depth. | 16 // StackFrameDepth keeps track of current call stack frame depth. |
17 // It is specifically used to control stack usage while tracing | 17 // It is specifically used to control stack usage while tracing |
18 // the object graph during a GC. | 18 // the object graph during a GC. |
19 // | 19 // |
20 // Use isSafeToRecurse() to determine if it is safe to consume | 20 // Use isSafeToRecurse() to determine if it is safe to consume |
21 // more stack by invoking another recursive call. | 21 // more stack by invoking another recursive call. |
22 class PLATFORM_EXPORT StackFrameDepth final { | 22 class PLATFORM_EXPORT StackFrameDepth final { |
23 DISALLOW_NEW(); | 23 DISALLOW_NEW(); |
24 public: | 24 public: |
| 25 StackFrameDepth(): m_stackFrameLimit(kMinimumStackLimit) {} |
25 bool isSafeToRecurse() | 26 bool isSafeToRecurse() |
26 { | 27 { |
27 // Asssume that the stack grows towards lower addresses, which | 28 // Asssume that the stack grows towards lower addresses, which |
28 // all the ABIs currently supported do. | 29 // all the ABIs currently supported do. |
29 // | 30 // |
30 // A unit test checks that the assumption holds for a target | 31 // A unit test checks that the assumption holds for a target |
31 // (HeapTest.StackGrowthDirection.) | 32 // (HeapTest.StackGrowthDirection.) |
32 return currentStackFrame() > m_stackFrameLimit; | 33 return currentStackFrame() > m_stackFrameLimit; |
33 } | 34 } |
34 | 35 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 m_depth->disableStackLimit(); | 107 m_depth->disableStackLimit(); |
107 } | 108 } |
108 | 109 |
109 private: | 110 private: |
110 StackFrameDepth* m_depth; | 111 StackFrameDepth* m_depth; |
111 }; | 112 }; |
112 | 113 |
113 } // namespace blink | 114 } // namespace blink |
114 | 115 |
115 #endif // StackFrameDepth_h | 116 #endif // StackFrameDepth_h |
OLD | NEW |