Skip to content
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
4d835b9
8315884: New Object to ObjectMonitor mapping
xmas92 Apr 15, 2024
2814350
More graceful JVMCI VM option interaction
xmas92 Jul 8, 2024
c824d2f
Revert "More graceful JVMCI VM option interaction"
xmas92 Jul 8, 2024
173b75b
Add JVMCI symbol exports
xmas92 Jul 8, 2024
ccaaef1
Update JavaThread::om_clear_monitor_cache
xmas92 Jul 9, 2024
700188c
Update LightweightSynchronizer::get_or_insert_monitor assert
xmas92 Jul 9, 2024
0b5088b
Update LightweightSynchronizer::exit assert
xmas92 Jul 9, 2024
d4a96a3
Fix BasicLock::object_monitor_cache() for other platforms
xmas92 Jul 10, 2024
d12aa5f
Add comment LightweightSynchronizer::inflate_locked_or_imse
xmas92 Jul 10, 2024
b0eef6e
Add missing inline qualifiers
xmas92 Jul 10, 2024
31503f5
Remove unused variable
xmas92 Jul 10, 2024
4fe8d4f
Fix typos
xmas92 Jul 10, 2024
a207544
Add extra comments in LightweightSynchronizer::inflate_fast_locked_ob…
xmas92 Jul 10, 2024
15997bc
Update arguments.cpp
xmas92 Jul 12, 2024
e1eb8c9
Cleanup c2 cache lookup
xmas92 Jul 12, 2024
cccffed
Avoid uniform initialization
xmas92 Jul 12, 2024
f92989f
Fix javaThread include
xmas92 Jul 14, 2024
e4786be
Remove strange comment
xmas92 Jul 14, 2024
00eef5c
Remove logStream include
xmas92 Jul 14, 2024
f43d547
Remove outdated comment LightweightSynchronizer::exit
xmas92 Jul 15, 2024
97e0c21
Fix indentation
xmas92 Jul 15, 2024
32884a5
Update assert message OMCache::set_monitor
xmas92 Jul 15, 2024
8cb27f1
Remove unused include
xmas92 Jul 15, 2024
076febb
Remove superfluous access specifier
xmas92 Jul 15, 2024
33447f9
Add explicit to single parameter constructors
xmas92 Jul 15, 2024
ebf1154
Remove try_read
xmas92 Jul 15, 2024
5ea4496
Merge tag 'jdk-24+10' into JDK-8315884
xmas92 Aug 12, 2024
a9d66a6
Revert instanceKlass.cpp comment change
xmas92 Aug 12, 2024
3515ecc
Rename _table_count to _items_count
xmas92 Aug 12, 2024
1c56bf8
Remove unnecessary assert
xmas92 Aug 12, 2024
517c300
Use [inc/dec]_no_safepoint_count directly instead of a conditionally …
xmas92 Aug 12, 2024
a8cf38a
Remove const for InflateCause parameters in lightweightSynchronizer
xmas92 Aug 12, 2024
1557468
Update comment basicLock.hpp
xmas92 Aug 12, 2024
a83e728
Rename ObjectMonitorWorld to ObjectMonitorTable
xmas92 Aug 12, 2024
937f531
Inline _table
xmas92 Aug 12, 2024
92a8836
Remove extra whitespace in UseObjectMonitorTableTest.java
xmas92 Aug 12, 2024
d020bc9
Missing DEBUG_ONLY
xmas92 Aug 12, 2024
38402a5
Remove top comment
xmas92 Aug 13, 2024
b96b916
Merge remote-tracking branch 'upstream_jdk/master' into JDK-8315884
xmas92 Aug 13, 2024
53f833b
Remove object_is_cleared
xmas92 Aug 13, 2024
1423871
Revert "Inline _table"
xmas92 Aug 13, 2024
651d64c
Make ObjectMonitorTable AllStatic
xmas92 Aug 13, 2024
123a268
Remove _omworld
xmas92 Aug 13, 2024
41fc859
Rename omworldtable_work to object_monitor_table_work
xmas92 Aug 13, 2024
7946d14
Remove the last OMWorld references
xmas92 Aug 13, 2024
68681c8
Whitespace and nits
xmas92 Aug 13, 2024
41ac7d3
Fix items count
xmas92 Aug 14, 2024
7afd245
Cleanup bytecodeInterpreter.cpp comments
xmas92 Aug 14, 2024
e5e47f4
Remove unnecessary assert
xmas92 Aug 14, 2024
690f72a
Update basicLock.inline.hpp comment
xmas92 Aug 14, 2024
c1649c7
Update globals.hpp flag description
xmas92 Aug 14, 2024
5678569
Change parameter order LightweightSynchronizer::remove_monitor
xmas92 Aug 14, 2024
bc74495
Fix lightweightSynchronize.hpp access modifier indentation
xmas92 Aug 14, 2024
e0928e5
Make lightweightSynchronizer::inflate* parameter order consistent
xmas92 Aug 14, 2024
c2a6d13
Fix lightweightSynchronizer.cpp include order
xmas92 Aug 14, 2024
15457aa
Remove extra include lightweightSynchronizer.cpp
xmas92 Aug 14, 2024
28ede7a
Fix lightweightSynchronizer.cpp access modifier indentation
xmas92 Aug 14, 2024
528e33b
lightweightSynchronizer.cpp add space between operator and operands
xmas92 Aug 14, 2024
9708828
Put `new ConcurrentTable` arguments on same line
xmas92 Aug 14, 2024
38a03e7
Update verify_monitor_get_result assert text
xmas92 Aug 14, 2024
24e78d1
Update ObjectMonitorTable::should_shrink comment
xmas92 Aug 14, 2024
7aa0919
Update logging and printing format
xmas92 Aug 14, 2024
354a651
lightweightSynchronizer.cpp add space between operator and operands
xmas92 Aug 14, 2024
f3fde37
Fix comment lightweightSynchronizer.cpp
xmas92 Aug 14, 2024
bed7676
lightweightSynchronizer.cpp fix whitespace
xmas92 Aug 14, 2024
f0e1154
Fix lockStack.hpp access modifier indentation
xmas92 Aug 14, 2024
b5114ff
Fix objectMonitor.hpp access modifier indentation
xmas92 Aug 14, 2024
488a658
Fix merge else if scopes ObjectMonitor::deflate_monitor
xmas92 Aug 14, 2024
1ecd964
Update `ObjectMonitor::install_displaced_markword_in_object` assert text
xmas92 Aug 14, 2024
09bda30
Fix serviceThread.cpp include order
xmas92 Aug 14, 2024
40fc395
Fix quick_enter parameter order
xmas92 Aug 14, 2024
0bf63df
Update `ObjectSynchronizer::FastHashCode` comment
xmas92 Aug 14, 2024
48d247d
Fix whitespace synchronizer.{inline.hpp,cpp}
xmas92 Aug 14, 2024
580e809
Revert monitors_used_above_threshold changes
xmas92 Aug 14, 2024
362f564
Fix test_objectMonitor.cpp indent
xmas92 Aug 14, 2024
b86dfd1
Align comment LockUnlock.java
xmas92 Aug 14, 2024
3f29e6d
Add and print random seed UseObjectMonitorTableTest.java
xmas92 Aug 14, 2024
4d67422
Use jdk.test.lib.Utils.getRandomInstance()
xmas92 Aug 14, 2024
e287445
Remove newline
xmas92 Aug 15, 2024
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
34 changes: 14 additions & 20 deletions src/hotspot/share/runtime/lightweightSynchronizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,16 @@
#include "precompiled.hpp"

#include "classfile/vmSymbols.hpp"
#include "javaThread.inline.hpp"
#include "jfrfiles/jfrEventClasses.hpp"
#include "logging/log.hpp"
#include "logging/logStream.hpp"
#include "memory/resourceArea.hpp"
#include "nmt/memflags.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/basicLock.inline.hpp"
#include "runtime/globals_extension.hpp"
#include "runtime/interfaceSupport.inline.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/javaThread.inline.hpp"
#include "runtime/lightweightSynchronizer.hpp"
#include "runtime/lockStack.inline.hpp"
#include "runtime/mutexLocker.hpp"
Expand Down Expand Up @@ -85,7 +83,7 @@ class ObjectMonitorWorld : public CHeapObj<MEMFLAGS::mtObjectMonitor> {
oop _obj;

public:
Lookup(oop obj) : _obj(obj) {}
explicit Lookup(oop obj) : _obj(obj) {}

uintx get_hash() const {
uintx hash = _obj->mark().hash();
Expand All @@ -94,7 +92,6 @@ class ObjectMonitorWorld : public CHeapObj<MEMFLAGS::mtObjectMonitor> {
}

bool equals(ObjectMonitor** value) {
// The entry is going to be removed soon.
assert(*value != nullptr, "must be");
return (*value)->object_refers_to(_obj);
}
Expand All @@ -109,7 +106,7 @@ class ObjectMonitorWorld : public CHeapObj<MEMFLAGS::mtObjectMonitor> {
ObjectMonitor* _monitor;

public:
LookupMonitor(ObjectMonitor* monitor) : _monitor(monitor) {}
explicit LookupMonitor(ObjectMonitor* monitor) : _monitor(monitor) {}

uintx get_hash() const {
return _monitor->hash();
Expand Down Expand Up @@ -343,22 +340,20 @@ class ObjectMonitorWorld : public CHeapObj<MEMFLAGS::mtObjectMonitor> {

ObjectMonitorWorld* LightweightSynchronizer::_omworld = nullptr;

ObjectMonitor* LightweightSynchronizer::get_or_insert_monitor_from_table(oop object, JavaThread* current, bool try_read, bool* inserted) {
ObjectMonitor* LightweightSynchronizer::get_or_insert_monitor_from_table(oop object, JavaThread* current, bool* inserted) {
assert(LockingMode == LM_LIGHTWEIGHT, "must be");

if (try_read) {
ObjectMonitor* monitor = get_monitor_from_table(current, object);
if (monitor != nullptr) {
*inserted = false;
return monitor;
}
ObjectMonitor* monitor = get_monitor_from_table(current, object);
if (monitor != nullptr) {
*inserted = false;
return monitor;
}

ObjectMonitor* alloced_monitor = new ObjectMonitor(object);
alloced_monitor->set_owner_anonymous();

// Try insert monitor
ObjectMonitor* monitor = add_monitor(current, alloced_monitor, object);
monitor = add_monitor(current, alloced_monitor, object);

*inserted = alloced_monitor == monitor;
if (!*inserted) {
Expand Down Expand Up @@ -389,13 +384,13 @@ static void post_monitor_inflate_event(EventJavaMonitorInflate* event,
}


ObjectMonitor* LightweightSynchronizer::get_or_insert_monitor(oop object, JavaThread* current, const ObjectSynchronizer::InflateCause cause, bool try_read) {
ObjectMonitor* LightweightSynchronizer::get_or_insert_monitor(oop object, JavaThread* current, const ObjectSynchronizer::InflateCause cause) {
assert(UseObjectMonitorTable, "must be");

EventJavaMonitorInflate event;

bool inserted;
ObjectMonitor* monitor = get_or_insert_monitor_from_table(object, current, try_read, &inserted);
ObjectMonitor* monitor = get_or_insert_monitor_from_table(object, current, &inserted);

if (inserted) {
// Hopefully the performance counters are allocated on distinct
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't look like the counters are on distinct cache lines (see objectMonitor.hpp, lines 212ff). If this is a concern, file a bug to investigate it later? The comment here is a bit misplaced, IMO.

Copy link
Member Author

Choose a reason for hiding this comment

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

It originates from

// Hopefully the performance counters are allocated on distinct cache lines

I think we just kept it and did not think more about it.

Not sure what it is referring to. Maybe @dcubed-ojdk knows more, they originated from him (9 years old comment).

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we ever got around to experimenting with putting the perf counters
on distinct cache lines. We've always had bigger fish to fry.

Expand Down Expand Up @@ -745,7 +740,6 @@ void LightweightSynchronizer::exit(oop object, JavaThread* current) {
}
}

// Fast-locking does not use the 'lock' argument.
while (mark.is_fast_locked()) {
markWord unlocked_mark = mark.set_unlocked();
markWord old_mark = mark;
Expand Down Expand Up @@ -966,8 +960,8 @@ ObjectMonitor* LightweightSynchronizer::inflate_fast_locked_object(oop object, J
assert(!mark.is_unlocked(), "Cannot be unlocked");

for (;;) {
// Fetch the monitor from the table
monitor = get_or_insert_monitor(object, current, cause, true /* try_read */);
// Fetch the monitor from the table
monitor = get_or_insert_monitor(object, current, cause);

// ObjectMonitors are always inserted as anonymously owned, this thread is
// the current holder of the monitor. So unless the entry is stale and
Expand Down Expand Up @@ -1043,7 +1037,7 @@ ObjectMonitor* LightweightSynchronizer::inflate_and_enter(oop object, JavaThread

// Get or create the monitor
if (monitor == nullptr) {
monitor = get_or_insert_monitor(object, current, cause, true /* try_read */);
monitor = get_or_insert_monitor(object, current, cause);
}

if (monitor->try_enter(locking_thread)) {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/runtime/lightweightSynchronizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class LightweightSynchronizer : AllStatic {
private:
static ObjectMonitorWorld* _omworld;

static ObjectMonitor* get_or_insert_monitor_from_table(oop object, JavaThread* current, bool try_read, bool* inserted);
static ObjectMonitor* get_or_insert_monitor(oop object, JavaThread* current, const ObjectSynchronizer::InflateCause cause, bool try_read);
static ObjectMonitor* get_or_insert_monitor_from_table(oop object, JavaThread* current, bool* inserted);
static ObjectMonitor* get_or_insert_monitor(oop object, JavaThread* current, const ObjectSynchronizer::InflateCause cause);

static ObjectMonitor* add_monitor(JavaThread* current, ObjectMonitor* monitor, oop obj);
static bool remove_monitor(Thread* current, oop obj, ObjectMonitor* monitor);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/lockStack.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ inline void OMCache::set_monitor(ObjectMonitor *monitor) {

oop obj = monitor->object_peek();
assert(obj != nullptr, "must be alive");
assert(monitor == LightweightSynchronizer::get_monitor_from_table(JavaThread::current(), obj), "must be exist in table");
assert(monitor == LightweightSynchronizer::get_monitor_from_table(JavaThread::current(), obj), "must exist in table");

OMCacheEntry to_insert = {obj, monitor};

Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/runtime/objectMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
#include "runtime/safefetch.hpp"
#include "runtime/safepointMechanism.inline.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/synchronizer.hpp"
#include "services/threadService.hpp"
#include "utilities/debug.hpp"
#include "utilities/dtrace.hpp"
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/runtime/objectMonitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ class ObjectMonitor : public CHeapObj<mtObjectMonitor> {

ObjectWaiter* volatile _WaitSet; // LL of threads wait()ing on the monitor
volatile int _waiters; // number of waiting threads
private:
volatile int _WaitSetLock; // protects Wait Queue - simple spinlock

public:
Expand Down