Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 4 additions & 38 deletions src/hotspot/cpu/zero/zeroInterpreter_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,26 +331,9 @@ int ZeroInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
monitor = nullptr;
if (method->is_synchronized()) {
monitor = (BasicObjectLock*) istate->stack_base();
oop lockee = monitor->obj();
bool success = false;
if (LockingMode == LM_LEGACY) {
markWord disp = lockee->mark().set_unlocked();
monitor->lock()->set_displaced_header(disp);
success = true;
if (lockee->cas_set_mark(markWord::from_pointer(monitor), disp) != disp) {
// Is it simple recursive case?
if (thread->is_lock_owned((address) disp.clear_lock_bits().to_pointer())) {
monitor->lock()->set_displaced_header(markWord::from_pointer(nullptr));
} else {
success = false;
}
}
}
if (!success) {
CALL_VM_NOCHECK(InterpreterRuntime::monitorenter(thread, monitor));
if (HAS_PENDING_EXCEPTION)
goto unwind_and_return;
}
CALL_VM_NOCHECK(InterpreterRuntime::monitorenter(thread, monitor));
if (HAS_PENDING_EXCEPTION)
goto unwind_and_return;
}

// Get the signature handler
Expand Down Expand Up @@ -481,24 +464,7 @@ int ZeroInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {

// Unlock if necessary
if (monitor) {
bool success = false;
if (LockingMode == LM_LEGACY) {
BasicLock* lock = monitor->lock();
oop rcvr = monitor->obj();
monitor->set_obj(nullptr);
success = true;
markWord header = lock->displaced_header();
if (header.to_pointer() != nullptr) { // Check for recursive lock
markWord old_header = markWord::encode(lock);
if (rcvr->cas_set_mark(header, old_header) != old_header) {
monitor->set_obj(rcvr);
success = false;
}
}
}
if (!success) {
InterpreterRuntime::monitorexit(monitor);
}
InterpreterRuntime::monitorexit(monitor);
}

unwind_and_return:
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_LIRGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ void LIRGenerator::monitor_exit(LIR_Opr object, LIR_Opr lock, LIR_Opr new_hdr, L
// setup registers
LIR_Opr hdr = lock;
lock = new_hdr;
CodeStub* slow_path = new MonitorExitStub(lock, LockingMode != LM_MONITOR, monitor_no);
CodeStub* slow_path = new MonitorExitStub(lock, true, monitor_no);
__ load_stack_address_monitor(monitor_no, lock);
__ unlock_object(hdr, object, lock, scratch, slow_path);
}
Expand Down
3 changes: 0 additions & 3 deletions src/hotspot/share/c1/c1_Runtime1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,9 +778,6 @@ JRT_BLOCK_ENTRY(void, Runtime1::monitorenter(JavaThread* current, oopDesc* obj,
_monitorenter_slowcase_cnt++;
}
#endif
if (LockingMode == LM_MONITOR) {
lock->set_obj(obj);
}
assert(obj == lock->obj(), "must match");
SharedRuntime::monitor_enter_helper(obj, lock->lock(), current);
JRT_END
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/g1/g1BarrierSet.inline.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -37,7 +37,7 @@

inline void G1BarrierSet::enqueue_preloaded(oop pre_val) {
// Nulls should have been already filtered.
assert(oopDesc::is_oop(pre_val, true), "Error");
assert(oopDesc::is_oop(pre_val), "Error");

G1SATBMarkQueueSet& queue_set = G1BarrierSet::satb_mark_queue_set();
if (!queue_set.is_active()) return;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1BarrierSetRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void G1BarrierSetRuntime::write_ref_array_post_entry(HeapWord* dst, size_t lengt
JRT_LEAF(void, G1BarrierSetRuntime::write_ref_field_pre_entry(oopDesc* orig, JavaThread* thread))
assert(thread == JavaThread::current(), "pre-condition");
assert(orig != nullptr, "should be optimized out");
assert(oopDesc::is_oop(orig, true /* ignore mark word */), "Error");
assert(oopDesc::is_oop(orig), "Error");
// store the original value that was in the field reference
SATBMarkQueue& queue = G1ThreadLocalData::satb_mark_queue(thread);
G1BarrierSet::satb_mark_queue_set().enqueue_known_active(queue, orig);
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/g1/g1HeapRegion.inline.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -350,7 +350,7 @@ inline HeapWord* G1HeapRegion::oops_on_memregion_iterate_in_unparsable(MemRegion
assert(bitmap->is_marked(cur), "inv");

oop obj = cast_to_oop(cur);
assert(oopDesc::is_oop(obj, true), "Not an oop at " PTR_FORMAT, p2i(cur));
assert(oopDesc::is_oop(obj), "Not an oop at " PTR_FORMAT, p2i(cur));

cur += obj->size();
bool is_precise;
Expand Down Expand Up @@ -418,7 +418,7 @@ inline HeapWord* G1HeapRegion::oops_on_memregion_iterate(MemRegion mr, Closure*
// All objects >= pb are parsable. So we can just take object sizes directly.
while (true) {
oop obj = cast_to_oop(cur);
assert(oopDesc::is_oop(obj, true), "Not an oop at " PTR_FORMAT, p2i(cur));
assert(oopDesc::is_oop(obj), "Not an oop at " PTR_FORMAT, p2i(cur));

bool is_precise = false;

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1SATBMarkQueueSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static inline bool requires_marking(const void* entry, G1CollectedHeap* g1h) {
return false;
}

assert(oopDesc::is_oop(cast_to_oop(entry), true /* ignore mark word */),
assert(oopDesc::is_oop(cast_to_oop(entry)),
"Invalid oop in SATB buffer: " PTR_FORMAT, p2i(entry));

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shared/cardTableBarrierSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void CardTableBarrierSet::flush_deferred_card_mark_barrier(JavaThread* thread) {
DEBUG_ONLY(oop old_obj = cast_to_oop(deferred.start());)
assert(!_card_table->is_in_young(old_obj),
"Else should have been filtered in on_slowpath_allocation_exit()");
assert(oopDesc::is_oop(old_obj, true), "Not an oop");
assert(oopDesc::is_oop(old_obj), "Not an oop");
assert(deferred.word_size() == old_obj->size(),
"Mismatch: multiple objects?");
}
Expand Down
6 changes: 0 additions & 6 deletions src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,6 @@ void ShenandoahHeap::increase_object_age(oop obj, uint additional_age) {
// For all these reasons, we take the conservative approach and not attempt
// to increase the age when the header is displaced.
markWord w = obj->mark();
// The mark-word has been copied from the original object. It can not be
// inflating, because inflation can not be interrupted by a safepoint,
// and after a safepoint, a Java thread would first have to successfully
// evacuate the object before it could inflate the monitor.
assert(!w.is_being_inflated() || LockingMode == LM_LIGHTWEIGHT, "must not inflate monitor before evacuation of object succeeds");
// It is possible that we have copied the object after another thread has
// already successfully completed evacuation. While harmless (we would never
// publish our copy), don't even attempt to modify the age when that
Expand All @@ -334,7 +329,6 @@ uint ShenandoahHeap::get_object_age(oop obj) {
markWord w = obj->mark();
assert(!w.is_marked(), "must not be forwarded");
if (UseObjectMonitorTable) {
assert(LockingMode == LM_LIGHTWEIGHT, "Must use LW locking, too");
assert(w.age() <= markWord::max_age, "Impossible!");
return w.age();
}
Expand Down
127 changes: 6 additions & 121 deletions src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,26 +624,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
// The initial monitor is ours for the taking.
BasicObjectLock* mon = &istate->monitor_base()[-1];
mon->set_obj(rcvr);

bool success = false;
if (LockingMode == LM_LEGACY) {
// Traditional fast locking.
markWord displaced = rcvr->mark().set_unlocked();
mon->lock()->set_displaced_header(displaced);
success = true;
if (rcvr->cas_set_mark(markWord::from_pointer(mon), displaced) != displaced) {
// Is it simple recursive case?
if (THREAD->is_lock_owned((address) displaced.clear_lock_bits().to_pointer())) {
mon->lock()->set_displaced_header(markWord::from_pointer(nullptr));
} else {
success = false;
}
}
}
if (!success) {
CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception);
}

CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception);
}
THREAD->set_do_not_unlock_if_synchronized(false);

Expand Down Expand Up @@ -725,26 +706,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
BasicObjectLock* entry = (BasicObjectLock*) istate->stack_base();
assert(entry->obj() == nullptr, "Frame manager didn't allocate the monitor");
entry->set_obj(lockee);

bool success = false;
if (LockingMode == LM_LEGACY) {
// Traditional fast locking.
markWord displaced = lockee->mark().set_unlocked();
entry->lock()->set_displaced_header(displaced);
success = true;
if (lockee->cas_set_mark(markWord::from_pointer(entry), displaced) != displaced) {
// Is it simple recursive case?
if (THREAD->is_lock_owned((address) displaced.clear_lock_bits().to_pointer())) {
entry->lock()->set_displaced_header(markWord::from_pointer(nullptr));
} else {
success = false;
}
}
}
if (!success) {
CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
}

CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
UPDATE_PC_AND_TOS(1, -1);
goto run;
}
Expand Down Expand Up @@ -1657,26 +1619,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
}
if (entry != nullptr) {
entry->set_obj(lockee);

bool success = false;
if (LockingMode == LM_LEGACY) {
// Traditional fast locking.
markWord displaced = lockee->mark().set_unlocked();
entry->lock()->set_displaced_header(displaced);
success = true;
if (lockee->cas_set_mark(markWord::from_pointer(entry), displaced) != displaced) {
// Is it simple recursive case?
if (THREAD->is_lock_owned((address) displaced.clear_lock_bits().to_pointer())) {
entry->lock()->set_displaced_header(markWord::from_pointer(nullptr));
} else {
success = false;
}
}
}
if (!success) {
CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
}

CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
} else {
istate->set_msg(more_monitors);
Expand All @@ -1694,25 +1637,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
while (most_recent != limit ) {
if ((most_recent)->obj() == lockee) {
BasicLock* lock = most_recent->lock();

bool success = false;
if (LockingMode == LM_LEGACY) {
// If it isn't recursive we either must swap old header or call the runtime
most_recent->set_obj(nullptr);
success = true;
markWord header = lock->displaced_header();
if (header.to_pointer() != nullptr) {
markWord old_header = markWord::encode(lock);
if (lockee->cas_set_mark(header, old_header) != old_header) {
// restore object for the slow case
most_recent->set_obj(lockee);
success = false;
}
}
}
if (!success) {
InterpreterRuntime::monitorexit(most_recent);
}
InterpreterRuntime::monitorexit(most_recent);
UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
}
most_recent++;
Expand Down Expand Up @@ -3137,27 +3062,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
while (end < base) {
oop lockee = end->obj();
if (lockee != nullptr) {
BasicLock* lock = end->lock();

bool success = false;
if (LockingMode == LM_LEGACY) {
markWord header = lock->displaced_header();
end->set_obj(nullptr);

// If it isn't recursive we either must swap old header or call the runtime
success = true;
if (header.to_pointer() != nullptr) {
markWord old_header = markWord::encode(lock);
if (lockee->cas_set_mark(header, old_header) != old_header) {
// restore object for the slow case
end->set_obj(lockee);
success = false;
}
}
}
if (!success) {
InterpreterRuntime::monitorexit(end);
}
InterpreterRuntime::monitorexit(end);

// One error is plenty
if (illegal_state_oop() == nullptr && !suppress_error) {
Expand Down Expand Up @@ -3204,32 +3109,12 @@ void BytecodeInterpreter::run(interpreterState istate) {
illegal_state_oop = Handle(THREAD, THREAD->pending_exception());
THREAD->clear_pending_exception();
}
} else if (LockingMode != LM_LEGACY) {
} else {
InterpreterRuntime::monitorexit(base);
if (THREAD->has_pending_exception()) {
if (!suppress_error) illegal_state_oop = Handle(THREAD, THREAD->pending_exception());
THREAD->clear_pending_exception();
}
} else {
BasicLock* lock = base->lock();
markWord header = lock->displaced_header();
base->set_obj(nullptr);

// If it isn't recursive we either must swap old header or call the runtime
bool dec_monitor_count = true;
if (header.to_pointer() != nullptr) {
markWord old_header = markWord::encode(lock);
if (rcvr->cas_set_mark(header, old_header) != old_header) {
// restore object for the slow case
base->set_obj(rcvr);
dec_monitor_count = false;
InterpreterRuntime::monitorexit(base);
if (THREAD->has_pending_exception()) {
if (!suppress_error) illegal_state_oop = Handle(THREAD, THREAD->pending_exception());
THREAD->clear_pending_exception();
}
}
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/jvmci/jvmciRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,8 @@ JRT_LEAF(void, JVMCIRuntime::log_object(JavaThread* thread, oopDesc* obj, bool a

if (obj == nullptr) {
tty->print("null");
} else if (oopDesc::is_oop_or_null(obj, true) && (!as_string || !java_lang_String::is_instance(obj))) {
if (oopDesc::is_oop_or_null(obj, true)) {
} else if (oopDesc::is_oop_or_null(obj) && (!as_string || !java_lang_String::is_instance(obj))) {
if (oopDesc::is_oop_or_null(obj)) {
char buf[O_BUFLEN];
tty->print("%s@" INTPTR_FORMAT, obj->klass()->name()->as_C_string(buf, O_BUFLEN), p2i(obj));
} else {
Expand Down
5 changes: 0 additions & 5 deletions src/hotspot/share/jvmci/vmStructs_jvmci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@
volatile_nonstatic_field(ObjectMonitor, _recursions, intptr_t) \
volatile_nonstatic_field(ObjectMonitor, _entry_list, ObjectWaiter*) \
volatile_nonstatic_field(ObjectMonitor, _succ, int64_t) \
volatile_nonstatic_field(ObjectMonitor, _stack_locker, BasicLock*) \
\
volatile_nonstatic_field(oopDesc, _mark, markWord) \
volatile_nonstatic_field(oopDesc, _metadata._klass, Klass*) \
Expand Down Expand Up @@ -780,10 +779,6 @@
declare_constant(InstanceKlass::being_initialized) \
declare_constant(InstanceKlass::fully_initialized) \
\
declare_constant(LockingMode::LM_MONITOR) \
declare_constant(LockingMode::LM_LEGACY) \
declare_constant(LockingMode::LM_LIGHTWEIGHT) \
\
/*********************************/ \
/* InstanceKlass _misc_flags */ \
/*********************************/ \
Expand Down
4 changes: 0 additions & 4 deletions src/hotspot/share/oops/instanceStackChunkKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,6 @@ void InstanceStackChunkKlass::oop_oop_iterate_stack_slow(stackChunkOop chunk, Oo

template <typename OopT>
void InstanceStackChunkKlass::oop_oop_iterate_lockstack(stackChunkOop chunk, OopIterateClosure* closure, MemRegion mr) {
if (LockingMode != LM_LIGHTWEIGHT) {
return;
}

StackChunkOopIterateFilterClosure<OopIterateClosure> cl(closure, mr);
if (chunk->has_bitmap()) {
chunk->iterate_lockstack<OopT>(&cl);
Expand Down
Loading