Index: src/platform-posix.cc |
diff --git a/src/platform-posix.cc b/src/platform-posix.cc |
index a729b662605ad1377395cf7f0fb9668d3863ce48..4b1edfe06a8895ae53d46c1ff5c08bd5419f86d8 100644 |
--- a/src/platform-posix.cc |
+++ b/src/platform-posix.cc |
@@ -127,15 +127,17 @@ double modulo(double x, double y) { |
} |
+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); \ |
} |
@@ -305,14 +307,14 @@ int OS::VSNPrintF(Vector<char> str, |
#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(); |