7007068: G1: refine the BOT during evac failure handling
Summary: During evacuation failure handling we refine the BOT to reflect the location of all the objects in the regions we scan. The changeset includes some minor cleanup: a) non-product print_on() method on the G1 BOT class, b) added more complete BOT verification during heap / region verification, c) slight modification to the BOT set up for humongous regions to be more consistent with the BOT set up during evac failure handling, and d) removed a couple of unused methods.
Reviewed-by: johnc, ysr
--- a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp Thu Jan 06 23:50:02 2011 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp Wed Jan 12 13:06:00 2011 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -222,7 +222,7 @@
// Action_mark - update the BOT for the block [blk_start, blk_end).
// Current typical use is for splitting a block.
-// Action_single - udpate the BOT for an allocation.
+// Action_single - update the BOT for an allocation.
// Action_verify - BOT verification.
void G1BlockOffsetArray::do_block_internal(HeapWord* blk_start,
HeapWord* blk_end,
@@ -331,47 +331,6 @@
do_block_internal(blk_start, blk_end, Action_mark);
}
-void G1BlockOffsetArray::join_blocks(HeapWord* blk1, HeapWord* blk2) {
- HeapWord* blk1_start = Universe::heap()->block_start(blk1);
- HeapWord* blk2_start = Universe::heap()->block_start(blk2);
- assert(blk1 == blk1_start && blk2 == blk2_start,
- "Must be block starts.");
- assert(blk1 + _sp->block_size(blk1) == blk2, "Must be contiguous.");
- size_t blk1_start_index = _array->index_for(blk1);
- size_t blk2_start_index = _array->index_for(blk2);
- assert(blk1_start_index <= blk2_start_index, "sanity");
- HeapWord* blk2_card_start = _array->address_for_index(blk2_start_index);
- if (blk2 == blk2_card_start) {
- // blk2 starts a card. Does blk1 start on the prevous card, or futher
- // back?
- assert(blk1_start_index < blk2_start_index, "must be lower card.");
- if (blk1_start_index + 1 == blk2_start_index) {
- // previous card; new value for blk2 card is size of blk1.
- _array->set_offset_array(blk2_start_index, (u_char) _sp->block_size(blk1));
- } else {
- // Earlier card; go back a card.
- _array->set_offset_array(blk2_start_index, N_words);
- }
- } else {
- // blk2 does not start a card. Does it cross a card? If not, nothing
- // to do.
- size_t blk2_end_index =
- _array->index_for(blk2 + _sp->block_size(blk2) - 1);
- assert(blk2_end_index >= blk2_start_index, "sanity");
- if (blk2_end_index > blk2_start_index) {
- // Yes, it crosses a card. The value for the next card must change.
- if (blk1_start_index + 1 == blk2_start_index) {
- // previous card; new value for second blk2 card is size of blk1.
- _array->set_offset_array(blk2_start_index + 1,
- (u_char) _sp->block_size(blk1));
- } else {
- // Earlier card; go back a card.
- _array->set_offset_array(blk2_start_index + 1, N_words);
- }
- }
- }
-}
-
HeapWord* G1BlockOffsetArray::block_start_unsafe(const void* addr) {
assert(_bottom <= addr && addr < _end,
"addr must be covered by this Array");
@@ -580,15 +539,50 @@
#endif
}
-void
-G1BlockOffsetArray::set_for_starts_humongous(HeapWord* new_end) {
- assert(_end == new_end, "_end should have already been updated");
+bool
+G1BlockOffsetArray::verify_for_object(HeapWord* obj_start,
+ size_t word_size) const {
+ size_t first_card = _array->index_for(obj_start);
+ size_t last_card = _array->index_for(obj_start + word_size - 1);
+ if (!_array->is_card_boundary(obj_start)) {
+ // If the object is not on a card boundary the BOT entry of the
+ // first card should point to another object so we should not
+ // check that one.
+ first_card += 1;
+ }
+ for (size_t card = first_card; card <= last_card; card += 1) {
+ HeapWord* card_addr = _array->address_for_index(card);
+ HeapWord* block_start = block_start_const(card_addr);
+ if (block_start != obj_start) {
+ gclog_or_tty->print_cr("block start: "PTR_FORMAT" is incorrect - "
+ "card index: "SIZE_FORMAT" "
+ "card addr: "PTR_FORMAT" BOT entry: %u "
+ "obj: "PTR_FORMAT" word size: "SIZE_FORMAT" "
+ "cards: ["SIZE_FORMAT","SIZE_FORMAT"]",
+ block_start, card, card_addr,
+ _array->offset_array(card),
+ obj_start, word_size, first_card, last_card);
+ return false;
+ }
+ }
+ return true;
+}
- // The first BOT entry should have offset 0.
- _array->set_offset_array(_array->index_for(_bottom), 0);
- // The rest should point to the first one.
- set_remainder_to_point_to_start(_bottom + N_words, new_end);
+#ifndef PRODUCT
+void
+G1BlockOffsetArray::print_on(outputStream* out) {
+ size_t from_index = _array->index_for(_bottom);
+ size_t to_index = _array->index_for(_end);
+ out->print_cr(">> BOT for area ["PTR_FORMAT","PTR_FORMAT") "
+ "cards ["SIZE_FORMAT","SIZE_FORMAT")",
+ _bottom, _end, from_index, to_index);
+ for (size_t i = from_index; i < to_index; ++i) {
+ out->print_cr(" entry "SIZE_FORMAT_W(8)" | "PTR_FORMAT" : %3u",
+ i, _array->address_for_index(i),
+ (uint) _array->offset_array(i));
+ }
}
+#endif // !PRODUCT
//////////////////////////////////////////////////////////////////////
// G1BlockOffsetArrayContigSpace
@@ -641,10 +635,20 @@
}
void
-G1BlockOffsetArrayContigSpace::set_for_starts_humongous(HeapWord* new_end) {
- G1BlockOffsetArray::set_for_starts_humongous(new_end);
+G1BlockOffsetArrayContigSpace::set_for_starts_humongous(HeapWord* new_top) {
+ assert(new_top <= _end, "_end should have already been updated");
+
+ // The first BOT entry should have offset 0.
+ zero_bottom_entry();
+ initialize_threshold();
+ alloc_block(_bottom, new_top);
+ }
- // Make sure _next_offset_threshold and _next_offset_index point to new_end.
- _next_offset_threshold = new_end;
- _next_offset_index = _array->index_for(new_end);
+#ifndef PRODUCT
+void
+G1BlockOffsetArrayContigSpace::print_on(outputStream* out) {
+ G1BlockOffsetArray::print_on(out);
+ out->print_cr(" next offset threshold: "PTR_FORMAT, _next_offset_threshold);
+ out->print_cr(" next offset index: "SIZE_FORMAT, _next_offset_index);
}
+#endif // !PRODUCT
--- a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp Thu Jan 06 23:50:02 2011 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp Wed Jan 12 13:06:00 2011 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -352,11 +352,6 @@
// The following methods are useful and optimized for a
// general, non-contiguous space.
- // The given arguments are required to be the starts of adjacent ("blk1"
- // before "blk2") well-formed blocks covered by "this". After this call,
- // they should be considered to form one block.
- virtual void join_blocks(HeapWord* blk1, HeapWord* blk2);
-
// Given a block [blk_start, blk_start + full_blk_size), and
// a left_blk_size < full_blk_size, adjust the BOT to show two
// blocks [blk_start, blk_start + left_blk_size) and
@@ -429,6 +424,12 @@
verify_single_block(blk, blk + size);
}
+ // Used by region verification. Checks that the contents of the
+ // BOT reflect that there's a single object that spans the address
+ // range [obj_start, obj_start + word_size); returns true if this is
+ // the case, returns false if it's not.
+ bool verify_for_object(HeapWord* obj_start, size_t word_size) const;
+
// Verify that the given block is before _unallocated_block
inline void verify_not_unallocated(HeapWord* blk_start,
HeapWord* blk_end) const {
@@ -444,7 +445,7 @@
void check_all_cards(size_t left_card, size_t right_card) const;
- virtual void set_for_starts_humongous(HeapWord* new_end);
+ virtual void print_on(outputStream* out) PRODUCT_RETURN;
};
// A subtype of BlockOffsetArray that takes advantage of the fact
@@ -494,7 +495,9 @@
HeapWord* block_start_unsafe(const void* addr);
HeapWord* block_start_unsafe_const(const void* addr) const;
- virtual void set_for_starts_humongous(HeapWord* new_end);
+ void set_for_starts_humongous(HeapWord* new_top);
+
+ virtual void print_on(outputStream* out) PRODUCT_RETURN;
};
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_HPP
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Thu Jan 06 23:50:02 2011 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Wed Jan 12 13:06:00 2011 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -3856,13 +3856,15 @@
size_t _next_marked_bytes;
OopsInHeapRegionClosure *_cl;
public:
- RemoveSelfPointerClosure(G1CollectedHeap* g1, OopsInHeapRegionClosure* cl) :
- _g1(g1), _cm(_g1->concurrent_mark()), _prev_marked_bytes(0),
+ RemoveSelfPointerClosure(G1CollectedHeap* g1, HeapRegion* hr,
+ OopsInHeapRegionClosure* cl) :
+ _g1(g1), _hr(hr), _cm(_g1->concurrent_mark()), _prev_marked_bytes(0),
_next_marked_bytes(0), _cl(cl) {}
size_t prev_marked_bytes() { return _prev_marked_bytes; }
size_t next_marked_bytes() { return _next_marked_bytes; }
+ // <original comment>
// The original idea here was to coalesce evacuated and dead objects.
// However that caused complications with the block offset table (BOT).
// In particular if there were two TLABs, one of them partially refined.
@@ -3871,15 +3873,24 @@
// of TLAB_2. If the last object of the TLAB_1 and the first object
// of TLAB_2 are coalesced, then the cards of the unrefined part
// would point into middle of the filler object.
+ // The current approach is to not coalesce and leave the BOT contents intact.
+ // </original comment>
//
- // The current approach is to not coalesce and leave the BOT contents intact.
+ // We now reset the BOT when we start the object iteration over the
+ // region and refine its entries for every object we come across. So
+ // the above comment is not really relevant and we should be able
+ // to coalesce dead objects if we want to.
void do_object(oop obj) {
+ HeapWord* obj_addr = (HeapWord*) obj;
+ assert(_hr->is_in(obj_addr), "sanity");
+ size_t obj_size = obj->size();
+ _hr->update_bot_for_object(obj_addr, obj_size);
if (obj->is_forwarded() && obj->forwardee() == obj) {
// The object failed to move.
assert(!_g1->is_obj_dead(obj), "We should not be preserving dead objs.");
_cm->markPrev(obj);
assert(_cm->isPrevMarked(obj), "Should be marked!");
- _prev_marked_bytes += (obj->size() * HeapWordSize);
+ _prev_marked_bytes += (obj_size * HeapWordSize);
if (_g1->mark_in_progress() && !_g1->is_obj_ill(obj)) {
_cm->markAndGrayObjectIfNecessary(obj);
}
@@ -3901,7 +3912,7 @@
} else {
// The object has been either evacuated or is dead. Fill it with a
// dummy object.
- MemRegion mr((HeapWord*)obj, obj->size());
+ MemRegion mr((HeapWord*)obj, obj_size);
CollectedHeap::fill_with_object(mr);
_cm->clearRangeBothMaps(mr);
}
@@ -3921,10 +3932,13 @@
HeapRegion* cur = g1_policy()->collection_set();
while (cur != NULL) {
assert(g1_policy()->assertMarkedBytesDataOK(), "Should be!");
-
- RemoveSelfPointerClosure rspc(_g1h, cl);
+ assert(!cur->isHumongous(), "sanity");
+
if (cur->evacuation_failed()) {
assert(cur->in_collection_set(), "bad CS");
+ RemoveSelfPointerClosure rspc(_g1h, cur, cl);
+
+ cur->reset_bot();
cl->set_region(cur);
cur->object_iterate(&rspc);
@@ -3989,15 +4003,6 @@
}
}
-void G1CollectedHeap::handle_evacuation_failure(oop old) {
- markOop m = old->mark();
- // forward to self
- assert(!old->is_forwarded(), "precondition");
-
- old->forward_to(old);
- handle_evacuation_failure_common(old, m);
-}
-
oop
G1CollectedHeap::handle_evacuation_failure_par(OopsInHeapRegionClosure* cl,
oop old) {
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Thu Jan 06 23:50:02 2011 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Wed Jan 12 13:06:00 2011 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -826,7 +826,6 @@
void finalize_for_evac_failure();
// An attempt to evacuate "obj" has failed; take necessary steps.
- void handle_evacuation_failure(oop obj);
oop handle_evacuation_failure_par(OopsInHeapRegionClosure* cl, oop obj);
void handle_evacuation_failure_common(oop obj, markOop m);
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp Thu Jan 06 23:50:02 2011 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp Wed Jan 12 13:06:00 2011 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -386,26 +386,27 @@
}
// </PREDICTION>
-void HeapRegion::set_startsHumongous(HeapWord* new_end) {
+void HeapRegion::set_startsHumongous(HeapWord* new_top, HeapWord* new_end) {
assert(end() == _orig_end,
"Should be normal before the humongous object allocation");
assert(top() == bottom(), "should be empty");
+ assert(bottom() <= new_top && new_top <= new_end, "pre-condition");
_humongous_type = StartsHumongous;
_humongous_start_region = this;
set_end(new_end);
- _offsets.set_for_starts_humongous(new_end);
+ _offsets.set_for_starts_humongous(new_top);
}
-void HeapRegion::set_continuesHumongous(HeapRegion* start) {
+void HeapRegion::set_continuesHumongous(HeapRegion* first_hr) {
assert(end() == _orig_end,
"Should be normal before the humongous object allocation");
assert(top() == bottom(), "should be empty");
- assert(start->startsHumongous(), "pre-condition");
+ assert(first_hr->startsHumongous(), "pre-condition");
_humongous_type = ContinuesHumongous;
- _humongous_start_region = start;
+ _humongous_start_region = first_hr;
}
bool HeapRegion::claimHeapRegion(jint claimValue) {
@@ -782,9 +783,6 @@
verify(allow_dirty, /* use_prev_marking */ true, /* failures */ &dummy);
}
-#define OBJ_SAMPLE_INTERVAL 0
-#define BLOCK_SAMPLE_INTERVAL 100
-
// This really ought to be commoned up into OffsetTableContigSpace somehow.
// We would need a mechanism to make that code skip dead objects.
@@ -795,83 +793,125 @@
*failures = false;
HeapWord* p = bottom();
HeapWord* prev_p = NULL;
- int objs = 0;
- int blocks = 0;
VerifyLiveClosure vl_cl(g1, use_prev_marking);
bool is_humongous = isHumongous();
+ bool do_bot_verify = !is_young();
size_t object_num = 0;
while (p < top()) {
- size_t size = oop(p)->size();
- if (is_humongous != g1->isHumongous(size)) {
+ oop obj = oop(p);
+ size_t obj_size = obj->size();
+ object_num += 1;
+
+ if (is_humongous != g1->isHumongous(obj_size)) {
gclog_or_tty->print_cr("obj "PTR_FORMAT" is of %shumongous size ("
SIZE_FORMAT" words) in a %shumongous region",
- p, g1->isHumongous(size) ? "" : "non-",
- size, is_humongous ? "" : "non-");
+ p, g1->isHumongous(obj_size) ? "" : "non-",
+ obj_size, is_humongous ? "" : "non-");
*failures = true;
+ return;
+ }
+
+ // If it returns false, verify_for_object() will output the
+ // appropriate messasge.
+ if (do_bot_verify && !_offsets.verify_for_object(p, obj_size)) {
+ *failures = true;
+ return;
}
- object_num += 1;
- if (blocks == BLOCK_SAMPLE_INTERVAL) {
- HeapWord* res = block_start_const(p + (size/2));
- if (p != res) {
- gclog_or_tty->print_cr("offset computation 1 for "PTR_FORMAT" and "
- SIZE_FORMAT" returned "PTR_FORMAT,
- p, size, res);
+
+ if (!g1->is_obj_dead_cond(obj, this, use_prev_marking)) {
+ if (obj->is_oop()) {
+ klassOop klass = obj->klass();
+ if (!klass->is_perm()) {
+ gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" "
+ "not in perm", klass, obj);
+ *failures = true;
+ return;
+ } else if (!klass->is_klass()) {
+ gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" "
+ "not a klass", klass, obj);
+ *failures = true;
+ return;
+ } else {
+ vl_cl.set_containing_obj(obj);
+ obj->oop_iterate(&vl_cl);
+ if (vl_cl.failures()) {
+ *failures = true;
+ }
+ if (G1MaxVerifyFailures >= 0 &&
+ vl_cl.n_failures() >= G1MaxVerifyFailures) {
+ return;
+ }
+ }
+ } else {
+ gclog_or_tty->print_cr(PTR_FORMAT" no an oop", obj);
*failures = true;
return;
}
- blocks = 0;
- } else {
- blocks++;
- }
- if (objs == OBJ_SAMPLE_INTERVAL) {
- oop obj = oop(p);
- if (!g1->is_obj_dead_cond(obj, this, use_prev_marking)) {
- if (obj->is_oop()) {
- klassOop klass = obj->klass();
- if (!klass->is_perm()) {
- gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" "
- "not in perm", klass, obj);
- *failures = true;
- return;
- } else if (!klass->is_klass()) {
- gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" "
- "not a klass", klass, obj);
- *failures = true;
- return;
- } else {
- vl_cl.set_containing_obj(obj);
- obj->oop_iterate(&vl_cl);
- if (vl_cl.failures()) {
- *failures = true;
- }
- if (G1MaxVerifyFailures >= 0 &&
- vl_cl.n_failures() >= G1MaxVerifyFailures) {
- return;
- }
- }
- } else {
- gclog_or_tty->print_cr(PTR_FORMAT" no an oop", obj);
- *failures = true;
- return;
- }
- }
- objs = 0;
- } else {
- objs++;
}
prev_p = p;
- p += size;
+ p += obj_size;
+ }
+
+ if (p != top()) {
+ gclog_or_tty->print_cr("end of last object "PTR_FORMAT" "
+ "does not match top "PTR_FORMAT, p, top());
+ *failures = true;
+ return;
}
- HeapWord* rend = end();
- HeapWord* rtop = top();
- if (rtop < rend) {
- HeapWord* res = block_start_const(rtop + (rend - rtop) / 2);
- if (res != rtop) {
- gclog_or_tty->print_cr("offset computation 2 for "PTR_FORMAT" and "
- PTR_FORMAT" returned "PTR_FORMAT,
- rtop, rend, res);
+
+ HeapWord* the_end = end();
+ assert(p == top(), "it should still hold");
+ // Do some extra BOT consistency checking for addresses in the
+ // range [top, end). BOT look-ups in this range should yield
+ // top. No point in doing that if top == end (there's nothing there).
+ if (p < the_end) {
+ // Look up top
+ HeapWord* addr_1 = p;
+ HeapWord* b_start_1 = _offsets.block_start_const(addr_1);
+ if (b_start_1 != p) {
+ gclog_or_tty->print_cr("BOT look up for top: "PTR_FORMAT" "
+ " yielded "PTR_FORMAT", expecting "PTR_FORMAT,
+ addr_1, b_start_1, p);
+ *failures = true;
+ return;
+ }
+
+ // Look up top + 1
+ HeapWord* addr_2 = p + 1;
+ if (addr_2 < the_end) {
+ HeapWord* b_start_2 = _offsets.block_start_const(addr_2);
+ if (b_start_2 != p) {
+ gclog_or_tty->print_cr("BOT look up for top + 1: "PTR_FORMAT" "
+ " yielded "PTR_FORMAT", expecting "PTR_FORMAT,
+ addr_2, b_start_2, p);
*failures = true;
return;
+ }
+ }
+
+ // Look up an address between top and end
+ size_t diff = pointer_delta(the_end, p) / 2;
+ HeapWord* addr_3 = p + diff;
+ if (addr_3 < the_end) {
+ HeapWord* b_start_3 = _offsets.block_start_const(addr_3);
+ if (b_start_3 != p) {
+ gclog_or_tty->print_cr("BOT look up for top + diff: "PTR_FORMAT" "
+ " yielded "PTR_FORMAT", expecting "PTR_FORMAT,
+ addr_3, b_start_3, p);
+ *failures = true;
+ return;
+ }
+ }
+
+ // Loook up end - 1
+ HeapWord* addr_4 = the_end - 1;
+ HeapWord* b_start_4 = _offsets.block_start_const(addr_4);
+ if (b_start_4 != p) {
+ gclog_or_tty->print_cr("BOT look up for end - 1: "PTR_FORMAT" "
+ " yielded "PTR_FORMAT", expecting "PTR_FORMAT,
+ addr_4, b_start_4, p);
+ *failures = true;
+ return;
}
}
@@ -880,12 +920,6 @@
"but has "SIZE_FORMAT", objects",
bottom(), end(), object_num);
*failures = true;
- }
-
- if (p != top()) {
- gclog_or_tty->print_cr("end of last object "PTR_FORMAT" "
- "does not match top "PTR_FORMAT, p, top());
- *failures = true;
return;
}
}
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp Thu Jan 06 23:50:02 2011 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp Wed Jan 12 13:06:00 2011 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -173,6 +173,19 @@
virtual HeapWord* cross_threshold(HeapWord* start, HeapWord* end);
virtual void print() const;
+
+ void reset_bot() {
+ _offsets.zero_bottom_entry();
+ _offsets.initialize_threshold();
+ }
+
+ void update_bot_for_object(HeapWord* start, size_t word_size) {
+ _offsets.alloc_block(start, word_size);
+ }
+
+ void print_bot_on(outputStream* out) {
+ _offsets.print_on(out);
+ }
};
class HeapRegion: public G1OffsetTableContigSpace {
@@ -404,13 +417,35 @@
return _humongous_start_region;
}
- // Causes the current region to represent a humongous object spanning "n"
- // regions.
- void set_startsHumongous(HeapWord* new_end);
+ // Makes the current region be a "starts humongous" region, i.e.,
+ // the first region in a series of one or more contiguous regions
+ // that will contain a single "humongous" object. The two parameters
+ // are as follows:
+ //
+ // new_top : The new value of the top field of this region which
+ // points to the end of the humongous object that's being
+ // allocated. If there is more than one region in the series, top
+ // will lie beyond this region's original end field and on the last
+ // region in the series.
+ //
+ // new_end : The new value of the end field of this region which
+ // points to the end of the last region in the series. If there is
+ // one region in the series (namely: this one) end will be the same
+ // as the original end of this region.
+ //
+ // Updating top and end as described above makes this region look as
+ // if it spans the entire space taken up by all the regions in the
+ // series and an single allocation moved its top to new_top. This
+ // ensures that the space (capacity / allocated) taken up by all
+ // humongous regions can be calculated by just looking at the
+ // "starts humongous" regions and by ignoring the "continues
+ // humongous" regions.
+ void set_startsHumongous(HeapWord* new_top, HeapWord* new_end);
- // The regions that continue a humongous sequence should be added using
- // this method, in increasing address order.
- void set_continuesHumongous(HeapRegion* start);
+ // Makes the current region be a "continues humongous'
+ // region. first_hr is the "start humongous" region of the series
+ // which this region will be part of.
+ void set_continuesHumongous(HeapRegion* first_hr);
// If the region has a remembered set, return a pointer to it.
HeapRegionRemSet* rem_set() const {
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp Thu Jan 06 23:50:02 2011 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp Wed Jan 12 13:06:00 2011 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -144,7 +144,7 @@
// will also update the BOT covering all the regions to reflect
// that there is a single object that starts at the bottom of the
// first region.
- first_hr->set_startsHumongous(new_end);
+ first_hr->set_startsHumongous(new_top, new_end);
// Then, if there are any, we will set up the "continues
// humongous" regions.