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

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

Issue 1527513002: Oilpan: support OSX thread stack size discovery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « no previous file | 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 e53e6a3cf48c13ea8f035b3e8c474bdc490866ed..b2203cdcfb66c015addc36abac473935d7d3f3f3 100644
--- a/third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp
+++ b/third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp
@@ -97,9 +97,26 @@ size_t StackFrameDepth::getUnderestimatedStackSize()
return 0;
#elif OS(MACOSX)
- // FIXME: pthread_get_stacksize_np() returns shorter size than actual stack
- // size for the main thread on Mavericks(10.9).
- return 0;
+ // pthread_get_stacksize_np() returns too low a value for the main thread on
+ // OSX 10.9, http://mail.openjdk.java.net/pipermail/hotspot-dev/2013-October/011369.html
+ //
+ // Multiple workarounds possible, adopt the one made by https://github.com/robovm/robovm/issues/274
+ // (cf. https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/CreatingThreads/CreatingThreads.html
+ // on why hardcoding sizes is reasonable.)
+ if (pthread_main_np()) {
+#if defined(IOS)
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+ size_t guardSize = 0;
+ pthread_attr_getguardsize(&attr, &guardSize);
+ // Stack size for the main thread is 1MB on iOS including the guard page size.
+ return (1 * 1024 * 1024 - guardSize);
+#else
+ // Stack size for the main thread is 8MB on OSX excluding the guard page size.
+ return (8 * 1024 * 1024);
+#endif
+ }
+ return pthread_get_stacksize_np(pthread_self());
#elif OS(WIN) && COMPILER(MSVC)
return ThreadState::current()->threadStackSize();
#else
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698