Skip to content

Commit 8322766

Browse files
rkennkepull[bot]
authored andcommitted
8307532: Implement LM_LIGHTWEIGHT for Zero
Reviewed-by: aboldtch, jwaters
1 parent 7dbcb0d commit 8322766

File tree

4 files changed

+20
-32
lines changed

4 files changed

+20
-32
lines changed

src/hotspot/cpu/zero/vm_version_zero.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,6 @@ void VM_Version::initialize() {
116116
FLAG_SET_DEFAULT(UseVectorizedMismatchIntrinsic, false);
117117
}
118118

119-
if ((LockingMode != LM_LEGACY) && (LockingMode != LM_MONITOR)) {
120-
warning("Unsupported locking mode for this CPU.");
121-
FLAG_SET_DEFAULT(LockingMode, LM_LEGACY);
122-
}
123-
124119
// Enable error context decoding on known platforms
125120
#if defined(IA32) || defined(AMD64) || defined(ARM) || \
126121
defined(AARCH64) || defined(PPC) || defined(RISCV) || \

src/hotspot/cpu/zero/zeroInterpreter_zero.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -485,26 +485,30 @@ int ZeroInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
485485

486486
// Unlock if necessary
487487
if (monitor) {
488-
BasicLock *lock = monitor->lock();
489-
markWord header = lock->displaced_header();
490-
oop rcvr = monitor->obj();
491-
monitor->set_obj(nullptr);
492-
493-
bool dec_monitor_count = true;
494-
if (header.to_pointer() != nullptr) {
495-
markWord old_header = markWord::encode(lock);
496-
if (rcvr->cas_set_mark(header, old_header) != old_header) {
497-
monitor->set_obj(rcvr);
498-
dec_monitor_count = false;
499-
InterpreterRuntime::monitorexit(monitor);
488+
bool success = false;
489+
if (LockingMode == LM_LEGACY) {
490+
BasicLock* lock = monitor->lock();
491+
oop rcvr = monitor->obj();
492+
monitor->set_obj(nullptr);
493+
success = true;
494+
markWord header = lock->displaced_header();
495+
if (header.to_pointer() != nullptr) { // Check for recursive lock
496+
markWord old_header = markWord::encode(lock);
497+
if (rcvr->cas_set_mark(header, old_header) != old_header) {
498+
monitor->set_obj(rcvr);
499+
success = false;
500+
}
501+
}
502+
if (success) {
503+
THREAD->dec_held_monitor_count();
500504
}
501505
}
502-
if (dec_monitor_count) {
503-
THREAD->dec_held_monitor_count();
506+
if (!success) {
507+
InterpreterRuntime::monitorexit(monitor);
504508
}
505509
}
506510

507-
unwind_and_return:
511+
unwind_and_return:
508512

509513
// Unwind the current activation
510514
thread->pop_zero_frame();

src/hotspot/share/runtime/arguments.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,17 +1817,6 @@ bool Arguments::check_vm_args_consistency() {
18171817
}
18181818
#endif
18191819

1820-
#if !defined(X86) && !defined(AARCH64) && !defined(RISCV64) && !defined(ARM) && !defined(PPC64) && !defined(S390)
1821-
if (LockingMode == LM_LIGHTWEIGHT) {
1822-
FLAG_SET_CMDLINE(LockingMode, LM_LEGACY);
1823-
warning("New lightweight locking not supported on this platform");
1824-
}
1825-
if (UseObjectMonitorTable) {
1826-
FLAG_SET_CMDLINE(UseObjectMonitorTable, false);
1827-
warning("UseObjectMonitorTable not supported on this platform");
1828-
}
1829-
#endif
1830-
18311820
if (UseObjectMonitorTable && LockingMode != LM_LIGHTWEIGHT) {
18321821
// ObjectMonitorTable requires lightweight locking.
18331822
FLAG_SET_CMDLINE(UseObjectMonitorTable, false);

src/hotspot/share/runtime/basicLock.inline.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ inline void BasicLock::set_displaced_header(markWord header) {
3939

4040
inline ObjectMonitor* BasicLock::object_monitor_cache() const {
4141
assert(UseObjectMonitorTable, "must be");
42-
#if defined(X86) || defined(AARCH64) || defined(RISCV64) || defined(PPC64) || defined(S390)
42+
#if !defined(ZERO) && (defined(X86) || defined(AARCH64) || defined(RISCV64) || defined(PPC64) || defined(S390))
4343
return reinterpret_cast<ObjectMonitor*>(get_metadata());
4444
#else
4545
// Other platforms do not make use of the cache yet,

0 commit comments

Comments
 (0)