Skip to content

Commit abfd2f9

Browse files
committed
8283710: JVMTI: Use BitSet for object marking
Reviewed-by: stuefe, coleenp
1 parent 7edd186 commit abfd2f9

File tree

10 files changed

+194
-229
lines changed

10 files changed

+194
-229
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
*
2323
*/
2424
#include "precompiled.hpp"
25-
#include "jfr/leakprofiler/chains/bitset.inline.hpp"
2625
#include "jfr/leakprofiler/chains/bfsClosure.hpp"
2726
#include "jfr/leakprofiler/chains/dfsClosure.hpp"
2827
#include "jfr/leakprofiler/chains/edge.hpp"
2928
#include "jfr/leakprofiler/chains/edgeStore.hpp"
3029
#include "jfr/leakprofiler/chains/edgeQueue.hpp"
30+
#include "jfr/leakprofiler/chains/jfrbitset.hpp"
3131
#include "jfr/leakprofiler/utilities/granularTimer.hpp"
3232
#include "jfr/leakprofiler/utilities/unifiedOopRef.inline.hpp"
3333
#include "logging/log.hpp"
@@ -37,7 +37,7 @@
3737
#include "oops/oop.inline.hpp"
3838
#include "utilities/align.hpp"
3939

40-
BFSClosure::BFSClosure(EdgeQueue* edge_queue, EdgeStore* edge_store, BitSet* mark_bits) :
40+
BFSClosure::BFSClosure(EdgeQueue* edge_queue, EdgeStore* edge_store, JFRBitSet* mark_bits) :
4141
_edge_queue(edge_queue),
4242
_edge_store(edge_store),
4343
_mark_bits(mark_bits),

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
#ifndef SHARE_JFR_LEAKPROFILER_CHAINS_BFSCLOSURE_HPP
2626
#define SHARE_JFR_LEAKPROFILER_CHAINS_BFSCLOSURE_HPP
2727

28+
#include "jfr/leakprofiler/chains/jfrbitset.hpp"
2829
#include "jfr/leakprofiler/utilities/unifiedOopRef.hpp"
2930
#include "memory/iterator.hpp"
3031

31-
class BitSet;
3232
class Edge;
3333
class EdgeStore;
3434
class EdgeQueue;
@@ -38,7 +38,7 @@ class BFSClosure : public BasicOopIterateClosure {
3838
private:
3939
EdgeQueue* _edge_queue;
4040
EdgeStore* _edge_store;
41-
BitSet* _mark_bits;
41+
JFRBitSet* _mark_bits;
4242
const Edge* _current_parent;
4343
mutable size_t _current_frontier_level;
4444
mutable size_t _next_frontier_idx;
@@ -65,7 +65,7 @@ class BFSClosure : public BasicOopIterateClosure {
6565
public:
6666
virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS_EXCEPT_REFERENT; }
6767

68-
BFSClosure(EdgeQueue* edge_queue, EdgeStore* edge_store, BitSet* mark_bits);
68+
BFSClosure(EdgeQueue* edge_queue, EdgeStore* edge_store, JFRBitSet* mark_bits);
6969
void process();
7070
void do_root(UnifiedOopRef ref);
7171

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
*/
2424

2525
#include "precompiled.hpp"
26-
#include "jfr/leakprofiler/chains/bitset.inline.hpp"
2726
#include "jfr/leakprofiler/chains/dfsClosure.hpp"
2827
#include "jfr/leakprofiler/chains/edge.hpp"
2928
#include "jfr/leakprofiler/chains/edgeStore.hpp"
29+
#include "jfr/leakprofiler/chains/jfrbitset.hpp"
3030
#include "jfr/leakprofiler/chains/rootSetClosure.hpp"
3131
#include "jfr/leakprofiler/utilities/granularTimer.hpp"
3232
#include "jfr/leakprofiler/utilities/rootType.hpp"
@@ -40,7 +40,7 @@
4040
UnifiedOopRef DFSClosure::_reference_stack[max_dfs_depth];
4141

4242
void DFSClosure::find_leaks_from_edge(EdgeStore* edge_store,
43-
BitSet* mark_bits,
43+
JFRBitSet* mark_bits,
4444
const Edge* start_edge) {
4545
assert(edge_store != NULL, "invariant");
4646
assert(mark_bits != NULL," invariant");
@@ -52,7 +52,7 @@ void DFSClosure::find_leaks_from_edge(EdgeStore* edge_store,
5252
}
5353

5454
void DFSClosure::find_leaks_from_root_set(EdgeStore* edge_store,
55-
BitSet* mark_bits) {
55+
JFRBitSet* mark_bits) {
5656
assert(edge_store != NULL, "invariant");
5757
assert(mark_bits != NULL, "invariant");
5858

@@ -68,7 +68,7 @@ void DFSClosure::find_leaks_from_root_set(EdgeStore* edge_store,
6868
rs.process();
6969
}
7070

71-
DFSClosure::DFSClosure(EdgeStore* edge_store, BitSet* mark_bits, const Edge* start_edge)
71+
DFSClosure::DFSClosure(EdgeStore* edge_store, JFRBitSet* mark_bits, const Edge* start_edge)
7272
:_edge_store(edge_store), _mark_bits(mark_bits), _start_edge(start_edge),
7373
_max_depth(max_dfs_depth), _depth(0), _ignore_root_set(false) {
7474
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
#ifndef SHARE_JFR_LEAKPROFILER_CHAINS_DFSCLOSURE_HPP
2626
#define SHARE_JFR_LEAKPROFILER_CHAINS_DFSCLOSURE_HPP
2727

28+
#include "jfr/leakprofiler/chains/jfrbitset.hpp"
2829
#include "jfr/leakprofiler/utilities/unifiedOopRef.hpp"
2930
#include "memory/iterator.hpp"
3031

31-
class BitSet;
3232
class Edge;
3333
class EdgeStore;
3434
class EdgeQueue;
@@ -41,22 +41,22 @@ class DFSClosure : public BasicOopIterateClosure {
4141
static UnifiedOopRef _reference_stack[max_dfs_depth];
4242

4343
EdgeStore* _edge_store;
44-
BitSet* _mark_bits;
44+
JFRBitSet* _mark_bits;
4545
const Edge*_start_edge;
4646
size_t _max_depth;
4747
size_t _depth;
4848
bool _ignore_root_set;
4949

50-
DFSClosure(EdgeStore* edge_store, BitSet* mark_bits, const Edge* start_edge);
50+
DFSClosure(EdgeStore* edge_store, JFRBitSet* mark_bits, const Edge* start_edge);
5151

5252
void add_chain();
5353
void closure_impl(UnifiedOopRef reference, const oop pointee);
5454

5555
public:
5656
virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS_EXCEPT_REFERENT; }
5757

58-
static void find_leaks_from_edge(EdgeStore* edge_store, BitSet* mark_bits, const Edge* start_edge);
59-
static void find_leaks_from_root_set(EdgeStore* edge_store, BitSet* mark_bits);
58+
static void find_leaks_from_edge(EdgeStore* edge_store, JFRBitSet* mark_bits, const Edge* start_edge);
59+
static void find_leaks_from_root_set(EdgeStore* edge_store, JFRBitSet* mark_bits);
6060
void do_root(UnifiedOopRef ref);
6161

6262
virtual void do_oop(oop* ref);
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022 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
@@ -21,37 +21,13 @@
2121
* questions.
2222
*
2323
*/
24-
#include "precompiled.hpp"
25-
#include "jfr/leakprofiler/chains/bitset.inline.hpp"
2624

27-
BitSet::BitMapFragment::BitMapFragment(uintptr_t granule, BitMapFragment* next) :
28-
_bits(_bitmap_granularity_size >> LogMinObjAlignmentInBytes, mtTracing, true /* clear */),
29-
_next(next) {
30-
}
25+
#ifndef SHARE_JFR_LEAKPROFILER_JFRBITMAP_HPP
26+
#define SHARE_JFR_LEAKPROFILER_JFRBITMAP_HPP
3127

32-
BitSet::BitMapFragmentTable::~BitMapFragmentTable() {
33-
for (int index = 0; index < table_size(); index ++) {
34-
Entry* e = bucket(index);
35-
while (e != nullptr) {
36-
Entry* tmp = e;
37-
e = e->next();
38-
free_entry(tmp);
39-
}
40-
}
41-
}
28+
#include "memory/allocation.hpp"
29+
#include "utilities/objectBitSet.inline.hpp"
4230

43-
BitSet::BitSet() :
44-
_bitmap_fragments(32),
45-
_fragment_list(NULL),
46-
_last_fragment_bits(NULL),
47-
_last_fragment_granule(UINTPTR_MAX) {
48-
}
31+
typedef ObjectBitSet<mtTracing> JFRBitSet;
4932

50-
BitSet::~BitSet() {
51-
BitMapFragment* current = _fragment_list;
52-
while (current != NULL) {
53-
BitMapFragment* next = current->next();
54-
delete current;
55-
current = next;
56-
}
57-
}
33+
#endif // SHARE_JFR_LEAKPROFILER_JFRBITMAP_HPP

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
#include "gc/shared/gc_globals.hpp"
2828
#include "jfr/leakprofiler/leakProfiler.hpp"
2929
#include "jfr/leakprofiler/chains/bfsClosure.hpp"
30-
#include "jfr/leakprofiler/chains/bitset.inline.hpp"
3130
#include "jfr/leakprofiler/chains/dfsClosure.hpp"
3231
#include "jfr/leakprofiler/chains/edge.hpp"
3332
#include "jfr/leakprofiler/chains/edgeQueue.hpp"
3433
#include "jfr/leakprofiler/chains/edgeStore.hpp"
34+
#include "jfr/leakprofiler/chains/jfrbitset.hpp"
3535
#include "jfr/leakprofiler/chains/objectSampleMarker.hpp"
3636
#include "jfr/leakprofiler/chains/rootSetClosure.hpp"
3737
#include "jfr/leakprofiler/chains/edgeStore.hpp"
@@ -84,7 +84,7 @@ void PathToGcRootsOperation::doit() {
8484
assert(_cutoff_ticks > 0, "invariant");
8585

8686
// The bitset used for marking is dimensioned as a function of the heap size
87-
BitSet mark_bits;
87+
JFRBitSet mark_bits;
8888

8989
// The edge queue is dimensioned as a fraction of the heap size
9090
const size_t edge_queue_reservation_size = edge_queue_memory_reservation();

0 commit comments

Comments
 (0)