< prev index next >
src/os/windows/vm/os_windows.cpp
Print this page
rev 9751 : [mq]: webrev.00
rev 9752 : [mq]: webrev.01
rev 9753 : [mq]: webrev.02
rev 9754 : [mq]: webrev.03
@@ -3421,12 +3421,11 @@
char * next_protect_addr = addr;
// Use VirtualQuery() to get the chunk size.
while (bytes_remaining) {
MEMORY_BASIC_INFORMATION alloc_info;
- ret = VirtualQuery(next_protect_addr, &alloc_info, sizeof(alloc_info)) != 0;
- if (!ret) {
+ if (VirtualQuery(next_protect_addr, &alloc_info, sizeof(alloc_info)) == 0) {
return false;
}
size_t bytes_to_protect = MIN2(bytes_remaining, (size_t)alloc_info.RegionSize);
// We used different API at allocate_pages_individually() based on UseNUMAInterleaving,
@@ -3469,11 +3468,18 @@
// have different (one-shot) semantics, from MSDN on PAGE_GUARD:
//
// Pages in the region become guard pages. Any attempt to access a guard page
// causes the system to raise a STATUS_GUARD_PAGE exception and turn off
// the guard page status. Guard pages thus act as a one-time access alarm.
- bool ret = protect_pages_individually(addr, bytes, p, &old_status);
+ bool ret;
+ if (UseNUMAInterleaving) {
+ // If UseNUMAInterleaving is enabled, the pages may have been allocated a chunk at a time,
+ // so we must protect the chunks individually.
+ ret = protect_pages_individually(addr, bytes, p, &old_status);
+ } else {
+ ret = VirtualProtect(addr, bytes, p, &old_status) != 0;
+ }
#ifdef ASSERT
if (!ret) {
int err = os::get_last_error();
char buf[256];
size_t buf_len = os::lasterror(buf, sizeof(buf));
< prev index next >