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 05cd6c6e58ce53527882bdc7d3606acd4e4f2db0..94379aa71692505ddc0cfdd4a82680c1f28216cf 100644 |
--- a/third_party/WebKit/Source/platform/heap/StackFrameDepth.h |
+++ b/third_party/WebKit/Source/platform/heap/StackFrameDepth.h |
@@ -14,15 +14,16 @@ |
namespace blink { |
// StackFrameDepth keeps track of current call stack frame depth. |
-// Use isSafeToRecurse() to query if there is a room in current |
-// call stack for more recursive call. |
+// It is specifically used to control stack usage while tracing |
+// the object graph during a GC. |
+// |
+// 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); |
public: |
inline static bool isSafeToRecurse() |
{ |
- ASSERT(s_stackFrameLimit || !s_isEnabled); |
- |
// Asssume that the stack grows towards lower addresses, which |
// all the ABIs currently supported do. |
// |
@@ -34,27 +35,18 @@ public: |
static void enableStackLimit(); |
static void disableStackLimit() |
{ |
- s_stackFrameLimit = 0; |
-#if ENABLE(ASSERT) |
- s_isEnabled = false; |
-#endif |
+ s_stackFrameLimit = kMinimumStackLimit; |
} |
#if ENABLE(ASSERT) |
- inline static bool isEnabled() { return s_isEnabled; } |
+ inline static bool isEnabled() { return s_stackFrameLimit != kMinimumStackLimit; } |
inline static bool isAcceptableStackUse() |
{ |
- // ASan adds extra stack usage leading to too noisy asserts. |
#if defined(ADDRESS_SANITIZER) |
+ // ASan adds extra stack usage leading to too noisy asserts. |
return true; |
#else |
- // If a conservative fallback stack size is in effect, use |
- // a larger stack limit so as to avoid false positives. |
- if (!s_isEnabled || isSafeToRecurse()) |
- return true; |
- if (s_isUsingFallbackStackSize) |
- return (s_stackFrameLimit - currentStackFrame()) < 3 * kSafeStackFrameSize; |
- return false; |
+ return !isEnabled() || isSafeToRecurse(); |
#endif |
} |
#endif |
@@ -85,16 +77,19 @@ public: |
private: |
// The maximum depth of eager, unrolled trace() calls that is |
- // considered safe and allowed. |
+ // considered safe and allowed for targets with an unknown |
+ // thread stack size. |
static const int kSafeStackFrameSize = 32 * 1024; |
+ // The stack pointer is assumed to grow towards lower addresses; |
+ // |kMinimumStackLimit| then being the limit that a stack |
+ // pointer will always exceed. |
+ static const uintptr_t kMinimumStackLimit = ~0ul; |
+ |
static uintptr_t getFallbackStackLimit(); |
+ // The (pointer-valued) stack limit. |
static uintptr_t s_stackFrameLimit; |
-#if ENABLE(ASSERT) |
- static bool s_isEnabled; |
- static bool s_isUsingFallbackStackSize; |
-#endif |
}; |
class StackFrameDepthScope { |