RFR: 8292591: Experimentally add back barrier-less Java thread transitions [v2]
Martin Doerr
mdoerr at openjdk.org
Thu Sep 8 12:12:47 UTC 2022
On Thu, 8 Sep 2022 09:44:44 GMT, Robbin Ehn <rehn at openjdk.org> wrote:
>> Please consider, only implemented on x64/aarch64 linux/windows.
>>
>> On my box calling clock_gettime via JNI goes from 35ns to 28ns when enabled.
>>
>> Passes t1-7 with option forced on, also passes t1-4 as is in this PR.
>
> Robbin Ehn has updated the pull request incrementally with one additional commit since the last revision:
>
> Change header and constants handling
We need to support older kernel versions on PPC64 as well. And let's just make it usable on PPC64. Improves performance of trivial native calls by about 20%.
diff --git a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp
index 5a55d8f4dc2..0902c0f35ed 100644
--- a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp
+++ b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp
@@ -2147,7 +2147,9 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
Label no_block, sync;
// Force this write out before the read below.
- __ fence();
+ if (!UseSystemMemoryBarrier) {
+ __ fence();
+ }
Register sync_state_addr = r_temp_4;
Register sync_state = r_temp_5;
diff --git a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp
index bd4e1ce9932..260d99bef81 100644
--- a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp
+++ b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp
@@ -1436,7 +1436,9 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
__ li(R0/*thread_state*/, _thread_in_native_trans);
__ release();
__ stw(R0/*thread_state*/, thread_(thread_state));
- __ fence();
+ if (!UseSystemMemoryBarrier) {
+ __ fence();
+ }
// Now before we return to java we must look for a current safepoint
// (a new safepoint can not start since we entered native_trans).
diff --git a/src/hotspot/os/linux/systemMemoryBarrier_linux.cpp b/src/hotspot/os/linux/systemMemoryBarrier_linux.cpp
index 796b596c675..66f77818ebc 100644
--- a/src/hotspot/os/linux/systemMemoryBarrier_linux.cpp
+++ b/src/hotspot/os/linux/systemMemoryBarrier_linux.cpp
@@ -35,6 +35,8 @@
#ifndef SYS_membarrier
#if defined(AMD64)
#define SYS_membarrier 324
+ #elif defined(PPC64)
+ #define SYS_membarrier 365
#else
#error define SYS_membarrier for the arch
#endif
Btw. are spaces in front of `#` ok? Some old preprocessors might have problems with that.
-------------
Changes requested by mdoerr (Reviewer).
PR: https://git.openjdk.org/jdk/pull/10123
More information about the hotspot-dev
mailing list