| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 } | 123 } |
| 124 return static_cast<uint64_t>(pages) * page_size; | 124 return static_cast<uint64_t>(pages) * page_size; |
| 125 #elif V8_OS_CYGWIN | 125 #elif V8_OS_CYGWIN |
| 126 MEMORYSTATUS memory_info; | 126 MEMORYSTATUS memory_info; |
| 127 memory_info.dwLength = sizeof(memory_info); | 127 memory_info.dwLength = sizeof(memory_info); |
| 128 if (!GlobalMemoryStatus(&memory_info)) { | 128 if (!GlobalMemoryStatus(&memory_info)) { |
| 129 UNREACHABLE(); | 129 UNREACHABLE(); |
| 130 return 0; | 130 return 0; |
| 131 } | 131 } |
| 132 return static_cast<uint64_t>(memory_info.dwTotalPhys); | 132 return static_cast<uint64_t>(memory_info.dwTotalPhys); |
| 133 #elif V8_OS_QNX |
| 134 struct stat stat_buf; |
| 135 if (stat("/proc", &stat_buf) != 0) { |
| 136 UNREACHABLE(); |
| 137 return 0; |
| 138 } |
| 139 return static_cast<uint64_t>(stat_buf.st_size); |
| 133 #else | 140 #else |
| 134 intptr_t pages = sysconf(_SC_PHYS_PAGES); | 141 intptr_t pages = sysconf(_SC_PHYS_PAGES); |
| 135 intptr_t page_size = sysconf(_SC_PAGESIZE); | 142 intptr_t page_size = sysconf(_SC_PAGESIZE); |
| 136 if (pages == -1 || page_size == -1) { | 143 if (pages == -1 || page_size == -1) { |
| 137 UNREACHABLE(); | 144 UNREACHABLE(); |
| 138 return 0; | 145 return 0; |
| 139 } | 146 } |
| 140 return static_cast<uint64_t>(pages) * page_size; | 147 return static_cast<uint64_t>(pages) * page_size; |
| 141 #endif | 148 #endif |
| 142 } | 149 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 raw_addr += 0x20000000; | 247 raw_addr += 0x20000000; |
| 241 # endif | 248 # endif |
| 242 #endif | 249 #endif |
| 243 return reinterpret_cast<void*>(raw_addr); | 250 return reinterpret_cast<void*>(raw_addr); |
| 244 } | 251 } |
| 245 return NULL; | 252 return NULL; |
| 246 } | 253 } |
| 247 | 254 |
| 248 | 255 |
| 249 size_t OS::AllocateAlignment() { | 256 size_t OS::AllocateAlignment() { |
| 250 return getpagesize(); | 257 return static_cast<size_t>(sysconf(_SC_PAGESIZE)); |
| 251 } | 258 } |
| 252 | 259 |
| 253 | 260 |
| 254 void OS::Sleep(int milliseconds) { | 261 void OS::Sleep(int milliseconds) { |
| 255 useconds_t ms = static_cast<useconds_t>(milliseconds); | 262 useconds_t ms = static_cast<useconds_t>(milliseconds); |
| 256 usleep(1000 * ms); | 263 usleep(1000 * ms); |
| 257 } | 264 } |
| 258 | 265 |
| 259 | 266 |
| 260 void OS::Abort() { | 267 void OS::Abort() { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 | 304 |
| 298 #define UNARY_MATH_FUNCTION(name, generator) \ | 305 #define UNARY_MATH_FUNCTION(name, generator) \ |
| 299 static UnaryMathFunction fast_##name##_function = NULL; \ | 306 static UnaryMathFunction fast_##name##_function = NULL; \ |
| 300 void init_fast_##name##_function() { \ | 307 void init_fast_##name##_function() { \ |
| 301 fast_##name##_function = generator; \ | 308 fast_##name##_function = generator; \ |
| 302 } \ | 309 } \ |
| 303 double fast_##name(double x) { \ | 310 double fast_##name(double x) { \ |
| 304 return (*fast_##name##_function)(x); \ | 311 return (*fast_##name##_function)(x); \ |
| 305 } | 312 } |
| 306 | 313 |
| 307 UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG)) | |
| 308 UNARY_MATH_FUNCTION(exp, CreateExpFunction()) | 314 UNARY_MATH_FUNCTION(exp, CreateExpFunction()) |
| 309 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) | 315 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) |
| 310 | 316 |
| 311 #undef UNARY_MATH_FUNCTION | 317 #undef UNARY_MATH_FUNCTION |
| 312 | 318 |
| 313 | 319 |
| 314 void lazily_initialize_fast_exp() { | 320 void lazily_initialize_fast_exp() { |
| 315 if (fast_exp_function == NULL) { | 321 if (fast_exp_function == NULL) { |
| 316 init_fast_exp_function(); | 322 init_fast_exp_function(); |
| 317 } | 323 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 | 504 |
| 499 | 505 |
| 500 OS::MemCopyUint8Function OS::memcopy_uint8_function = &OS::MemCopyUint8Wrapper; | 506 OS::MemCopyUint8Function OS::memcopy_uint8_function = &OS::MemCopyUint8Wrapper; |
| 501 OS::MemCopyUint16Uint8Function OS::memcopy_uint16_uint8_function = | 507 OS::MemCopyUint16Uint8Function OS::memcopy_uint16_uint8_function = |
| 502 &OS::MemCopyUint16Uint8Wrapper; | 508 &OS::MemCopyUint16Uint8Wrapper; |
| 503 // Defined in codegen-arm.cc. | 509 // Defined in codegen-arm.cc. |
| 504 OS::MemCopyUint8Function CreateMemCopyUint8Function( | 510 OS::MemCopyUint8Function CreateMemCopyUint8Function( |
| 505 OS::MemCopyUint8Function stub); | 511 OS::MemCopyUint8Function stub); |
| 506 OS::MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function( | 512 OS::MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function( |
| 507 OS::MemCopyUint16Uint8Function stub); | 513 OS::MemCopyUint16Uint8Function stub); |
| 514 |
| 515 #elif defined(V8_HOST_ARCH_MIPS) |
| 516 OS::MemCopyUint8Function OS::memcopy_uint8_function = &OS::MemCopyUint8Wrapper; |
| 517 // Defined in codegen-mips.cc. |
| 518 OS::MemCopyUint8Function CreateMemCopyUint8Function( |
| 519 OS::MemCopyUint8Function stub); |
| 508 #endif | 520 #endif |
| 509 | 521 |
| 510 | 522 |
| 511 void OS::PostSetUp() { | 523 void OS::PostSetUp() { |
| 512 #if V8_TARGET_ARCH_IA32 | 524 #if V8_TARGET_ARCH_IA32 |
| 513 OS::MemMoveFunction generated_memmove = CreateMemMoveFunction(); | 525 OS::MemMoveFunction generated_memmove = CreateMemMoveFunction(); |
| 514 if (generated_memmove != NULL) { | 526 if (generated_memmove != NULL) { |
| 515 memmove_function = generated_memmove; | 527 memmove_function = generated_memmove; |
| 516 } | 528 } |
| 517 #elif defined(V8_HOST_ARCH_ARM) | 529 #elif defined(V8_HOST_ARCH_ARM) |
| 518 OS::memcopy_uint8_function = | 530 OS::memcopy_uint8_function = |
| 519 CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper); | 531 CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper); |
| 520 OS::memcopy_uint16_uint8_function = | 532 OS::memcopy_uint16_uint8_function = |
| 521 CreateMemCopyUint16Uint8Function(&OS::MemCopyUint16Uint8Wrapper); | 533 CreateMemCopyUint16Uint8Function(&OS::MemCopyUint16Uint8Wrapper); |
| 534 #elif defined(V8_HOST_ARCH_MIPS) |
| 535 OS::memcopy_uint8_function = |
| 536 CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper); |
| 522 #endif | 537 #endif |
| 523 init_fast_log_function(); | |
| 524 // fast_exp is initialized lazily. | 538 // fast_exp is initialized lazily. |
| 525 init_fast_sqrt_function(); | 539 init_fast_sqrt_function(); |
| 526 } | 540 } |
| 527 | 541 |
| 528 | 542 |
| 529 // ---------------------------------------------------------------------------- | 543 // ---------------------------------------------------------------------------- |
| 530 // POSIX string support. | 544 // POSIX string support. |
| 531 // | 545 // |
| 532 | 546 |
| 533 char* OS::StrChr(char* str, int c) { | 547 char* OS::StrChr(char* str, int c) { |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 | 778 |
| 765 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { | 779 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { |
| 766 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); | 780 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); |
| 767 int result = pthread_setspecific(pthread_key, value); | 781 int result = pthread_setspecific(pthread_key, value); |
| 768 ASSERT_EQ(0, result); | 782 ASSERT_EQ(0, result); |
| 769 USE(result); | 783 USE(result); |
| 770 } | 784 } |
| 771 | 785 |
| 772 | 786 |
| 773 } } // namespace v8::internal | 787 } } // namespace v8::internal |
| OLD | NEW |