Index: src/platform-posix.cc |
diff --git a/src/platform-posix.cc b/src/platform-posix.cc |
index 422180806a52ab4d547c45f4697cb126ec5a5e08..95edead8330b992a06803b1ff56bd0284528e9ae 100644 |
--- a/src/platform-posix.cc |
+++ b/src/platform-posix.cc |
@@ -127,17 +127,16 @@ double modulo(double x, double y) { |
} |
-static Mutex* math_function_mutex = OS::CreateMutex(); |
- |
#define UNARY_MATH_FUNCTION(name, generator) \ |
static UnaryMathFunction fast_##name##_function = NULL; \ |
+V8_DECLARE_ONCE(fast_##name##_init_once); \ |
+void init_fast_##name##_function() { \ |
fschneider
2012/03/12 16:06:40
I wonder if you can make this part of InitializeOn
|
+ fast_##name##_function = generator; \ |
+ MemoryBarrier(); \ |
fschneider
2012/03/12 16:25:46
You can remove this since CallOnce already has Mem
|
+} \ |
double fast_##name(double x) { \ |
- if (fast_##name##_function == NULL) { \ |
- ScopedLock lock(math_function_mutex); \ |
- UnaryMathFunction temp = generator; \ |
- MemoryBarrier(); \ |
- fast_##name##_function = temp; \ |
- } \ |
+ CallOnce(&fast_##name##_init_once, \ |
+ &init_fast_##name##_function); \ |
return (*fast_##name##_function)(x); \ |
} |