diff options
Diffstat (limited to 'deps/v8/src/platform-posix.cc')
-rw-r--r-- | deps/v8/src/platform-posix.cc | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/deps/v8/src/platform-posix.cc b/deps/v8/src/platform-posix.cc index 4543a66e8c..a729b66260 100644 --- a/deps/v8/src/platform-posix.cc +++ b/deps/v8/src/platform-posix.cc @@ -127,27 +127,25 @@ double modulo(double x, double y) { } -static Mutex* transcendental_function_mutex = OS::CreateMutex(); - -#define TRANSCENDENTAL_FUNCTION(name, type) \ -static TranscendentalFunction fast_##name##_function = NULL; \ -double fast_##name(double x) { \ - if (fast_##name##_function == NULL) { \ - ScopedLock lock(transcendental_function_mutex); \ - TranscendentalFunction temp = \ - CreateTranscendentalFunction(type); \ - MemoryBarrier(); \ - fast_##name##_function = temp; \ - } \ - return (*fast_##name##_function)(x); \ +#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); \ + return (*fast_##name##_function)(x); \ } -TRANSCENDENTAL_FUNCTION(sin, TranscendentalCache::SIN) -TRANSCENDENTAL_FUNCTION(cos, TranscendentalCache::COS) -TRANSCENDENTAL_FUNCTION(tan, TranscendentalCache::TAN) -TRANSCENDENTAL_FUNCTION(log, TranscendentalCache::LOG) +UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN)) +UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS)) +UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN)) +UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG)) +UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) -#undef TRANSCENDENTAL_FUNCTION +#undef MATH_FUNCTION double OS::nan_value() { @@ -307,14 +305,14 @@ int OS::VSNPrintF(Vector<char> str, #if defined(V8_TARGET_ARCH_IA32) static OS::MemCopyFunction memcopy_function = NULL; -static Mutex* memcopy_function_mutex = OS::CreateMutex(); +static LazyMutex memcopy_function_mutex = LAZY_MUTEX_INITIALIZER; // 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); + ScopedLock lock(memcopy_function_mutex.Pointer()); if (memcopy_function == NULL) { OS::MemCopyFunction temp = CreateMemCopyFunction(); MemoryBarrier(); |