Changeset 31560 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Apr 1, 2008, 11:38:32 PM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Darin.

Make MathExtras.h thread safe.

  • kjs/math_object.cpp: (KJS::mathProtoFuncRandom): If threading is enabled, rely on initializeThreading to call wtf_random_init().
  • wtf/Threading.h:
  • wtf/ThreadingGtk.cpp: (WTF::initializeThreading):
  • wtf/ThreadingNone.cpp: (WTF::initializeThreading):
  • wtf/ThreadingPthreads.cpp: (WTF::initializeThreading):
  • wtf/ThreadingWin.cpp: (WTF::initializeThreading): Call wtf_random_init(); made the function non-inline to avoid having to include too many headers in Threading.h.
Location:
trunk/JavaScriptCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r31454 r31560  
     12008-04-01  Alexey Proskuryakov  <[email protected]>
     2
     3        Reviewed by Darin.
     4
     5        Make MathExtras.h thread safe.
     6
     7        * kjs/math_object.cpp:
     8        (KJS::mathProtoFuncRandom): If threading is enabled, rely on initializeThreading to call
     9        wtf_random_init().
     10
     11        * wtf/Threading.h:
     12        * wtf/ThreadingGtk.cpp:
     13        (WTF::initializeThreading):
     14        * wtf/ThreadingNone.cpp:
     15        (WTF::initializeThreading):
     16        * wtf/ThreadingPthreads.cpp:
     17        (WTF::initializeThreading):
     18        * wtf/ThreadingWin.cpp:
     19        (WTF::initializeThreading):
     20        Call wtf_random_init(); made the function non-inline to avoid having to include too many
     21        headers in Threading.h.
     22
    1232008-03-31  Eric Seidel  <[email protected]>
    224
  • trunk/JavaScriptCore/kjs/math_object.cpp

    r29541 r31560  
    207207}
    208208
    209 static bool didInitRandom;
    210 
    211209JSValue* mathProtoFuncRandom(ExecState*, JSObject*, const List&)
    212210{
     211#if !USE(MULTIPLE_THREADS)
     212    static bool didInitRandom;
    213213    if (!didInitRandom) {
    214214        wtf_random_init();
    215215        didInitRandom = true;
    216216    }
     217#endif
     218
    217219    return jsNumber(wtf_random());
    218220}
  • trunk/JavaScriptCore/wtf/Threading.h

    r31404 r31560  
    243243extern Mutex* atomicallyInitializedStaticMutex;
    244244
    245 #if !PLATFORM(GTK)
    246 inline void initializeThreading()
    247 {
    248     if (!atomicallyInitializedStaticMutex)
    249         atomicallyInitializedStaticMutex = new Mutex;
    250 }
    251 #endif
    252 
    253245} // namespace WTF
    254246
  • trunk/JavaScriptCore/wtf/ThreadingGtk.cpp

    r30851 r31560  
    3131#include "Threading.h"
    3232
    33 #include "HashMap.h"
     33#include <wtf/HashMap.h>
     34#include <wtf/MathExtras.h>
    3435
    3536#include <glib.h>
     
    4546        ASSERT(!atomicallyInitializedStaticMutex);
    4647        atomicallyInitializedStaticMutex = new Mutex;
     48        wtf_random_init();
    4749    }
    4850    ASSERT(g_thread_supported());
  • trunk/JavaScriptCore/wtf/ThreadingNone.cpp

    r30849 r31560  
    3434Mutex* atomicallyInitializedStaticMutex;
    3535
     36void initializeThreading() {}
    3637ThreadIdentifier createThread(ThreadFunction, void*) { return 0; }
    3738int waitForThreadCompletion(ThreadIdentifier, void**) { return 0; }
  • trunk/JavaScriptCore/wtf/ThreadingPthreads.cpp

    r31048 r31560  
    3131
    3232#include <wtf/HashMap.h>
     33#include <wtf/MathExtras.h>
    3334
    3435#include <errno.h>
     
    3839
    3940Mutex* atomicallyInitializedStaticMutex;
     41
     42void initializeThreading()
     43{
     44    if (!atomicallyInitializedStaticMutex) {
     45        atomicallyInitializedStaticMutex = new Mutex;
     46        wtf_random_init();
     47    }
     48}
    4049
    4150static Mutex& threadMapMutex()
  • trunk/JavaScriptCore/wtf/ThreadingWin.cpp

    r30855 r31560  
    6666#include <windows.h>
    6767#include <wtf/HashMap.h>
     68#include <wtf/MathExtras.h>
    6869
    6970namespace WTF {
    7071
    7172Mutex* atomicallyInitializedStaticMutex;
     73
     74void initializeThreading()
     75{
     76    if (!atomicallyInitializedStaticMutex) {
     77        atomicallyInitializedStaticMutex = new Mutex;
     78        wtf_random_init();
     79    }
     80}
    7281
    7382static Mutex& threadMapMutex()
Note: See TracChangeset for help on using the changeset viewer.