comparison src/os/linux/vm/os_linux.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 9c2ecc2ffb12
children d95b224e9f17 850fdf70db2b
comparison
equal deleted inserted replaced
235:9c2ecc2ffb12 237:1fdb98a17101
2412 2412
2413 size = align_size_up(pointer_delta(addr, bottom, 1) + size, os::Linux::page_size()); 2413 size = align_size_up(pointer_delta(addr, bottom, 1) + size, os::Linux::page_size());
2414 return ::mprotect(bottom, size, prot) == 0; 2414 return ::mprotect(bottom, size, prot) == 0;
2415 } 2415 }
2416 2416
2417 bool os::protect_memory(char* addr, size_t size) { 2417 // Set protections specified
2418 return linux_mprotect(addr, size, PROT_READ); 2418 bool os::protect_memory(char* addr, size_t bytes, ProtType prot,
2419 bool is_committed) {
2420 unsigned int p = 0;
2421 switch (prot) {
2422 case MEM_PROT_NONE: p = PROT_NONE; break;
2423 case MEM_PROT_READ: p = PROT_READ; break;
2424 case MEM_PROT_RW: p = PROT_READ|PROT_WRITE; break;
2425 case MEM_PROT_RWX: p = PROT_READ|PROT_WRITE|PROT_EXEC; break;
2426 default:
2427 ShouldNotReachHere();
2428 }
2429 // is_committed is unused.
2430 return linux_mprotect(addr, bytes, p);
2419 } 2431 }
2420 2432
2421 bool os::guard_memory(char* addr, size_t size) { 2433 bool os::guard_memory(char* addr, size_t size) {
2422 return linux_mprotect(addr, size, PROT_NONE); 2434 return linux_mprotect(addr, size, PROT_NONE);
2423 } 2435 }
3702 fatal("Could not disable polling page"); 3714 fatal("Could not disable polling page");
3703 }; 3715 };
3704 3716
3705 // Mark the polling page as readable 3717 // Mark the polling page as readable
3706 void os::make_polling_page_readable(void) { 3718 void os::make_polling_page_readable(void) {
3707 if( !protect_memory((char *)_polling_page, Linux::page_size()) ) 3719 if( !linux_mprotect((char *)_polling_page, Linux::page_size(), PROT_READ)) {
3708 fatal("Could not enable polling page"); 3720 fatal("Could not enable polling page");
3721 }
3709 }; 3722 };
3710 3723
3711 int os::active_processor_count() { 3724 int os::active_processor_count() {
3712 // Linux doesn't yet have a (official) notion of processor sets, 3725 // Linux doesn't yet have a (official) notion of processor sets,
3713 // so just return the number of online processors. 3726 // so just return the number of online processors.