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 OpenBSD and NetBSD goes here. For the | 5 // Platform-specific code for OpenBSD and NetBSD goes here. For the |
6 // POSIX-compatible parts, the implementation is in platform-posix.cc. | 6 // POSIX-compatible 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 206 |
207 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } | 207 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } |
208 | 208 |
209 | 209 |
210 VirtualMemory::VirtualMemory(size_t size) | 210 VirtualMemory::VirtualMemory(size_t size) |
211 : address_(ReserveRegion(size)), size_(size) { } | 211 : address_(ReserveRegion(size)), size_(size) { } |
212 | 212 |
213 | 213 |
214 VirtualMemory::VirtualMemory(size_t size, size_t alignment) | 214 VirtualMemory::VirtualMemory(size_t size, size_t alignment) |
215 : address_(NULL), size_(0) { | 215 : address_(NULL), size_(0) { |
216 DCHECK(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment()))); | 216 DCHECK((alignment % OS::AllocateAlignment()) == 0); |
217 size_t request_size = RoundUp(size + alignment, | 217 size_t request_size = RoundUp(size + alignment, |
218 static_cast<intptr_t>(OS::AllocateAlignment())); | 218 static_cast<intptr_t>(OS::AllocateAlignment())); |
219 void* reservation = mmap(OS::GetRandomMmapAddr(), | 219 void* reservation = mmap(OS::GetRandomMmapAddr(), |
220 request_size, | 220 request_size, |
221 PROT_NONE, | 221 PROT_NONE, |
222 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, | 222 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, |
223 kMmapFd, | 223 kMmapFd, |
224 kMmapFdOffset); | 224 kMmapFdOffset); |
225 if (reservation == MAP_FAILED) return; | 225 if (reservation == MAP_FAILED) return; |
226 | 226 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 return munmap(base, size) == 0; | 329 return munmap(base, size) == 0; |
330 } | 330 } |
331 | 331 |
332 | 332 |
333 bool VirtualMemory::HasLazyCommits() { | 333 bool VirtualMemory::HasLazyCommits() { |
334 // TODO(alph): implement for the platform. | 334 // TODO(alph): implement for the platform. |
335 return false; | 335 return false; |
336 } | 336 } |
337 | 337 |
338 } } // namespace v8::base | 338 } } // namespace v8::base |
OLD | NEW |