| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // ---------------------------------------------------------------------------- | 122 // ---------------------------------------------------------------------------- |
| 123 // Math functions | 123 // Math functions |
| 124 | 124 |
| 125 double modulo(double x, double y) { | 125 double modulo(double x, double y) { |
| 126 return fmod(x, y); | 126 return fmod(x, y); |
| 127 } | 127 } |
| 128 | 128 |
| 129 | 129 |
| 130 #define UNARY_MATH_FUNCTION(name, generator) \ | 130 #define UNARY_MATH_FUNCTION(name, generator) \ |
| 131 static UnaryMathFunction fast_##name##_function = NULL; \ | 131 static UnaryMathFunction fast_##name##_function = NULL; \ |
| 132 V8_DECLARE_ONCE(fast_##name##_init_once); \ | |
| 133 void init_fast_##name##_function() { \ | 132 void init_fast_##name##_function() { \ |
| 134 fast_##name##_function = generator; \ | 133 fast_##name##_function = generator; \ |
| 135 } \ | 134 } \ |
| 136 double fast_##name(double x) { \ | 135 double fast_##name(double x) { \ |
| 137 CallOnce(&fast_##name##_init_once, \ | |
| 138 &init_fast_##name##_function); \ | |
| 139 return (*fast_##name##_function)(x); \ | 136 return (*fast_##name##_function)(x); \ |
| 140 } | 137 } |
| 141 | 138 |
| 142 UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN)) | 139 UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN)) |
| 143 UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS)) | 140 UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS)) |
| 144 UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN)) | 141 UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN)) |
| 145 UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG)) | 142 UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG)) |
| 146 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) | 143 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) |
| 147 | 144 |
| 148 #undef MATH_FUNCTION | 145 #undef MATH_FUNCTION |
| 149 | 146 |
| 150 | 147 |
| 148 void MathSetup() { |
| 149 init_fast_sin_function(); |
| 150 init_fast_cos_function(); |
| 151 init_fast_tan_function(); |
| 152 init_fast_log_function(); |
| 153 init_fast_sqrt_function(); |
| 154 } |
| 155 |
| 156 |
| 151 double OS::nan_value() { | 157 double OS::nan_value() { |
| 152 // NAN from math.h is defined in C99 and not in POSIX. | 158 // NAN from math.h is defined in C99 and not in POSIX. |
| 153 return NAN; | 159 return NAN; |
| 154 } | 160 } |
| 155 | 161 |
| 156 | 162 |
| 157 // ---------------------------------------------------------------------------- | 163 // ---------------------------------------------------------------------------- |
| 158 // POSIX date/time support. | 164 // POSIX date/time support. |
| 159 // | 165 // |
| 160 | 166 |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 return ntohl(value); | 519 return ntohl(value); |
| 514 } | 520 } |
| 515 | 521 |
| 516 | 522 |
| 517 Socket* OS::CreateSocket() { | 523 Socket* OS::CreateSocket() { |
| 518 return new POSIXSocket(); | 524 return new POSIXSocket(); |
| 519 } | 525 } |
| 520 | 526 |
| 521 | 527 |
| 522 } } // namespace v8::internal | 528 } } // namespace v8::internal |
| OLD | NEW |