# HG changeset patch # User blacklion # Date 1229105979 28800 # Node ID 06d2c3204df47646aca909838d27bd0afc692cfd # Parent a7fac4381b50ec17234649834e18f5620e014c33# Parent 7b75310e57e2f9188cfe9a4f46bb702b8e3e90bb Merge diff -r 7b75310e57e2 -r 06d2c3204df4 src/os/linux/vm/os_linux.cpp --- a/src/os/linux/vm/os_linux.cpp Thu Dec 11 17:20:10 2008 -0800 +++ b/src/os/linux/vm/os_linux.cpp Fri Dec 12 10:19:39 2008 -0800 @@ -2500,7 +2500,7 @@ } bool os::unguard_memory(char* addr, size_t size) { - return linux_mprotect(addr, size, PROT_READ|PROT_WRITE|PROT_EXEC); + return linux_mprotect(addr, size, PROT_READ|PROT_WRITE); } // Large page support diff -r 7b75310e57e2 -r 06d2c3204df4 src/os/solaris/vm/os_solaris.cpp --- a/src/os/solaris/vm/os_solaris.cpp Thu Dec 11 17:20:10 2008 -0800 +++ b/src/os/solaris/vm/os_solaris.cpp Fri Dec 12 10:19:39 2008 -0800 @@ -3026,6 +3026,8 @@ // Protect memory (Used to pass readonly pages through // JNI GetArrayElements with empty arrays.) +// Also, used for serialization page and for compressed oops null pointer +// checking. bool os::protect_memory(char* addr, size_t bytes, ProtType prot, bool is_committed) { unsigned int p = 0; @@ -3049,7 +3051,7 @@ } bool os::unguard_memory(char* addr, size_t bytes) { - return solaris_mprotect(addr, bytes, PROT_READ|PROT_WRITE|PROT_EXEC); + return solaris_mprotect(addr, bytes, PROT_READ|PROT_WRITE); } // Large page support diff -r 7b75310e57e2 -r 06d2c3204df4 src/os/windows/vm/os_windows.cpp --- a/src/os/windows/vm/os_windows.cpp Thu Dec 11 17:20:10 2008 -0800 +++ b/src/os/windows/vm/os_windows.cpp Fri Dec 12 10:19:39 2008 -0800 @@ -2020,10 +2020,11 @@ if (UnguardOnExecutionViolation > 0 && addr != last_addr && (UnguardOnExecutionViolation > 1 || os::address_is_in_vm(addr))) { - // Unguard and retry + // Set memory to RWX and retry address page_start = (address) align_size_down((intptr_t) addr, (intptr_t) page_size); - bool res = os::unguard_memory((char*) page_start, page_size); + bool res = os::protect_memory((char*) page_start, page_size, + os::MEM_PROT_RWX); if (PrintMiscellaneous && Verbose) { char buf[256]; @@ -2755,12 +2756,12 @@ bool os::guard_memory(char* addr, size_t bytes) { DWORD old_status; - return VirtualProtect(addr, bytes, PAGE_EXECUTE_READWRITE | PAGE_GUARD, &old_status) != 0; + return VirtualProtect(addr, bytes, PAGE_READWRITE | PAGE_GUARD, &old_status) != 0; } bool os::unguard_memory(char* addr, size_t bytes) { DWORD old_status; - return VirtualProtect(addr, bytes, PAGE_EXECUTE_READWRITE, &old_status) != 0; + return VirtualProtect(addr, bytes, PAGE_READWRITE, &old_status) != 0; } void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) { } diff -r 7b75310e57e2 -r 06d2c3204df4 src/os_cpu/linux_x86/vm/os_linux_x86.cpp --- a/src/os_cpu/linux_x86/vm/os_linux_x86.cpp Thu Dec 11 17:20:10 2008 -0800 +++ b/src/os_cpu/linux_x86/vm/os_linux_x86.cpp Fri Dec 12 10:19:39 2008 -0800 @@ -422,10 +422,11 @@ if (addr != last_addr && (UnguardOnExecutionViolation > 1 || os::address_is_in_vm(addr))) { - // Unguard and retry + // Set memory to RWX and retry address page_start = (address) align_size_down((intptr_t) addr, (intptr_t) page_size); - bool res = os::unguard_memory((char*) page_start, page_size); + bool res = os::protect_memory((char*) page_start, page_size, + os::MEM_PROT_RWX); if (PrintMiscellaneous && Verbose) { char buf[256]; diff -r 7b75310e57e2 -r 06d2c3204df4 src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp --- a/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Thu Dec 11 17:20:10 2008 -0800 +++ b/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Fri Dec 12 10:19:39 2008 -0800 @@ -576,10 +576,11 @@ if (addr != last_addr && (UnguardOnExecutionViolation > 1 || os::address_is_in_vm(addr))) { - // Unguard and retry + // Make memory rwx and retry address page_start = (address) align_size_down((intptr_t) addr, (intptr_t) page_size); - bool res = os::unguard_memory((char*) page_start, page_size); + bool res = os::protect_memory((char*) page_start, page_size, + os::MEM_PROT_RWX); if (PrintMiscellaneous && Verbose) { char buf[256]; diff -r 7b75310e57e2 -r 06d2c3204df4 src/share/vm/prims/jni.cpp --- a/src/share/vm/prims/jni.cpp Thu Dec 11 17:20:10 2008 -0800 +++ b/src/share/vm/prims/jni.cpp Fri Dec 12 10:19:39 2008 -0800 @@ -2173,7 +2173,8 @@ size_t size = os::vm_allocation_granularity(); bad_address = os::reserve_memory(size); if (bad_address != NULL) { - os::protect_memory(bad_address, size, os::MEM_PROT_READ); + os::protect_memory(bad_address, size, os::MEM_PROT_READ, + /*is_committed*/false); } } return bad_address; diff -r 7b75310e57e2 -r 06d2c3204df4 src/share/vm/runtime/os.cpp --- a/src/share/vm/runtime/os.cpp Thu Dec 11 17:20:10 2008 -0800 +++ b/src/share/vm/runtime/os.cpp Fri Dec 12 10:19:39 2008 -0800 @@ -932,8 +932,9 @@ // the mutator thread if such case is encountered. See bug 6546278 for details. Thread::muxAcquire(&SerializePageLock, "serialize_thread_states"); os::protect_memory((char *)os::get_memory_serialize_page(), - os::vm_page_size(), MEM_PROT_READ, /*is_committed*/true ); - os::unguard_memory((char *)os::get_memory_serialize_page(), os::vm_page_size()); + os::vm_page_size(), MEM_PROT_READ); + os::protect_memory((char *)os::get_memory_serialize_page(), + os::vm_page_size(), MEM_PROT_RW); Thread::muxRelease(&SerializePageLock); } diff -r 7b75310e57e2 -r 06d2c3204df4 src/share/vm/runtime/os.hpp --- a/src/share/vm/runtime/os.hpp Thu Dec 11 17:20:10 2008 -0800 +++ b/src/share/vm/runtime/os.hpp Fri Dec 12 10:19:39 2008 -0800 @@ -208,7 +208,7 @@ enum ProtType { MEM_PROT_NONE, MEM_PROT_READ, MEM_PROT_RW, MEM_PROT_RWX }; static bool protect_memory(char* addr, size_t bytes, ProtType prot, - bool is_committed = false); + bool is_committed = true); static bool guard_memory(char* addr, size_t bytes); static bool unguard_memory(char* addr, size_t bytes); diff -r 7b75310e57e2 -r 06d2c3204df4 src/share/vm/runtime/synchronizer.cpp --- a/src/share/vm/runtime/synchronizer.cpp Thu Dec 11 17:20:10 2008 -0800 +++ b/src/share/vm/runtime/synchronizer.cpp Fri Dec 12 10:19:39 2008 -0800 @@ -3363,13 +3363,13 @@ // If the wakee is cold then transiently setting it's affinity // to the current CPU is a good idea. // See http://j2se.east/~dice/PERSIST/050624-PullAffinity.txt + DTRACE_MONITOR_PROBE(contended__exit, this, object(), Self); Trigger->unpark() ; // Maintain stats and report events to JVMTI if (ObjectSynchronizer::_sync_Parks != NULL) { ObjectSynchronizer::_sync_Parks->inc() ; } - DTRACE_MONITOR_PROBE(contended__exit, this, object(), Self); }