Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Unified Diff: third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp

Issue 1673543002: Split out fallback stack limit determination. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment improvements Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/heap/StackFrameDepth.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()
« no previous file with comments | « third_party/WebKit/Source/platform/heap/StackFrameDepth.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698