| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 (*memcopy_function)(dest, src, size); | 160 (*memcopy_function)(dest, src, size); |
| 161 #ifdef DEBUG | 161 #ifdef DEBUG |
| 162 CHECK_EQ(0, memcmp(dest, src, size)); | 162 CHECK_EQ(0, memcmp(dest, src, size)); |
| 163 #endif | 163 #endif |
| 164 } | 164 } |
| 165 #endif // V8_TARGET_ARCH_IA32 | 165 #endif // V8_TARGET_ARCH_IA32 |
| 166 | 166 |
| 167 #ifdef _WIN64 | 167 #ifdef _WIN64 |
| 168 typedef double (*ModuloFunction)(double, double); | 168 typedef double (*ModuloFunction)(double, double); |
| 169 static ModuloFunction modulo_function = NULL; | 169 static ModuloFunction modulo_function = NULL; |
| 170 V8_DECLARE_ONCE(modulo_function_init_once); | |
| 171 // Defined in codegen-x64.cc. | 170 // Defined in codegen-x64.cc. |
| 172 ModuloFunction CreateModuloFunction(); | 171 ModuloFunction CreateModuloFunction(); |
| 173 | 172 |
| 174 void init_modulo_function() { | 173 void init_modulo_function() { |
| 175 modulo_function = CreateModuloFunction(); | 174 modulo_function = CreateModuloFunction(); |
| 176 } | 175 } |
| 177 | 176 |
| 178 double modulo(double x, double y) { | 177 double modulo(double x, double y) { |
| 179 CallOnce(&modulo_function_init_once, &init_modulo_function); | |
| 180 // Note: here we rely on dependent reads being ordered. This is true | 178 // Note: here we rely on dependent reads being ordered. This is true |
| 181 // on all architectures we currently support. | 179 // on all architectures we currently support. |
| 182 return (*modulo_function)(x, y); | 180 return (*modulo_function)(x, y); |
| 183 } | 181 } |
| 184 #else // Win32 | 182 #else // Win32 |
| 185 | 183 |
| 186 double modulo(double x, double y) { | 184 double modulo(double x, double y) { |
| 187 // Workaround MS fmod bugs. ECMA-262 says: | 185 // Workaround MS fmod bugs. ECMA-262 says: |
| 188 // dividend is finite and divisor is an infinity => result equals dividend | 186 // dividend is finite and divisor is an infinity => result equals dividend |
| 189 // dividend is a zero and divisor is nonzero finite => result equals dividend | 187 // dividend is a zero and divisor is nonzero finite => result equals dividend |
| 190 if (!(isfinite(x) && (!isfinite(y) && !isnan(y))) && | 188 if (!(isfinite(x) && (!isfinite(y) && !isnan(y))) && |
| 191 !(x == 0 && (y != 0 && isfinite(y)))) { | 189 !(x == 0 && (y != 0 && isfinite(y)))) { |
| 192 x = fmod(x, y); | 190 x = fmod(x, y); |
| 193 } | 191 } |
| 194 return x; | 192 return x; |
| 195 } | 193 } |
| 196 | 194 |
| 197 #endif // _WIN64 | 195 #endif // _WIN64 |
| 198 | 196 |
| 199 | 197 |
| 200 #define UNARY_MATH_FUNCTION(name, generator) \ | 198 #define UNARY_MATH_FUNCTION(name, generator) \ |
| 201 static UnaryMathFunction fast_##name##_function = NULL; \ | 199 static UnaryMathFunction fast_##name##_function = NULL; \ |
| 202 V8_DECLARE_ONCE(fast_##name##_init_once); \ | |
| 203 void init_fast_##name##_function() { \ | 200 void init_fast_##name##_function() { \ |
| 204 fast_##name##_function = generator; \ | 201 fast_##name##_function = generator; \ |
| 205 } \ | 202 } \ |
| 206 double fast_##name(double x) { \ | 203 double fast_##name(double x) { \ |
| 207 CallOnce(&fast_##name##_init_once, \ | |
| 208 &init_fast_##name##_function); \ | |
| 209 return (*fast_##name##_function)(x); \ | 204 return (*fast_##name##_function)(x); \ |
| 210 } | 205 } |
| 211 | 206 |
| 212 UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN)) | 207 UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN)) |
| 213 UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS)) | 208 UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS)) |
| 214 UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN)) | 209 UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN)) |
| 215 UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG)) | 210 UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG)) |
| 216 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) | 211 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) |
| 217 | 212 |
| 218 #undef MATH_FUNCTION | 213 #undef MATH_FUNCTION |
| 219 | 214 |
| 220 | 215 |
| 216 void MathSetup() { |
| 217 init_modulo_function(); |
| 218 init_fast_sin_function(); |
| 219 init_fast_cos_function(); |
| 220 init_fast_tan_function(); |
| 221 init_fast_log_function(); |
| 222 init_fast_sqrt_function(); |
| 223 } |
| 224 |
| 225 |
| 221 // ---------------------------------------------------------------------------- | 226 // ---------------------------------------------------------------------------- |
| 222 // The Time class represents time on win32. A timestamp is represented as | 227 // The Time class represents time on win32. A timestamp is represented as |
| 223 // a 64-bit integer in 100 nanoseconds since January 1, 1601 (UTC). JavaScript | 228 // a 64-bit integer in 100 nanoseconds since January 1, 1601 (UTC). JavaScript |
| 224 // timestamps are represented as a doubles in milliseconds since 00:00:00 UTC, | 229 // timestamps are represented as a doubles in milliseconds since 00:00:00 UTC, |
| 225 // January 1, 1970. | 230 // January 1, 1970. |
| 226 | 231 |
| 227 class Time { | 232 class Time { |
| 228 public: | 233 public: |
| 229 // Constructors. | 234 // Constructors. |
| 230 Time(); | 235 Time(); |
| (...skipping 1856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2087 | 2092 |
| 2088 | 2093 |
| 2089 void Sampler::Stop() { | 2094 void Sampler::Stop() { |
| 2090 ASSERT(IsActive()); | 2095 ASSERT(IsActive()); |
| 2091 SamplerThread::RemoveActiveSampler(this); | 2096 SamplerThread::RemoveActiveSampler(this); |
| 2092 SetActive(false); | 2097 SetActive(false); |
| 2093 } | 2098 } |
| 2094 | 2099 |
| 2095 | 2100 |
| 2096 } } // namespace v8::internal | 2101 } } // namespace v8::internal |
| OLD | NEW |