| 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> |
| 11 #include <stdarg.h> | 11 #include <stdarg.h> |
| 12 #include <strings.h> // index | 12 #include <strings.h> // index |
| 13 #include <sys/mman.h> // mmap & munmap | 13 #include <sys/mman.h> // mmap & munmap |
| 14 #include <sys/time.h> | 14 #include <sys/time.h> |
| 15 #include <unistd.h> // sysconf | 15 #include <unistd.h> // sysconf |
| 16 | 16 |
| 17 #include <cmath> |
| 18 |
| 17 #undef MAP_TYPE | 19 #undef MAP_TYPE |
| 18 | 20 |
| 19 #include "src/v8.h" | |
| 20 | |
| 21 #include "src/base/win32-headers.h" | 21 #include "src/base/win32-headers.h" |
| 22 #include "src/platform.h" | 22 #include "src/platform.h" |
| 23 #include "src/utils.h" |
| 23 | 24 |
| 24 namespace v8 { | 25 namespace v8 { |
| 25 namespace internal { | 26 namespace internal { |
| 26 | 27 |
| 27 | 28 |
| 28 const char* OS::LocalTimezone(double time, TimezoneCache* cache) { | 29 const char* OS::LocalTimezone(double time, TimezoneCache* cache) { |
| 29 if (std::isnan(time)) return ""; | 30 if (std::isnan(time)) return ""; |
| 30 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond)); | 31 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond)); |
| 31 struct tm* t = localtime(&tv); | 32 struct tm* t = localtime(&tv); |
| 32 if (NULL == t) return ""; | 33 if (NULL == t) return ""; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 : address_(ReserveRegion(size)), size_(size) { } | 231 : address_(ReserveRegion(size)), size_(size) { } |
| 231 | 232 |
| 232 | 233 |
| 233 VirtualMemory::VirtualMemory(size_t size, size_t alignment) | 234 VirtualMemory::VirtualMemory(size_t size, size_t alignment) |
| 234 : address_(NULL), size_(0) { | 235 : address_(NULL), size_(0) { |
| 235 ASSERT(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment()))); | 236 ASSERT(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment()))); |
| 236 size_t request_size = RoundUp(size + alignment, | 237 size_t request_size = RoundUp(size + alignment, |
| 237 static_cast<intptr_t>(OS::AllocateAlignment())); | 238 static_cast<intptr_t>(OS::AllocateAlignment())); |
| 238 void* address = ReserveRegion(request_size); | 239 void* address = ReserveRegion(request_size); |
| 239 if (address == NULL) return; | 240 if (address == NULL) return; |
| 240 Address base = RoundUp(static_cast<Address>(address), alignment); | 241 uint8_t* base = RoundUp(static_cast<uint8_t*>(address), alignment); |
| 241 // Try reducing the size by freeing and then reallocating a specific area. | 242 // Try reducing the size by freeing and then reallocating a specific area. |
| 242 bool result = ReleaseRegion(address, request_size); | 243 bool result = ReleaseRegion(address, request_size); |
| 243 USE(result); | 244 USE(result); |
| 244 ASSERT(result); | 245 ASSERT(result); |
| 245 address = VirtualAlloc(base, size, MEM_RESERVE, PAGE_NOACCESS); | 246 address = VirtualAlloc(base, size, MEM_RESERVE, PAGE_NOACCESS); |
| 246 if (address != NULL) { | 247 if (address != NULL) { |
| 247 request_size = size; | 248 request_size = size; |
| 248 ASSERT(base == static_cast<Address>(address)); | 249 ASSERT(base == static_cast<uint8_t*>(address)); |
| 249 } else { | 250 } else { |
| 250 // Resizing failed, just go with a bigger area. | 251 // Resizing failed, just go with a bigger area. |
| 251 address = ReserveRegion(request_size); | 252 address = ReserveRegion(request_size); |
| 252 if (address == NULL) return; | 253 if (address == NULL) return; |
| 253 } | 254 } |
| 254 address_ = address; | 255 address_ = address; |
| 255 size_ = request_size; | 256 size_ = request_size; |
| 256 } | 257 } |
| 257 | 258 |
| 258 | 259 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 return VirtualFree(base, 0, MEM_RELEASE) != 0; | 322 return VirtualFree(base, 0, MEM_RELEASE) != 0; |
| 322 } | 323 } |
| 323 | 324 |
| 324 | 325 |
| 325 bool VirtualMemory::HasLazyCommits() { | 326 bool VirtualMemory::HasLazyCommits() { |
| 326 // TODO(alph): implement for the platform. | 327 // TODO(alph): implement for the platform. |
| 327 return false; | 328 return false; |
| 328 } | 329 } |
| 329 | 330 |
| 330 } } // namespace v8::internal | 331 } } // namespace v8::internal |
| OLD | NEW |