| Index: src/platform-posix.cc
|
| diff --git a/src/platform-posix.cc b/src/platform-posix.cc
|
| index 34fd5c4498507f678ea83a2bd33b8eb6a53e318f..4543a66e8c595c6926ed7081f6fbf02b7258506f 100644
|
| --- a/src/platform-posix.cc
|
| +++ b/src/platform-posix.cc
|
| @@ -53,6 +53,7 @@
|
|
|
| #include "v8.h"
|
|
|
| +#include "codegen.h"
|
| #include "platform.h"
|
|
|
| namespace v8 {
|
| @@ -126,6 +127,29 @@ double modulo(double x, double y) {
|
| }
|
|
|
|
|
| +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
|
| +
|
| +
|
| double OS::nan_value() {
|
| // NAN from math.h is defined in C99 and not in POSIX.
|
| return NAN;
|
|
|