Reviewers: Yang,

Description:
Use lazy instance initializer to remove static initializers in two places.

Please review this at https://chromiumcodereview.appspot.com/9664067/

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/platform-posix.cc
  M     src/platform-win32.cc


Index: src/platform-posix.cc
===================================================================
--- src/platform-posix.cc       (revision 11012)
+++ src/platform-posix.cc       (working copy)
@@ -127,13 +127,13 @@
 }


-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;                       \
Index: src/platform-win32.cc
===================================================================
--- src/platform-win32.cc       (revision 11012)
+++ src/platform-win32.cc       (working copy)
@@ -208,13 +208,13 @@
 #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;                       \


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to