| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 asm("int $3"); | 281 asm("int $3"); |
| 282 #else | 282 #else |
| 283 #error Unsupported host architecture. | 283 #error Unsupported host architecture. |
| 284 #endif | 284 #endif |
| 285 } | 285 } |
| 286 | 286 |
| 287 | 287 |
| 288 // ---------------------------------------------------------------------------- | 288 // ---------------------------------------------------------------------------- |
| 289 // Math functions | 289 // Math functions |
| 290 | 290 |
| 291 double ceiling(double x) { | |
| 292 // Correct buggy 'ceil' on some systems (i.e. FreeBSD, OS X 10.5) | |
| 293 return (-1.0 < x && x < 0.0) ? -0.0 : ceil(x); | |
| 294 } | |
| 295 | |
| 296 | |
| 297 double modulo(double x, double y) { | 291 double modulo(double x, double y) { |
| 298 return fmod(x, y); | 292 return fmod(x, y); |
| 299 } | 293 } |
| 300 | 294 |
| 301 | 295 |
| 302 #define UNARY_MATH_FUNCTION(name, generator) \ | 296 #define UNARY_MATH_FUNCTION(name, generator) \ |
| 303 static UnaryMathFunction fast_##name##_function = NULL; \ | 297 static UnaryMathFunction fast_##name##_function = NULL; \ |
| 304 void init_fast_##name##_function() { \ | 298 void init_fast_##name##_function() { \ |
| 305 fast_##name##_function = generator; \ | 299 fast_##name##_function = generator; \ |
| 306 } \ | 300 } \ |
| 307 double fast_##name(double x) { \ | 301 double fast_##name(double x) { \ |
| 308 return (*fast_##name##_function)(x); \ | 302 return (*fast_##name##_function)(x); \ |
| 309 } | 303 } |
| 310 | 304 |
| 311 UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN)) | |
| 312 UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS)) | |
| 313 UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN)) | |
| 314 UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG)) | 305 UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG)) |
| 315 UNARY_MATH_FUNCTION(exp, CreateExpFunction()) | 306 UNARY_MATH_FUNCTION(exp, CreateExpFunction()) |
| 316 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) | 307 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) |
| 317 | 308 |
| 318 #undef UNARY_MATH_FUNCTION | 309 #undef UNARY_MATH_FUNCTION |
| 319 | 310 |
| 320 | 311 |
| 321 void lazily_initialize_fast_exp() { | 312 void lazily_initialize_fast_exp() { |
| 322 if (fast_exp_function == NULL) { | 313 if (fast_exp_function == NULL) { |
| 323 init_fast_exp_function(); | 314 init_fast_exp_function(); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 | 496 |
| 506 | 497 |
| 507 OS::MemCopyUint8Function OS::memcopy_uint8_function = &OS::MemCopyUint8Wrapper; | 498 OS::MemCopyUint8Function OS::memcopy_uint8_function = &OS::MemCopyUint8Wrapper; |
| 508 OS::MemCopyUint16Uint8Function OS::memcopy_uint16_uint8_function = | 499 OS::MemCopyUint16Uint8Function OS::memcopy_uint16_uint8_function = |
| 509 &OS::MemCopyUint16Uint8Wrapper; | 500 &OS::MemCopyUint16Uint8Wrapper; |
| 510 // Defined in codegen-arm.cc. | 501 // Defined in codegen-arm.cc. |
| 511 OS::MemCopyUint8Function CreateMemCopyUint8Function( | 502 OS::MemCopyUint8Function CreateMemCopyUint8Function( |
| 512 OS::MemCopyUint8Function stub); | 503 OS::MemCopyUint8Function stub); |
| 513 OS::MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function( | 504 OS::MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function( |
| 514 OS::MemCopyUint16Uint8Function stub); | 505 OS::MemCopyUint16Uint8Function stub); |
| 506 |
| 507 #elif defined(V8_HOST_ARCH_MIPS) |
| 508 OS::MemCopyUint8Function OS::memcopy_uint8_function = &OS::MemCopyUint8Wrapper; |
| 509 // Defined in codegen-mips.cc. |
| 510 OS::MemCopyUint8Function CreateMemCopyUint8Function( |
| 511 OS::MemCopyUint8Function stub); |
| 515 #endif | 512 #endif |
| 516 | 513 |
| 517 | 514 |
| 518 void OS::PostSetUp() { | 515 void OS::PostSetUp() { |
| 519 #if V8_TARGET_ARCH_IA32 | 516 #if V8_TARGET_ARCH_IA32 |
| 520 OS::MemMoveFunction generated_memmove = CreateMemMoveFunction(); | 517 OS::MemMoveFunction generated_memmove = CreateMemMoveFunction(); |
| 521 if (generated_memmove != NULL) { | 518 if (generated_memmove != NULL) { |
| 522 memmove_function = generated_memmove; | 519 memmove_function = generated_memmove; |
| 523 } | 520 } |
| 524 #elif defined(V8_HOST_ARCH_ARM) | 521 #elif defined(V8_HOST_ARCH_ARM) |
| 525 OS::memcopy_uint8_function = | 522 OS::memcopy_uint8_function = |
| 526 CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper); | 523 CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper); |
| 527 OS::memcopy_uint16_uint8_function = | 524 OS::memcopy_uint16_uint8_function = |
| 528 CreateMemCopyUint16Uint8Function(&OS::MemCopyUint16Uint8Wrapper); | 525 CreateMemCopyUint16Uint8Function(&OS::MemCopyUint16Uint8Wrapper); |
| 526 #elif defined(V8_HOST_ARCH_MIPS) |
| 527 OS::memcopy_uint8_function = |
| 528 CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper); |
| 529 #endif | 529 #endif |
| 530 init_fast_sin_function(); | |
| 531 init_fast_cos_function(); | |
| 532 init_fast_tan_function(); | |
| 533 init_fast_log_function(); | 530 init_fast_log_function(); |
| 534 // fast_exp is initialized lazily. | 531 // fast_exp is initialized lazily. |
| 535 init_fast_sqrt_function(); | 532 init_fast_sqrt_function(); |
| 536 } | 533 } |
| 537 | 534 |
| 538 | 535 |
| 539 // ---------------------------------------------------------------------------- | 536 // ---------------------------------------------------------------------------- |
| 540 // POSIX string support. | 537 // POSIX string support. |
| 541 // | 538 // |
| 542 | 539 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 | 771 |
| 775 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { | 772 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { |
| 776 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); | 773 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); |
| 777 int result = pthread_setspecific(pthread_key, value); | 774 int result = pthread_setspecific(pthread_key, value); |
| 778 ASSERT_EQ(0, result); | 775 ASSERT_EQ(0, result); |
| 779 USE(result); | 776 USE(result); |
| 780 } | 777 } |
| 781 | 778 |
| 782 | 779 |
| 783 } } // namespace v8::internal | 780 } } // namespace v8::internal |
| OLD | NEW |