Commit 7985e2bc authored by andersca@apple.com's avatar andersca@apple.com

Replace WTF::ThreadingOnce with std::call_once

https://bugs.webkit.org/show_bug.cgi?id=126215

Reviewed by Sam Weinig.

Source/JavaScriptCore:

* dfg/DFGWorklist.cpp:
(JSC::DFG::globalWorklist):
* runtime/InitializeThreading.cpp:
(JSC::initializeThreading):

Source/WTF:

* GNUmakefile.list.am:
* wtf/CompilationThread.cpp:
(WTF::initializeCompilationThreads):
* wtf/ThreadingOnce.h: Removed.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161146 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 51855c51
2013-12-30 Anders Carlsson <andersca@apple.com>
Replace WTF::ThreadingOnce with std::call_once
https://bugs.webkit.org/show_bug.cgi?id=126215
Reviewed by Sam Weinig.
* dfg/DFGWorklist.cpp:
(JSC::DFG::globalWorklist):
* runtime/InitializeThreading.cpp:
(JSC::initializeThreading):
2013-12-30 Martin Robinson <mrobinson@igalia.com>
[CMake] [GTK] Add support for GObject introspection
......
......@@ -31,8 +31,7 @@
#include "CodeBlock.h"
#include "DeferGC.h"
#include "DFGLongLivedState.h"
#include <wtf/ThreadingOnce.h>
#include <mutex>
namespace JSC { namespace DFG {
......@@ -264,22 +263,20 @@ void Worklist::threadFunction(void* argument)
static Worklist* theGlobalWorklist;
static void initializeGlobalWorklistOnce()
{
unsigned numberOfThreads;
if (Options::useExperimentalFTL())
numberOfThreads = 1; // We don't yet use LLVM in a thread-safe way.
else
numberOfThreads = Options::numberOfCompilerThreads();
theGlobalWorklist = Worklist::create(numberOfThreads).leakRef();
}
Worklist* globalWorklist()
{
static WTF::ThreadingOnce initializeGlobalWorklistKeyOnce;
initializeGlobalWorklistKeyOnce.callOnce(initializeGlobalWorklistOnce);
static std::once_flag initializeGlobalWorklistOnceFlag;
std::call_once(initializeGlobalWorklistOnceFlag, [] {
unsigned numberOfThreads;
if (Options::useExperimentalFTL())
numberOfThreads = 1; // We don't yet use LLVM in a thread-safe way.
else
numberOfThreads = Options::numberOfCompilerThreads();
theGlobalWorklist = Worklist::create(numberOfThreads).leakRef();
});
return theGlobalWorklist;
}
......
......@@ -39,6 +39,7 @@
#include "JSLock.h"
#include "LLIntData.h"
#include "WriteBarrier.h"
#include <mutex>
#include <wtf/dtoa.h>
#include <wtf/Threading.h>
#include <wtf/dtoa/cached-powers.h>
......@@ -47,44 +48,31 @@ using namespace WTF;
namespace JSC {
#if OS(DARWIN)
static pthread_once_t initializeThreadingKeyOnce = PTHREAD_ONCE_INIT;
#endif
static void initializeThreadingOnce()
void initializeThreading()
{
WTF::double_conversion::initialize();
WTF::initializeThreading();
GlobalJSLock::initialize();
Options::initialize();
if (Options::recordGCPauseTimes())
HeapStatistics::initialize();
static std::once_flag initializeThreadingOnceFlag;
std::call_once(initializeThreadingOnceFlag, []{
WTF::double_conversion::initialize();
WTF::initializeThreading();
GlobalJSLock::initialize();
Options::initialize();
if (Options::recordGCPauseTimes())
HeapStatistics::initialize();
#if ENABLE(WRITE_BARRIER_PROFILING)
WriteBarrierCounters::initialize();
WriteBarrierCounters::initialize();
#endif
#if ENABLE(ASSEMBLER)
ExecutableAllocator::initializeAllocator();
ExecutableAllocator::initializeAllocator();
#endif
JSStack::initializeThreading();
JSStack::initializeThreading();
#if ENABLE(LLINT)
LLInt::initialize();
LLInt::initialize();
#endif
#ifndef NDEBUG
DisallowGC::initialize();
#endif
}
void initializeThreading()
{
#if OS(DARWIN)
pthread_once(&initializeThreadingKeyOnce, initializeThreadingOnce);
#else
static bool initializedThreading = false;
if (!initializedThreading) {
initializeThreadingOnce();
initializedThreading = true;
}
DisallowGC::initialize();
#endif
});
}
} // namespace JSC
2013-12-30 Anders Carlsson <andersca@apple.com>
Replace WTF::ThreadingOnce with std::call_once
https://bugs.webkit.org/show_bug.cgi?id=126215
Reviewed by Sam Weinig.
* GNUmakefile.list.am:
* wtf/CompilationThread.cpp:
(WTF::initializeCompilationThreads):
* wtf/ThreadingOnce.h: Removed.
2013-12-26 Sam Weinig <sam@webkit.org>
Move FilterIterator and IteratorPair to WTF and reimplement HashMap::keys() and HashMap::values() using IteratorPair
......
......@@ -175,7 +175,6 @@ wtf_sources += \
Source/WTF/wtf/ThreadSpecificWin.cpp \
Source/WTF/wtf/Threading.cpp \
Source/WTF/wtf/Threading.h \
Source/WTF/wtf/ThreadingOnce.h \
Source/WTF/wtf/ThreadingPrimitives.h \
Source/WTF/wtf/ThreadingPthreads.cpp \
Source/WTF/wtf/ThreadingWin.cpp \
......
......@@ -29,21 +29,18 @@
#include "StdLibExtras.h"
#include "ThreadSpecific.h"
#include "Threading.h"
#include "ThreadingOnce.h"
#include <mutex>
namespace WTF {
static ThreadSpecific<bool>* s_isCompilationThread;
static void initializeCompilationThreadsOnce()
{
s_isCompilationThread = new ThreadSpecific<bool>();
}
static void initializeCompilationThreads()
{
static ThreadingOnce initializeCompilationThreadsKeyOnce;
initializeCompilationThreadsKeyOnce.callOnce(initializeCompilationThreadsOnce);
static std::once_flag initializeCompilationThreadsOnceFlag;
std::call_once(initializeCompilationThreadsOnceFlag, []{
s_isCompilationThread = new ThreadSpecific<bool>();
});
}
bool isCompilationThread()
......
/*
* Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ThreadingOnce_h
#define ThreadingOnce_h
#include <wtf/ThreadingPrimitives.h>
namespace WTF {
class ThreadingOnce {
WTF_MAKE_NONCOPYABLE(ThreadingOnce);
public:
ThreadingOnce()
#if USE(PTHREADS)
: m_onceHandle(PTHREAD_ONCE_INIT)
#else
: m_calledOnce(false)
#endif
{
}
void callOnce(void (*initRoutine)())
{
#if USE(PTHREADS)
pthread_once(&m_onceHandle, initRoutine);
#else
m_mutex.lock();
if (!m_calledOnce) {
initRoutine();
m_calledOnce = true;
}
m_mutex.unlock();
#endif
}
private:
#if USE(PTHREADS)
pthread_once_t m_onceHandle;
#else
Mutex m_mutex;
bool m_calledOnce;
#endif
};
} // namespace WTF
#endif // ThreadingOnce_h
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