Index: third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp |
diff --git a/third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp b/third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp |
index 8e459762a3b7ab125a3cf164076134b7a4166cde..c11218b3d8fa7b3a40e8475a002e14209c8064f3 100644 |
--- a/third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp |
+++ b/third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp |
@@ -58,6 +58,21 @@ void StackFrameDepth::enableStackLimit() |
dummy[sizeof(dummy) - 1] = 0; |
} |
+bool StackFrameDepth::hasInsufficientStackForGC() |
+{ |
+ size_t stackSize = getUnderestimatedStackSize(); |
+ if (!stackSize) |
+ return false; |
+ |
+ Address stackBase = reinterpret_cast<Address>(getStackStart()); |
+ RELEASE_ASSERT(stackBase > reinterpret_cast<Address>(stackSize)); |
+ uintptr_t stackLimit = reinterpret_cast<uintptr_t>(stackBase - stackSize); |
+ |
+ // If less than 8k of stack space is left, better not run a GC. |
+ char dummy[2]; |
+ return (currentStackFrameBaseOnCallee(dummy) - stackLimit) < 8 * 1024; |
+} |
+ |
size_t StackFrameDepth::getUnderestimatedStackSize() |
{ |
// FIXME: ASAN bot uses a fake stack as a thread stack frame, |