Reviewers: fschneider,
Message:
PTAL.
Description:
Remove static Mutex from math function intializers.
BUG=
TEST=
Please review this at http://codereview.chromium.org/9662064/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/platform-posix.cc
M src/platform-win32.cc
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() { \
+ fast_##name##_function = generator; \
+ MemoryBarrier(); \
+} \
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); \
}
Index: src/platform-win32.cc
diff --git a/src/platform-win32.cc b/src/platform-win32.cc
index
2a25f044efa79beef6f9b8b72cbccfb41d8f461d..fece1a4a188afc391f3301291db871af05e774a9
100644
--- a/src/platform-win32.cc
+++ b/src/platform-win32.cc
@@ -208,17 +208,16 @@ double modulo(double x, double y) {
#endif // _WIN64
-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() { \
+ fast_##name##_function = generator; \
+ MemoryBarrier(); \
+} \
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); \
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev