-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8315884: New Object to ObjectMonitor mapping #20067
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
Changes from 10 commits
4d835b9
2814350
c824d2f
173b75b
ccaaef1
700188c
0b5088b
d4a96a3
d12aa5f
b0eef6e
31503f5
4fe8d4f
a207544
15997bc
e1eb8c9
cccffed
f92989f
e4786be
00eef5c
f43d547
97e0c21
32884a5
8cb27f1
076febb
33447f9
ebf1154
5ea4496
a9d66a6
3515ecc
1c56bf8
517c300
a8cf38a
1557468
a83e728
937f531
92a8836
d020bc9
38402a5
b96b916
53f833b
1423871
651d64c
123a268
41fc859
7946d14
68681c8
41ac7d3
7afd245
e5e47f4
690f72a
c1649c7
5678569
bc74495
e0928e5
c2a6d13
15457aa
28ede7a
528e33b
9708828
38a03e7
24e78d1
7aa0919
354a651
f3fde37
bed7676
f0e1154
b5114ff
488a658
1ecd964
09bda30
40fc395
0bf63df
48d247d
580e809
362f564
b86dfd1
3f29e6d
4d67422
e287445
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -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" | ||||
|
|
@@ -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(); | ||||
|
|
@@ -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); | ||||
| } | ||||
|
|
@@ -109,7 +106,7 @@ class ObjectMonitorWorld : public CHeapObj<MEMFLAGS::mtObjectMonitor> { | |||
| ObjectMonitor* _monitor; | ||||
|
|
||||
| public: | ||||
xmas92 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||
| LookupMonitor(ObjectMonitor* monitor) : _monitor(monitor) {} | ||||
| explicit LookupMonitor(ObjectMonitor* monitor) : _monitor(monitor) {} | ||||
|
|
||||
| uintx get_hash() const { | ||||
| return _monitor->hash(); | ||||
|
|
@@ -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"); | ||||
xmas92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
|
|
||||
| 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) { | ||||
|
|
@@ -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 | ||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It originates from jdk/src/hotspot/share/runtime/synchronizer.cpp Line 1543 in 15997bc
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). There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||
|
|
@@ -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; | ||||
|
|
@@ -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 | ||||
|
|
@@ -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)) { | ||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.