| 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 a7380d5687aafb2676bb0d3da91bc87a2855f64e..6b1aa49e119a30e9eb080ec313ef55fbed4a8940 100644
|
| --- a/third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp
|
| +++ b/third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp
|
| @@ -32,6 +32,23 @@ NEVER_INLINE static uintptr_t currentStackFrameBaseOnCallee(const char* dummy)
|
| return StackFrameDepth::currentStackFrame();
|
| }
|
|
|
| +uintptr_t StackFrameDepth::getFallbackStackLimit()
|
| +{
|
| + // Allocate an |kSafeStackFrameSize|-sized object on stack and query
|
| + // stack frame base after it.
|
| + char dummy[kSafeStackFrameSize];
|
| +
|
| + // Check that the stack frame can be used.
|
| + dummy[sizeof(dummy) - 1] = 0;
|
| +#if ENABLE(ASSERT)
|
| + // Use a larger stack limit for what's acceptable if the platform
|
| + // thread ends up using the fallback size to decide if switching to
|
| + // lazy marking is in order.
|
| + s_isUsingFallbackStackSize = true;
|
| +#endif
|
| + return currentStackFrameBaseOnCallee(dummy);
|
| +}
|
| +
|
| void StackFrameDepth::enableStackLimit()
|
| {
|
| #if ENABLE(ASSERT)
|
| @@ -39,31 +56,20 @@ void StackFrameDepth::enableStackLimit()
|
| s_isUsingFallbackStackSize = false;
|
| #endif
|
|
|
| - static const int kStackRoomSize = 1024;
|
| -
|
| + // Windows and OSX platforms will always return a non-zero estimate.
|
| size_t stackSize = getUnderestimatedStackSize();
|
| - if (stackSize) {
|
| - Address stackBase = reinterpret_cast<Address>(getStackStart());
|
| - RELEASE_ASSERT(stackSize > static_cast<const size_t>(kStackRoomSize));
|
| - size_t stackRoom = stackSize - kStackRoomSize;
|
| - RELEASE_ASSERT(stackBase > reinterpret_cast<Address>(stackRoom));
|
| - s_stackFrameLimit = reinterpret_cast<uintptr_t>(stackBase - stackRoom);
|
| + if (!stackSize) {
|
| + s_stackFrameLimit = getFallbackStackLimit();
|
| return;
|
| }
|
|
|
| - // Fallback version
|
| - // Allocate a 32KB object on stack and query stack frame base after it.
|
| - char dummy[kSafeStackFrameSize];
|
| - s_stackFrameLimit = currentStackFrameBaseOnCallee(dummy);
|
| + static const int kStackRoomSize = 1024;
|
|
|
| - // Assert that the stack frame can be used.
|
| - dummy[sizeof(dummy) - 1] = 0;
|
| -#if ENABLE(ASSERT)
|
| - // Use a larger stack limit for what's acceptable if the platform
|
| - // thread ends up using the fallback size to decide if switching to
|
| - // lazy marking is in order.
|
| - s_isUsingFallbackStackSize = true;
|
| -#endif
|
| + Address stackBase = reinterpret_cast<Address>(getStackStart());
|
| + RELEASE_ASSERT(stackSize > static_cast<const size_t>(kStackRoomSize));
|
| + size_t stackRoom = stackSize - kStackRoomSize;
|
| + RELEASE_ASSERT(stackBase > reinterpret_cast<Address>(stackRoom));
|
| + s_stackFrameLimit = reinterpret_cast<uintptr_t>(stackBase - stackRoom);
|
| }
|
|
|
| size_t StackFrameDepth::getUnderestimatedStackSize()
|
|
|