Commit b2d6e144 authored by darin@apple.com's avatar darin@apple.com

2008-11-03 Darin Adler <darin@apple.com>

        Reviewed by Tim Hatcher.

        - https://bugs.webkit.org/show_bug.cgi?id=22061
          create script to check for exit-time destructors

        * JavaScriptCore.exp: Changed to export functions rather than
        a global for the atomically initialized static mutex.

        * JavaScriptCore.xcodeproj/project.pbxproj: Added a script
        phase that runs the check-for-exit-time-destructors script.

        * wtf/MainThread.cpp:
        (WTF::mainThreadFunctionQueueMutex): Changed to leak an object
        rather than using an exit time destructor.
        (WTF::functionQueue): Ditto.
        * wtf/unicode/icu/CollatorICU.cpp:
        (WTF::cachedCollatorMutex): Ditto.

        * wtf/Threading.h: Changed other platforms to share the Windows
        approach where the mutex is internal and the functions are exported.
        * wtf/ThreadingGtk.cpp:
        (WTF::lockAtomicallyInitializedStaticMutex): Ditto.
        (WTF::unlockAtomicallyInitializedStaticMutex): Ditto.
        * wtf/ThreadingNone.cpp:
        (WTF::lockAtomicallyInitializedStaticMutex): Ditto.
        (WTF::unlockAtomicallyInitializedStaticMutex): Ditto.
        * wtf/ThreadingPthreads.cpp:
        (WTF::threadMapMutex): Changed to leak an object rather than using
        an exit time destructor.
        (WTF::lockAtomicallyInitializedStaticMutex): Mutex change.
        (WTF::unlockAtomicallyInitializedStaticMutex): Ditto.
        (WTF::threadMap): Changed to leak an object rather than using
        an exit time destructor.
        * wtf/ThreadingQt.cpp:
        (WTF::lockAtomicallyInitializedStaticMutex): Mutex change.
        (WTF::unlockAtomicallyInitializedStaticMutex): Ditto.
        * wtf/ThreadingWin.cpp:
        (WTF::lockAtomicallyInitializedStaticMutex): Added an assertion.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@38101 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d0175992
2008-11-03 Darin Adler <darin@apple.com>
Reviewed by Tim Hatcher.
- https://bugs.webkit.org/show_bug.cgi?id=22061
create script to check for exit-time destructors
* JavaScriptCore.exp: Changed to export functions rather than
a global for the atomically initialized static mutex.
* JavaScriptCore.xcodeproj/project.pbxproj: Added a script
phase that runs the check-for-exit-time-destructors script.
* wtf/MainThread.cpp:
(WTF::mainThreadFunctionQueueMutex): Changed to leak an object
rather than using an exit time destructor.
(WTF::functionQueue): Ditto.
* wtf/unicode/icu/CollatorICU.cpp:
(WTF::cachedCollatorMutex): Ditto.
* wtf/Threading.h: Changed other platforms to share the Windows
approach where the mutex is internal and the functions are exported.
* wtf/ThreadingGtk.cpp:
(WTF::lockAtomicallyInitializedStaticMutex): Ditto.
(WTF::unlockAtomicallyInitializedStaticMutex): Ditto.
* wtf/ThreadingNone.cpp:
(WTF::lockAtomicallyInitializedStaticMutex): Ditto.
(WTF::unlockAtomicallyInitializedStaticMutex): Ditto.
* wtf/ThreadingPthreads.cpp:
(WTF::threadMapMutex): Changed to leak an object rather than using
an exit time destructor.
(WTF::lockAtomicallyInitializedStaticMutex): Mutex change.
(WTF::unlockAtomicallyInitializedStaticMutex): Ditto.
(WTF::threadMap): Changed to leak an object rather than using
an exit time destructor.
* wtf/ThreadingQt.cpp:
(WTF::lockAtomicallyInitializedStaticMutex): Mutex change.
(WTF::unlockAtomicallyInitializedStaticMutex): Ditto.
* wtf/ThreadingWin.cpp:
(WTF::lockAtomicallyInitializedStaticMutex): Added an assertion.
2008-11-04 Adam Roben <aroben@apple.com>
Windows build fix
......
......@@ -289,7 +289,8 @@ __ZN3WTF21RefCountedLeakCounterD1Ev
__ZN3WTF23waitForThreadCompletionEjPPv
__ZN3WTF27releaseFastMallocFreeMemoryEv
__ZN3WTF28setMainThreadCallbacksPausedEb
__ZN3WTF32atomicallyInitializedStaticMutexE
__ZN3WTF36lockAtomicallyInitializedStaticMutexEv
__ZN3WTF38unlockAtomicallyInitializedStaticMutexEv
__ZN3WTF5Mutex4lockEv
__ZN3WTF5Mutex6unlockEv
__ZN3WTF5Mutex7tryLockEv
......
......@@ -1617,6 +1617,7 @@
932F5B3F0822A1C700736975 /* Headers */,
932F5B910822A1C700736975 /* Sources */,
9319586B09D9F91A00A56FD4 /* Check For Global Initializers */,
933457200EBFDC3F00B80894 /* Check For Exit Time Destructors */,
5D29D8BE0E9860B400C3D2D0 /* Check For Weak VTables */,
932F5BD20822A1C700736975 /* Frameworks */,
1C395CBC0C6BCC16000D1E52 /* Generate 64-bit Export File */,
......@@ -1807,6 +1808,20 @@
shellPath = /bin/sh;
shellScript = "if [ -f ../WebKitTools/Scripts/check-for-global-initializers ]; then\n ../WebKitTools/Scripts/check-for-global-initializers || exit $?\nfi";
};
933457200EBFDC3F00B80894 /* Check For Exit Time Destructors */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check For Exit Time Destructors";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ -f ../WebKitTools/Scripts/check-for-exit-time-destructors ]; then\n ../WebKitTools/Scripts/check-for-exit-time-destructors || exit $?\nfi";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
......
......@@ -49,17 +49,17 @@ struct FunctionWithContext {
typedef Vector<FunctionWithContext> FunctionQueue;
static bool callbacksPaused; // This global varialble is only accessed from main thread.
static bool callbacksPaused; // This global variable is only accessed from main thread.
Mutex& mainThreadFunctionQueueMutex()
{
static Mutex staticMutex;
static Mutex& staticMutex = *new Mutex;
return staticMutex;
}
static FunctionQueue& functionQueue()
{
static FunctionQueue staticFunctionQueue;
static FunctionQueue& staticFunctionQueue = *new FunctionQueue;
return staticFunctionQueue;
}
......
......@@ -251,14 +251,8 @@ private:
// Darwin is an exception to this rule: it is OK to call it from any thread, the only requirement is that the calls are not reentrant.
void initializeThreading();
#if !PLATFORM(WIN_OS) || PLATFORM(WX)
extern Mutex* atomicallyInitializedStaticMutex;
inline void lockAtomicallyInitializedStaticMutex() { atomicallyInitializedStaticMutex->lock(); }
inline void unlockAtomicallyInitializedStaticMutex() { atomicallyInitializedStaticMutex->unlock(); }
#else
void lockAtomicallyInitializedStaticMutex();
void unlockAtomicallyInitializedStaticMutex();
#endif
} // namespace WTF
......
......@@ -40,7 +40,7 @@
namespace WTF {
Mutex* atomicallyInitializedStaticMutex;
static Mutex* atomicallyInitializedStaticMutex;
static ThreadIdentifier mainThreadIdentifier;
......@@ -65,6 +65,17 @@ void initializeThreading()
}
}
void lockAtomicallyInitializedStaticMutex()
{
ASSERT(atomicallyInitializedStaticMutex);
atomicallyInitializedStaticMutex->lock();
}
void unlockAtomicallyInitializedStaticMutex()
{
atomicallyInitializedStaticMutex->unlock();
}
static HashMap<ThreadIdentifier, GThread*>& threadMap()
{
static HashMap<ThreadIdentifier, GThread*> map;
......
......@@ -26,13 +26,12 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "Threading.h"
namespace WTF {
Mutex* atomicallyInitializedStaticMutex;
void initializeThreading() {}
ThreadIdentifier createThread(ThreadFunction, void*, const char*) { return 0; }
int waitForThreadCompletion(ThreadIdentifier, void**) { return 0; }
......@@ -44,7 +43,7 @@ Mutex::Mutex() {}
Mutex::~Mutex() {}
void Mutex::lock() {}
bool Mutex::tryLock() { return false; }
void Mutex::unlock() {};
void Mutex::unlock() {}
ThreadCondition::ThreadCondition() {}
ThreadCondition::~ThreadCondition() {}
......@@ -53,4 +52,7 @@ bool ThreadCondition::timedWait(Mutex& mutex, double interval) { return false; }
void ThreadCondition::signal() {}
void ThreadCondition::broadcast() {}
void lockAtomicallyInitializedStaticMutex() {}
void unlockAtomicallyInitializedStaticMutex() { }
} // namespace WebCore
......@@ -40,7 +40,7 @@
namespace WTF {
Mutex* atomicallyInitializedStaticMutex;
static Mutex* atomicallyInitializedStaticMutex;
#if !PLATFORM(DARWIN)
static ThreadIdentifier mainThreadIdentifier; // The thread that was the first to call initializeThreading(), which must be the main thread.
......@@ -48,7 +48,7 @@ static ThreadIdentifier mainThreadIdentifier; // The thread that was the first t
static Mutex& threadMapMutex()
{
static Mutex mutex;
static Mutex& mutex = *new Mutex;
return mutex;
}
......@@ -65,9 +65,20 @@ void initializeThreading()
}
}
void lockAtomicallyInitializedStaticMutex()
{
ASSERT(atomicallyInitializedStaticMutex);
atomicallyInitializedStaticMutex->lock();
}
void unlockAtomicallyInitializedStaticMutex()
{
atomicallyInitializedStaticMutex->unlock();
}
static HashMap<ThreadIdentifier, pthread_t>& threadMap()
{
static HashMap<ThreadIdentifier, pthread_t> map;
static HashMap<ThreadIdentifier, pthread_t>& map = *new HashMap<ThreadIdentifier, pthread_t>;
return map;
}
......
......@@ -64,7 +64,7 @@ void ThreadPrivate::run()
}
Mutex* atomicallyInitializedStaticMutex;
static Mutex* atomicallyInitializedStaticMutex;
static ThreadIdentifier mainThreadIdentifier;
......@@ -122,7 +122,7 @@ static QThread* threadForIdentifier(ThreadIdentifier id)
void initializeThreading()
{
if(!atomicallyInitializedStaticMutex) {
if (!atomicallyInitializedStaticMutex) {
atomicallyInitializedStaticMutex = new Mutex;
threadMapMutex();
wtf_random_init();
......@@ -134,6 +134,17 @@ void initializeThreading()
}
}
void lockAtomicallyInitializedStaticMutex()
{
ASSERT(atomicallyInitializedStaticMutex);
atomicallyInitializedStaticMutex->lock();
}
void unlockAtomicallyInitializedStaticMutex()
{
atomicallyInitializedStaticMutex->unlock();
}
ThreadIdentifier createThread(ThreadFunction entryPoint, void* data, const char*)
{
ThreadPrivate* thread = new ThreadPrivate(entryPoint, data);
......
......@@ -111,6 +111,7 @@ static Mutex* atomicallyInitializedStaticMutex;
void lockAtomicallyInitializedStaticMutex()
{
ASSERT(atomicallyInitializedStaticMutex);
atomicallyInitializedStaticMutex->lock();
}
......
......@@ -45,7 +45,7 @@ namespace WTF {
static UCollator* cachedCollator;
static Mutex& cachedCollatorMutex()
{
AtomicallyInitializedStatic(Mutex, mutex);
AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
return mutex;
}
......
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