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 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 prot); | 790 prot); |
791 | 791 |
792 if (mbase == NULL) return NULL; | 792 if (mbase == NULL) return NULL; |
793 | 793 |
794 DCHECK((reinterpret_cast<uintptr_t>(mbase) % OS::AllocateAlignment()) == 0); | 794 DCHECK((reinterpret_cast<uintptr_t>(mbase) % OS::AllocateAlignment()) == 0); |
795 | 795 |
796 *allocated = msize; | 796 *allocated = msize; |
797 return mbase; | 797 return mbase; |
798 } | 798 } |
799 | 799 |
| 800 void* OS::AllocateGuarded(const size_t requested) { |
| 801 return VirtualAlloc(nullptr, requested, MEM_RESERVE, PAGE_NOACCESS); |
| 802 } |
800 | 803 |
801 void OS::Free(void* address, const size_t size) { | 804 void OS::Free(void* address, const size_t size) { |
802 // TODO(1240712): VirtualFree has a return value which is ignored here. | 805 // TODO(1240712): VirtualFree has a return value which is ignored here. |
803 VirtualFree(address, 0, MEM_RELEASE); | 806 VirtualFree(address, 0, MEM_RELEASE); |
804 USE(size); | 807 USE(size); |
805 } | 808 } |
806 | 809 |
807 | 810 |
808 intptr_t OS::CommitPageSize() { | 811 intptr_t OS::CommitPageSize() { |
809 return 4096; | 812 return 4096; |
810 } | 813 } |
811 | 814 |
812 | 815 |
813 void OS::ProtectCode(void* address, const size_t size) { | 816 void OS::ProtectCode(void* address, const size_t size) { |
814 DWORD old_protect; | 817 DWORD old_protect; |
815 VirtualProtect(address, size, PAGE_EXECUTE_READ, &old_protect); | 818 VirtualProtect(address, size, PAGE_EXECUTE_READ, &old_protect); |
816 } | 819 } |
817 | 820 |
818 | 821 |
819 void OS::Guard(void* address, const size_t size) { | 822 void OS::Guard(void* address, const size_t size) { |
820 DWORD oldprotect; | 823 DWORD oldprotect; |
821 VirtualProtect(address, size, PAGE_NOACCESS, &oldprotect); | 824 VirtualProtect(address, size, PAGE_NOACCESS, &oldprotect); |
822 } | 825 } |
823 | 826 |
| 827 void OS::Unprotect(void* address, const size_t size) { |
| 828 LPVOID result = VirtualAlloc(address, size, MEM_COMMIT, PAGE_READWRITE); |
| 829 DCHECK_IMPLIES(result != nullptr, GetLastError() == 0); |
| 830 } |
824 | 831 |
825 void OS::Sleep(TimeDelta interval) { | 832 void OS::Sleep(TimeDelta interval) { |
826 ::Sleep(static_cast<DWORD>(interval.InMilliseconds())); | 833 ::Sleep(static_cast<DWORD>(interval.InMilliseconds())); |
827 } | 834 } |
828 | 835 |
829 | 836 |
830 void OS::Abort() { | 837 void OS::Abort() { |
831 if (g_hard_abort) { | 838 if (g_hard_abort) { |
832 V8_IMMEDIATE_CRASH(); | 839 V8_IMMEDIATE_CRASH(); |
833 } | 840 } |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 | 1403 |
1397 | 1404 |
1398 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { | 1405 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { |
1399 BOOL result = TlsSetValue(static_cast<DWORD>(key), value); | 1406 BOOL result = TlsSetValue(static_cast<DWORD>(key), value); |
1400 USE(result); | 1407 USE(result); |
1401 DCHECK(result); | 1408 DCHECK(result); |
1402 } | 1409 } |
1403 | 1410 |
1404 } // namespace base | 1411 } // namespace base |
1405 } // namespace v8 | 1412 } // namespace v8 |
OLD | NEW |