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

Unified Diff: src/platform-win32.cc

Issue 9583037: Reland r10908 (Ensure consistent result of transcendental function0.) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 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
Index: src/platform-win32.cc
diff --git a/src/platform-win32.cc b/src/platform-win32.cc
index 783fd6c4654fdfad806b1b8de75171dcac7b6b36..ee9fb6592496ef859bcb446f9f4619e35647b164 100644
--- a/src/platform-win32.cc
+++ b/src/platform-win32.cc
@@ -32,6 +32,7 @@
#include "v8.h"
+#include "codegen.h"
#include "platform.h"
#include "vm-state-inl.h"
@@ -201,6 +202,30 @@ double modulo(double x, double y) {
#endif // _WIN64
+
+static Mutex* transcendental_function_mutex = OS::CreateMutex();
+
+#define TRANSCENDENTAL_FUNCTION(name, type) \
+static TranscendentalFunction fast_##name##_function = NULL; \
+double fast_##name(double x) { \
+ if (fast_##name##_function == NULL) { \
+ ScopedLock lock(transcendental_function_mutex); \
+ TranscendentalFunction temp = \
+ CreateTranscendentalFunction(type); \
+ MemoryBarrier(); \
+ fast_##name##_function = temp; \
+ } \
+ return (*fast_##name##_function)(x); \
+}
+
+TRANSCENDENTAL_FUNCTION(sin, TranscendentalCache::SIN)
+TRANSCENDENTAL_FUNCTION(cos, TranscendentalCache::COS)
+TRANSCENDENTAL_FUNCTION(tan, TranscendentalCache::TAN)
+TRANSCENDENTAL_FUNCTION(log, TranscendentalCache::LOG)
+
+#undef TRANSCENDENTAL_FUNCTION
+
+
// ----------------------------------------------------------------------------
// The Time class represents time on win32. A timestamp is represented as
// a 64-bit integer in 100 nanoseconds since January 1, 1601 (UTC). JavaScript

Powered by Google App Engine
This is Rietveld 408576698