| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN)) | 141 UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN)) |
| 142 UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS)) | 142 UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS)) |
| 143 UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN)) | 143 UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN)) |
| 144 UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG)) | 144 UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG)) |
| 145 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) | 145 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) |
| 146 | 146 |
| 147 #undef MATH_FUNCTION | 147 #undef MATH_FUNCTION |
| 148 | 148 |
| 149 | 149 |
| 150 void MathSetup() { | |
| 151 init_fast_sin_function(); | |
| 152 init_fast_cos_function(); | |
| 153 init_fast_tan_function(); | |
| 154 init_fast_log_function(); | |
| 155 init_fast_sqrt_function(); | |
| 156 } | |
| 157 | |
| 158 | |
| 159 double OS::nan_value() { | 150 double OS::nan_value() { |
| 160 // NAN from math.h is defined in C99 and not in POSIX. | 151 // NAN from math.h is defined in C99 and not in POSIX. |
| 161 return NAN; | 152 return NAN; |
| 162 } | 153 } |
| 163 | 154 |
| 164 | 155 |
| 165 // ---------------------------------------------------------------------------- | 156 // ---------------------------------------------------------------------------- |
| 166 // POSIX date/time support. | 157 // POSIX date/time support. |
| 167 // | 158 // |
| 168 | 159 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 str[str.length() - 1] = '\0'; | 297 str[str.length() - 1] = '\0'; |
| 307 return -1; | 298 return -1; |
| 308 } else { | 299 } else { |
| 309 return n; | 300 return n; |
| 310 } | 301 } |
| 311 } | 302 } |
| 312 | 303 |
| 313 | 304 |
| 314 #if defined(V8_TARGET_ARCH_IA32) | 305 #if defined(V8_TARGET_ARCH_IA32) |
| 315 static OS::MemCopyFunction memcopy_function = NULL; | 306 static OS::MemCopyFunction memcopy_function = NULL; |
| 316 static LazyMutex memcopy_function_mutex = LAZY_MUTEX_INITIALIZER; | |
| 317 // Defined in codegen-ia32.cc. | 307 // Defined in codegen-ia32.cc. |
| 318 OS::MemCopyFunction CreateMemCopyFunction(); | 308 OS::MemCopyFunction CreateMemCopyFunction(); |
| 319 | 309 |
| 320 // Copy memory area to disjoint memory area. | 310 // Copy memory area to disjoint memory area. |
| 321 void OS::MemCopy(void* dest, const void* src, size_t size) { | 311 void OS::MemCopy(void* dest, const void* src, size_t size) { |
| 322 if (memcopy_function == NULL) { | |
| 323 ScopedLock lock(memcopy_function_mutex.Pointer()); | |
| 324 if (memcopy_function == NULL) { | |
| 325 OS::MemCopyFunction temp = CreateMemCopyFunction(); | |
| 326 MemoryBarrier(); | |
| 327 memcopy_function = temp; | |
| 328 } | |
| 329 } | |
| 330 // Note: here we rely on dependent reads being ordered. This is true | 312 // Note: here we rely on dependent reads being ordered. This is true |
| 331 // on all architectures we currently support. | 313 // on all architectures we currently support. |
| 332 (*memcopy_function)(dest, src, size); | 314 (*memcopy_function)(dest, src, size); |
| 333 #ifdef DEBUG | 315 #ifdef DEBUG |
| 334 CHECK_EQ(0, memcmp(dest, src, size)); | 316 CHECK_EQ(0, memcmp(dest, src, size)); |
| 335 #endif | 317 #endif |
| 336 } | 318 } |
| 337 #endif // V8_TARGET_ARCH_IA32 | 319 #endif // V8_TARGET_ARCH_IA32 |
| 338 | 320 |
| 321 |
| 322 void POSIXPostSetUp() { |
| 323 #if defined(V8_TARGET_ARCH_IA32) |
| 324 memcopy_function = CreateMemCopyFunction(); |
| 325 #endif |
| 326 init_fast_sin_function(); |
| 327 init_fast_cos_function(); |
| 328 init_fast_tan_function(); |
| 329 init_fast_log_function(); |
| 330 init_fast_sqrt_function(); |
| 331 } |
| 332 |
| 339 // ---------------------------------------------------------------------------- | 333 // ---------------------------------------------------------------------------- |
| 340 // POSIX string support. | 334 // POSIX string support. |
| 341 // | 335 // |
| 342 | 336 |
| 343 char* OS::StrChr(char* str, int c) { | 337 char* OS::StrChr(char* str, int c) { |
| 344 return strchr(str, c); | 338 return strchr(str, c); |
| 345 } | 339 } |
| 346 | 340 |
| 347 | 341 |
| 348 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { | 342 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 return ntohl(value); | 515 return ntohl(value); |
| 522 } | 516 } |
| 523 | 517 |
| 524 | 518 |
| 525 Socket* OS::CreateSocket() { | 519 Socket* OS::CreateSocket() { |
| 526 return new POSIXSocket(); | 520 return new POSIXSocket(); |
| 527 } | 521 } |
| 528 | 522 |
| 529 | 523 |
| 530 } } // namespace v8::internal | 524 } } // namespace v8::internal |
| OLD | NEW |