Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/hotspot/share/utilities/rbTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,13 @@ class AbstractRBTree {

// Inserts the given node into the tree.
void insert(const K& key, NodeType* node, const NodeType* hint_node = nullptr) {
assert(node != nullptr, "must be");
Cursor node_cursor = cursor(key, hint_node);
insert_at_cursor(node, node_cursor);
}

void remove(NodeType* node) {
assert(node != nullptr, "must be");
Cursor node_cursor = cursor(node);
remove_at_cursor(node_cursor);
}
Expand Down Expand Up @@ -472,6 +474,8 @@ class RBTree : public AbstractRBTree<K, RBNode<K, V>, COMPARATOR> {
using BaseType::prev;

void replace_at_cursor(RBNode<K, V>* new_node, const Cursor& node_cursor) {
assert(new_node != nullptr, "must be");
assert(node_cursor.valid() && node_cursor.found(), "must be");
RBNode<K, V>* old_node = node_cursor.node();
BaseType::replace_at_cursor(new_node, node_cursor);
free_node(old_node);
Expand All @@ -494,6 +498,7 @@ class RBTree : public AbstractRBTree<K, RBNode<K, V>, COMPARATOR> {
}

void free_node(RBNode<K, V>* node) {
assert(node != nullptr, "must be");
node->_value.~V();
_allocator.free(node);
}
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/utilities/rbTree.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ AbstractRBTree<K, NodeType, COMPARATOR>::cursor(const K& key, const NodeType* hi

template <typename K, typename NodeType, typename COMPARATOR>
inline void AbstractRBTree<K, NodeType, COMPARATOR>::insert_at_cursor(NodeType* node, const Cursor& node_cursor) {
assert(node != nullptr, "must be");
assert(node_cursor.valid() && !node_cursor.found(), "must be");
_num_nodes++;

Expand Down Expand Up @@ -543,6 +544,7 @@ AbstractRBTree<K, NodeType, COMPARATOR>::prev(const Cursor& node_cursor) const {

template <typename K, typename NodeType, typename COMPARATOR>
inline void AbstractRBTree<K, NodeType, COMPARATOR>::replace_at_cursor(NodeType* new_node, const Cursor& node_cursor) {
assert(new_node != nullptr, "must be");
assert(node_cursor.valid() && node_cursor.found(), "must be");
NodeType* old_node = node_cursor.node();
if (old_node == new_node) {
Expand Down