Mercurial > hg > graal-compiler
comparison src/os/windows/vm/os_windows.cpp @ 237:1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
Summary: allocate alignment-sized page(s) below java heap so that memory accesses at heap_base+1page give signal and cause an implicit null check
Reviewed-by: kvn, jmasa, phh, jcoomes
author | coleenp |
---|---|
date | Sat, 19 Jul 2008 17:38:22 -0400 |
parents | d1605aabd0a1 |
children | d95b224e9f17 |
comparison
equal
deleted
inserted
replaced
235:9c2ecc2ffb12 | 237:1fdb98a17101 |
---|---|
2168 #else /* !IA64 */ | 2168 #else /* !IA64 */ |
2169 | 2169 |
2170 // Windows 98 reports faulting addresses incorrectly | 2170 // Windows 98 reports faulting addresses incorrectly |
2171 if (!MacroAssembler::needs_explicit_null_check((intptr_t)addr) || | 2171 if (!MacroAssembler::needs_explicit_null_check((intptr_t)addr) || |
2172 !os::win32::is_nt()) { | 2172 !os::win32::is_nt()) { |
2173 | |
2173 return Handle_Exception(exceptionInfo, | 2174 return Handle_Exception(exceptionInfo, |
2174 SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL)); | 2175 SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL)); |
2175 } | 2176 } |
2176 report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord, | 2177 report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord, |
2177 exceptionInfo->ContextRecord); | 2178 exceptionInfo->ContextRecord); |
2561 | 2562 |
2562 bool os::release_memory(char* addr, size_t bytes) { | 2563 bool os::release_memory(char* addr, size_t bytes) { |
2563 return VirtualFree(addr, 0, MEM_RELEASE) != 0; | 2564 return VirtualFree(addr, 0, MEM_RELEASE) != 0; |
2564 } | 2565 } |
2565 | 2566 |
2566 bool os::protect_memory(char* addr, size_t bytes) { | 2567 // Set protections specified |
2568 bool os::protect_memory(char* addr, size_t bytes, ProtType prot, | |
2569 bool is_committed) { | |
2570 unsigned int p = 0; | |
2571 switch (prot) { | |
2572 case MEM_PROT_NONE: p = PAGE_NOACCESS; break; | |
2573 case MEM_PROT_READ: p = PAGE_READONLY; break; | |
2574 case MEM_PROT_RW: p = PAGE_READWRITE; break; | |
2575 case MEM_PROT_RWX: p = PAGE_EXECUTE_READWRITE; break; | |
2576 default: | |
2577 ShouldNotReachHere(); | |
2578 } | |
2579 | |
2567 DWORD old_status; | 2580 DWORD old_status; |
2568 return VirtualProtect(addr, bytes, PAGE_READONLY, &old_status) != 0; | 2581 |
2582 // Strange enough, but on Win32 one can change protection only for committed | |
2583 // memory, not a big deal anyway, as bytes less or equal than 64K | |
2584 if (!is_committed && !commit_memory(addr, bytes)) { | |
2585 fatal("cannot commit protection page"); | |
2586 } | |
2587 // One cannot use os::guard_memory() here, as on Win32 guard page | |
2588 // have different (one-shot) semantics, from MSDN on PAGE_GUARD: | |
2589 // | |
2590 // Pages in the region become guard pages. Any attempt to access a guard page | |
2591 // causes the system to raise a STATUS_GUARD_PAGE exception and turn off | |
2592 // the guard page status. Guard pages thus act as a one-time access alarm. | |
2593 return VirtualProtect(addr, bytes, p, &old_status) != 0; | |
2569 } | 2594 } |
2570 | 2595 |
2571 bool os::guard_memory(char* addr, size_t bytes) { | 2596 bool os::guard_memory(char* addr, size_t bytes) { |
2572 DWORD old_status; | 2597 DWORD old_status; |
2573 return VirtualProtect(addr, bytes, PAGE_EXECUTE_READWRITE | PAGE_GUARD, &old_status) != 0; | 2598 return VirtualProtect(addr, bytes, PAGE_EXECUTE_READWRITE | PAGE_GUARD, &old_status) != 0; |