Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(485)

Unified Diff: src/platform-posix.cc

Issue 9662064: Remove static Mutex from math function intializers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/platform-win32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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); \
}
« no previous file with comments | « no previous file | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698