inlinevoid HeapRegionSetBase::add(HeapRegion* hr) {
check_mt_safety();
assert_heap_region_set(hr->containing_set() == NULL, "should not already have a containing set");
assert_heap_region_set(hr->next() == NULL, "should not already be linked");
assert_heap_region_set(hr->prev() == NULL, "should not already be linked");
if (_head != NULL) { // Link into list, next is already NULL, no need to set.
region_to_add->set_prev(_tail);
_tail->set_next(region_to_add);
_tail = region_to_add;
} else { // Empty list, this region is now the list.
_head = region_to_add;
_tail = region_to_add;
}
increase_length(region_to_add->node_index());
}
// Find first entry with a Region Index larger than entry to insert. while (curr != NULL && curr->hrm_index() < hr->hrm_index()) {
curr = curr->next();
}
hr->set_next(curr);
if (curr == NULL) { // Adding at the end
hr->set_prev(_tail);
_tail->set_next(hr);
_tail = hr;
} elseif (curr->prev() == NULL) { // Adding at the beginning
hr->set_prev(NULL);
_head = hr;
curr->set_prev(hr);
} else {
hr->set_prev(curr->prev());
hr->prev()->set_next(hr);
curr->set_prev(hr);
}
} else { // The list was empty
_tail = hr;
_head = hr;
}
_last = hr;
// Find the region to use, searching from _head or _tail as requested.
size_t cur_depth = 0; if (from_head) { for (cur = _head;
cur != NULL && cur_depth < max_search_depth;
cur = cur->next(), ++cur_depth) { if (requested_node_index == cur->node_index()) { break;
}
}
} else { for (cur = _tail;
cur != NULL && cur_depth < max_search_depth;
cur = cur->prev(), ++cur_depth) { if (requested_node_index == cur->node_index()) { break;
}
}
}
// Didn't find a region to use. if (cur == NULL || cur_depth >= max_search_depth) { return NULL;
}
// Splice the region out of the list.
HeapRegion* prev = cur->prev();
HeapRegion* next = cur->next(); if (prev == NULL) {
_head = next;
} else {
prev->set_next(next);
} if (next == NULL) {
_tail = prev;
} else {
next->set_prev(prev);
}
cur->set_prev(NULL);
cur->set_next(NULL);
inlinevoid FreeRegionList::NodeInfo::decrease_length(uint node_index) { if (node_index < _num_nodes) {
assert(_length_of_node[node_index] > 0, "Current length %u should be greater than zero for node %u",
_length_of_node[node_index], node_index);
_length_of_node[node_index] -= 1;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.