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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 299 |
300 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } | 300 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } |
301 | 301 |
302 | 302 |
303 VirtualMemory::VirtualMemory(size_t size) | 303 VirtualMemory::VirtualMemory(size_t size) |
304 : address_(ReserveRegion(size)), size_(size) { } | 304 : address_(ReserveRegion(size)), size_(size) { } |
305 | 305 |
306 | 306 |
307 VirtualMemory::VirtualMemory(size_t size, size_t alignment) | 307 VirtualMemory::VirtualMemory(size_t size, size_t alignment) |
308 : address_(NULL), size_(0) { | 308 : address_(NULL), size_(0) { |
309 DCHECK(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment()))); | 309 DCHECK((alignment % OS::AllocateAlignment()) == 0); |
310 size_t request_size = RoundUp(size + alignment, | 310 size_t request_size = RoundUp(size + alignment, |
311 static_cast<intptr_t>(OS::AllocateAlignment())); | 311 static_cast<intptr_t>(OS::AllocateAlignment())); |
312 void* reservation = mmap(OS::GetRandomMmapAddr(), | 312 void* reservation = mmap(OS::GetRandomMmapAddr(), |
313 request_size, | 313 request_size, |
314 PROT_NONE, | 314 PROT_NONE, |
315 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, | 315 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, |
316 kMmapFd, | 316 kMmapFd, |
317 kMmapFdOffset); | 317 kMmapFdOffset); |
318 if (reservation == MAP_FAILED) return; | 318 if (reservation == MAP_FAILED) return; |
319 | 319 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 #endif | 437 #endif |
438 return munmap(base, size) == 0; | 438 return munmap(base, size) == 0; |
439 } | 439 } |
440 | 440 |
441 | 441 |
442 bool VirtualMemory::HasLazyCommits() { | 442 bool VirtualMemory::HasLazyCommits() { |
443 return true; | 443 return true; |
444 } | 444 } |
445 | 445 |
446 } } // namespace v8::base | 446 } } // namespace v8::base |
OLD | NEW |