/* * Copyright (c) 2017, 2022, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
// 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);
}
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.