Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8292170: Convert CodeRootSetTable to use ResourceHashtable #11675

Closed
wants to merge 13 commits into from
Closed
7 changes: 4 additions & 3 deletions src/hotspot/share/gc/g1/g1CodeCacheRemSet.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
@@ -75,7 +75,7 @@ void G1CodeRootSetTable::nmethods_do(CodeBlobClosure* blk) {

template<typename CB>
void G1CodeRootSetTable::remove_if(CB& should_remove) {
_table.unlink_destruct([&](nmethod* nm, nmethod* nm2){ return should_remove(nm);});
_table.unlink(&should_remove);
}

G1CodeRootSet::~G1CodeRootSet() {
@@ -180,6 +180,7 @@ void G1CodeRootSet::nmethods_do(CodeBlobClosure* blk) const {
}

class CleanCallback : public StackObj {
NONCOPYABLE(CleanCallback); // can not copy, _blobs will point to old copy
class PointsIntoHRDetectionClosure : public OopClosure {
HeapRegion* _hr;
public:
@@ -208,7 +209,7 @@ class CleanCallback : public StackObj {
public:
CleanCallback(HeapRegion* hr) : _detector(hr), _blobs(&_detector, !CodeBlobToOopClosure::FixRelocations) {}

bool operator() (nmethod* nm) {
bool do_entry(nmethod* nm, nmethod* _) {
_detector._points_into = false;
_blobs.do_code_blob(nm);
return !_detector._points_into;
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1CodeCacheRemSet.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1CodeRootSetTable.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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
2 changes: 1 addition & 1 deletion src/hotspot/share/utilities/resizeableResourceHash.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 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
30 changes: 0 additions & 30 deletions src/hotspot/share/utilities/resourceHash.hpp
Original file line number Diff line number Diff line change
@@ -274,36 +274,6 @@ class ResourceHashtableBase : public STORAGE {
}
}

// The argument should_remove() have the signature: bool Function(K const&, V const&).
// The predicate should_remove() will be called for each entry in the table.
// If should_remove() returns true, the element will be removed from the table.
// If the Node is C_HEAP allocated the entry is deleted, else the destructor
// of the Node will be called. Unlike unlink (above), this method uses a functor
// interface and will call the destructor of the Node, and thus the destructor
// of the element (even if the Node is resource allocated).
template<typename Function>
void unlink_destruct(Function&& should_remove) {
const unsigned sz = table_size();
for (unsigned index = 0; index < sz; index++) {
Node** ptr = bucket_at(index);
while (*ptr != nullptr) {
Node* node = *ptr;
bool clean = should_remove(node->_key, node->_value);
if (clean) {
*ptr = node->_next;
if (ALLOC_TYPE == AnyObj::C_HEAP) {
delete node;
} else {
node->~Node();
}
_number_of_entries --;
} else {
ptr = &(node->_next);
}
}
}
}

template<typename Function>
TableStatistics statistics_calculate(Function size_function) const {
NumberSeq summary;