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 FreeBSD goes here. For the POSIX-compatible | 5 // Platform-specific code for FreeBSD 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 175 |
176 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } | 176 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } |
177 | 177 |
178 | 178 |
179 VirtualMemory::VirtualMemory(size_t size) | 179 VirtualMemory::VirtualMemory(size_t size) |
180 : address_(ReserveRegion(size)), size_(size) { } | 180 : address_(ReserveRegion(size)), size_(size) { } |
181 | 181 |
182 | 182 |
183 VirtualMemory::VirtualMemory(size_t size, size_t alignment) | 183 VirtualMemory::VirtualMemory(size_t size, size_t alignment) |
184 : address_(NULL), size_(0) { | 184 : address_(NULL), size_(0) { |
185 DCHECK(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment()))); | 185 DCHECK((alignment % OS::AllocateAlignment()) == 0); |
186 size_t request_size = RoundUp(size + alignment, | 186 size_t request_size = RoundUp(size + alignment, |
187 static_cast<intptr_t>(OS::AllocateAlignment())); | 187 static_cast<intptr_t>(OS::AllocateAlignment())); |
188 void* reservation = mmap(OS::GetRandomMmapAddr(), | 188 void* reservation = mmap(OS::GetRandomMmapAddr(), |
189 request_size, | 189 request_size, |
190 PROT_NONE, | 190 PROT_NONE, |
191 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, | 191 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, |
192 kMmapFd, | 192 kMmapFd, |
193 kMmapFdOffset); | 193 kMmapFdOffset); |
194 if (reservation == MAP_FAILED) return; | 194 if (reservation == MAP_FAILED) return; |
195 | 195 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 return munmap(base, size) == 0; | 298 return munmap(base, size) == 0; |
299 } | 299 } |
300 | 300 |
301 | 301 |
302 bool VirtualMemory::HasLazyCommits() { | 302 bool VirtualMemory::HasLazyCommits() { |
303 // TODO(alph): implement for the platform. | 303 // TODO(alph): implement for the platform. |
304 return false; | 304 return false; |
305 } | 305 } |
306 | 306 |
307 } } // namespace v8::base | 307 } } // namespace v8::base |
OLD | NEW |