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
This commit is contained in:
fschneider@chromium.org 2012-03-12 16:10:53 +00:00
parent 758638a53f
commit 56e9118f56
2 changed files with 4 additions and 4 deletions

View File

@ -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) \ #define UNARY_MATH_FUNCTION(name, generator) \
static UnaryMathFunction fast_##name##_function = NULL; \ static UnaryMathFunction fast_##name##_function = NULL; \
double fast_##name(double x) { \ double fast_##name(double x) { \
if (fast_##name##_function == NULL) { \ if (fast_##name##_function == NULL) { \
ScopedLock lock(math_function_mutex); \ ScopedLock lock(math_function_mutex.Pointer()); \
UnaryMathFunction temp = generator; \ UnaryMathFunction temp = generator; \
MemoryBarrier(); \ MemoryBarrier(); \
fast_##name##_function = temp; \ fast_##name##_function = temp; \

View File

@ -208,13 +208,13 @@ double modulo(double x, double y) {
#endif // _WIN64 #endif // _WIN64
static Mutex* math_function_mutex = OS::CreateMutex(); static LazyMutex math_function_mutex = LAZY_MUTEX_INITIALIZER;
#define UNARY_MATH_FUNCTION(name, generator) \ #define UNARY_MATH_FUNCTION(name, generator) \
static UnaryMathFunction fast_##name##_function = NULL; \ static UnaryMathFunction fast_##name##_function = NULL; \
double fast_##name(double x) { \ double fast_##name(double x) { \
if (fast_##name##_function == NULL) { \ if (fast_##name##_function == NULL) { \
ScopedLock lock(math_function_mutex); \ ScopedLock lock(math_function_mutex.Pointer()); \
UnaryMathFunction temp = generator; \ UnaryMathFunction temp = generator; \
MemoryBarrier(); \ MemoryBarrier(); \
fast_##name##_function = temp; \ fast_##name##_function = temp; \