Skip to content

Commit 66c65c8

Browse files
author
duke
committedApr 3, 2023
Automatic merge of jdk:master into master
2 parents d8a7188 + 4de24cd commit 66c65c8

13 files changed

+51
-28
lines changed
 

‎src/hotspot/cpu/arm/sharedRuntime_arm.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,9 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
12111211
__ str_32(Rtemp, Address(Rthread, JavaThread::thread_state_offset()));
12121212

12131213
// make sure the store is observed before reading the SafepointSynchronize state and further mem refs
1214-
__ membar(MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad | MacroAssembler::StoreStore), Rtemp);
1214+
if (!UseSystemMemoryBarrier) {
1215+
__ membar(MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad | MacroAssembler::StoreStore), Rtemp);
1216+
}
12151217

12161218
__ safepoint_poll(R2, call_safepoint_runtime);
12171219
__ ldr_u32(R3, Address(Rthread, JavaThread::suspend_flags_offset()));

‎src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1007,8 +1007,10 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
10071007
__ mov(Rtemp, _thread_in_native_trans);
10081008
__ str_32(Rtemp, Address(Rthread, JavaThread::thread_state_offset()));
10091009

1010-
// Force this write out before the read below
1011-
__ membar(MacroAssembler::StoreLoad, Rtemp);
1010+
// Force this write out before the read below
1011+
if (!UseSystemMemoryBarrier) {
1012+
__ membar(MacroAssembler::StoreLoad, Rtemp);
1013+
}
10121014

10131015
// Protect the return value in the interleaved code: save it to callee-save registers.
10141016
__ mov(Rsaved_result_lo, R0);

‎src/hotspot/cpu/riscv/downcallLinker_riscv.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ void DowncallStubGenerator::generate() {
265265
__ sw(t0, Address(xthread, JavaThread::thread_state_offset()));
266266

267267
// Force this write out before the read below
268-
__ membar(MacroAssembler::AnyAny);
268+
if (!UseSystemMemoryBarrier) {
269+
__ membar(MacroAssembler::AnyAny);
270+
}
269271

270272
Label L_after_safepoint_poll;
271273
Label L_safepoint_poll_slow_path;

‎src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "prims/methodHandles.hpp"
4545
#include "runtime/continuation.hpp"
4646
#include "runtime/continuationEntry.inline.hpp"
47+
#include "runtime/globals.hpp"
4748
#include "runtime/jniHandles.hpp"
4849
#include "runtime/safepointMechanism.hpp"
4950
#include "runtime/sharedRuntime.hpp"
@@ -1746,7 +1747,9 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
17461747
__ sw(t0, Address(xthread, JavaThread::thread_state_offset()));
17471748

17481749
// Force this write out before the read below
1749-
__ membar(MacroAssembler::AnyAny);
1750+
if (!UseSystemMemoryBarrier) {
1751+
__ membar(MacroAssembler::AnyAny);
1752+
}
17501753

17511754
// check for safepoint operation in progress and/or pending suspend requests
17521755
{

‎src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "runtime/arguments.hpp"
4646
#include "runtime/deoptimization.hpp"
4747
#include "runtime/frame.inline.hpp"
48+
#include "runtime/globals.hpp"
4849
#include "runtime/jniHandles.hpp"
4950
#include "runtime/sharedRuntime.hpp"
5051
#include "runtime/stubRoutines.hpp"
@@ -1159,7 +1160,9 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
11591160
__ sw(t0, Address(xthread, JavaThread::thread_state_offset()));
11601161

11611162
// Force this write out before the read below
1162-
__ membar(MacroAssembler::AnyAny);
1163+
if (!UseSystemMemoryBarrier) {
1164+
__ membar(MacroAssembler::AnyAny);
1165+
}
11631166

11641167
// check for safepoint operation in progress and/or pending suspend requests
11651168
{

‎src/hotspot/cpu/s390/sharedRuntime_s390.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,9 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
18381838
save_native_result(masm, ret_type, workspace_slot_offset); // Make Z_R2 available as work reg.
18391839

18401840
// Force this write out before the read below.
1841-
__ z_fence();
1841+
if (!UseSystemMemoryBarrier) {
1842+
__ z_fence();
1843+
}
18421844

18431845
__ safepoint_poll(sync, Z_R1);
18441846

‎src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,9 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
15251525
// synchronization is progress, and escapes.
15261526

15271527
__ set_thread_state(_thread_in_native_trans);
1528-
__ z_fence();
1528+
if (!UseSystemMemoryBarrier) {
1529+
__ z_fence();
1530+
}
15291531

15301532
// Now before we return to java we must look for a current safepoint
15311533
// (a new safepoint can not start since we entered native_trans).

‎src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -1772,9 +1772,11 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
17721772
__ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_native_trans);
17731773

17741774
// Force this write out before the read below
1775-
__ membar(Assembler::Membar_mask_bits(
1776-
Assembler::LoadLoad | Assembler::LoadStore |
1777-
Assembler::StoreLoad | Assembler::StoreStore));
1775+
if (!UseSystemMemoryBarrier) {
1776+
__ membar(Assembler::Membar_mask_bits(
1777+
Assembler::LoadLoad | Assembler::LoadStore |
1778+
Assembler::StoreLoad | Assembler::StoreStore));
1779+
}
17781780

17791781
if (AlwaysRestoreFPU) {
17801782
// Make sure the control word is correct.

‎src/hotspot/os/linux/systemMemoryBarrier_linux.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,21 @@ static int membarrier(int cmd, unsigned int flags, int cpu_id) {
7272
bool LinuxSystemMemoryBarrier::initialize() {
7373
int ret = membarrier(MEMBARRIER_CMD_QUERY, 0, 0);
7474
if (ret < 0) {
75-
log_error(os)("MEMBARRIER_CMD_QUERY unsupported");
75+
log_info(os)("MEMBARRIER_CMD_QUERY unsupported");
7676
return false;
7777
}
7878
if (!(ret & MEMBARRIER_CMD_PRIVATE_EXPEDITED) ||
7979
!(ret & MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED)) {
80-
log_error(os)("MEMBARRIER PRIVATE_EXPEDITED unsupported");
80+
log_info(os)("MEMBARRIER PRIVATE_EXPEDITED unsupported");
8181
return false;
8282
}
8383
ret = membarrier(MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED, 0, 0);
8484
guarantee_with_errno(ret == 0, "MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED failed");
85+
log_info(os)("Using MEMBARRIER PRIVATE_EXPEDITED");
8586
return true;
8687
}
8788

8889
void LinuxSystemMemoryBarrier::emit() {
8990
int s = membarrier(MEMBARRIER_CMD_PRIVATE_EXPEDITED, 0, 0);
9091
guarantee_with_errno(s >= 0, "MEMBARRIER_CMD_PRIVATE_EXPEDITED failed");
9192
}
92-

‎src/hotspot/share/runtime/arguments.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#include "utilities/parseInteger.hpp"
6565
#include "utilities/powerOfTwo.hpp"
6666
#include "utilities/stringUtils.hpp"
67+
#include "utilities/systemMemoryBarrier.hpp"
6768
#if INCLUDE_JFR
6869
#include "jfr/jfr.hpp"
6970
#endif
@@ -2153,6 +2154,8 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *vm_options_args,
21532154

21542155
os::init_container_support();
21552156

2157+
SystemMemoryBarrier::initialize();
2158+
21562159
// Do final processing now that all arguments have been parsed
21572160
result = finalize_vm_init_args(patch_mod_javabase);
21582161
if (result != JNI_OK) {

‎src/hotspot/share/runtime/globals.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1293,8 +1293,8 @@ const int ObjectAlignmentInBytes = 8;
12931293
"Delay in milliseconds for option SafepointTimeout") \
12941294
range(0, max_intx LP64_ONLY(/MICROUNITS)) \
12951295
\
1296-
product(bool, UseSystemMemoryBarrier, false, EXPERIMENTAL, \
1297-
"Try to enable system memory barrier") \
1296+
product(bool, UseSystemMemoryBarrier, false, \
1297+
"Try to enable system memory barrier if supported by OS") \
12981298
\
12991299
product(intx, NmethodSweepActivity, 4, \
13001300
"Removes cold nmethods from code cache if > 0. Higher values " \

‎src/hotspot/share/runtime/threads.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
#include "utilities/dtrace.hpp"
9696
#include "utilities/events.hpp"
9797
#include "utilities/macros.hpp"
98-
#include "utilities/systemMemoryBarrier.hpp"
9998
#include "utilities/vmError.hpp"
10099
#if INCLUDE_JVMCI
101100
#include "jvmci/jvmci.hpp"
@@ -552,14 +551,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
552551
// crash Linux VM, see notes in os_linux.cpp.
553552
main_thread->stack_overflow_state()->create_stack_guard_pages();
554553

555-
if (UseSystemMemoryBarrier) {
556-
if (!SystemMemoryBarrier::initialize()) {
557-
vm_shutdown_during_initialization("Failed to initialize the requested system memory barrier synchronization.");
558-
return JNI_EINVAL;
559-
}
560-
log_debug(os)("Using experimental system memory barrier synchronization");
561-
}
562-
563554
// Initialize Java-Level synchronization subsystem
564555
ObjectMonitor::Initialize();
565556
ObjectSynchronizer::initialize();

‎src/hotspot/share/utilities/systemMemoryBarrier.hpp

+14-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#define SHARE_UTILITIES_SYSTEMMEMORYBARRIER_HPP
2727

2828
#include "logging/log.hpp"
29+
#include "runtime/globals.hpp"
30+
#include "runtime/globals_extension.hpp"
2931
#include "utilities/globalDefinitions.hpp"
3032

3133
#if defined(LINUX)
@@ -38,7 +40,7 @@ typedef WindowsSystemMemoryBarrier SystemMemoryBarrierDefault;
3840
class NoSystemMemoryBarrier {
3941
public:
4042
static bool initialize() {
41-
log_error(os)("SystemMemoryBarrier not supported on this platform");
43+
log_info(os)("SystemMemoryBarrier not supported on this platform");
4244
return false;
4345
}
4446
static void emit() {
@@ -51,8 +53,17 @@ typedef NoSystemMemoryBarrier SystemMemoryBarrierDefault;
5153
template <typename SystemMemoryBarrierImpl>
5254
class SystemMemoryBarrierType : public AllStatic {
5355
public:
54-
static bool initialize() { return SystemMemoryBarrierImpl::initialize(); }
55-
static void emit() { SystemMemoryBarrierImpl::emit(); }
56+
static void initialize() {
57+
if (UseSystemMemoryBarrier) {
58+
if (!SystemMemoryBarrierImpl::initialize()) {
59+
if (!FLAG_IS_DEFAULT(UseSystemMemoryBarrier)) {
60+
warning("UseSystemMemoryBarrier specified, but not supported on this OS version. Use -Xlog:os=info for details.");
61+
}
62+
FLAG_SET_ERGO(UseSystemMemoryBarrier, false);
63+
}
64+
}
65+
}
66+
static void emit() { SystemMemoryBarrierImpl::emit(); }
5667
};
5768

5869
typedef SystemMemoryBarrierType<SystemMemoryBarrierDefault> SystemMemoryBarrier;

0 commit comments

Comments
 (0)
Please sign in to comment.