<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[214319] trunk/Source/JavaScriptCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/214319">214319</a></dd>
<dt>Author</dt> <dd>utatane.tea@gmail.com</dd>
<dt>Date</dt> <dd>2017-03-23 14:54:58 -0700 (Thu, 23 Mar 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>[JSC] MachineThreads does not consider situation that one thread has multiple VMs
https://bugs.webkit.org/show_bug.cgi?id=169819
Reviewed by Mark Lam.
The Linux port of PlatformThread suspend/resume mechanism relies on having a thread
specific singleton thread data, and was relying on MachineThreads::Thread to be this
thread specific singleton. But because MachineThreads::Thread is not a thread specific
singleton, we can get a deadlock in the GTK port's DatabaseProcess.
This patch fixes this issue by moving per thread data from MachineThreads::Thread to
MachineThreads::ThreadData, where there will only be one instance of
MachineThreads::ThreadData per thread. Each MachineThreads::Thread will now point to
the same MachineThreads::ThreadData for any given thread.
* heap/MachineStackMarker.cpp:
(pthreadSignalHandlerSuspendResume):
(JSC::threadData):
(JSC::MachineThreads::Thread::Thread):
(JSC::MachineThreads::Thread::createForCurrentThread):
(JSC::MachineThreads::Thread::operator==):
(JSC::MachineThreads::ThreadData::ThreadData):
(JSC::MachineThreads::ThreadData::~ThreadData):
(JSC::MachineThreads::ThreadData::suspend):
(JSC::MachineThreads::ThreadData::resume):
(JSC::MachineThreads::ThreadData::getRegisters):
(JSC::MachineThreads::ThreadData::Registers::stackPointer):
(JSC::MachineThreads::ThreadData::Registers::framePointer):
(JSC::MachineThreads::ThreadData::Registers::instructionPointer):
(JSC::MachineThreads::ThreadData::Registers::llintPC):
(JSC::MachineThreads::ThreadData::freeRegisters):
(JSC::MachineThreads::ThreadData::captureStack):
(JSC::MachineThreads::tryCopyOtherThreadStacks):
(JSC::MachineThreads::Thread::~Thread): Deleted.
(JSC::MachineThreads::Thread::suspend): Deleted.
(JSC::MachineThreads::Thread::resume): Deleted.
(JSC::MachineThreads::Thread::getRegisters): Deleted.
(JSC::MachineThreads::Thread::Registers::stackPointer): Deleted.
(JSC::MachineThreads::Thread::Registers::framePointer): Deleted.
(JSC::MachineThreads::Thread::Registers::instructionPointer): Deleted.
(JSC::MachineThreads::Thread::Registers::llintPC): Deleted.
(JSC::MachineThreads::Thread::freeRegisters): Deleted.
(JSC::MachineThreads::Thread::captureStack): Deleted.
* heap/MachineStackMarker.h:
(JSC::MachineThreads::Thread::operator!=):
(JSC::MachineThreads::Thread::suspend):
(JSC::MachineThreads::Thread::resume):
(JSC::MachineThreads::Thread::getRegisters):
(JSC::MachineThreads::Thread::freeRegisters):
(JSC::MachineThreads::Thread::captureStack):
(JSC::MachineThreads::Thread::platformThread):
(JSC::MachineThreads::Thread::stackBase):
(JSC::MachineThreads::Thread::stackEnd):
* runtime/SamplingProfiler.cpp:
(JSC::FrameWalker::isValidFramePointer):
* runtime/VMTraps.cpp:
(JSC::findActiveVMAndStackBounds):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapMachineStackMarkercpp">trunk/Source/JavaScriptCore/heap/MachineStackMarker.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapMachineStackMarkerh">trunk/Source/JavaScriptCore/heap/MachineStackMarker.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeSamplingProfilercpp">trunk/Source/JavaScriptCore/runtime/SamplingProfiler.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeVMTrapscpp">trunk/Source/JavaScriptCore/runtime/VMTraps.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (214318 => 214319)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2017-03-23 21:45:08 UTC (rev 214318)
+++ trunk/Source/JavaScriptCore/ChangeLog        2017-03-23 21:54:58 UTC (rev 214319)
</span><span class="lines">@@ -1,3 +1,63 @@
</span><ins>+2017-03-23 Yusuke Suzuki <utatane.tea@gmail.com>
+
+ [JSC] MachineThreads does not consider situation that one thread has multiple VMs
+ https://bugs.webkit.org/show_bug.cgi?id=169819
+
+ Reviewed by Mark Lam.
+
+ The Linux port of PlatformThread suspend/resume mechanism relies on having a thread
+ specific singleton thread data, and was relying on MachineThreads::Thread to be this
+ thread specific singleton. But because MachineThreads::Thread is not a thread specific
+ singleton, we can get a deadlock in the GTK port's DatabaseProcess.
+
+ This patch fixes this issue by moving per thread data from MachineThreads::Thread to
+ MachineThreads::ThreadData, where there will only be one instance of
+ MachineThreads::ThreadData per thread. Each MachineThreads::Thread will now point to
+ the same MachineThreads::ThreadData for any given thread.
+
+ * heap/MachineStackMarker.cpp:
+ (pthreadSignalHandlerSuspendResume):
+ (JSC::threadData):
+ (JSC::MachineThreads::Thread::Thread):
+ (JSC::MachineThreads::Thread::createForCurrentThread):
+ (JSC::MachineThreads::Thread::operator==):
+ (JSC::MachineThreads::ThreadData::ThreadData):
+ (JSC::MachineThreads::ThreadData::~ThreadData):
+ (JSC::MachineThreads::ThreadData::suspend):
+ (JSC::MachineThreads::ThreadData::resume):
+ (JSC::MachineThreads::ThreadData::getRegisters):
+ (JSC::MachineThreads::ThreadData::Registers::stackPointer):
+ (JSC::MachineThreads::ThreadData::Registers::framePointer):
+ (JSC::MachineThreads::ThreadData::Registers::instructionPointer):
+ (JSC::MachineThreads::ThreadData::Registers::llintPC):
+ (JSC::MachineThreads::ThreadData::freeRegisters):
+ (JSC::MachineThreads::ThreadData::captureStack):
+ (JSC::MachineThreads::tryCopyOtherThreadStacks):
+ (JSC::MachineThreads::Thread::~Thread): Deleted.
+ (JSC::MachineThreads::Thread::suspend): Deleted.
+ (JSC::MachineThreads::Thread::resume): Deleted.
+ (JSC::MachineThreads::Thread::getRegisters): Deleted.
+ (JSC::MachineThreads::Thread::Registers::stackPointer): Deleted.
+ (JSC::MachineThreads::Thread::Registers::framePointer): Deleted.
+ (JSC::MachineThreads::Thread::Registers::instructionPointer): Deleted.
+ (JSC::MachineThreads::Thread::Registers::llintPC): Deleted.
+ (JSC::MachineThreads::Thread::freeRegisters): Deleted.
+ (JSC::MachineThreads::Thread::captureStack): Deleted.
+ * heap/MachineStackMarker.h:
+ (JSC::MachineThreads::Thread::operator!=):
+ (JSC::MachineThreads::Thread::suspend):
+ (JSC::MachineThreads::Thread::resume):
+ (JSC::MachineThreads::Thread::getRegisters):
+ (JSC::MachineThreads::Thread::freeRegisters):
+ (JSC::MachineThreads::Thread::captureStack):
+ (JSC::MachineThreads::Thread::platformThread):
+ (JSC::MachineThreads::Thread::stackBase):
+ (JSC::MachineThreads::Thread::stackEnd):
+ * runtime/SamplingProfiler.cpp:
+ (JSC::FrameWalker::isValidFramePointer):
+ * runtime/VMTraps.cpp:
+ (JSC::findActiveVMAndStackBounds):
+
</ins><span class="cx"> 2017-03-23 Mark Lam <mark.lam@apple.com>
</span><span class="cx">
</span><span class="cx"> Clients of JSArray::tryCreateForInitializationPrivate() should do their own null checks.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapMachineStackMarkercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/MachineStackMarker.cpp (214318 => 214319)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/MachineStackMarker.cpp        2017-03-23 21:45:08 UTC (rev 214318)
+++ trunk/Source/JavaScriptCore/heap/MachineStackMarker.cpp        2017-03-23 21:54:58 UTC (rev 214319)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include <setjmp.h>
</span><span class="cx"> #include <stdlib.h>
</span><span class="cx"> #include <wtf/MainThread.h>
</span><ins>+#include <wtf/NeverDestroyed.h>
</ins><span class="cx"> #include <wtf/StdLibExtras.h>
</span><span class="cx">
</span><span class="cx"> #if OS(DARWIN)
</span><span class="lines">@@ -69,14 +70,14 @@
</span><span class="cx"> // We use SIGUSR2 to suspend and resume machine threads in JavaScriptCore.
</span><span class="cx"> static const int SigThreadSuspendResume = SIGUSR2;
</span><span class="cx"> static StaticLock globalSignalLock;
</span><del>-thread_local static std::atomic<JSC::MachineThreads::Thread*> threadLocalCurrentThread;
</del><ins>+thread_local static std::atomic<JSC::MachineThreads::ThreadData*> threadLocalCurrentThread { nullptr };
</ins><span class="cx">
</span><span class="cx"> static void pthreadSignalHandlerSuspendResume(int, siginfo_t*, void* ucontext)
</span><span class="cx"> {
</span><span class="cx"> // Touching thread local atomic types from signal handlers is allowed.
</span><del>- JSC::MachineThreads::Thread* thread = threadLocalCurrentThread.load();
</del><ins>+ JSC::MachineThreads::ThreadData* threadData = threadLocalCurrentThread.load();
</ins><span class="cx">
</span><del>- if (thread->suspended.load(std::memory_order_acquire)) {
</del><ins>+ if (threadData->suspended.load(std::memory_order_acquire)) {
</ins><span class="cx"> // This is signal handler invocation that is intended to be used to resume sigsuspend.
</span><span class="cx"> // So this handler invocation itself should not process.
</span><span class="cx"> //
</span><span class="lines">@@ -88,9 +89,9 @@
</span><span class="cx">
</span><span class="cx"> ucontext_t* userContext = static_cast<ucontext_t*>(ucontext);
</span><span class="cx"> #if CPU(PPC)
</span><del>- thread->suspendedMachineContext = *userContext->uc_mcontext.uc_regs;
</del><ins>+ threadData->suspendedMachineContext = *userContext->uc_mcontext.uc_regs;
</ins><span class="cx"> #else
</span><del>- thread->suspendedMachineContext = userContext->uc_mcontext;
</del><ins>+ threadData->suspendedMachineContext = userContext->uc_mcontext;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> // Allow suspend caller to see that this thread is suspended.
</span><span class="lines">@@ -99,7 +100,7 @@
</span><span class="cx"> //
</span><span class="cx"> // And sem_post emits memory barrier that ensures that suspendedMachineContext is correctly saved.
</span><span class="cx"> // http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_11
</span><del>- sem_post(&thread->semaphoreForSuspendResume);
</del><ins>+ sem_post(&threadData->semaphoreForSuspendResume);
</ins><span class="cx">
</span><span class="cx"> // Reaching here, SigThreadSuspendResume is blocked in this handler (this is configured by sigaction's sa_mask).
</span><span class="cx"> // So before calling sigsuspend, SigThreadSuspendResume to this thread is deferred. This ensures that the handler is not executed recursively.
</span><span class="lines">@@ -109,7 +110,7 @@
</span><span class="cx"> sigsuspend(&blockedSignalSet);
</span><span class="cx">
</span><span class="cx"> // Allow resume caller to see that this thread is resumed.
</span><del>- sem_post(&thread->semaphoreForSuspendResume);
</del><ins>+ sem_post(&threadData->semaphoreForSuspendResume);
</ins><span class="cx"> }
</span><span class="cx"> #endif // USE(PTHREADS) && !OS(WINDOWS) && !OS(DARWIN)
</span><span class="cx">
</span><span class="lines">@@ -200,18 +201,29 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static MachineThreads::ThreadData* threadData()
+{
+ static NeverDestroyed<ThreadSpecific<MachineThreads::ThreadData, CanBeGCThread::True>> threadData;
+ return threadData.get();
+}
+
+MachineThreads::Thread::Thread(ThreadData* threadData)
+ : data(threadData)
+{
+ ASSERT(threadData);
+}
+
</ins><span class="cx"> Thread* MachineThreads::Thread::createForCurrentThread()
</span><span class="cx"> {
</span><del>- auto stackBounds = wtfThreadData().stack();
- return new Thread(currentPlatformThread(), stackBounds.origin(), stackBounds.end());
</del><ins>+ return new Thread(threadData());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool MachineThreads::Thread::operator==(const PlatformThread& other) const
</span><span class="cx"> {
</span><span class="cx"> #if OS(DARWIN) || OS(WINDOWS)
</span><del>- return platformThread == other;
</del><ins>+ return data->platformThread == other;
</ins><span class="cx"> #elif USE(PTHREADS)
</span><del>- return !!pthread_equal(platformThread, other);
</del><ins>+ return !!pthread_equal(data->platformThread, other);
</ins><span class="cx"> #else
</span><span class="cx"> #error Need a way to compare threads on this platform
</span><span class="cx"> #endif
</span><span class="lines">@@ -308,11 +320,13 @@
</span><span class="cx"> conservativeRoots.add(currentThreadState.stackTop, currentThreadState.stackOrigin, jitStubRoutines, codeBlocks);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-MachineThreads::Thread::Thread(const PlatformThread& platThread, void* base, void* end)
- : platformThread(platThread)
- , stackBase(base)
- , stackEnd(end)
</del><ins>+MachineThreads::ThreadData::ThreadData()
</ins><span class="cx"> {
</span><ins>+ auto stackBounds = wtfThreadData().stack();
+ platformThread = currentPlatformThread();
+ stackBase = stackBounds.origin();
+ stackEnd = stackBounds.end();
+
</ins><span class="cx"> #if OS(WINDOWS)
</span><span class="cx"> ASSERT(platformThread == GetCurrentThreadId());
</span><span class="cx"> bool isSuccessful =
</span><span class="lines">@@ -345,7 +359,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-MachineThreads::Thread::~Thread()
</del><ins>+MachineThreads::ThreadData::~ThreadData()
</ins><span class="cx"> {
</span><span class="cx"> #if OS(WINDOWS)
</span><span class="cx"> CloseHandle(platformThreadHandle);
</span><span class="lines">@@ -354,7 +368,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool MachineThreads::Thread::suspend()
</del><ins>+bool MachineThreads::ThreadData::suspend()
</ins><span class="cx"> {
</span><span class="cx"> #if OS(DARWIN)
</span><span class="cx"> kern_return_t result = thread_suspend(platformThread);
</span><span class="lines">@@ -391,7 +405,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void MachineThreads::Thread::resume()
</del><ins>+void MachineThreads::ThreadData::resume()
</ins><span class="cx"> {
</span><span class="cx"> #if OS(DARWIN)
</span><span class="cx"> thread_resume(platformThread);
</span><span class="lines">@@ -422,9 +436,9 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-size_t MachineThreads::Thread::getRegisters(Thread::Registers& registers)
</del><ins>+size_t MachineThreads::ThreadData::getRegisters(ThreadData::Registers& registers)
</ins><span class="cx"> {
</span><del>- Thread::Registers::PlatformRegisters& regs = registers.regs;
</del><ins>+ ThreadData::Registers::PlatformRegisters& regs = registers.regs;
</ins><span class="cx"> #if OS(DARWIN)
</span><span class="cx"> #if CPU(X86)
</span><span class="cx"> unsigned user_count = sizeof(regs)/sizeof(int);
</span><span class="lines">@@ -481,7 +495,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void* MachineThreads::Thread::Registers::stackPointer() const
</del><ins>+void* MachineThreads::ThreadData::Registers::stackPointer() const
</ins><span class="cx"> {
</span><span class="cx"> #if OS(DARWIN) || OS(WINDOWS) || ((OS(FREEBSD) || defined(__GLIBC__)) && ENABLE(JIT))
</span><span class="cx"> return MachineContext::stackPointer(regs);
</span><span class="lines">@@ -505,7 +519,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(SAMPLING_PROFILER)
</span><del>-void* MachineThreads::Thread::Registers::framePointer() const
</del><ins>+void* MachineThreads::ThreadData::Registers::framePointer() const
</ins><span class="cx"> {
</span><span class="cx"> #if OS(DARWIN) || OS(WINDOWS) || (OS(FREEBSD) || defined(__GLIBC__))
</span><span class="cx"> return MachineContext::framePointer(regs);
</span><span class="lines">@@ -514,7 +528,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void* MachineThreads::Thread::Registers::instructionPointer() const
</del><ins>+void* MachineThreads::ThreadData::Registers::instructionPointer() const
</ins><span class="cx"> {
</span><span class="cx"> #if OS(DARWIN) || OS(WINDOWS) || (OS(FREEBSD) || defined(__GLIBC__))
</span><span class="cx"> return MachineContext::instructionPointer(regs);
</span><span class="lines">@@ -523,7 +537,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void* MachineThreads::Thread::Registers::llintPC() const
</del><ins>+void* MachineThreads::ThreadData::Registers::llintPC() const
</ins><span class="cx"> {
</span><span class="cx"> // LLInt uses regT4 as PC.
</span><span class="cx"> #if OS(DARWIN) || OS(WINDOWS) || (OS(FREEBSD) || defined(__GLIBC__))
</span><span class="lines">@@ -534,9 +548,9 @@
</span><span class="cx"> }
</span><span class="cx"> #endif // ENABLE(SAMPLING_PROFILER)
</span><span class="cx">
</span><del>-void MachineThreads::Thread::freeRegisters(Thread::Registers& registers)
</del><ins>+void MachineThreads::ThreadData::freeRegisters(ThreadData::Registers& registers)
</ins><span class="cx"> {
</span><del>- Thread::Registers::PlatformRegisters& regs = registers.regs;
</del><ins>+ ThreadData::Registers::PlatformRegisters& regs = registers.regs;
</ins><span class="cx"> #if USE(PTHREADS) && !OS(WINDOWS) && !OS(DARWIN) && !((OS(FREEBSD) || defined(__GLIBC__)) && ENABLE(JIT))
</span><span class="cx"> pthread_attr_destroy(&regs.attribute);
</span><span class="cx"> #else
</span><span class="lines">@@ -559,7 +573,7 @@
</span><span class="cx"> return redZoneAdjustment;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-std::pair<void*, size_t> MachineThreads::Thread::captureStack(void* stackTop)
</del><ins>+std::pair<void*, size_t> MachineThreads::ThreadData::captureStack(void* stackTop)
</ins><span class="cx"> {
</span><span class="cx"> char* begin = reinterpret_cast_ptr<char*>(stackBase);
</span><span class="cx"> char* end = bitwise_cast<char*>(WTF::roundUpToMultipleOf<sizeof(void*)>(reinterpret_cast<uintptr_t>(stackTop)));
</span><span class="lines">@@ -647,12 +661,12 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Re-do the suspension to get the actual failure result for logging.
</span><del>- kern_return_t error = thread_suspend(thread->platformThread);
</del><ins>+ kern_return_t error = thread_suspend(thread->platformThread());
</ins><span class="cx"> ASSERT(error != KERN_SUCCESS);
</span><span class="cx">
</span><span class="cx"> WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION,
</span><span class="cx"> "JavaScript garbage collection encountered an invalid thread (err 0x%x): Thread [%d/%d: %p] platformThread %p.",
</span><del>- error, index, numberOfThreads, thread, reinterpret_cast<void*>(thread->platformThread));
</del><ins>+ error, index, numberOfThreads, thread, reinterpret_cast<void*>(thread->platformThread()));
</ins><span class="cx">
</span><span class="cx"> // Put the invalid thread on the threadsToBeDeleted list.
</span><span class="cx"> // We can't just delete it here because we have suspended other
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapMachineStackMarkerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/MachineStackMarker.h (214318 => 214319)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/MachineStackMarker.h        2017-03-23 21:45:08 UTC (rev 214318)
+++ trunk/Source/JavaScriptCore/heap/MachineStackMarker.h        2017-03-23 21:54:58 UTC (rev 214319)
</span><span class="lines">@@ -64,14 +64,13 @@
</span><span class="cx">
</span><span class="cx"> JS_EXPORT_PRIVATE void addCurrentThread(); // Only needs to be called by clients that can use the same heap from multiple threads.
</span><span class="cx">
</span><del>- class Thread {
</del><ins>+ class ThreadData {
</ins><span class="cx"> WTF_MAKE_FAST_ALLOCATED;
</span><del>- Thread(const PlatformThread& platThread, void* base, void* end);
-
</del><span class="cx"> public:
</span><del>- ~Thread();
</del><ins>+ ThreadData();
+ ~ThreadData();
</ins><span class="cx">
</span><del>- static Thread* createForCurrentThread();
</del><ins>+ static ThreadData* createForCurrentThread();
</ins><span class="cx">
</span><span class="cx"> struct Registers {
</span><span class="cx"> void* stackPointer() const;
</span><span class="lines">@@ -92,12 +91,9 @@
</span><span class="cx"> #else
</span><span class="cx"> #error Need a thread register struct for this platform
</span><span class="cx"> #endif
</span><del>-
</del><ins>+
</ins><span class="cx"> PlatformRegisters regs;
</span><span class="cx"> };
</span><del>-
- bool operator==(const PlatformThread& other) const;
- bool operator!=(const PlatformThread& other) const { return !(*this == other); }
</del><span class="cx">
</span><span class="cx"> bool suspend();
</span><span class="cx"> void resume();
</span><span class="lines">@@ -105,7 +101,6 @@
</span><span class="cx"> void freeRegisters(Registers&);
</span><span class="cx"> std::pair<void*, size_t> captureStack(void* stackTop);
</span><span class="cx">
</span><del>- Thread* next;
</del><span class="cx"> PlatformThread platformThread;
</span><span class="cx"> void* stackBase;
</span><span class="cx"> void* stackEnd;
</span><span class="lines">@@ -119,6 +114,32 @@
</span><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+ class Thread {
+ WTF_MAKE_FAST_ALLOCATED;
+ Thread(ThreadData*);
+
+ public:
+ using Registers = ThreadData::Registers;
+
+ static Thread* createForCurrentThread();
+
+ bool operator==(const PlatformThread& other) const;
+ bool operator!=(const PlatformThread& other) const { return !(*this == other); }
+
+ bool suspend() { return data->suspend(); }
+ void resume() { data->resume(); }
+ size_t getRegisters(Registers& regs) { return data->getRegisters(regs); }
+ void freeRegisters(Registers& regs) { data->freeRegisters(regs); }
+ std::pair<void*, size_t> captureStack(void* stackTop) { return data->captureStack(stackTop); }
+
+ const PlatformThread& platformThread() { return data->platformThread; }
+ void* stackBase() const { return data->stackBase; }
+ void* stackEnd() const { return data->stackEnd; }
+
+ Thread* next;
+ ThreadData* data;
+ };
+
</ins><span class="cx"> Lock& getLock() { return m_registeredThreadsMutex; }
</span><span class="cx"> Thread* threadsListHead(const AbstractLocker&) const { ASSERT(m_registeredThreadsMutex.isLocked()); return m_registeredThreads; }
</span><span class="cx"> Thread* machineThreadForCurrentThread();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeSamplingProfilercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/SamplingProfiler.cpp (214318 => 214319)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/SamplingProfiler.cpp        2017-03-23 21:45:08 UTC (rev 214318)
+++ trunk/Source/JavaScriptCore/runtime/SamplingProfiler.cpp        2017-03-23 21:54:58 UTC (rev 214319)
</span><span class="lines">@@ -169,8 +169,8 @@
</span><span class="cx"> {
</span><span class="cx"> uint8_t* fpCast = bitwise_cast<uint8_t*>(exec);
</span><span class="cx"> for (MachineThreads::Thread* thread = m_vm.heap.machineThreads().threadsListHead(m_machineThreadsLocker); thread; thread = thread->next) {
</span><del>- uint8_t* stackBase = static_cast<uint8_t*>(thread->stackBase);
- uint8_t* stackLimit = static_cast<uint8_t*>(thread->stackEnd);
</del><ins>+ uint8_t* stackBase = static_cast<uint8_t*>(thread->stackBase());
+ uint8_t* stackLimit = static_cast<uint8_t*>(thread->stackEnd());
</ins><span class="cx"> RELEASE_ASSERT(stackBase);
</span><span class="cx"> RELEASE_ASSERT(stackLimit);
</span><span class="cx"> if (fpCast <= stackBase && fpCast >= stackLimit)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeVMTrapscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/VMTraps.cpp (214318 => 214319)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/VMTraps.cpp        2017-03-23 21:45:08 UTC (rev 214318)
+++ trunk/Source/JavaScriptCore/runtime/VMTraps.cpp        2017-03-23 21:54:58 UTC (rev 214319)
</span><span class="lines">@@ -111,11 +111,11 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> for (MachineThreads::Thread* thread = machineThreads.threadsListHead(machineThreadsLocker); thread; thread = thread->next) {
</span><del>- RELEASE_ASSERT(thread->stackBase);
- RELEASE_ASSERT(thread->stackEnd);
- if (stackPointer <= thread->stackBase && stackPointer >= thread->stackEnd) {
</del><ins>+ RELEASE_ASSERT(thread->stackBase());
+ RELEASE_ASSERT(thread->stackEnd());
+ if (stackPointer <= thread->stackBase() && stackPointer >= thread->stackEnd()) {
</ins><span class="cx"> activeVM = &vm;
</span><del>- stackBounds = StackBounds(thread->stackBase, thread->stackEnd);
</del><ins>+ stackBounds = StackBounds(thread->stackBase(), thread->stackEnd());
</ins><span class="cx"> return VMInspector::FunctorStatus::Done;
</span><span class="cx"> }
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>