Skip to content

Commit

Permalink
8283710: JVMTI: Use BitSet for object marking
Browse files Browse the repository at this point in the history
Reviewed-by: stuefe, coleenp
  • Loading branch information
rkennke committed Apr 11, 2022
1 parent 7edd186 commit abfd2f9
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 229 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/share/jfr/leakprofiler/chains/bfsClosure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
*
*/
#include "precompiled.hpp"
#include "jfr/leakprofiler/chains/bitset.inline.hpp"
#include "jfr/leakprofiler/chains/bfsClosure.hpp"
#include "jfr/leakprofiler/chains/dfsClosure.hpp"
#include "jfr/leakprofiler/chains/edge.hpp"
#include "jfr/leakprofiler/chains/edgeStore.hpp"
#include "jfr/leakprofiler/chains/edgeQueue.hpp"
#include "jfr/leakprofiler/chains/jfrbitset.hpp"
#include "jfr/leakprofiler/utilities/granularTimer.hpp"
#include "jfr/leakprofiler/utilities/unifiedOopRef.inline.hpp"
#include "logging/log.hpp"
Expand All @@ -37,7 +37,7 @@
#include "oops/oop.inline.hpp"
#include "utilities/align.hpp"

BFSClosure::BFSClosure(EdgeQueue* edge_queue, EdgeStore* edge_store, BitSet* mark_bits) :
BFSClosure::BFSClosure(EdgeQueue* edge_queue, EdgeStore* edge_store, JFRBitSet* mark_bits) :
_edge_queue(edge_queue),
_edge_store(edge_store),
_mark_bits(mark_bits),
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/jfr/leakprofiler/chains/bfsClosure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
#ifndef SHARE_JFR_LEAKPROFILER_CHAINS_BFSCLOSURE_HPP
#define SHARE_JFR_LEAKPROFILER_CHAINS_BFSCLOSURE_HPP

#include "jfr/leakprofiler/chains/jfrbitset.hpp"
#include "jfr/leakprofiler/utilities/unifiedOopRef.hpp"
#include "memory/iterator.hpp"

class BitSet;
class Edge;
class EdgeStore;
class EdgeQueue;
Expand All @@ -38,7 +38,7 @@ class BFSClosure : public BasicOopIterateClosure {
private:
EdgeQueue* _edge_queue;
EdgeStore* _edge_store;
BitSet* _mark_bits;
JFRBitSet* _mark_bits;
const Edge* _current_parent;
mutable size_t _current_frontier_level;
mutable size_t _next_frontier_idx;
Expand All @@ -65,7 +65,7 @@ class BFSClosure : public BasicOopIterateClosure {
public:
virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS_EXCEPT_REFERENT; }

BFSClosure(EdgeQueue* edge_queue, EdgeStore* edge_store, BitSet* mark_bits);
BFSClosure(EdgeQueue* edge_queue, EdgeStore* edge_store, JFRBitSet* mark_bits);
void process();
void do_root(UnifiedOopRef ref);

Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/jfr/leakprofiler/chains/dfsClosure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
*/

#include "precompiled.hpp"
#include "jfr/leakprofiler/chains/bitset.inline.hpp"
#include "jfr/leakprofiler/chains/dfsClosure.hpp"
#include "jfr/leakprofiler/chains/edge.hpp"
#include "jfr/leakprofiler/chains/edgeStore.hpp"
#include "jfr/leakprofiler/chains/jfrbitset.hpp"
#include "jfr/leakprofiler/chains/rootSetClosure.hpp"
#include "jfr/leakprofiler/utilities/granularTimer.hpp"
#include "jfr/leakprofiler/utilities/rootType.hpp"
Expand All @@ -40,7 +40,7 @@
UnifiedOopRef DFSClosure::_reference_stack[max_dfs_depth];

void DFSClosure::find_leaks_from_edge(EdgeStore* edge_store,
BitSet* mark_bits,
JFRBitSet* mark_bits,
const Edge* start_edge) {
assert(edge_store != NULL, "invariant");
assert(mark_bits != NULL," invariant");
Expand All @@ -52,7 +52,7 @@ void DFSClosure::find_leaks_from_edge(EdgeStore* edge_store,
}

void DFSClosure::find_leaks_from_root_set(EdgeStore* edge_store,
BitSet* mark_bits) {
JFRBitSet* mark_bits) {
assert(edge_store != NULL, "invariant");
assert(mark_bits != NULL, "invariant");

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

DFSClosure::DFSClosure(EdgeStore* edge_store, BitSet* mark_bits, const Edge* start_edge)
DFSClosure::DFSClosure(EdgeStore* edge_store, JFRBitSet* mark_bits, const Edge* start_edge)
:_edge_store(edge_store), _mark_bits(mark_bits), _start_edge(start_edge),
_max_depth(max_dfs_depth), _depth(0), _ignore_root_set(false) {
}
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/share/jfr/leakprofiler/chains/dfsClosure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
#ifndef SHARE_JFR_LEAKPROFILER_CHAINS_DFSCLOSURE_HPP
#define SHARE_JFR_LEAKPROFILER_CHAINS_DFSCLOSURE_HPP

#include "jfr/leakprofiler/chains/jfrbitset.hpp"
#include "jfr/leakprofiler/utilities/unifiedOopRef.hpp"
#include "memory/iterator.hpp"

class BitSet;
class Edge;
class EdgeStore;
class EdgeQueue;
Expand All @@ -41,22 +41,22 @@ class DFSClosure : public BasicOopIterateClosure {
static UnifiedOopRef _reference_stack[max_dfs_depth];

EdgeStore* _edge_store;
BitSet* _mark_bits;
JFRBitSet* _mark_bits;
const Edge*_start_edge;
size_t _max_depth;
size_t _depth;
bool _ignore_root_set;

DFSClosure(EdgeStore* edge_store, BitSet* mark_bits, const Edge* start_edge);
DFSClosure(EdgeStore* edge_store, JFRBitSet* mark_bits, const Edge* start_edge);

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

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

static void find_leaks_from_edge(EdgeStore* edge_store, BitSet* mark_bits, const Edge* start_edge);
static void find_leaks_from_root_set(EdgeStore* edge_store, BitSet* mark_bits);
static void find_leaks_from_edge(EdgeStore* edge_store, JFRBitSet* mark_bits, const Edge* start_edge);
static void find_leaks_from_root_set(EdgeStore* edge_store, JFRBitSet* mark_bits);
void do_root(UnifiedOopRef ref);

virtual void do_oop(oop* ref);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -21,37 +21,13 @@
* questions.
*
*/
#include "precompiled.hpp"
#include "jfr/leakprofiler/chains/bitset.inline.hpp"

BitSet::BitMapFragment::BitMapFragment(uintptr_t granule, BitMapFragment* next) :
_bits(_bitmap_granularity_size >> LogMinObjAlignmentInBytes, mtTracing, true /* clear */),
_next(next) {
}
#ifndef SHARE_JFR_LEAKPROFILER_JFRBITMAP_HPP
#define SHARE_JFR_LEAKPROFILER_JFRBITMAP_HPP

BitSet::BitMapFragmentTable::~BitMapFragmentTable() {
for (int index = 0; index < table_size(); index ++) {
Entry* e = bucket(index);
while (e != nullptr) {
Entry* tmp = e;
e = e->next();
free_entry(tmp);
}
}
}
#include "memory/allocation.hpp"
#include "utilities/objectBitSet.inline.hpp"

BitSet::BitSet() :
_bitmap_fragments(32),
_fragment_list(NULL),
_last_fragment_bits(NULL),
_last_fragment_granule(UINTPTR_MAX) {
}
typedef ObjectBitSet<mtTracing> JFRBitSet;

BitSet::~BitSet() {
BitMapFragment* current = _fragment_list;
while (current != NULL) {
BitMapFragment* next = current->next();
delete current;
current = next;
}
}
#endif // SHARE_JFR_LEAKPROFILER_JFRBITMAP_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
#include "gc/shared/gc_globals.hpp"
#include "jfr/leakprofiler/leakProfiler.hpp"
#include "jfr/leakprofiler/chains/bfsClosure.hpp"
#include "jfr/leakprofiler/chains/bitset.inline.hpp"
#include "jfr/leakprofiler/chains/dfsClosure.hpp"
#include "jfr/leakprofiler/chains/edge.hpp"
#include "jfr/leakprofiler/chains/edgeQueue.hpp"
#include "jfr/leakprofiler/chains/edgeStore.hpp"
#include "jfr/leakprofiler/chains/jfrbitset.hpp"
#include "jfr/leakprofiler/chains/objectSampleMarker.hpp"
#include "jfr/leakprofiler/chains/rootSetClosure.hpp"
#include "jfr/leakprofiler/chains/edgeStore.hpp"
Expand Down Expand Up @@ -84,7 +84,7 @@ void PathToGcRootsOperation::doit() {
assert(_cutoff_ticks > 0, "invariant");

// The bitset used for marking is dimensioned as a function of the heap size
BitSet mark_bits;
JFRBitSet mark_bits;

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

1 comment on commit abfd2f9

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.