Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 270674c

Browse files
committed
Merge
2 parents f39a0d5 + 20dbc94 commit 270674c

File tree

5 files changed

+40
-61
lines changed

5 files changed

+40
-61
lines changed

.hgtags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,3 +634,4 @@ dd5198db2e5b1ebcafe065d987c03ba9fcb50fc3 jdk-15+17
634634
12b55fad80f30d24b1f8fdb3b947ea6465ef9518 jdk-15+21
635635
7223c6d610343fd8323af9d07d501e01fa1a7696 jdk-15+22
636636
f143729ca00ec14a98ea5c7f73acba88da97746e jdk-15+23
637+
497fd9f9129c4928fd5a876dd55e0daf6298b511 jdk-15+24

src/hotspot/share/jfr/leakprofiler/chains/dfsClosure.cpp

Lines changed: 27 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,8 @@
3737
#include "oops/oop.inline.hpp"
3838
#include "utilities/align.hpp"
3939

40-
// max dfs depth should not exceed size of stack
41-
static const size_t max_dfs_depth = 5000;
42-
43-
EdgeStore* DFSClosure::_edge_store = NULL;
44-
BitSet* DFSClosure::_mark_bits = NULL;
45-
const Edge* DFSClosure::_start_edge = NULL;
46-
size_t DFSClosure::_max_depth = max_dfs_depth;
47-
bool DFSClosure::_ignore_root_set = false;
48-
49-
DFSClosure::DFSClosure() :
50-
_parent(NULL),
51-
_reference(UnifiedOopRef::encode_null()),
52-
_depth(0) {
53-
}
54-
55-
DFSClosure::DFSClosure(DFSClosure* parent, size_t depth) :
56-
_parent(parent),
57-
_reference(UnifiedOopRef::encode_null()),
58-
_depth(depth) {
59-
}
40+
// max dfs depth should not exceed size of stack
41+
static const size_t max_dfs_depth = 4000;
6042

6143
void DFSClosure::find_leaks_from_edge(EdgeStore* edge_store,
6244
BitSet* mark_bits,
@@ -65,14 +47,8 @@ void DFSClosure::find_leaks_from_edge(EdgeStore* edge_store,
6547
assert(mark_bits != NULL," invariant");
6648
assert(start_edge != NULL, "invariant");
6749

68-
_edge_store = edge_store;
69-
_mark_bits = mark_bits;
70-
_start_edge = start_edge;
71-
_ignore_root_set = false;
72-
assert(_max_depth == max_dfs_depth, "invariant");
73-
7450
// Depth-first search, starting from a BFS egde
75-
DFSClosure dfs;
51+
DFSClosure dfs(edge_store, mark_bits, start_edge);
7652
start_edge->pointee()->oop_iterate(&dfs);
7753
}
7854

@@ -81,42 +57,45 @@ void DFSClosure::find_leaks_from_root_set(EdgeStore* edge_store,
8157
assert(edge_store != NULL, "invariant");
8258
assert(mark_bits != NULL, "invariant");
8359

84-
_edge_store = edge_store;
85-
_mark_bits = mark_bits;
86-
_start_edge = NULL;
87-
8860
// Mark root set, to avoid going sideways
89-
_max_depth = 1;
90-
_ignore_root_set = false;
91-
DFSClosure dfs;
61+
DFSClosure dfs(edge_store, mark_bits, NULL);
62+
dfs._max_depth = 1;
9263
RootSetClosure<DFSClosure> rs(&dfs);
9364
rs.process();
9465

9566
// Depth-first search
96-
_max_depth = max_dfs_depth;
97-
_ignore_root_set = true;
98-
assert(_start_edge == NULL, "invariant");
67+
dfs._max_depth = max_dfs_depth;
68+
dfs._ignore_root_set = true;
9969
rs.process();
10070
}
10171

72+
DFSClosure::DFSClosure(EdgeStore* edge_store, BitSet* mark_bits, const Edge* start_edge)
73+
:_edge_store(edge_store), _mark_bits(mark_bits), _start_edge(start_edge),
74+
_max_depth(max_dfs_depth), _depth(0), _ignore_root_set(false) {
75+
_reference_stack = NEW_C_HEAP_ARRAY(UnifiedOopRef, max_dfs_depth, mtTracing);
76+
}
77+
78+
DFSClosure::~DFSClosure() {
79+
FREE_C_HEAP_ARRAY(UnifiedOopRef, _reference_stack);
80+
}
81+
10282
void DFSClosure::closure_impl(UnifiedOopRef reference, const oop pointee) {
10383
assert(pointee != NULL, "invariant");
10484
assert(!reference.is_null(), "invariant");
10585

10686
if (GranularTimer::is_finished()) {
107-
return;
87+
return;
10888
}
10989
if (_depth == 0 && _ignore_root_set) {
11090
// Root set is already marked, but we want
11191
// to continue, so skip is_marked check.
11292
assert(_mark_bits->is_marked(pointee), "invariant");
113-
} else {
93+
} else {
11494
if (_mark_bits->is_marked(pointee)) {
11595
return;
11696
}
11797
}
118-
119-
_reference = reference;
98+
_reference_stack[_depth] = reference;
12099
_mark_bits->mark_obj(pointee);
121100
assert(_mark_bits->is_marked(pointee), "invariant");
122101

@@ -127,8 +106,10 @@ void DFSClosure::closure_impl(UnifiedOopRef reference, const oop pointee) {
127106

128107
assert(_max_depth >= 1, "invariant");
129108
if (_depth < _max_depth - 1) {
130-
DFSClosure next_level(this, _depth + 1);
131-
pointee->oop_iterate(&next_level);
109+
_depth++;
110+
pointee->oop_iterate(this);
111+
assert(_depth > 0, "invariant");
112+
_depth--;
132113
}
133114
}
134115

@@ -140,11 +121,10 @@ void DFSClosure::add_chain() {
140121
size_t idx = 0;
141122

142123
// aggregate from depth-first search
143-
const DFSClosure* c = this;
144-
while (c != NULL) {
124+
for (size_t i = 0; i <= _depth; i++) {
145125
const size_t next = idx + 1;
146-
chain[idx++] = Edge(&chain[next], c->reference());
147-
c = c->parent();
126+
const size_t depth = _depth - i;
127+
chain[idx++] = Edge(&chain[next], _reference_stack[depth]);
148128
}
149129
assert(_depth + 1 == idx, "invariant");
150130
assert(array_length == idx + 1, "invariant");

src/hotspot/share/jfr/leakprofiler/chains/dfsClosure.hpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,20 @@ class EdgeQueue;
3636
// Class responsible for iterating the heap depth-first
3737
class DFSClosure : public BasicOopIterateClosure {
3838
private:
39-
static EdgeStore* _edge_store;
40-
static BitSet* _mark_bits;
41-
static const Edge*_start_edge;
42-
static size_t _max_depth;
43-
static bool _ignore_root_set;
44-
DFSClosure* _parent;
45-
UnifiedOopRef _reference;
39+
EdgeStore* _edge_store;
40+
BitSet* _mark_bits;
41+
const Edge*_start_edge;
42+
size_t _max_depth;
4643
size_t _depth;
44+
bool _ignore_root_set;
45+
UnifiedOopRef* _reference_stack;
46+
47+
DFSClosure(EdgeStore* edge_store, BitSet* mark_bits, const Edge* start_edge);
48+
~DFSClosure();
4749

4850
void add_chain();
4951
void closure_impl(UnifiedOopRef reference, const oop pointee);
5052

51-
DFSClosure* parent() const { return _parent; }
52-
UnifiedOopRef reference() const { return _reference; }
53-
54-
DFSClosure(DFSClosure* parent, size_t depth);
55-
DFSClosure();
56-
5753
public:
5854
virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS_EXCEPT_REFERENT; }
5955
virtual bool should_verify_oops() { return false; }

src/hotspot/share/jfr/leakprofiler/utilities/unifiedOopRef.inline.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ inline UnifiedOopRef UnifiedOopRef::encode_in_heap(const oop* ref) {
8585
}
8686

8787
inline UnifiedOopRef UnifiedOopRef::encode_null() {
88-
return UnifiedOopRef();
88+
UnifiedOopRef result = { 0 };
89+
return result;
8990
}
9091

9192
inline oop UnifiedOopRef::dereference() const {

test/jdk/ProblemList.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ java/net/MulticastSocket/SetGetNetworkInterfaceTest.java 8219083 windows-
628628

629629
java/net/ServerSocket/AcceptInheritHandle.java 8211854 aix-ppc64
630630

631+
java/net/SocketOption/AfterClose.java 8245517 linux-all
631632

632633
############################################################################
633634

0 commit comments

Comments
 (0)