From 56e9118f56c8ae849340c1cedeef497beb10cc54 Mon Sep 17 00:00:00 2001 From: "fschneider@chromium.org" Date: Mon, 12 Mar 2012 16:10:53 +0000 Subject: [PATCH] Use lazy instance initializer to remove static initializers in two places. Review URL: https://chromiumcodereview.appspot.com/9664067 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11014 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/platform-posix.cc | 4 ++-- src/platform-win32.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/platform-posix.cc b/src/platform-posix.cc index 422180806a..34b19d732b 100644 --- a/src/platform-posix.cc +++ b/src/platform-posix.cc @@ -127,13 +127,13 @@ double modulo(double x, double y) { } -static Mutex* math_function_mutex = OS::CreateMutex(); +static LazyMutex math_function_mutex = LAZY_MUTEX_INITIALIZER; #define UNARY_MATH_FUNCTION(name, generator) \ static UnaryMathFunction fast_##name##_function = NULL; \ double fast_##name(double x) { \ if (fast_##name##_function == NULL) { \ - ScopedLock lock(math_function_mutex); \ + ScopedLock lock(math_function_mutex.Pointer()); \ UnaryMathFunction temp = generator; \ MemoryBarrier(); \ fast_##name##_function = temp; \ diff --git a/src/platform-win32.cc b/src/platform-win32.cc index 2a25f044ef..16a5b0bc8a 100644 --- a/src/platform-win32.cc +++ b/src/platform-win32.cc @@ -208,13 +208,13 @@ double modulo(double x, double y) { #endif // _WIN64 -static Mutex* math_function_mutex = OS::CreateMutex(); +static LazyMutex math_function_mutex = LAZY_MUTEX_INITIALIZER; #define UNARY_MATH_FUNCTION(name, generator) \ static UnaryMathFunction fast_##name##_function = NULL; \ double fast_##name(double x) { \ if (fast_##name##_function == NULL) { \ - ScopedLock lock(math_function_mutex); \ + ScopedLock lock(math_function_mutex.Pointer()); \ UnaryMathFunction temp = generator; \ MemoryBarrier(); \ fast_##name##_function = temp; \