Skip to content

8354448: [REDO] Remove friends for ObjectMonitor #24626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
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
7 changes: 2 additions & 5 deletions src/hotspot/share/runtime/objectMonitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ class ObjectWaiter : public CHeapObj<mtThread> {
#define OM_CACHE_LINE_SIZE DEFAULT_CACHE_LINE_SIZE

class ObjectMonitor : public CHeapObj<mtObjectMonitor> {
friend class LightweightSynchronizer;
friend class ObjectSynchronizer;
friend class ObjectWaiter;
friend class VMStructs;
JVMCI_ONLY(friend class JVMCIVMStructs;)

Expand Down Expand Up @@ -334,6 +331,7 @@ class ObjectMonitor : public CHeapObj<mtObjectMonitor> {
void add_to_contentions(int value);
intx recursions() const { return _recursions; }
void set_recursions(size_t recursions);
void increment_recursions(JavaThread* current);

// JVM/TI GetObjectMonitorUsage() needs this:
int waiters() const;
Expand Down Expand Up @@ -424,13 +422,12 @@ class ObjectMonitor : public CHeapObj<mtObjectMonitor> {
bool short_fixed_spin(JavaThread* current, int spin_count, bool adapt);
void exit_epilog(JavaThread* current, ObjectWaiter* Wakee);

public:
// Deflation support
bool deflate_monitor(Thread* current);
private:
void install_displaced_markword_in_object(const oop obj);

// JFR support
public:
static bool is_jfr_excluded(const Klass* monitor_klass);
};

Expand Down
5 changes: 5 additions & 0 deletions src/hotspot/share/runtime/objectMonitor.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ inline void ObjectMonitor::set_recursions(size_t recursions) {
_recursions = checked_cast<intx>(recursions);
}

inline void ObjectMonitor::increment_recursions(JavaThread* current) {
assert(has_owner(current), "must be the owner");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be overkill to have this assert ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this method will be removed with legacy locking.

_recursions++;
}

// Clear _owner field; current value must match old_value.
inline void ObjectMonitor::release_clear_owner(JavaThread* old_owner) {
int64_t old_value = owner_id_from(old_owner);
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/runtime/synchronizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ bool ObjectSynchronizer::quick_enter_legacy(oop obj, BasicLock* lock, JavaThread
// Case: TLE inimical operations such as nested/recursive synchronization

if (m->has_owner(current)) {
m->_recursions++;
m->increment_recursions(current);
current->inc_held_monitor_count();
return true;
}
Expand All @@ -440,7 +440,7 @@ bool ObjectSynchronizer::quick_enter_legacy(oop obj, BasicLock* lock, JavaThread
lock->set_displaced_header(markWord::unused_mark());

if (!m->has_owner() && m->try_set_owner(current)) {
assert(m->_recursions == 0, "invariant");
assert(m->recursions() == 0, "invariant");
current->inc_held_monitor_count();
return true;
}
Expand Down