- Revision
- 219994
- Author
- [email protected]
- Date
- 2017-07-27 22:11:19 -0700 (Thu, 27 Jul 2017)
Log Message
[WTF] Drop Thread initialization wait in some platforms by introducing StackBounds::newThreadStackBounds(PlatformThreadHandle&)
https://bugs.webkit.org/show_bug.cgi?id=174303
Reviewed by Mark Lam.
Currently, the caller thread of Thread::create() need to wait for completion of the initialization of the target thread.
This is because we need to initialize Thread::m_stack in the target thread. Before this patch, a target thread's
StackBounds can only be retrieved by the target thread itself. However, this potentially causes context-switching between
the caller and the target threads and hurts efficiency of creating threads.
Fortunately, in some platforms (including major platforms except for Windows), we can get StackBounds of a target
thread from a caller thread. This allows us to avoid waiting for completion of thread initialization.
In this patch, we introduce HAVE_STACK_BOUNDS_FOR_NEW_THREAD and StackBounds::newThreadStackBounds. When creating
a new thread, we will use StackBounds::newThreadStackBounds to get StackBounds if possible. As a result, we
do not need to wait for completion of thread initialization to ensure m_stack field of Thread is initialized.
While some documents claim that it is possible on Windows to get the StackBounds of another thread[1], the method relies on
undocumented Windows NT APIs (NtQueryInformationThread, NtReadVirtualMemory etc.). So in this patch, we just
use the conservative approach simply waiting for completion of thread initialization.
[1]: https://stackoverflow.com/questions/3918375/how-to-get-thread-stack-information-on-windows
* wtf/Platform.h:
* wtf/StackBounds.cpp:
(WTF::StackBounds::newThreadStackBounds):
(WTF::StackBounds::currentThreadStackBoundsInternal):
(WTF::StackBounds::initialize): Deleted.
* wtf/StackBounds.h:
(WTF::StackBounds::currentThreadStackBounds):
(WTF::StackBounds::StackBounds):
* wtf/Threading.cpp:
(WTF::Thread::NewThreadContext::NewThreadContext):
(WTF::Thread::entryPoint):
(WTF::Thread::create):
(WTF::Thread::initialize): Deleted.
* wtf/Threading.h:
* wtf/ThreadingPrimitives.h:
* wtf/ThreadingPthreads.cpp:
(WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
(WTF::wtfThreadEntryPoint):
(WTF::Thread::establishHandle):
(WTF::Thread::initializeCurrentThreadInternal):
(WTF::Thread::current):
* wtf/ThreadingWin.cpp:
(WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
(WTF::Thread::initializeCurrentThreadInternal):
(WTF::Thread::current):
* wtf/win/MainThreadWin.cpp:
(WTF::initializeMainThreadPlatform):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (219993 => 219994)
--- trunk/Source/WTF/ChangeLog 2017-07-28 04:44:45 UTC (rev 219993)
+++ trunk/Source/WTF/ChangeLog 2017-07-28 05:11:19 UTC (rev 219994)
@@ -1,3 +1,56 @@
+2017-07-27 Yusuke Suzuki <[email protected]>
+
+ [WTF] Drop Thread initialization wait in some platforms by introducing StackBounds::newThreadStackBounds(PlatformThreadHandle&)
+ https://bugs.webkit.org/show_bug.cgi?id=174303
+
+ Reviewed by Mark Lam.
+
+ Currently, the caller thread of Thread::create() need to wait for completion of the initialization of the target thread.
+ This is because we need to initialize Thread::m_stack in the target thread. Before this patch, a target thread's
+ StackBounds can only be retrieved by the target thread itself. However, this potentially causes context-switching between
+ the caller and the target threads and hurts efficiency of creating threads.
+
+ Fortunately, in some platforms (including major platforms except for Windows), we can get StackBounds of a target
+ thread from a caller thread. This allows us to avoid waiting for completion of thread initialization.
+
+ In this patch, we introduce HAVE_STACK_BOUNDS_FOR_NEW_THREAD and StackBounds::newThreadStackBounds. When creating
+ a new thread, we will use StackBounds::newThreadStackBounds to get StackBounds if possible. As a result, we
+ do not need to wait for completion of thread initialization to ensure m_stack field of Thread is initialized.
+
+ While some documents claim that it is possible on Windows to get the StackBounds of another thread[1], the method relies on
+ undocumented Windows NT APIs (NtQueryInformationThread, NtReadVirtualMemory etc.). So in this patch, we just
+ use the conservative approach simply waiting for completion of thread initialization.
+
+ [1]: https://stackoverflow.com/questions/3918375/how-to-get-thread-stack-information-on-windows
+
+ * wtf/Platform.h:
+ * wtf/StackBounds.cpp:
+ (WTF::StackBounds::newThreadStackBounds):
+ (WTF::StackBounds::currentThreadStackBoundsInternal):
+ (WTF::StackBounds::initialize): Deleted.
+ * wtf/StackBounds.h:
+ (WTF::StackBounds::currentThreadStackBounds):
+ (WTF::StackBounds::StackBounds):
+ * wtf/Threading.cpp:
+ (WTF::Thread::NewThreadContext::NewThreadContext):
+ (WTF::Thread::entryPoint):
+ (WTF::Thread::create):
+ (WTF::Thread::initialize): Deleted.
+ * wtf/Threading.h:
+ * wtf/ThreadingPrimitives.h:
+ * wtf/ThreadingPthreads.cpp:
+ (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
+ (WTF::wtfThreadEntryPoint):
+ (WTF::Thread::establishHandle):
+ (WTF::Thread::initializeCurrentThreadInternal):
+ (WTF::Thread::current):
+ * wtf/ThreadingWin.cpp:
+ (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
+ (WTF::Thread::initializeCurrentThreadInternal):
+ (WTF::Thread::current):
+ * wtf/win/MainThreadWin.cpp:
+ (WTF::initializeMainThreadPlatform):
+
2017-07-27 JF Bastien <[email protected]>
Update lock benchmarks
Modified: trunk/Source/WTF/wtf/Platform.h (219993 => 219994)
--- trunk/Source/WTF/wtf/Platform.h 2017-07-28 04:44:45 UTC (rev 219993)
+++ trunk/Source/WTF/wtf/Platform.h 2017-07-28 05:11:19 UTC (rev 219994)
@@ -1267,4 +1267,8 @@
#define HAVE_RSA_PSS 1
#endif
+#if !OS(WINDOWS) && !OS(SOLARIS)
+#define HAVE_STACK_BOUNDS_FOR_NEW_THREAD 1
+#endif
+
#endif /* WTF_Platform_h */
Modified: trunk/Source/WTF/wtf/StackBounds.cpp (219993 => 219994)
--- trunk/Source/WTF/wtf/StackBounds.cpp 2017-07-28 04:44:45 UTC (rev 219993)
+++ trunk/Source/WTF/wtf/StackBounds.cpp 2017-07-28 05:11:19 UTC (rev 219994)
@@ -48,56 +48,64 @@
#if OS(DARWIN)
-void StackBounds::initialize()
+StackBounds StackBounds::newThreadStackBounds(PlatformThreadHandle thread)
{
- pthread_t thread = pthread_self();
- m_origin = pthread_get_stackaddr_np(thread);
- rlim_t size = 0;
+ void* origin = pthread_get_stackaddr_np(thread);
+ rlim_t size = pthread_get_stacksize_np(thread);
+ void* bound = static_cast<char*>(origin) - size;
+ return StackBounds { origin, bound };
+}
+
+StackBounds StackBounds::currentThreadStackBoundsInternal()
+{
if (pthread_main_np()) {
// FIXME: <rdar://problem/13741204>
// pthread_get_size lies to us when we're the main thread, use get_rlimit instead
+ void* origin = pthread_get_stackaddr_np(pthread_self());
rlimit limit;
getrlimit(RLIMIT_STACK, &limit);
- size = limit.rlim_cur;
- } else
- size = pthread_get_stacksize_np(thread);
-
- m_bound = static_cast<char*>(m_origin) - size;
+ rlim_t size = limit.rlim_cur;
+ void* bound = static_cast<char*>(origin) - size;
+ return StackBounds { origin, bound };
+ }
+ return newThreadStackBounds(pthread_self());
}
#elif OS(SOLARIS)
-void StackBounds::initialize()
+StackBounds StackBounds::currentThreadStackBoundsInternal()
{
stack_t s;
thr_stksegment(&s);
- m_origin = s.ss_sp;
- m_bound = static_cast<char*>(m_origin) - s.ss_size;
+ void* origin = s.ss_sp;
+ void* bound = static_cast<char*>(origin) - s.ss_size;
+ return StackBounds { origin, bound };
}
-#elif OS(OPENBSD)
+#elif OS(UNIX)
-void StackBounds::initialize()
+#if OS(OPENBSD)
+
+StackBounds StackBounds::newThreadStackBounds(PlatformThreadHandle thread)
{
- pthread_t thread = pthread_self();
stack_t stack;
pthread_stackseg_np(thread, &stack);
- m_origin = stack.ss_sp;
+ void* origin = stack.ss_sp;
#if CPU(HPPA)
- m_bound = static_cast<char*>(m_origin) + stack.ss_size;
+ void* bound = static_cast<char*>(origin) + stack.ss_size;
#else
- m_bound = static_cast<char*>(m_origin) - stack.ss_size;
+ void* bound = static_cast<char*>(origin) - stack.ss_size;
#endif
+ return StackBounds { origin, bound };
}
-#elif OS(UNIX)
+#else // !OS(OPENBSD)
-void StackBounds::initialize()
+StackBounds StackBounds::newThreadStackBounds(PlatformThreadHandle thread)
{
- void* stackBase = 0;
+ void* bound = nullptr;
size_t stackSize = 0;
- pthread_t thread = pthread_self();
pthread_attr_t sattr;
pthread_attr_init(&sattr);
#if HAVE(PTHREAD_NP_H) || OS(NETBSD)
@@ -107,23 +115,30 @@
// FIXME: this function is non-portable; other POSIX systems may have different np alternatives
pthread_getattr_np(thread, &sattr);
#endif
- int rc = pthread_attr_getstack(&sattr, &stackBase, &stackSize);
- (void)rc; // FIXME: Deal with error code somehow? Seems fatal.
- ASSERT(stackBase);
+ int rc = pthread_attr_getstack(&sattr, &bound, &stackSize);
+ UNUSED_PARAM(rc);
+ ASSERT(bound);
pthread_attr_destroy(&sattr);
- m_bound = stackBase;
- m_origin = static_cast<char*>(stackBase) + stackSize;
+ void* origin = static_cast<char*>(bound) + stackSize;
+ return StackBounds { origin, bound };
}
+#endif // OS(OPENBSD)
+
+StackBounds StackBounds::currentThreadStackBoundsInternal()
+{
+ return newThreadStackBounds(pthread_self());
+}
+
#elif OS(WINDOWS)
-void StackBounds::initialize()
+StackBounds StackBounds::currentThreadStackBoundsInternal()
{
MEMORY_BASIC_INFORMATION stackOrigin = { 0 };
VirtualQuery(&stackOrigin, &stackOrigin, sizeof(stackOrigin));
// stackOrigin.AllocationBase points to the reserved stack memory base address.
- m_origin = static_cast<char*>(stackOrigin.BaseAddress) + stackOrigin.RegionSize;
+ void* origin = static_cast<char*>(stackOrigin.BaseAddress) + stackOrigin.RegionSize;
// The stack on Windows consists out of three parts (uncommitted memory, a guard page and present
// committed memory). The 3 regions have different BaseAddresses but all have the same AllocationBase
// since they are all from the same VirtualAlloc. The 3 regions are laid out in memory (from high to
@@ -154,7 +169,7 @@
VirtualQuery(static_cast<char*>(guardPage.BaseAddress) + guardPage.RegionSize, &committedMemory, sizeof(committedMemory));
ASSERT(committedMemory.State == MEM_COMMIT);
- void* computedEnd = static_cast<char*>(m_origin) - (uncommittedMemory.RegionSize + guardPage.RegionSize + committedMemory.RegionSize);
+ void* computedEnd = static_cast<char*>(origin) - (uncommittedMemory.RegionSize + guardPage.RegionSize + committedMemory.RegionSize);
ASSERT(stackOrigin.AllocationBase == uncommittedMemory.AllocationBase);
ASSERT(stackOrigin.AllocationBase == guardPage.AllocationBase);
@@ -162,7 +177,8 @@
ASSERT(stackOrigin.AllocationBase == uncommittedMemory.BaseAddress);
ASSERT(endOfStack == computedEnd);
#endif // NDEBUG
- m_bound = static_cast<char*>(endOfStack) + guardPage.RegionSize;
+ void* bound = static_cast<char*>(endOfStack) + guardPage.RegionSize;
+ return StackBounds { origin, bound };
}
#else
Modified: trunk/Source/WTF/wtf/StackBounds.h (219993 => 219994)
--- trunk/Source/WTF/wtf/StackBounds.h 2017-07-28 04:44:45 UTC (rev 219993)
+++ trunk/Source/WTF/wtf/StackBounds.h 2017-07-28 05:11:19 UTC (rev 219994)
@@ -28,6 +28,7 @@
#define StackBounds_h
#include <algorithm>
+#include <wtf/ThreadingPrimitives.h>
namespace WTF {
@@ -42,20 +43,17 @@
public:
static constexpr StackBounds emptyBounds() { return StackBounds(); }
+#if HAVE(STACK_BOUNDS_FOR_NEW_THREAD)
+ // This function is only effective for newly created threads. In some platform, it returns a bogus value for the main thread.
+ static StackBounds newThreadStackBounds(PlatformThreadHandle);
+#endif
static StackBounds currentThreadStackBounds()
{
- StackBounds bounds;
- bounds.initialize();
- bounds.checkConsistency();
- return bounds;
+ auto result = currentThreadStackBoundsInternal();
+ result.checkConsistency();
+ return result;
}
- StackBounds(void* origin, void* end)
- : m_origin(origin)
- , m_bound(end)
- {
- }
-
void* origin() const
{
ASSERT(m_origin);
@@ -127,6 +125,12 @@
}
private:
+ StackBounds(void* origin, void* end)
+ : m_origin(origin)
+ , m_bound(end)
+ {
+ }
+
constexpr StackBounds()
: m_origin(nullptr)
, m_bound(nullptr)
@@ -133,7 +137,7 @@
{
}
- WTF_EXPORT_PRIVATE void initialize();
+ WTF_EXPORT_PRIVATE static StackBounds currentThreadStackBoundsInternal();
void checkConsistency() const
{
Modified: trunk/Source/WTF/wtf/Threading.cpp (219993 => 219994)
--- trunk/Source/WTF/wtf/Threading.cpp 2017-07-28 04:44:45 UTC (rev 219993)
+++ trunk/Source/WTF/wtf/Threading.cpp 2017-07-28 05:11:19 UTC (rev 219994)
@@ -46,17 +46,25 @@
namespace WTF {
-enum class Stage {
- Start, EstablishedHandle, Initialized
-};
+struct Thread::NewThreadContext : public ThreadSafeRefCounted<NewThreadContext> {
+public:
+ NewThreadContext(const char* name, Function<void()>&& entryPoint, Ref<Thread>&& thread)
+ : name(name)
+ , entryPoint(WTFMove(entryPoint))
+ , thread(WTFMove(thread))
+ {
+ }
-struct Thread::NewThreadContext {
const char* name;
Function<void()> entryPoint;
- Stage stage;
+ Ref<Thread> thread;
Mutex mutex;
+ enum class Stage { Start, EstablishedHandle, Initialized };
+ Stage stage { Stage::Start };
+
+#if !HAVE(STACK_BOUNDS_FOR_NEW_THREAD)
ThreadCondition condition;
- Thread& thread;
+#endif
};
const char* Thread::normalizeThreadName(const char* threadName)
@@ -86,24 +94,31 @@
#endif
}
-void Thread::entryPoint(NewThreadContext* context)
+void Thread::entryPoint(NewThreadContext* newThreadContext)
{
Function<void()> function;
{
+ // Ref is already incremented by Thread::create.
+ Ref<NewThreadContext> context = adoptRef(*newThreadContext);
// Block until our creating thread has completed any extra setup work, including establishing ThreadIdentifier.
MutexLocker locker(context->mutex);
- ASSERT(context->stage == Stage::EstablishedHandle);
+ ASSERT(context->stage == NewThreadContext::Stage::EstablishedHandle);
// Initialize thread holder with established ID.
- ThreadHolder::initialize(context->thread);
+ ThreadHolder::initialize(context->thread.get());
- Thread::initializeCurrentThreadInternal(context->thread, context->name);
+ Thread::initializeCurrentThreadInternal(context->name);
function = WTFMove(context->entryPoint);
+#if !HAVE(STACK_BOUNDS_FOR_NEW_THREAD)
+ context->thread->m_stack = StackBounds::currentThreadStackBounds();
// Ack completion of initialization to the creating thread.
- context->stage = Stage::Initialized;
+ context->stage = NewThreadContext::Stage::Initialized;
context->condition.signal();
+#endif
}
+
+ ASSERT(!Thread::current().stack().isEmpty());
function();
}
@@ -110,14 +125,33 @@
RefPtr<Thread> Thread::create(const char* name, Function<void()>&& entryPoint)
{
Ref<Thread> thread = adoptRef(*new Thread());
- NewThreadContext context { name, WTFMove(entryPoint), Stage::Start, { }, { }, thread.get() };
- MutexLocker locker(context.mutex);
- if (!thread->establishHandle(&context))
- return nullptr;
- context.stage = Stage::EstablishedHandle;
- // After establishing Thread, release the mutex and wait for completion of initialization.
- while (context.stage != Stage::Initialized)
- context.condition.wait(context.mutex);
+ Ref<NewThreadContext> context = adoptRef(*new NewThreadContext { name, WTFMove(entryPoint), thread.copyRef() });
+ // Increment the context ref on behalf of the created thread. We do not just use a unique_ptr and leak it to the created thread because both the creator and created thread has a need to keep the context alive:
+ // 1. the created thread needs to keep it alive because Thread::create() can exit before the created thread has a chance to use the context.
+ // 2. the creator thread (if HAVE(STACK_BOUNDS_FOR_NEW_THREAD) is false) needs to keep it alive because the created thread may exit before the creator has a chance to wake up from waiting for the completion of the created thread's initialization. This waiting uses a condition variable in the context.
+ // Hence, a joint ownership model is needed if HAVE(STACK_BOUNDS_FOR_NEW_THREAD) is false. To simplify the code, we just go with joint ownership by both the creator and created threads,
+ // and make the context ThreadSafeRefCounted.
+ context->ref();
+ {
+ MutexLocker locker(context->mutex);
+ if (!thread->establishHandle(context.ptr())) {
+ context->deref();
+ return nullptr;
+ }
+ context->stage = NewThreadContext::Stage::EstablishedHandle;
+
+#if HAVE(STACK_BOUNDS_FOR_NEW_THREAD)
+ thread->m_stack = StackBounds::newThreadStackBounds(thread->m_handle);
+#else
+ // In platforms which do not support StackBounds::newThreadStackBounds(), we do not have a way to get stack
+ // bounds outside the target thread itself. Thus, we need to initialize thread information in the target thread
+ // and wait for completion of initialization in the caller side.
+ while (context->stage != NewThreadContext::Stage::Initialized)
+ context->condition.wait(context->mutex);
+#endif
+ }
+
+ ASSERT(!thread->stack().isEmpty());
return WTFMove(thread);
}
@@ -129,11 +163,6 @@
return nullptr;
}
-void Thread::initialize()
-{
- m_stack = StackBounds::currentThreadStackBounds();
-}
-
static bool shouldRemoveThreadFromThreadGroup()
{
#if OS(WINDOWS)
Modified: trunk/Source/WTF/wtf/Threading.h (219993 => 219994)
--- trunk/Source/WTF/wtf/Threading.h 2017-07-28 04:44:45 UTC (rev 219993)
+++ trunk/Source/WTF/wtf/Threading.h 2017-07-28 05:11:19 UTC (rev 219994)
@@ -114,8 +114,8 @@
// Called in the thread during initialization.
// Helpful for platforms where the thread name must be set from within the thread.
- static void initializeCurrentThreadInternal(Thread&, const char* threadName);
- static void initializeCurrentThreadEvenIfNonWTFCreated(Thread&);
+ static void initializeCurrentThreadInternal(const char* threadName);
+ static void initializeCurrentThreadEvenIfNonWTFCreated();
WTF_EXPORT_PRIVATE static const unsigned lockSpinLimit;
WTF_EXPORT_PRIVATE static void yield();
@@ -146,12 +146,12 @@
#endif
struct NewThreadContext;
- static void entryPoint(NewThreadContext* data);
+ static void entryPoint(NewThreadContext*);
protected:
Thread();
// Internal platform-specific Thread establishment implementation.
- bool establishHandle(NewThreadContext* data);
+ bool establishHandle(NewThreadContext*);
#if USE(PTHREADS)
void establishPlatformSpecificHandle(pthread_t);
@@ -158,7 +158,6 @@
#else
void establishPlatformSpecificHandle(HANDLE, ThreadIdentifier);
#endif
- void initialize();
#if USE(PTHREADS) && !OS(DARWIN)
static void signalHandlerSuspendResume(int, siginfo_t*, void* ucontext);
Modified: trunk/Source/WTF/wtf/ThreadingPrimitives.h (219993 => 219994)
--- trunk/Source/WTF/wtf/ThreadingPrimitives.h 2017-07-28 04:44:45 UTC (rev 219993)
+++ trunk/Source/WTF/wtf/ThreadingPrimitives.h 2017-07-28 05:11:19 UTC (rev 219994)
@@ -46,9 +46,11 @@
namespace WTF {
#if USE(PTHREADS)
-typedef pthread_mutex_t PlatformMutex;
-typedef pthread_cond_t PlatformCondition;
+using PlatformThreadHandle = pthread_t;
+using PlatformMutex = pthread_mutex_t;
+using PlatformCondition = pthread_cond_t;
#elif OS(WINDOWS)
+using PlatformThreadHandle = HANDLE;
struct PlatformMutex {
CRITICAL_SECTION m_internalMutex;
size_t m_recursionCount;
Modified: trunk/Source/WTF/wtf/ThreadingPthreads.cpp (219993 => 219994)
--- trunk/Source/WTF/wtf/ThreadingPthreads.cpp 2017-07-28 04:44:45 UTC (rev 219993)
+++ trunk/Source/WTF/wtf/ThreadingPthreads.cpp 2017-07-28 05:11:19 UTC (rev 219994)
@@ -188,9 +188,8 @@
#endif
}
-void Thread::initializeCurrentThreadEvenIfNonWTFCreated(Thread& thread)
+void Thread::initializeCurrentThreadEvenIfNonWTFCreated()
{
- thread.initialize();
#if !OS(DARWIN)
sigset_t mask;
sigemptyset(&mask);
@@ -199,13 +198,13 @@
#endif
}
-static void* wtfThreadEntryPoint(void* data)
+static void* wtfThreadEntryPoint(void* context)
{
- Thread::entryPoint(reinterpret_cast<Thread::NewThreadContext*>(data));
+ Thread::entryPoint(reinterpret_cast<Thread::NewThreadContext*>(context));
return nullptr;
}
-bool Thread::establishHandle(NewThreadContext* data)
+bool Thread::establishHandle(NewThreadContext* context)
{
pthread_t threadHandle;
pthread_attr_t attr;
@@ -213,10 +212,10 @@
#if HAVE(QOS_CLASSES)
pthread_attr_set_qos_class_np(&attr, adjustedQOSClass(QOS_CLASS_USER_INITIATED), 0);
#endif
- int error = pthread_create(&threadHandle, &attr, wtfThreadEntryPoint, data);
+ int error = pthread_create(&threadHandle, &attr, wtfThreadEntryPoint, context);
pthread_attr_destroy(&attr);
if (error) {
- LOG_ERROR("Failed to create pthread at entry point %p with data %p", wtfThreadEntryPoint, data);
+ LOG_ERROR("Failed to create pthread at entry point %p with context %p", wtfThreadEntryPoint, context);
return false;
}
establishPlatformSpecificHandle(threadHandle);
@@ -223,7 +222,7 @@
return true;
}
-void Thread::initializeCurrentThreadInternal(Thread& thread, const char* threadName)
+void Thread::initializeCurrentThreadInternal(const char* threadName)
{
#if HAVE(PTHREAD_SETNAME_NP)
pthread_setname_np(normalizeThreadName(threadName));
@@ -232,7 +231,7 @@
#else
UNUSED_PARAM(threadName);
#endif
- initializeCurrentThreadEvenIfNonWTFCreated(thread);
+ initializeCurrentThreadEvenIfNonWTFCreated();
}
void Thread::changePriority(int delta)
@@ -295,8 +294,9 @@
// Not a WTF-created thread, ThreadIdentifier is not established yet.
Ref<Thread> thread = adoptRef(*new Thread());
thread->establishPlatformSpecificHandle(pthread_self());
+ thread->m_stack = StackBounds::currentThreadStackBounds();
ThreadHolder::initialize(thread.get());
- initializeCurrentThreadEvenIfNonWTFCreated(thread.get());
+ initializeCurrentThreadEvenIfNonWTFCreated();
return thread.get();
}
Modified: trunk/Source/WTF/wtf/ThreadingWin.cpp (219993 => 219994)
--- trunk/Source/WTF/wtf/ThreadingWin.cpp 2017-07-28 04:44:45 UTC (rev 219993)
+++ trunk/Source/WTF/wtf/ThreadingWin.cpp 2017-07-28 05:11:19 UTC (rev 219994)
@@ -115,9 +115,8 @@
CloseHandle(m_handle);
}
-void Thread::initializeCurrentThreadEvenIfNonWTFCreated(Thread& thread)
+void Thread::initializeCurrentThreadEvenIfNonWTFCreated()
{
- thread.initialize();
}
// MS_VC_EXCEPTION, THREADNAME_INFO, and setThreadNameInternal all come from <http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>.
@@ -132,7 +131,7 @@
} THREADNAME_INFO;
#pragma pack(pop)
-void Thread::initializeCurrentThreadInternal(Thread& thread, const char* szThreadName)
+void Thread::initializeCurrentThreadInternal(const char* szThreadName)
{
#if COMPILER(MINGW)
// FIXME: Implement thread name setting with MingW.
@@ -149,7 +148,7 @@
} __except (EXCEPTION_CONTINUE_EXECUTION) {
}
#endif
- initializeCurrentThreadEvenIfNonWTFCreated(thread);
+ initializeCurrentThreadEvenIfNonWTFCreated();
}
void Thread::initializePlatformThreading()
@@ -257,8 +256,9 @@
RELEASE_ASSERT(isSuccessful);
thread->establishPlatformSpecificHandle(handle, currentID());
+ thread->m_stack = StackBounds::currentThreadStackBounds();
ThreadHolder::initialize(thread.get());
- initializeCurrentThreadEvenIfNonWTFCreated(thread.get());
+ initializeCurrentThreadEvenIfNonWTFCreated();
return thread.get();
}
Modified: trunk/Source/WTF/wtf/win/MainThreadWin.cpp (219993 => 219994)
--- trunk/Source/WTF/wtf/win/MainThreadWin.cpp 2017-07-28 04:44:45 UTC (rev 219993)
+++ trunk/Source/WTF/wtf/win/MainThreadWin.cpp 2017-07-28 05:11:19 UTC (rev 219994)
@@ -64,7 +64,7 @@
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, HWND_MESSAGE, 0, 0, 0);
threadingFiredMessage = RegisterWindowMessageW(L"com.apple.WebKit.MainThreadFired");
- Thread::initializeCurrentThreadInternal(Thread::current(), "Main Thread");
+ Thread::initializeCurrentThreadInternal("Main Thread");
}
void scheduleDispatchFunctionsOnMainThread()