| Index: src/platform-win32.cc
|
| diff --git a/src/platform-win32.cc b/src/platform-win32.cc
|
| index 2801b711bf7afc73dd1040938e53aff67aab6e6d..e7be9304d7787547b3e3af65e670b5f86c66e7ef 100644
|
| --- a/src/platform-win32.cc
|
| +++ b/src/platform-win32.cc
|
| @@ -149,14 +149,14 @@ static Mutex* limit_mutex = NULL;
|
|
|
| #if defined(V8_TARGET_ARCH_IA32)
|
| static OS::MemCopyFunction memcopy_function = NULL;
|
| -static LazyMutex memcopy_function_mutex = LAZY_MUTEX_INITIALIZER;
|
| +static Mutex* memcopy_function_mutex = OS::CreateMutex();
|
| // Defined in codegen-ia32.cc.
|
| OS::MemCopyFunction CreateMemCopyFunction();
|
|
|
| // Copy memory area to disjoint memory area.
|
| void OS::MemCopy(void* dest, const void* src, size_t size) {
|
| if (memcopy_function == NULL) {
|
| - ScopedLock lock(memcopy_function_mutex.Pointer());
|
| + ScopedLock lock(memcopy_function_mutex);
|
| if (memcopy_function == NULL) {
|
| OS::MemCopyFunction temp = CreateMemCopyFunction();
|
| MemoryBarrier();
|
| @@ -175,16 +175,19 @@ void OS::MemCopy(void* dest, const void* src, size_t size) {
|
| #ifdef _WIN64
|
| typedef double (*ModuloFunction)(double, double);
|
| static ModuloFunction modulo_function = NULL;
|
| -V8_DECLARE_ONCE(modulo_function_init_once);
|
| +static Mutex* modulo_function_mutex = OS::CreateMutex();
|
| // Defined in codegen-x64.cc.
|
| ModuloFunction CreateModuloFunction();
|
|
|
| -void init_modulo_function() {
|
| - modulo_function = CreateModuloFunction();
|
| -}
|
| -
|
| double modulo(double x, double y) {
|
| - CallOnce(&modulo_function_init_once, &init_modulo_function);
|
| + if (modulo_function == NULL) {
|
| + ScopedLock lock(modulo_function_mutex);
|
| + if (modulo_function == NULL) {
|
| + ModuloFunction temp = CreateModuloFunction();
|
| + MemoryBarrier();
|
| + modulo_function = temp;
|
| + }
|
| + }
|
| // Note: here we rely on dependent reads being ordered. This is true
|
| // on all architectures we currently support.
|
| return (*modulo_function)(x, y);
|
| @@ -205,15 +208,17 @@ double modulo(double x, double y) {
|
| #endif // _WIN64
|
|
|
|
|
| +static Mutex* math_function_mutex = OS::CreateMutex();
|
| +
|
| #define UNARY_MATH_FUNCTION(name, generator) \
|
| static UnaryMathFunction fast_##name##_function = NULL; \
|
| -V8_DECLARE_ONCE(fast_##name##_init_once); \
|
| -void init_fast_##name##_function() { \
|
| - fast_##name##_function = generator; \
|
| -} \
|
| double fast_##name(double x) { \
|
| - CallOnce(&fast_##name##_init_once, \
|
| - &init_fast_##name##_function); \
|
| + if (fast_##name##_function == NULL) { \
|
| + ScopedLock lock(math_function_mutex); \
|
| + UnaryMathFunction temp = generator; \
|
| + MemoryBarrier(); \
|
| + fast_##name##_function = temp; \
|
| + } \
|
| return (*fast_##name##_function)(x); \
|
| }
|
|
|
| @@ -1956,7 +1961,7 @@ class SamplerThread : public Thread {
|
| interval_(interval) {}
|
|
|
| static void AddActiveSampler(Sampler* sampler) {
|
| - ScopedLock lock(mutex_.Pointer());
|
| + ScopedLock lock(mutex_);
|
| SamplerRegistry::AddActiveSampler(sampler);
|
| if (instance_ == NULL) {
|
| instance_ = new SamplerThread(sampler->interval());
|
| @@ -1967,7 +1972,7 @@ class SamplerThread : public Thread {
|
| }
|
|
|
| static void RemoveActiveSampler(Sampler* sampler) {
|
| - ScopedLock lock(mutex_.Pointer());
|
| + ScopedLock lock(mutex_);
|
| SamplerRegistry::RemoveActiveSampler(sampler);
|
| if (SamplerRegistry::GetState() == SamplerRegistry::HAS_NO_SAMPLERS) {
|
| RuntimeProfiler::StopRuntimeProfilerThreadBeforeShutdown(instance_);
|
| @@ -2053,7 +2058,7 @@ class SamplerThread : public Thread {
|
| RuntimeProfilerRateLimiter rate_limiter_;
|
|
|
| // Protects the process wide state below.
|
| - static LazyMutex mutex_;
|
| + static Mutex* mutex_;
|
| static SamplerThread* instance_;
|
|
|
| private:
|
| @@ -2061,7 +2066,7 @@ class SamplerThread : public Thread {
|
| };
|
|
|
|
|
| -LazyMutex SamplerThread::mutex_ = LAZY_MUTEX_INITIALIZER;
|
| +Mutex* SamplerThread::mutex_ = OS::CreateMutex();
|
| SamplerThread* SamplerThread::instance_ = NULL;
|
|
|
|
|
|
|