OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "platform/heap/StackFrameDepth.h" | 6 #include "platform/heap/StackFrameDepth.h" |
7 | 7 |
8 #include "public/platform/Platform.h" | 8 #include "public/platform/Platform.h" |
9 | 9 |
10 #if OS(WIN) | 10 #if OS(WIN) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 RELEASE_ASSERT(!error); | 90 RELEASE_ASSERT(!error); |
91 pthread_attr_destroy(&attr); | 91 pthread_attr_destroy(&attr); |
92 return size; | 92 return size; |
93 } | 93 } |
94 #if OS(FREEBSD) | 94 #if OS(FREEBSD) |
95 pthread_attr_destroy(&attr); | 95 pthread_attr_destroy(&attr); |
96 #endif | 96 #endif |
97 | 97 |
98 return 0; | 98 return 0; |
99 #elif OS(MACOSX) | 99 #elif OS(MACOSX) |
100 // FIXME: pthread_get_stacksize_np() returns shorter size than actual stack | 100 // pthread_get_stacksize_np() returns too low a value for the main thread on |
101 // size for the main thread on Mavericks(10.9). | 101 // OSX 10.9, http://mail.openjdk.java.net/pipermail/hotspot-dev/2013-October
/011369.html |
102 return 0; | 102 // |
| 103 // Multiple workarounds possible, adopt the one made by https://github.com/r
obovm/robovm/issues/274 |
| 104 // (cf. https://developer.apple.com/library/mac/documentation/Cocoa/Conceptu
al/Multithreading/CreatingThreads/CreatingThreads.html |
| 105 // on why hardcoding sizes is reasonable.) |
| 106 if (pthread_main_np()) { |
| 107 #if defined(IOS) |
| 108 pthread_attr_t attr; |
| 109 pthread_attr_init(&attr); |
| 110 size_t guardSize = 0; |
| 111 pthread_attr_getguardsize(&attr, &guardSize); |
| 112 // Stack size for the main thread is 1MB on iOS including the guard page
size. |
| 113 return (1 * 1024 * 1024 - guardSize); |
| 114 #else |
| 115 // Stack size for the main thread is 8MB on OSX excluding the guard page
size. |
| 116 return (8 * 1024 * 1024); |
| 117 #endif |
| 118 } |
| 119 return pthread_get_stacksize_np(pthread_self()); |
103 #elif OS(WIN) && COMPILER(MSVC) | 120 #elif OS(WIN) && COMPILER(MSVC) |
104 return ThreadState::current()->threadStackSize(); | 121 return ThreadState::current()->threadStackSize(); |
105 #else | 122 #else |
106 #error "Stack frame size estimation not supported on this platform." | 123 #error "Stack frame size estimation not supported on this platform." |
107 return 0; | 124 return 0; |
108 #endif | 125 #endif |
109 } | 126 } |
110 | 127 |
111 void* StackFrameDepth::getStackStart() | 128 void* StackFrameDepth::getStackStart() |
112 { | 129 { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 return reinterpret_cast<void*>(__readgsqword(offsetof(NT_TIB64, StackBase)))
; | 167 return reinterpret_cast<void*>(__readgsqword(offsetof(NT_TIB64, StackBase)))
; |
151 #else | 168 #else |
152 return reinterpret_cast<void*>(__readfsdword(offsetof(NT_TIB, StackBase))); | 169 return reinterpret_cast<void*>(__readfsdword(offsetof(NT_TIB, StackBase))); |
153 #endif | 170 #endif |
154 #else | 171 #else |
155 #error Unsupported getStackStart on this platform. | 172 #error Unsupported getStackStart on this platform. |
156 #endif | 173 #endif |
157 } | 174 } |
158 | 175 |
159 } // namespace blink | 176 } // namespace blink |
OLD | NEW |