< prev index next >
src/hotspot/os/aix/safepointMechanism_aix.cpp
Print this page
rev 48405 : 8194258: PPC64 safepoint mechanism: Fix initialization on AIX and support SIGTRAP
Summary: Use mmap on AIX to allocate protected page. Use trap instructions for polling if UseSIGTRAP is enabled.
Reviewed-by:
@@ -28,12 +28,22 @@
#include "runtime/os.hpp"
#include "runtime/safepointMechanism.hpp"
#include <sys/mman.h>
void SafepointMechanism::pd_initialize() {
+ // No special code needed if we can use SIGTRAP
+ if (ThreadLocalHandshakes && USE_POLL_BIT_ONLY) {
+ default_initialize();
+ return;
+ }
+
+ // Allocate one protected page
char* map_address = (char*)MAP_FAILED;
const size_t page_size = os::vm_page_size();
+ const int prot = PROT_READ;
+ const int flags = MAP_PRIVATE | MAP_ANONYMOUS;
+
// Use optimized addresses for the polling page,
// e.g. map it to a special 32-bit address.
if (OptimizePollingPageLocation) {
// architecture-specific list of address wishes:
char* address_wishes[] = {
@@ -56,12 +66,12 @@
for (int i = 0; i < address_wishes_length; i++) {
// Try to map with current address wish.
// AIX: AIX needs MAP_FIXED if we provide an address and mmap will
// fail if the address is already mapped.
map_address = (char*) ::mmap(address_wishes[i] - (ssize_t)page_size,
- page_size, PROT_READ,
- MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED,
+ page_size, prot,
+ flags | MAP_FIXED,
-1, 0);
log_debug(os)("SafePoint Polling Page address: %p (wish) => %p",
address_wishes[i], map_address + (ssize_t)page_size);
if (map_address + (ssize_t)page_size == address_wishes[i]) {
@@ -76,10 +86,18 @@
}
// Map failed, continue loop.
}
}
if (map_address == (char*)MAP_FAILED) {
- map_address = os::reserve_memory(page_size, NULL, page_size);
+ map_address = (char*) ::mmap(NULL, page_size, prot, flags, -1, 0);
}
guarantee(map_address != (char*)MAP_FAILED, "SafepointMechanism::pd_initialize: failed to allocate polling page");
os::set_polling_page((address)(map_address));
+
+ // Use same page for ThreadLocalHandshakes without SIGTRAP
+ if (ThreadLocalHandshakes) {
+ set_uses_thread_local_poll();
+ intptr_t bad_page_val = reinterpret_cast<intptr_t>(map_address);
+ _poll_armed_value = reinterpret_cast<void*>(bad_page_val | poll_bit());
+ _poll_disarmed_value = NULL; // Readable on AIX
+ }
}
< prev index next >