// Using region 0 for testing.
HeapRegion* region = heap->heap_region_containing(heap->bottom_addr_for_region(0));
// Mark some "oops" in the bitmap.
G1CMBitMap* bitmap = heap->concurrent_mark()->mark_bitmap();
bitmap->par_mark(region->bottom());
bitmap->par_mark(region->bottom() + MARK_OFFSET_1);
bitmap->par_mark(region->bottom() + MARK_OFFSET_2);
bitmap->par_mark(region->bottom() + MARK_OFFSET_3);
bitmap->par_mark(region->end());
VerifyAndCountMarkClosure cl(bitmap);
HeapWord* old_top = region->top();
// When top is equal to bottom the closure should not be // applied to any object because apply_to_marked_objects // will stop at HeapRegion::scan_limit which is equal to top.
region->set_top(region->bottom());
region->apply_to_marked_objects(bitmap, &cl);
EXPECT_EQ(0, cl.count());
cl.reset();
// Set top to offset_1 and expect only to find 1 entry (bottom)
region->set_top(region->bottom() + MARK_OFFSET_1);
region->apply_to_marked_objects(bitmap, &cl);
EXPECT_EQ(1, cl.count());
cl.reset();
// Set top to (offset_2 + 1) and expect only to find 3 // entries (bottom, offset_1 and offset_2)
region->set_top(region->bottom() + MARK_OFFSET_2 + MinObjAlignment);
region->apply_to_marked_objects(bitmap, &cl);
EXPECT_EQ(3, cl.count());
cl.reset();
// Still expect same 3 entries when top is (offset_3 - 1)
region->set_top(region->bottom() + MARK_OFFSET_3 - MinObjAlignment);
region->apply_to_marked_objects(bitmap, &cl);
EXPECT_EQ(3, cl.count());
cl.reset();
// Setting top to end should render 4 entries.
region->set_top(region->end());
region->apply_to_marked_objects(bitmap, &cl);
EXPECT_EQ(4, cl.count());
cl.reset();
region->set_top(old_top);
}
TEST_VM(HeapRegion, apply_to_marked_object) { if (!UseG1GC) { return;
}
// Run the test in our very own safepoint, because otherwise it // modifies a region behind the back of a possibly using allocation // or running GC.
VM_HeapRegionApplyToMarkedObjectsTest op;
ThreadInVMfromNative invm(JavaThread::current());
VMThread::execute(&op);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-06-11)
¤
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.