| 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 Win32. | 5 // Platform-specific code for Win32. |
| 6 | 6 |
| 7 // Secure API functions are not available using MinGW with msvcrt.dll | 7 // Secure API functions are not available using MinGW with msvcrt.dll |
| 8 // on Windows XP. Make sure MINGW_HAS_SECURE_API is not defined to | 8 // on Windows XP. Make sure MINGW_HAS_SECURE_API is not defined to |
| 9 // disable definition of secure API functions in standard headers that | 9 // disable definition of secure API functions in standard headers that |
| 10 // would conflict with our own implementation. | 10 // would conflict with our own implementation. |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 | 779 |
| 780 // Windows XP SP2 allows Data Excution Prevention (DEP). | 780 // Windows XP SP2 allows Data Excution Prevention (DEP). |
| 781 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; | 781 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; |
| 782 | 782 |
| 783 LPVOID mbase = RandomizedVirtualAlloc(msize, | 783 LPVOID mbase = RandomizedVirtualAlloc(msize, |
| 784 MEM_COMMIT | MEM_RESERVE, | 784 MEM_COMMIT | MEM_RESERVE, |
| 785 prot); | 785 prot); |
| 786 | 786 |
| 787 if (mbase == NULL) return NULL; | 787 if (mbase == NULL) return NULL; |
| 788 | 788 |
| 789 DCHECK(IsAligned(reinterpret_cast<size_t>(mbase), OS::AllocateAlignment())); | 789 DCHECK((static_cast<uintptr_t>(mbase) % OS::AllocateAlignment()) == 0); |
| 790 | 790 |
| 791 *allocated = msize; | 791 *allocated = msize; |
| 792 return mbase; | 792 return mbase; |
| 793 } | 793 } |
| 794 | 794 |
| 795 | 795 |
| 796 void OS::Free(void* address, const size_t size) { | 796 void OS::Free(void* address, const size_t size) { |
| 797 // TODO(1240712): VirtualFree has a return value which is ignored here. | 797 // TODO(1240712): VirtualFree has a return value which is ignored here. |
| 798 VirtualFree(address, 0, MEM_RELEASE); | 798 VirtualFree(address, 0, MEM_RELEASE); |
| 799 USE(size); | 799 USE(size); |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 | 1198 |
| 1199 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } | 1199 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } |
| 1200 | 1200 |
| 1201 | 1201 |
| 1202 VirtualMemory::VirtualMemory(size_t size) | 1202 VirtualMemory::VirtualMemory(size_t size) |
| 1203 : address_(ReserveRegion(size)), size_(size) { } | 1203 : address_(ReserveRegion(size)), size_(size) { } |
| 1204 | 1204 |
| 1205 | 1205 |
| 1206 VirtualMemory::VirtualMemory(size_t size, size_t alignment) | 1206 VirtualMemory::VirtualMemory(size_t size, size_t alignment) |
| 1207 : address_(NULL), size_(0) { | 1207 : address_(NULL), size_(0) { |
| 1208 DCHECK(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment()))); | 1208 DCHECK((alignment % OS::AllocateAlignment()) == 0); |
| 1209 size_t request_size = RoundUp(size + alignment, | 1209 size_t request_size = RoundUp(size + alignment, |
| 1210 static_cast<intptr_t>(OS::AllocateAlignment())); | 1210 static_cast<intptr_t>(OS::AllocateAlignment())); |
| 1211 void* address = ReserveRegion(request_size); | 1211 void* address = ReserveRegion(request_size); |
| 1212 if (address == NULL) return; | 1212 if (address == NULL) return; |
| 1213 uint8_t* base = RoundUp(static_cast<uint8_t*>(address), alignment); | 1213 uint8_t* base = RoundUp(static_cast<uint8_t*>(address), alignment); |
| 1214 // Try reducing the size by freeing and then reallocating a specific area. | 1214 // Try reducing the size by freeing and then reallocating a specific area. |
| 1215 bool result = ReleaseRegion(address, request_size); | 1215 bool result = ReleaseRegion(address, request_size); |
| 1216 USE(result); | 1216 USE(result); |
| 1217 DCHECK(result); | 1217 DCHECK(result); |
| 1218 address = VirtualAlloc(base, size, MEM_RESERVE, PAGE_NOACCESS); | 1218 address = VirtualAlloc(base, size, MEM_RESERVE, PAGE_NOACCESS); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 DCHECK(result); | 1397 DCHECK(result); |
| 1398 } | 1398 } |
| 1399 | 1399 |
| 1400 | 1400 |
| 1401 | 1401 |
| 1402 void Thread::YieldCPU() { | 1402 void Thread::YieldCPU() { |
| 1403 Sleep(0); | 1403 Sleep(0); |
| 1404 } | 1404 } |
| 1405 | 1405 |
| 1406 } } // namespace v8::base | 1406 } } // namespace v8::base |
| OLD | NEW |