Skip to content

Commit

Permalink
[Backport] 8283710: JVMTI: Use BitSet for object marking
Browse files Browse the repository at this point in the history
Summary: JVMTI: Use BitSet for object marking. Backport for lilliput project.

Test Plan: CICD

Reviewed-by: ddh, yanglong

Issue: #704
  • Loading branch information
mmyxym committed Nov 6, 2023
1 parent b28ebaf commit e0c2ae0
Show file tree
Hide file tree
Showing 12 changed files with 408 additions and 309 deletions.
3 changes: 1 addition & 2 deletions src/hotspot/share/jfr/leakprofiler/chains/bfsClosure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*
*/
#include "precompiled.hpp"
#include "jfr/leakprofiler/chains/bitset.hpp"
#include "jfr/leakprofiler/chains/bfsClosure.hpp"
#include "jfr/leakprofiler/chains/dfsClosure.hpp"
#include "jfr/leakprofiler/chains/edge.hpp"
Expand All @@ -37,7 +36,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,9 +25,9 @@
#ifndef SHARE_VM_JFR_LEAKPROFILER_CHAINS_BFSCLOSURE_HPP
#define SHARE_VM_JFR_LEAKPROFILER_CHAINS_BFSCLOSURE_HPP

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

class BitSet;
class Edge;
class EdgeStore;
class EdgeQueue;
Expand All @@ -37,7 +37,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 @@ -62,7 +62,7 @@ class BFSClosure : public BasicOopIterateClosure {
void process_queue();

public:
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(const oop* ref);

Expand Down
58 changes: 0 additions & 58 deletions src/hotspot/share/jfr/leakprofiler/chains/bitset.cpp

This file was deleted.

79 changes: 0 additions & 79 deletions src/hotspot/share/jfr/leakprofiler/chains/bitset.hpp

This file was deleted.

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.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 @@ -41,7 +41,7 @@
static const size_t max_dfs_depth = 5000;

EdgeStore* DFSClosure::_edge_store = NULL;
BitSet* DFSClosure::_mark_bits = NULL;
JFRBitSet* DFSClosure::_mark_bits = NULL;
const Edge* DFSClosure::_start_edge = NULL;
size_t DFSClosure::_max_depth = max_dfs_depth;
bool DFSClosure::_ignore_root_set = false;
Expand All @@ -59,7 +59,7 @@ DFSClosure::DFSClosure(DFSClosure* parent, size_t 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 @@ -77,7 +77,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 Down
8 changes: 4 additions & 4 deletions src/hotspot/share/jfr/leakprofiler/chains/dfsClosure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
#ifndef SHARE_VM_JFR_LEAKPROFILER_CHAINS_DFSCLOSURE_HPP
#define SHARE_VM_JFR_LEAKPROFILER_CHAINS_DFSCLOSURE_HPP

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

class BitSet;
class Edge;
class EdgeStore;
class EdgeQueue;
Expand All @@ -36,7 +36,7 @@ class EdgeQueue;
class DFSClosure : public BasicOopIterateClosure {
private:
static EdgeStore* _edge_store;
static BitSet* _mark_bits;
static JFRBitSet* _mark_bits;
static const Edge*_start_edge;
static size_t _max_depth;
static bool _ignore_root_set;
Expand All @@ -54,8 +54,8 @@ class DFSClosure : public BasicOopIterateClosure {
DFSClosure();

public:
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(const oop* ref);

virtual void do_oop(oop* ref);
Expand Down
33 changes: 33 additions & 0 deletions src/hotspot/share/jfr/leakprofiler/chains/jfrbitset.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/

#ifndef SHARE_JFR_LEAKPROFILER_JFRBITMAP_HPP
#define SHARE_JFR_LEAKPROFILER_JFRBITMAP_HPP

#include "memory/allocation.hpp"
#include "utilities/objectBitSet.inline.hpp"

typedef ObjectBitSet<mtInternal> JFRBitSet;

#endif // SHARE_JFR_LEAKPROFILER_JFRBITMAP_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "gc/shared/collectedHeap.hpp"
#include "jfr/leakprofiler/leakProfiler.hpp"
#include "jfr/leakprofiler/chains/bfsClosure.hpp"
#include "jfr/leakprofiler/chains/bitset.hpp"
#include "jfr/leakprofiler/chains/dfsClosure.hpp"
#include "jfr/leakprofiler/chains/edge.hpp"
#include "jfr/leakprofiler/chains/edgeQueue.hpp"
Expand Down Expand Up @@ -84,7 +83,7 @@ void PathToGcRootsOperation::doit() {

// The bitset used for marking is dimensioned as a function of the heap size
const MemRegion heap_region = Universe::heap()->reserved_region();
BitSet mark_bits(heap_region);
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(heap_region);
Expand All @@ -93,7 +92,7 @@ void PathToGcRootsOperation::doit() {
// The initialize() routines will attempt to reserve and allocate backing storage memory.
// Failure to accommodate will render root chain processing impossible.
// As a fallback on failure, just write out the existing samples, flat, without chains.
if (!(mark_bits.initialize() && edge_queue.initialize())) {
if (!edge_queue.initialize()) {
log_warning(jfr)("Unable to allocate memory for root chain processing");
return;
}
Expand Down
Loading

0 comments on commit e0c2ae0

Please sign in to comment.