| 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 Cygwin goes here. For the POSIX-compatible | 5 // Platform-specific code for Cygwin 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 <errno.h> | 8 #include <errno.h> |
| 9 #include <pthread.h> | 9 #include <pthread.h> |
| 10 #include <semaphore.h> | 10 #include <semaphore.h> |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 198 |
| 199 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } | 199 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } |
| 200 | 200 |
| 201 | 201 |
| 202 VirtualMemory::VirtualMemory(size_t size) | 202 VirtualMemory::VirtualMemory(size_t size) |
| 203 : address_(ReserveRegion(size)), size_(size) { } | 203 : address_(ReserveRegion(size)), size_(size) { } |
| 204 | 204 |
| 205 | 205 |
| 206 VirtualMemory::VirtualMemory(size_t size, size_t alignment) | 206 VirtualMemory::VirtualMemory(size_t size, size_t alignment) |
| 207 : address_(NULL), size_(0) { | 207 : address_(NULL), size_(0) { |
| 208 DCHECK(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment()))); | 208 DCHECK((alignment % OS::AllocateAlignment()) == 0); |
| 209 size_t request_size = RoundUp(size + alignment, | 209 size_t request_size = RoundUp(size + alignment, |
| 210 static_cast<intptr_t>(OS::AllocateAlignment())); | 210 static_cast<intptr_t>(OS::AllocateAlignment())); |
| 211 void* address = ReserveRegion(request_size); | 211 void* address = ReserveRegion(request_size); |
| 212 if (address == NULL) return; | 212 if (address == NULL) return; |
| 213 uint8_t* base = RoundUp(static_cast<uint8_t*>(address), alignment); | 213 uint8_t* base = RoundUp(static_cast<uint8_t*>(address), alignment); |
| 214 // Try reducing the size by freeing and then reallocating a specific area. | 214 // Try reducing the size by freeing and then reallocating a specific area. |
| 215 bool result = ReleaseRegion(address, request_size); | 215 bool result = ReleaseRegion(address, request_size); |
| 216 USE(result); | 216 USE(result); |
| 217 DCHECK(result); | 217 DCHECK(result); |
| 218 address = VirtualAlloc(base, size, MEM_RESERVE, PAGE_NOACCESS); | 218 address = VirtualAlloc(base, size, MEM_RESERVE, PAGE_NOACCESS); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 return VirtualFree(base, 0, MEM_RELEASE) != 0; | 294 return VirtualFree(base, 0, MEM_RELEASE) != 0; |
| 295 } | 295 } |
| 296 | 296 |
| 297 | 297 |
| 298 bool VirtualMemory::HasLazyCommits() { | 298 bool VirtualMemory::HasLazyCommits() { |
| 299 // TODO(alph): implement for the platform. | 299 // TODO(alph): implement for the platform. |
| 300 return false; | 300 return false; |
| 301 } | 301 } |
| 302 | 302 |
| 303 } } // namespace v8::base | 303 } } // namespace v8::base |
| OLD | NEW |