| Index: third_party/WebKit/Source/wtf/StackUtil.cpp
|
| diff --git a/third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp b/third_party/WebKit/Source/wtf/StackUtil.cpp
|
| similarity index 68%
|
| copy from third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp
|
| copy to third_party/WebKit/Source/wtf/StackUtil.cpp
|
| index 1d164f510a36de4ecb3328e6c80065f4913eca5d..e40048e65762a0fdb7356fc39c0778f505caf22e 100644
|
| --- a/third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp
|
| +++ b/third_party/WebKit/Source/wtf/StackUtil.cpp
|
| @@ -1,10 +1,11 @@
|
| -// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "platform/heap/StackFrameDepth.h"
|
| +#include "wtf/StackUtil.h"
|
|
|
| -#include "public/platform/Platform.h"
|
| +#include "wtf/Assertions.h"
|
| +#include "wtf/WTFThreadData.h"
|
|
|
| #if OS(WIN)
|
| #include <stddef.h>
|
| @@ -14,51 +15,9 @@
|
| extern "C" void* __libc_stack_end; // NOLINT
|
| #endif
|
|
|
| -namespace blink {
|
| +namespace WTF {
|
|
|
| -static const char* s_avoidOptimization = nullptr;
|
| -
|
| -// NEVER_INLINE ensures that |dummy| array on configureLimit() is not optimized
|
| -// away, and the stack frame base register is adjusted |kSafeStackFrameSize|.
|
| -NEVER_INLINE static uintptr_t currentStackFrameBaseOnCallee(const char* dummy) {
|
| - s_avoidOptimization = 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;
|
| - return currentStackFrameBaseOnCallee(dummy);
|
| -}
|
| -
|
| -void StackFrameDepth::enableStackLimit() {
|
| - // All supported platforms will currently return a non-zero estimate,
|
| - // except if ASan is enabled.
|
| - size_t stackSize = getUnderestimatedStackSize();
|
| - if (!stackSize) {
|
| - m_stackFrameLimit = getFallbackStackLimit();
|
| - return;
|
| - }
|
| -
|
| - static const int kStackRoomSize = 1024;
|
| -
|
| - 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));
|
| - m_stackFrameLimit = reinterpret_cast<uintptr_t>(stackBase - stackRoom);
|
| -
|
| - // If current stack use is already exceeding estimated limit, mark as
|
| - // disabled.
|
| - if (!isSafeToRecurse())
|
| - disableStackLimit();
|
| -}
|
| -
|
| -size_t StackFrameDepth::getUnderestimatedStackSize() {
|
| +size_t getUnderestimatedStackSize() {
|
| // FIXME: ASAN bot uses a fake stack as a thread stack frame,
|
| // and its size is different from the value which APIs tells us.
|
| #if defined(ADDRESS_SANITIZER)
|
| @@ -127,14 +86,14 @@ size_t StackFrameDepth::getUnderestimatedStackSize() {
|
| }
|
| return pthread_get_stacksize_np(pthread_self());
|
| #elif OS(WIN) && COMPILER(MSVC)
|
| - return ThreadState::current()->threadStackSize();
|
| + return WTFThreadData::current().threadStackSize();
|
| #else
|
| #error "Stack frame size estimation not supported on this platform."
|
| return 0;
|
| #endif
|
| }
|
|
|
| -void* StackFrameDepth::getStackStart() {
|
| +void* getStackStart() {
|
| #if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD)
|
| pthread_attr_t attr;
|
| int error;
|
| @@ -162,7 +121,7 @@ void* StackFrameDepth::getStackStart() {
|
| // See https://code.google.com/p/nativeclient/issues/detail?id=3431.
|
| return __libc_stack_end;
|
| #else
|
| - ASSERT_NOT_REACHED();
|
| + NOTREACHED();
|
| return nullptr;
|
| #endif
|
| #elif OS(MACOSX)
|
| @@ -181,4 +140,4 @@ void* StackFrameDepth::getStackStart() {
|
| #endif
|
| }
|
|
|
| -} // namespace blink
|
| +} // namespace WTF
|
|
|