Skip to content

Commit 5303b59

Browse files
committed
Resolved parts
1 parent 7a4a09b commit 5303b59

File tree

7 files changed

+17
-75
lines changed

7 files changed

+17
-75
lines changed

src/hotspot/share/jfr/leakprofiler/checkpoint/rootResolver.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -248,12 +248,6 @@ bool ReferenceToThreadRootClosure::do_thread_stack_detailed(JavaThread* jt) {
248248
ReferenceLocateClosure rcl(_callback, OldObjectRoot::_threads, OldObjectRoot::_stack_variable, jt);
249249

250250
if (jt->has_last_Java_frame()) {
251-
// Traverse the monitor chunks
252-
MonitorChunk* chunk = jt->monitor_chunks();
253-
for (; chunk != NULL; chunk = chunk->next()) {
254-
chunk->oops_do(&rcl);
255-
}
256-
257251
if (rcl.complete()) {
258252
return true;
259253
}

src/hotspot/share/runtime/monitorChunk.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
3030
MonitorChunk::MonitorChunk(int number_on_monitors) {
3131
_number_of_monitors = number_on_monitors;
3232
_monitors = NEW_C_HEAP_ARRAY(BasicObjectLock, number_on_monitors, mtSynchronizer);
33-
_next = NULL;
3433
}
3534

3635

src/hotspot/share/runtime/monitorChunk.hpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -35,16 +35,11 @@ class MonitorChunk: public CHeapObj<mtSynchronizer> {
3535
int _number_of_monitors;
3636
BasicObjectLock* _monitors;
3737
BasicObjectLock* monitors() const { return _monitors; }
38-
MonitorChunk* _next;
3938
public:
4039
// Constructor
4140
MonitorChunk(int number_on_monitors);
4241
~MonitorChunk();
4342

44-
// link operations
45-
MonitorChunk* next() const { return _next; }
46-
void set_next(MonitorChunk* next) { _next = next; }
47-
4843
// Tells whether the monitor chunk is linked into the JavaThread
4944
bool is_linked() const { return next() != NULL; }
5045

@@ -54,7 +49,6 @@ class MonitorChunk: public CHeapObj<mtSynchronizer> {
5449
// Returns the index'th monitor
5550
BasicObjectLock* at(int index) { assert(index >= 0 && index < number_of_monitors(), "out of bounds check"); return &monitors()[index]; }
5651

57-
5852
// Memory management
5953
void oops_do(OopClosure* f);
6054

src/hotspot/share/runtime/synchronizer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,8 @@ intptr_t ObjectSynchronizer::FastHashCode(Thread* current, oop obj) {
961961
}
962962
// Fall thru so we only have one place that installs the hash in
963963
// the ObjectMonitor.
964-
} else if (current->is_lock_owned((address)mark.locker())) {
964+
} else if (current->is_Java_thread()
965+
&& JavaThread::cast(current)->is_lock_owned((address)mark.locker())) {
965966
// This is a stack lock owned by the calling thread so fetch the
966967
// displaced markWord from the BasicLock on the stack.
967968
temp = mark.displaced_mark_helper();

src/hotspot/share/runtime/thread.cpp

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -699,15 +699,6 @@ void Thread::print_owned_locks_on(outputStream* st) const {
699699
}
700700
#endif // ASSERT
701701

702-
// We had to move these methods here, because vm threads get into ObjectSynchronizer::enter
703-
// However, there is a note in JavaThread::is_lock_owned() about the VM threads not being
704-
// used for compilation in the future. If that change is made, the need for these methods
705-
// should be revisited, and they should be removed if possible.
706-
707-
bool Thread::is_lock_owned(address adr) const {
708-
return is_in_full_stack(adr);
709-
}
710-
711702
bool Thread::set_as_starting_thread() {
712703
assert(_starting_thread == NULL, "already initialized: "
713704
"_starting_thread=" INTPTR_FORMAT, p2i(_starting_thread));
@@ -1035,8 +1026,6 @@ JavaThread::JavaThread() :
10351026
_current_waiting_monitor(NULL),
10361027
_Stalled(0),
10371028

1038-
_monitor_chunks(nullptr),
1039-
10401029
_suspend_flags(0),
10411030
_async_exception_condition(_no_async_condition),
10421031
_pending_async_exception(nullptr),
@@ -1573,13 +1562,7 @@ JavaThread* JavaThread::active() {
15731562
}
15741563

15751564
bool JavaThread::is_lock_owned(address adr) const {
1576-
if (Thread::is_lock_owned(adr)) return true;
1577-
1578-
for (MonitorChunk* chunk = monitor_chunks(); chunk != NULL; chunk = chunk->next()) {
1579-
if (chunk->contains(adr)) return true;
1580-
}
1581-
1582-
return false;
1565+
return is_in_full_stack(adr);
15831566
}
15841567

15851568
oop JavaThread::exception_oop() const {
@@ -1590,23 +1573,6 @@ void JavaThread::set_exception_oop(oop o) {
15901573
Atomic::store(&_exception_oop, o);
15911574
}
15921575

1593-
void JavaThread::add_monitor_chunk(MonitorChunk* chunk) {
1594-
chunk->set_next(monitor_chunks());
1595-
set_monitor_chunks(chunk);
1596-
}
1597-
1598-
void JavaThread::remove_monitor_chunk(MonitorChunk* chunk) {
1599-
guarantee(monitor_chunks() != NULL, "must be non empty");
1600-
if (monitor_chunks() == chunk) {
1601-
set_monitor_chunks(chunk->next());
1602-
} else {
1603-
MonitorChunk* prev = monitor_chunks();
1604-
while (prev->next() != chunk) prev = prev->next();
1605-
prev->set_next(chunk->next());
1606-
}
1607-
}
1608-
1609-
16101576
// Asynchronous exceptions support
16111577
//
16121578
// Note: this function shouldn't block if it's called in
@@ -1994,13 +1960,6 @@ void JavaThread::oops_do_no_frames(OopClosure* f, CodeBlobClosure* cf) {
19941960

19951961
DEBUG_ONLY(verify_frame_info();)
19961962

1997-
if (has_last_Java_frame()) {
1998-
// Traverse the monitor chunks
1999-
for (MonitorChunk* chunk = monitor_chunks(); chunk != NULL; chunk = chunk->next()) {
2000-
chunk->oops_do(f);
2001-
}
2002-
}
2003-
20041963
assert(vframe_array_head() == NULL, "deopt in progress at a safepoint!");
20051964
// If we have deferred set_locals there might be oops waiting to be
20061965
// written

src/hotspot/share/runtime/thread.hpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -800,10 +800,6 @@ class JavaThread: public Thread {
800800
}
801801

802802
private:
803-
MonitorChunk* _monitor_chunks; // Contains the off stack monitors
804-
// allocated during deoptimization
805-
// and by JNI_MonitorEnter/Exit
806-
807803
enum SuspendFlags {
808804
// NOTE: avoid using the sign-bit as cc generates different test code
809805
// when the sign-bit is used, and sometimes incorrectly - see CR 6398077
@@ -1208,7 +1204,7 @@ class JavaThread: public Thread {
12081204
(_suspend_flags & (_obj_deopt JFR_ONLY(| _trace_flag))) != 0;
12091205
}
12101206

1211-
// Fast-locking support
1207+
// Stack-locking support
12121208
bool is_lock_owned(address adr) const;
12131209

12141210
// Accessors for vframe array top
@@ -1385,13 +1381,7 @@ class JavaThread: public Thread {
13851381
int depth_first_number() { return _depth_first_number; }
13861382
void set_depth_first_number(int dfn) { _depth_first_number = dfn; }
13871383

1388-
private:
1389-
void set_monitor_chunks(MonitorChunk* monitor_chunks) { _monitor_chunks = monitor_chunks; }
1390-
13911384
public:
1392-
MonitorChunk* monitor_chunks() const { return _monitor_chunks; }
1393-
void add_monitor_chunk(MonitorChunk* chunk);
1394-
void remove_monitor_chunk(MonitorChunk* chunk);
13951385
bool in_deopt_handler() const { return _in_deopt_handler > 0; }
13961386
void inc_in_deopt_handler() { _in_deopt_handler++; }
13971387
void dec_in_deopt_handler() {

src/hotspot/share/runtime/vframeArray.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -49,11 +49,9 @@
4949

5050
int vframeArrayElement:: bci(void) const { return (_bci == SynchronizationEntryBCI ? 0 : _bci); }
5151

52-
void vframeArrayElement::free_monitors(JavaThread* jt) {
52+
void vframeArrayElement::free_monitors() {
5353
if (_monitors != NULL) {
5454
MonitorChunk* chunk = _monitors;
55-
_monitors = NULL;
56-
jt->remove_monitor_chunk(chunk);
5755
delete chunk;
5856
}
5957
}
@@ -95,9 +93,16 @@ void vframeArrayElement::fill_in(compiledVFrame* vf, bool realloc_failures) {
9593
if (monitor->owner_is_scalar_replaced()) {
9694
dest->set_obj(NULL);
9795
} else {
98-
assert(monitor->owner() == NULL || (!monitor->owner()->is_unlocked() && !monitor->owner()->has_bias_pattern()), "object must be null or locked, and unbiased");
96+
assert(monitor->owner() != nullptr, "monitor owner must not be null");
97+
assert(!monitor->owner()->is_unlocked() && !monitor->owner()->has_bias_pattern(), "object must be null or locked, and unbiased");
9998
dest->set_obj(monitor->owner());
99+
assert(ObjectSynchronizer::current_thread_holds_lock(current_thread, Handle(current_thread, dest->obj())),
100+
"should be held, before move_to");
101+
100102
monitor->lock()->move_to(monitor->owner(), dest->lock());
103+
104+
assert(ObjectSynchronizer::current_thread_holds_lock(current_thread, Handle(current_thread, dest->obj())),
105+
"should be held, after move_to");
101106
}
102107
}
103108
}

0 commit comments

Comments
 (0)