Mercurial > hg > truffle
diff src/share/vm/gc_implementation/g1/heapRegionSet.cpp @ 2432:455328d90876
7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
Summary: What the synopsis says.
Reviewed-by: jwilhelm, iveresov, johnc
author | tonyp |
---|---|
date | Tue, 29 Mar 2011 22:36:16 -0400 |
parents | 1216415d8e35 |
children | 8aae2050e83e |
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/g1/heapRegionSet.cpp Mon Mar 28 10:58:54 2011 -0700 +++ b/src/share/vm/gc_implementation/g1/heapRegionSet.cpp Tue Mar 29 22:36:16 2011 -0400 @@ -261,6 +261,45 @@ msg->append(" hd: "PTR_FORMAT" tl: "PTR_FORMAT, head(), tail()); } +void HeapRegionLinkedList::add_as_head(HeapRegionLinkedList* from_list) { + hrs_assert_mt_safety_ok(this); + hrs_assert_mt_safety_ok(from_list); + + verify_optional(); + from_list->verify_optional(); + + if (from_list->is_empty()) return; + +#ifdef ASSERT + HeapRegionLinkedListIterator iter(from_list); + while (iter.more_available()) { + HeapRegion* hr = iter.get_next(); + // In set_containing_set() we check that we either set the value + // from NULL to non-NULL or vice versa to catch bugs. So, we have + // to NULL it first before setting it to the value. + hr->set_containing_set(NULL); + hr->set_containing_set(this); + } +#endif // ASSERT + + if (_head != NULL) { + assert(length() > 0 && _tail != NULL, hrs_ext_msg(this, "invariant")); + from_list->_tail->set_next(_head); + } else { + assert(length() == 0 && _head == NULL, hrs_ext_msg(this, "invariant")); + _tail = from_list->_tail; + } + _head = from_list->_head; + + _length += from_list->length(); + _region_num += from_list->region_num(); + _total_used_bytes += from_list->total_used_bytes(); + from_list->clear(); + + verify_optional(); + from_list->verify_optional(); +} + void HeapRegionLinkedList::add_as_tail(HeapRegionLinkedList* from_list) { hrs_assert_mt_safety_ok(this); hrs_assert_mt_safety_ok(from_list);