Chromium Code Reviews| 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 <errno.h> | 10 #include <errno.h> |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 } | 141 } |
| 142 | 142 |
| 143 | 143 |
| 144 int OS::ActivationFrameAlignment() { | 144 int OS::ActivationFrameAlignment() { |
| 145 #if V8_TARGET_ARCH_ARM | 145 #if V8_TARGET_ARCH_ARM |
| 146 // On EABI ARM targets this is required for fp correctness in the | 146 // On EABI ARM targets this is required for fp correctness in the |
| 147 // runtime system. | 147 // runtime system. |
| 148 return 8; | 148 return 8; |
| 149 #elif V8_TARGET_ARCH_MIPS | 149 #elif V8_TARGET_ARCH_MIPS |
| 150 return 8; | 150 return 8; |
| 151 #elif V8_TARGET_ARCH_PPC | |
|
Sven Panne
2014/09/01 07:55:17
No need for a separate case here, just extend the
| |
| 152 return 16; | |
| 151 #else | 153 #else |
| 152 // Otherwise we just assume 16 byte alignment, i.e.: | 154 // Otherwise we just assume 16 byte alignment, i.e.: |
| 153 // - With gcc 4.4 the tree vectorization optimizer can generate code | 155 // - With gcc 4.4 the tree vectorization optimizer can generate code |
| 154 // that requires 16 byte alignment such as movdqa on x86. | 156 // that requires 16 byte alignment such as movdqa on x86. |
| 155 // - Mac OS X and Solaris (64-bit) activation frames must be 16 byte-aligned; | 157 // - Mac OS X and Solaris (64-bit) activation frames must be 16 byte-aligned; |
| 156 // see "Mac OS X ABI Function Call Guide" | 158 // see "Mac OS X ABI Function Call Guide" |
| 157 return 16; | 159 return 16; |
| 158 #endif | 160 #endif |
| 159 } | 161 } |
| 160 | 162 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 return NULL; | 233 return NULL; |
| 232 #endif | 234 #endif |
| 233 uintptr_t raw_addr; | 235 uintptr_t raw_addr; |
| 234 platform_random_number_generator.Pointer()->NextBytes(&raw_addr, | 236 platform_random_number_generator.Pointer()->NextBytes(&raw_addr, |
| 235 sizeof(raw_addr)); | 237 sizeof(raw_addr)); |
| 236 #if V8_TARGET_ARCH_X64 | 238 #if V8_TARGET_ARCH_X64 |
| 237 // Currently available CPUs have 48 bits of virtual addressing. Truncate | 239 // Currently available CPUs have 48 bits of virtual addressing. Truncate |
| 238 // the hint address to 46 bits to give the kernel a fighting chance of | 240 // the hint address to 46 bits to give the kernel a fighting chance of |
| 239 // fulfilling our placement request. | 241 // fulfilling our placement request. |
| 240 raw_addr &= V8_UINT64_C(0x3ffffffff000); | 242 raw_addr &= V8_UINT64_C(0x3ffffffff000); |
| 243 #elif V8_TARGET_ARCH_PPC64 | |
| 244 #if V8_TARGET_ARCH_PPC_BE | |
|
Sven Panne
2014/09/01 07:55:17
Please don't mix up the architecture and the endia
| |
| 245 // Big-endian Linux: 44 bits of virtual addressing. | |
| 246 raw_addr &= V8_UINT64_C(0x03fffffff000); | |
| 247 #else | |
| 248 // Little-endian Linux: 48 bits of virtual addressing. | |
| 249 raw_addr &= V8_UINT64_C(0x3ffffffff000); | |
| 250 #endif | |
| 241 #else | 251 #else |
| 242 raw_addr &= 0x3ffff000; | 252 raw_addr &= 0x3ffff000; |
| 243 | 253 |
| 244 # ifdef __sun | 254 # ifdef __sun |
| 245 // For our Solaris/illumos mmap hint, we pick a random address in the bottom | 255 // For our Solaris/illumos mmap hint, we pick a random address in the bottom |
| 246 // half of the top half of the address space (that is, the third quarter). | 256 // half of the top half of the address space (that is, the third quarter). |
| 247 // Because we do not MAP_FIXED, this will be treated only as a hint -- the | 257 // Because we do not MAP_FIXED, this will be treated only as a hint -- the |
| 248 // system will not fail to mmap() because something else happens to already | 258 // system will not fail to mmap() because something else happens to already |
| 249 // be mapped at our random address. We deliberately set the hint high enough | 259 // be mapped at our random address. We deliberately set the hint high enough |
| 250 // to get well above the system's break (that is, the heap); Solaris and | 260 // to get well above the system's break (that is, the heap); Solaris and |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 | 295 |
| 286 void OS::DebugBreak() { | 296 void OS::DebugBreak() { |
| 287 #if V8_HOST_ARCH_ARM | 297 #if V8_HOST_ARCH_ARM |
| 288 asm("bkpt 0"); | 298 asm("bkpt 0"); |
| 289 #elif V8_HOST_ARCH_ARM64 | 299 #elif V8_HOST_ARCH_ARM64 |
| 290 asm("brk 0"); | 300 asm("brk 0"); |
| 291 #elif V8_HOST_ARCH_MIPS | 301 #elif V8_HOST_ARCH_MIPS |
| 292 asm("break"); | 302 asm("break"); |
| 293 #elif V8_HOST_ARCH_MIPS64 | 303 #elif V8_HOST_ARCH_MIPS64 |
| 294 asm("break"); | 304 asm("break"); |
| 305 #elif V8_HOST_ARCH_PPC | |
| 306 asm("twge 2,2"); | |
| 295 #elif V8_HOST_ARCH_IA32 | 307 #elif V8_HOST_ARCH_IA32 |
| 296 #if defined(__native_client__) | 308 #if defined(__native_client__) |
| 297 asm("hlt"); | 309 asm("hlt"); |
| 298 #else | 310 #else |
| 299 asm("int $3"); | 311 asm("int $3"); |
| 300 #endif // __native_client__ | 312 #endif // __native_client__ |
| 301 #elif V8_HOST_ARCH_X64 | 313 #elif V8_HOST_ARCH_X64 |
| 302 asm("int $3"); | 314 asm("int $3"); |
| 303 #else | 315 #else |
| 304 #error Unsupported host architecture. | 316 #error Unsupported host architecture. |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 597 USE(result); | 609 USE(result); |
| 598 } | 610 } |
| 599 | 611 |
| 600 | 612 |
| 601 void Thread::Join() { | 613 void Thread::Join() { |
| 602 pthread_join(data_->thread_, NULL); | 614 pthread_join(data_->thread_, NULL); |
| 603 } | 615 } |
| 604 | 616 |
| 605 | 617 |
| 606 void Thread::YieldCPU() { | 618 void Thread::YieldCPU() { |
| 619 #if V8_TARGET_ARCH_PPC | |
|
Sven Panne
2014/09/01 07:55:17
Huh? How is this related to the *architecture*? Do
| |
| 620 OS::Sleep(0); | |
| 621 #else | |
| 607 int result = sched_yield(); | 622 int result = sched_yield(); |
| 608 DCHECK_EQ(0, result); | 623 DCHECK_EQ(0, result); |
| 609 USE(result); | 624 USE(result); |
| 625 #endif | |
| 610 } | 626 } |
| 611 | 627 |
| 612 | 628 |
| 613 static Thread::LocalStorageKey PthreadKeyToLocalKey(pthread_key_t pthread_key) { | 629 static Thread::LocalStorageKey PthreadKeyToLocalKey(pthread_key_t pthread_key) { |
| 614 #if V8_OS_CYGWIN | 630 #if V8_OS_CYGWIN |
| 615 // We need to cast pthread_key_t to Thread::LocalStorageKey in two steps | 631 // We need to cast pthread_key_t to Thread::LocalStorageKey in two steps |
| 616 // because pthread_key_t is a pointer type on Cygwin. This will probably not | 632 // because pthread_key_t is a pointer type on Cygwin. This will probably not |
| 617 // work on 64-bit platforms, but Cygwin doesn't support 64-bit anyway. | 633 // work on 64-bit platforms, but Cygwin doesn't support 64-bit anyway. |
| 618 STATIC_ASSERT(sizeof(Thread::LocalStorageKey) == sizeof(pthread_key_t)); | 634 STATIC_ASSERT(sizeof(Thread::LocalStorageKey) == sizeof(pthread_key_t)); |
| 619 intptr_t ptr_key = reinterpret_cast<intptr_t>(pthread_key); | 635 intptr_t ptr_key = reinterpret_cast<intptr_t>(pthread_key); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 728 | 744 |
| 729 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { | 745 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { |
| 730 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); | 746 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); |
| 731 int result = pthread_setspecific(pthread_key, value); | 747 int result = pthread_setspecific(pthread_key, value); |
| 732 DCHECK_EQ(0, result); | 748 DCHECK_EQ(0, result); |
| 733 USE(result); | 749 USE(result); |
| 734 } | 750 } |
| 735 | 751 |
| 736 | 752 |
| 737 } } // namespace v8::base | 753 } } // namespace v8::base |
| OLD | NEW |