void pop_back() { if (back) { nrex_node* old = back; if (!old->previous) { childset.pop(); } if (mode != Bracket) { increment_length(old->length, true); } back = old->previous; NREX_DELETE(old); } }
void add_child(nrex_node* node) { node->parent = this; node->previous = back; if (back && mode != Bracket) { back->next = node; } else { childset.push(node); } if (mode != Bracket) { increment_length(node->length); } back = node; }
MemRegion HeapRegionSeq::expand_by(HeapWord* old_end, HeapWord* new_end, FreeRegionList* list) { assert(old_end < new_end, "don't call it otherwise"); G1CollectedHeap* g1h = G1CollectedHeap::heap(); HeapWord* next_bottom = old_end; assert(heap_bottom() <= next_bottom, "invariant"); while (next_bottom < new_end) { assert(next_bottom < heap_end(), "invariant"); uint index = length(); assert(index < max_length(), "otherwise we cannot expand further"); if (index == 0) { // We have not allocated any regions so far assert(next_bottom == heap_bottom(), "invariant"); } else { // next_bottom should match the end of the last/previous region assert(next_bottom == at(index - 1)->end(), "invariant"); } if (index == _allocated_length) { // We have to allocate a new HeapRegion. HeapRegion* new_hr = g1h->new_heap_region(index, next_bottom); if (new_hr == NULL) { // allocation failed, we bail out and return what we have done so far return MemRegion(old_end, next_bottom); } assert(_regions.get_by_index(index) == NULL, "invariant"); _regions.set_by_index(index, new_hr); increment_allocated_length(); } // Have to increment the length first, otherwise we will get an // assert failure at(index) below. increment_length(); HeapRegion* hr = at(index); list->add_as_tail(hr); next_bottom = hr->end(); } assert(next_bottom == new_end, "post-condition"); return MemRegion(old_end, next_bottom); }
nrex_node* swap_back(nrex_node* node) { if (!back) { add_child(node); return NULL; } nrex_node* old = back; if (!old->previous) { childset.pop(); } if (mode != Bracket) { increment_length(old->length, true); } back = old->previous; add_child(node); return old; }