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 <errno.h> | 9 #include <errno.h> |
10 #include <limits.h> | 10 #include <limits.h> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 #if V8_TARGET_ARCH_ARM | 78 #if V8_TARGET_ARCH_ARM |
79 // On EABI ARM targets this is required for fp correctness in the | 79 // On EABI ARM targets this is required for fp correctness in the |
80 // runtime system. | 80 // runtime system. |
81 return 8; | 81 return 8; |
82 #elif V8_TARGET_ARCH_MIPS | 82 #elif V8_TARGET_ARCH_MIPS |
83 return 8; | 83 return 8; |
84 #else | 84 #else |
85 // Otherwise we just assume 16 byte alignment, i.e.: | 85 // Otherwise we just assume 16 byte alignment, i.e.: |
86 // - With gcc 4.4 the tree vectorization optimizer can generate code | 86 // - With gcc 4.4 the tree vectorization optimizer can generate code |
87 // that requires 16 byte alignment such as movdqa on x86. | 87 // that requires 16 byte alignment such as movdqa on x86. |
88 // - Mac OS X and Solaris (64-bit) activation frames must be 16 byte-aligned; | 88 // - Mac OS X, PPC and Solaris (64-bit) activation frames must |
89 // see "Mac OS X ABI Function Call Guide" | 89 // be 16 byte-aligned; see "Mac OS X ABI Function Call Guide" |
Sven Panne
2015/01/08 10:13:53
Micro-nit: Indentation.
michael_dawson
2015/01/08 23:51:11
Will do
| |
90 return 16; | 90 return 16; |
91 #endif | 91 #endif |
92 } | 92 } |
93 | 93 |
94 | 94 |
95 intptr_t OS::CommitPageSize() { | 95 intptr_t OS::CommitPageSize() { |
96 static intptr_t page_size = getpagesize(); | 96 static intptr_t page_size = getpagesize(); |
97 return page_size; | 97 return page_size; |
98 } | 98 } |
99 | 99 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 return NULL; | 164 return NULL; |
165 #endif | 165 #endif |
166 uintptr_t raw_addr; | 166 uintptr_t raw_addr; |
167 platform_random_number_generator.Pointer()->NextBytes(&raw_addr, | 167 platform_random_number_generator.Pointer()->NextBytes(&raw_addr, |
168 sizeof(raw_addr)); | 168 sizeof(raw_addr)); |
169 #if V8_TARGET_ARCH_X64 | 169 #if V8_TARGET_ARCH_X64 |
170 // Currently available CPUs have 48 bits of virtual addressing. Truncate | 170 // Currently available CPUs have 48 bits of virtual addressing. Truncate |
171 // the hint address to 46 bits to give the kernel a fighting chance of | 171 // the hint address to 46 bits to give the kernel a fighting chance of |
172 // fulfilling our placement request. | 172 // fulfilling our placement request. |
173 raw_addr &= V8_UINT64_C(0x3ffffffff000); | 173 raw_addr &= V8_UINT64_C(0x3ffffffff000); |
174 #elif V8_TARGET_ARCH_PPC64 | |
175 #if V8_TARGET_BIG_ENDIAN | |
176 // Big-endian Linux: 44 bits of virtual addressing. | |
177 raw_addr &= V8_UINT64_C(0x03fffffff000); | |
178 #else | |
179 // Little-endian Linux: 48 bits of virtual addressing. | |
180 raw_addr &= V8_UINT64_C(0x3ffffffff000); | |
181 #endif | |
174 #else | 182 #else |
175 raw_addr &= 0x3ffff000; | 183 raw_addr &= 0x3ffff000; |
176 | 184 |
177 # ifdef __sun | 185 # ifdef __sun |
178 // For our Solaris/illumos mmap hint, we pick a random address in the bottom | 186 // For our Solaris/illumos mmap hint, we pick a random address in the bottom |
179 // half of the top half of the address space (that is, the third quarter). | 187 // half of the top half of the address space (that is, the third quarter). |
180 // Because we do not MAP_FIXED, this will be treated only as a hint -- the | 188 // Because we do not MAP_FIXED, this will be treated only as a hint -- the |
181 // system will not fail to mmap() because something else happens to already | 189 // system will not fail to mmap() because something else happens to already |
182 // be mapped at our random address. We deliberately set the hint high enough | 190 // be mapped at our random address. We deliberately set the hint high enough |
183 // to get well above the system's break (that is, the heap); Solaris and | 191 // 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... | |
218 | 226 |
219 void OS::DebugBreak() { | 227 void OS::DebugBreak() { |
220 #if V8_HOST_ARCH_ARM | 228 #if V8_HOST_ARCH_ARM |
221 asm("bkpt 0"); | 229 asm("bkpt 0"); |
222 #elif V8_HOST_ARCH_ARM64 | 230 #elif V8_HOST_ARCH_ARM64 |
223 asm("brk 0"); | 231 asm("brk 0"); |
224 #elif V8_HOST_ARCH_MIPS | 232 #elif V8_HOST_ARCH_MIPS |
225 asm("break"); | 233 asm("break"); |
226 #elif V8_HOST_ARCH_MIPS64 | 234 #elif V8_HOST_ARCH_MIPS64 |
227 asm("break"); | 235 asm("break"); |
236 #elif V8_HOST_ARCH_PPC | |
237 asm("twge 2,2"); | |
228 #elif V8_HOST_ARCH_IA32 | 238 #elif V8_HOST_ARCH_IA32 |
229 #if V8_OS_NACL | 239 #if V8_OS_NACL |
230 asm("hlt"); | 240 asm("hlt"); |
231 #else | 241 #else |
232 asm("int $3"); | 242 asm("int $3"); |
233 #endif // V8_OS_NACL | 243 #endif // V8_OS_NACL |
234 #elif V8_HOST_ARCH_X64 | 244 #elif V8_HOST_ARCH_X64 |
235 asm("int $3"); | 245 asm("int $3"); |
236 #else | 246 #else |
237 #error Unsupported host architecture. | 247 #error Unsupported host architecture. |
238 #endif | 248 #endif |
239 } | 249 } |
240 | 250 |
241 | 251 |
242 // ---------------------------------------------------------------------------- | 252 // ---------------------------------------------------------------------------- |
243 // Math functions | 253 // Math functions |
244 | 254 |
255 | |
245 double OS::nan_value() { | 256 double OS::nan_value() { |
246 // NAN from math.h is defined in C99 and not in POSIX. | 257 // NAN from math.h is defined in C99 and not in POSIX. |
247 return NAN; | 258 return NAN; |
248 } | 259 } |
249 | 260 |
250 | 261 |
251 int OS::GetCurrentProcessId() { | 262 int OS::GetCurrentProcessId() { |
252 return static_cast<int>(getpid()); | 263 return static_cast<int>(getpid()); |
253 } | 264 } |
254 | 265 |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
670 | 681 |
671 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { | 682 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { |
672 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); | 683 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); |
673 int result = pthread_setspecific(pthread_key, value); | 684 int result = pthread_setspecific(pthread_key, value); |
674 DCHECK_EQ(0, result); | 685 DCHECK_EQ(0, result); |
675 USE(result); | 686 USE(result); |
676 } | 687 } |
677 | 688 |
678 | 689 |
679 } } // namespace v8::base | 690 } } // namespace v8::base |
OLD | NEW |