8205609: [PPC64] Fix PPC64 part of 8010319 and TLH without UseSIGTRAP on AIX
Reviewed-by: dholmes, goetz
--- a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp Wed Jun 27 02:20:55 2018 -0700
+++ b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp Wed Jun 27 11:54:15 2018 +0200
@@ -725,18 +725,6 @@
return start;
}
- // Fairer handling of safepoints for native methods.
- //
- // Generate code which reads from the polling page. This special handling is needed as the
- // linux-ppc64 kernel before 2.6.6 doesn't set si_addr on some segfaults in 64bit mode
- // (cf. http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.6), especially when we try
- // to read from the safepoint polling page.
- address generate_load_from_poll() {
- StubCodeMark mark(this, "StubRoutines", "generate_load_from_poll");
- address start = __ function_entry();
- __ unimplemented("StubRoutines::verify_oop", 95); // TODO PPC port
- return start;
- }
// -XX:+OptimizeFill : convert fill/copy loops into intrinsic
//
--- a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp Wed Jun 27 02:20:55 2018 -0700
+++ b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp Wed Jun 27 11:54:15 2018 +0200
@@ -3320,9 +3320,9 @@
// - byte_no
//
// Output:
-// - Rmethod: The method to invoke next.
+// - Rmethod: The method to invoke next or i-klass (invokeinterface).
// - Rret_addr: The return address to return to.
-// - Rindex: MethodType (invokehandle) or CallSite obj (invokedynamic)
+// - Rindex: MethodType (invokehandle), CallSite obj (invokedynamic) or Method (invokeinterface)
// - Rrecv: Cache for "this" pointer, might be noreg if static call.
// - Rflags: Method flags from const pool cache.
//
@@ -3332,7 +3332,7 @@
void TemplateTable::prepare_invoke(int byte_no,
Register Rmethod, // linked method (or i-klass)
Register Rret_addr,// return address
- Register Rindex, // itable index, MethodType, etc.
+ Register Rindex, // itable index, MethodType, Method, etc.
Register Rrecv, // If caller wants to see it.
Register Rflags, // If caller wants to test it.
Register Rscratch
@@ -3618,9 +3618,9 @@
Register Rscratch = Rflags; // Rflags is dead now.
__ profile_final_call(Rscratch1, Rscratch);
- __ profile_arguments_type(Rindex, Rscratch, Rrecv_klass /* scratch */, true);
-
- __ call_from_interpreter(Rindex, Rret_addr, Rscratch, Rrecv_klass /* scratch */);
+ __ profile_arguments_type(Rmethod, Rscratch, Rrecv_klass /* scratch */, true);
+
+ __ call_from_interpreter(Rmethod, Rret_addr, Rscratch, Rrecv_klass /* scratch */);
__ bind(LnotVFinal);
--- a/src/hotspot/os/aix/safepointMechanism_aix.cpp Wed Jun 27 02:20:55 2018 -0700
+++ b/src/hotspot/os/aix/safepointMechanism_aix.cpp Wed Jun 27 11:54:15 2018 +0200
@@ -38,7 +38,7 @@
// Allocate one protected page
char* map_address = (char*)MAP_FAILED;
- const size_t page_size = os::vm_page_size();
+ const size_t map_size = ThreadLocalHandshakes ? 2 * os::vm_page_size() : os::vm_page_size();
const int prot = PROT_READ;
const int flags = MAP_PRIVATE | MAP_ANONYMOUS;
@@ -68,7 +68,7 @@
// 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],
- page_size, prot,
+ map_size, prot,
flags | MAP_FIXED,
-1, 0);
log_debug(os)("SafePoint Polling Page address: %p (wish) => %p",
@@ -81,24 +81,27 @@
if (map_address != (char*)MAP_FAILED) {
// Map succeeded, but polling_page is not at wished address, unmap and continue.
- ::munmap(map_address, page_size);
+ ::munmap(map_address, map_size);
map_address = (char*)MAP_FAILED;
}
// Map failed, continue loop.
}
}
if (map_address == (char*)MAP_FAILED) {
- map_address = (char*) ::mmap(NULL, page_size, prot, flags, -1, 0);
+ map_address = (char*) ::mmap(NULL, map_size, prot, flags, -1, 0);
}
- guarantee(map_address != (char*)MAP_FAILED, "SafepointMechanism::pd_initialize: failed to allocate polling page");
+ guarantee(map_address != (char*)MAP_FAILED && map_address != NULL,
+ "SafepointMechanism::pd_initialize: failed to allocate polling page");
log_info(os)("SafePoint Polling address: " INTPTR_FORMAT, p2i(map_address));
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
+ os::make_polling_page_unreadable();
+ intptr_t bad_page_val = reinterpret_cast<intptr_t>(map_address),
+ good_page_val = bad_page_val + os::vm_page_size();
+ _poll_armed_value = reinterpret_cast<void*>(bad_page_val + poll_bit());
+ _poll_disarmed_value = reinterpret_cast<void*>(good_page_val);
}
}