Commit 2840a27b authored by mark.lam@apple.com's avatar mark.lam@apple.com

Fixed JSLock to use the platform abstraction for Mutex instead of

depending on pthreads.
https://bugs.webkit.org/show_bug.cgi?id=96858.

Reviewed by Filip Pizlo.

This fixes a synchronization problem on the Windows port and makes
it more reliable when running the layout tests.

* runtime/InitializeThreading.cpp:
(JSC::initializeThreadingOnce):
* runtime/JSLock.cpp:
(JSC):
(JSC::GlobalJSLock::GlobalJSLock):
(JSC::GlobalJSLock::~GlobalJSLock):
(JSC::GlobalJSLock::initialize):
* runtime/JSLock.h:
(GlobalJSLock):
(JSLock):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@128704 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6ee5f486
2012-09-15 Mark Lam <mark.lam@apple.com>
Fixed JSLock to use the platform abstraction for Mutex instead of
depending on pthreads.
https://bugs.webkit.org/show_bug.cgi?id=96858.
Reviewed by Filip Pizlo.
This fixes a synchronization problem on the Windows port and makes
it more reliable when running the layout tests.
* runtime/InitializeThreading.cpp:
(JSC::initializeThreadingOnce):
* runtime/JSLock.cpp:
(JSC):
(JSC::GlobalJSLock::GlobalJSLock):
(JSC::GlobalJSLock::~GlobalJSLock):
(JSC::GlobalJSLock::initialize):
* runtime/JSLock.h:
(GlobalJSLock):
(JSLock):
2012-09-15 Filip Pizlo <fpizlo@apple.com>
Structure check hoisting fails to consider the possibility of conflicting checks on the source of the first assignment to the hoisted variable
......
......@@ -35,6 +35,7 @@
#include "Identifier.h"
#include "JSDateMath.h"
#include "JSGlobalObject.h"
#include "JSLock.h"
#include "LLIntData.h"
#include "WriteBarrier.h"
#include <wtf/dtoa.h>
......@@ -53,6 +54,7 @@ static void initializeThreadingOnce()
{
WTF::double_conversion::initialize();
WTF::initializeThreading();
GlobalJSLock::initialize();
Options::initialize();
#if ENABLE(WRITE_BARRIER_PROFILING)
WriteBarrierCounters::initialize();
......
......@@ -33,21 +33,21 @@
namespace JSC {
// JSLock is only needed to support an obsolete execution model where JavaScriptCore
// automatically protected against concurrent access from multiple threads.
// So it's safe to disable it on non-mac platforms where we don't have native pthreads.
#if (OS(DARWIN) || USE(PTHREADS))
static pthread_mutex_t sharedInstanceLock = PTHREAD_MUTEX_INITIALIZER;
Mutex* GlobalJSLock::s_sharedInstanceLock = 0;
GlobalJSLock::GlobalJSLock()
{
pthread_mutex_lock(&sharedInstanceLock);
s_sharedInstanceLock->lock();
}
GlobalJSLock::~GlobalJSLock()
{
pthread_mutex_unlock(&sharedInstanceLock);
s_sharedInstanceLock->unlock();
}
void GlobalJSLock::initialize()
{
s_sharedInstanceLock = new Mutex();
}
JSLockHolder::JSLockHolder(ExecState* exec)
......@@ -216,95 +216,4 @@ JSLock::DropAllLocks::~DropAllLocks()
m_globalData->apiLock().grabAllLocks(m_lockCount);
}
#else // (OS(DARWIN) || USE(PTHREADS))
GlobalJSLock::GlobalJSLock()
{
}
GlobalJSLock::~GlobalJSLock()
{
}
JSLockHolder::JSLockHolder(JSGlobalData*)
{
}
JSLockHolder::JSLockHolder(JSGlobalData&)
{
}
JSLockHolder::JSLockHolder(ExecState*)
{
}
JSLockHolder::~JSLockHolder()
{
}
JSLock::JSLock()
{
}
JSLock::~JSLock()
{
}
bool JSLock::currentThreadIsHoldingLock()
{
return true;
}
void JSLock::lock()
{
}
void JSLock::unlock()
{
}
void JSLock::lock(ExecState*)
{
}
void JSLock::unlock(ExecState*)
{
}
void JSLock::lock(JSGlobalData&)
{
}
void JSLock::unlock(JSGlobalData&)
{
}
unsigned JSLock::dropAllLocks()
{
return 0;
}
unsigned JSLock::dropAllLocksUnconditionally()
{
return 0;
}
void JSLock::grabAllLocks(unsigned)
{
}
JSLock::DropAllLocks::DropAllLocks(ExecState*)
{
}
JSLock::DropAllLocks::DropAllLocks(JSGlobalData*)
{
}
JSLock::DropAllLocks::~DropAllLocks()
{
}
#endif // (OS(DARWIN) || USE(PTHREADS))
} // namespace JSC
......@@ -58,6 +58,10 @@ namespace JSC {
public:
JS_EXPORT_PRIVATE GlobalJSLock();
JS_EXPORT_PRIVATE ~GlobalJSLock();
static void initialize();
private:
static Mutex* s_sharedInstanceLock;
};
class JSLockHolder {
......@@ -91,12 +95,6 @@ namespace JSC {
unsigned dropAllLocksUnconditionally();
void grabAllLocks(unsigned lockCount);
SpinLock m_spinLock;
Mutex m_lock;
ThreadIdentifier m_ownerThread;
intptr_t m_lockCount;
unsigned m_lockDropDepth;
class DropAllLocks {
WTF_MAKE_NONCOPYABLE(DropAllLocks);
public:
......@@ -108,6 +106,13 @@ namespace JSC {
intptr_t m_lockCount;
RefPtr<JSGlobalData> m_globalData;
};
private:
SpinLock m_spinLock;
Mutex m_lock;
ThreadIdentifier m_ownerThread;
intptr_t m_lockCount;
unsigned m_lockDropDepth;
};
} // namespace
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment