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
parent 758638a5
......@@ -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; \
......
......@@ -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; \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment