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 Linux goes here. For the POSIX-compatible | 5 // Platform-specific code for Linux goes here. For the POSIX-compatible |
6 // parts, the implementation is in platform-posix.cc. | 6 // parts, the implementation is in platform-posix.cc. |
7 | 7 |
8 #include <pthread.h> | 8 #include <pthread.h> |
9 #include <semaphore.h> | 9 #include <semaphore.h> |
10 #include <signal.h> | 10 #include <signal.h> |
(...skipping 21 matching lines...) Expand all Loading... |
32 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ | 32 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ |
33 (defined(__arm__) || defined(__aarch64__)) && \ | 33 (defined(__arm__) || defined(__aarch64__)) && \ |
34 !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) | 34 !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) |
35 #include <asm/sigcontext.h> // NOLINT | 35 #include <asm/sigcontext.h> // NOLINT |
36 #endif | 36 #endif |
37 | 37 |
38 #if defined(LEAK_SANITIZER) | 38 #if defined(LEAK_SANITIZER) |
39 #include <sanitizer/lsan_interface.h> | 39 #include <sanitizer/lsan_interface.h> |
40 #endif | 40 #endif |
41 | 41 |
| 42 #include <cmath> |
| 43 |
42 #undef MAP_TYPE | 44 #undef MAP_TYPE |
43 | 45 |
44 #include "src/v8.h" | |
45 | |
46 #include "src/platform.h" | 46 #include "src/platform.h" |
| 47 #include "src/utils.h" |
47 | 48 |
48 | 49 |
49 namespace v8 { | 50 namespace v8 { |
50 namespace internal { | 51 namespace internal { |
51 | 52 |
52 | 53 |
53 #ifdef __arm__ | 54 #ifdef __arm__ |
54 | 55 |
55 bool OS::ArmUsingHardFloat() { | 56 bool OS::ArmUsingHardFloat() { |
56 // GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify | 57 // GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 void OS::SignalCodeMovingGC() { | 248 void OS::SignalCodeMovingGC() { |
248 // Support for ll_prof.py. | 249 // Support for ll_prof.py. |
249 // | 250 // |
250 // The Linux profiler built into the kernel logs all mmap's with | 251 // The Linux profiler built into the kernel logs all mmap's with |
251 // PROT_EXEC so that analysis tools can properly attribute ticks. We | 252 // PROT_EXEC so that analysis tools can properly attribute ticks. We |
252 // do a mmap with a name known by ll_prof.py and immediately munmap | 253 // do a mmap with a name known by ll_prof.py and immediately munmap |
253 // it. This injects a GC marker into the stream of events generated | 254 // it. This injects a GC marker into the stream of events generated |
254 // by the kernel and allows us to synchronize V8 code log and the | 255 // by the kernel and allows us to synchronize V8 code log and the |
255 // kernel log. | 256 // kernel log. |
256 int size = sysconf(_SC_PAGESIZE); | 257 int size = sysconf(_SC_PAGESIZE); |
257 FILE* f = fopen(FLAG_gc_fake_mmap, "w+"); | 258 FILE* f = fopen(OS::GetGCFakeMMapFile(), "w+"); |
258 if (f == NULL) { | 259 if (f == NULL) { |
259 OS::PrintError("Failed to open %s\n", FLAG_gc_fake_mmap); | 260 OS::PrintError("Failed to open %s\n", OS::GetGCFakeMMapFile()); |
260 OS::Abort(); | 261 OS::Abort(); |
261 } | 262 } |
262 void* addr = mmap(OS::GetRandomMmapAddr(), | 263 void* addr = mmap(OS::GetRandomMmapAddr(), |
263 size, | 264 size, |
264 #if defined(__native_client__) | 265 #if defined(__native_client__) |
265 // The Native Client port of V8 uses an interpreter, | 266 // The Native Client port of V8 uses an interpreter, |
266 // so code pages don't need PROT_EXEC. | 267 // so code pages don't need PROT_EXEC. |
267 PROT_READ, | 268 PROT_READ, |
268 #else | 269 #else |
269 PROT_READ | PROT_EXEC, | 270 PROT_READ | PROT_EXEC, |
(...skipping 25 matching lines...) Expand all Loading... |
295 size_t request_size = RoundUp(size + alignment, | 296 size_t request_size = RoundUp(size + alignment, |
296 static_cast<intptr_t>(OS::AllocateAlignment())); | 297 static_cast<intptr_t>(OS::AllocateAlignment())); |
297 void* reservation = mmap(OS::GetRandomMmapAddr(), | 298 void* reservation = mmap(OS::GetRandomMmapAddr(), |
298 request_size, | 299 request_size, |
299 PROT_NONE, | 300 PROT_NONE, |
300 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, | 301 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, |
301 kMmapFd, | 302 kMmapFd, |
302 kMmapFdOffset); | 303 kMmapFdOffset); |
303 if (reservation == MAP_FAILED) return; | 304 if (reservation == MAP_FAILED) return; |
304 | 305 |
305 Address base = static_cast<Address>(reservation); | 306 uint8_t* base = static_cast<uint8_t*>(reservation); |
306 Address aligned_base = RoundUp(base, alignment); | 307 uint8_t* aligned_base = RoundUp(base, alignment); |
307 ASSERT_LE(base, aligned_base); | 308 ASSERT_LE(base, aligned_base); |
308 | 309 |
309 // Unmap extra memory reserved before and after the desired block. | 310 // Unmap extra memory reserved before and after the desired block. |
310 if (aligned_base != base) { | 311 if (aligned_base != base) { |
311 size_t prefix_size = static_cast<size_t>(aligned_base - base); | 312 size_t prefix_size = static_cast<size_t>(aligned_base - base); |
312 OS::Free(base, prefix_size); | 313 OS::Free(base, prefix_size); |
313 request_size -= prefix_size; | 314 request_size -= prefix_size; |
314 } | 315 } |
315 | 316 |
316 size_t aligned_size = RoundUp(size, OS::AllocateAlignment()); | 317 size_t aligned_size = RoundUp(size, OS::AllocateAlignment()); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 #endif | 423 #endif |
423 return munmap(base, size) == 0; | 424 return munmap(base, size) == 0; |
424 } | 425 } |
425 | 426 |
426 | 427 |
427 bool VirtualMemory::HasLazyCommits() { | 428 bool VirtualMemory::HasLazyCommits() { |
428 return true; | 429 return true; |
429 } | 430 } |
430 | 431 |
431 } } // namespace v8::internal | 432 } } // namespace v8::internal |
OLD | NEW |