| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Platform-specific code for POSIX goes here. This is not a platform on its | 5 // Platform-specific code for POSIX goes here. This is not a platform on its |
| 6 // own, but contains the parts which are the same across the POSIX platforms | 6 // own, but contains the parts which are the same across the POSIX platforms |
| 7 // Linux, MacOS, FreeBSD, OpenBSD, NetBSD and QNX. | 7 // Linux, MacOS, FreeBSD, OpenBSD, NetBSD and QNX. |
| 8 | 8 |
| 9 #include <dlfcn.h> | 9 #include <dlfcn.h> |
| 10 #include <pthread.h> | 10 #include <pthread.h> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 #undef MAP_TYPE | 37 #undef MAP_TYPE |
| 38 | 38 |
| 39 #if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT) | 39 #if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT) |
| 40 #define LOG_TAG "v8" | 40 #define LOG_TAG "v8" |
| 41 #include <android/log.h> | 41 #include <android/log.h> |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 #include "v8.h" | 44 #include "v8.h" |
| 45 | 45 |
| 46 #include "codegen.h" | |
| 47 #include "isolate-inl.h" | 46 #include "isolate-inl.h" |
| 48 #include "platform.h" | 47 #include "platform.h" |
| 49 | 48 |
| 50 namespace v8 { | 49 namespace v8 { |
| 51 namespace internal { | 50 namespace internal { |
| 52 | 51 |
| 53 // 0 is never a valid thread id. | 52 // 0 is never a valid thread id. |
| 54 static const pthread_t kNoThread = (pthread_t) 0; | 53 static const pthread_t kNoThread = (pthread_t) 0; |
| 55 | 54 |
| 56 | 55 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 asm("int $3"); | 277 asm("int $3"); |
| 279 #else | 278 #else |
| 280 #error Unsupported host architecture. | 279 #error Unsupported host architecture. |
| 281 #endif | 280 #endif |
| 282 } | 281 } |
| 283 | 282 |
| 284 | 283 |
| 285 // ---------------------------------------------------------------------------- | 284 // ---------------------------------------------------------------------------- |
| 286 // Math functions | 285 // Math functions |
| 287 | 286 |
| 288 double modulo(double x, double y) { | |
| 289 return std::fmod(x, y); | |
| 290 } | |
| 291 | |
| 292 | |
| 293 #define UNARY_MATH_FUNCTION(name, generator) \ | |
| 294 static UnaryMathFunction fast_##name##_function = NULL; \ | |
| 295 void init_fast_##name##_function() { \ | |
| 296 fast_##name##_function = generator; \ | |
| 297 } \ | |
| 298 double fast_##name(double x) { \ | |
| 299 return (*fast_##name##_function)(x); \ | |
| 300 } | |
| 301 | |
| 302 UNARY_MATH_FUNCTION(exp, CreateExpFunction()) | |
| 303 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) | |
| 304 | |
| 305 #undef UNARY_MATH_FUNCTION | |
| 306 | |
| 307 | |
| 308 void lazily_initialize_fast_exp() { | |
| 309 if (fast_exp_function == NULL) { | |
| 310 init_fast_exp_function(); | |
| 311 } | |
| 312 } | |
| 313 | |
| 314 | |
| 315 double OS::nan_value() { | 287 double OS::nan_value() { |
| 316 // NAN from math.h is defined in C99 and not in POSIX. | 288 // NAN from math.h is defined in C99 and not in POSIX. |
| 317 return NAN; | 289 return NAN; |
| 318 } | 290 } |
| 319 | 291 |
| 320 | 292 |
| 321 int OS::GetCurrentProcessId() { | 293 int OS::GetCurrentProcessId() { |
| 322 return static_cast<int>(getpid()); | 294 return static_cast<int>(getpid()); |
| 323 } | 295 } |
| 324 | 296 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 } | 506 } |
| 535 #elif defined(V8_HOST_ARCH_ARM) | 507 #elif defined(V8_HOST_ARCH_ARM) |
| 536 OS::memcopy_uint8_function = | 508 OS::memcopy_uint8_function = |
| 537 CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper); | 509 CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper); |
| 538 OS::memcopy_uint16_uint8_function = | 510 OS::memcopy_uint16_uint8_function = |
| 539 CreateMemCopyUint16Uint8Function(&OS::MemCopyUint16Uint8Wrapper); | 511 CreateMemCopyUint16Uint8Function(&OS::MemCopyUint16Uint8Wrapper); |
| 540 #elif defined(V8_HOST_ARCH_MIPS) | 512 #elif defined(V8_HOST_ARCH_MIPS) |
| 541 OS::memcopy_uint8_function = | 513 OS::memcopy_uint8_function = |
| 542 CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper); | 514 CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper); |
| 543 #endif | 515 #endif |
| 544 // fast_exp is initialized lazily. | |
| 545 init_fast_sqrt_function(); | |
| 546 } | 516 } |
| 547 | 517 |
| 548 | 518 |
| 549 // ---------------------------------------------------------------------------- | 519 // ---------------------------------------------------------------------------- |
| 550 // POSIX string support. | 520 // POSIX string support. |
| 551 // | 521 // |
| 552 | 522 |
| 553 char* OS::StrChr(char* str, int c) { | 523 char* OS::StrChr(char* str, int c) { |
| 554 return strchr(str, c); | 524 return strchr(str, c); |
| 555 } | 525 } |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 | 759 |
| 790 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { | 760 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { |
| 791 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); | 761 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); |
| 792 int result = pthread_setspecific(pthread_key, value); | 762 int result = pthread_setspecific(pthread_key, value); |
| 793 ASSERT_EQ(0, result); | 763 ASSERT_EQ(0, result); |
| 794 USE(result); | 764 USE(result); |
| 795 } | 765 } |
| 796 | 766 |
| 797 | 767 |
| 798 } } // namespace v8::internal | 768 } } // namespace v8::internal |
| OLD | NEW |