annotate src/hotspot/share/gc/shared/markBitMap.cpp @ 52321:31b159f30fb2

8180193: Make marking bitmap code available to other GCs Reviewed-by: shade, stefank
author rkennke
date Wed, 29 Aug 2018 20:15:09 +0200
parents
children 5b87d3fc1093
rev   line source
rkennke@52321 1 /*
rkennke@52321 2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
rkennke@52321 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
rkennke@52321 4 *
rkennke@52321 5 * This code is free software; you can redistribute it and/or modify it
rkennke@52321 6 * under the terms of the GNU General Public License version 2 only, as
rkennke@52321 7 * published by the Free Software Foundation.
rkennke@52321 8 *
rkennke@52321 9 * This code is distributed in the hope that it will be useful, but WITHOUT
rkennke@52321 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
rkennke@52321 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
rkennke@52321 12 * version 2 for more details (a copy is included in the LICENSE file that
rkennke@52321 13 * accompanied this code).
rkennke@52321 14 *
rkennke@52321 15 * You should have received a copy of the GNU General Public License version
rkennke@52321 16 * 2 along with this work; if not, write to the Free Software Foundation,
rkennke@52321 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
rkennke@52321 18 *
rkennke@52321 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
rkennke@52321 20 * or visit www.oracle.com if you need additional information or have any
rkennke@52321 21 * questions.
rkennke@52321 22 *
rkennke@52321 23 */
rkennke@52321 24
rkennke@52321 25 #include "precompiled.hpp"
rkennke@52321 26 #include "gc/shared/markBitMap.inline.hpp"
rkennke@52321 27 #include "memory/virtualspace.hpp"
rkennke@52321 28
rkennke@52321 29 void MarkBitMap::print_on_error(outputStream* st, const char* prefix) const {
rkennke@52321 30 _bm.print_on_error(st, prefix);
rkennke@52321 31 }
rkennke@52321 32
rkennke@52321 33 size_t MarkBitMap::compute_size(size_t heap_size) {
rkennke@52321 34 return ReservedSpace::allocation_align_size_up(heap_size / mark_distance());
rkennke@52321 35 }
rkennke@52321 36
rkennke@52321 37 size_t MarkBitMap::mark_distance() {
rkennke@52321 38 return MinObjAlignmentInBytes * BitsPerByte;
rkennke@52321 39 }
rkennke@52321 40
rkennke@52321 41 void MarkBitMap::initialize(MemRegion heap, MemRegion storage) {
rkennke@52321 42 _covered = heap;
rkennke@52321 43
rkennke@52321 44 _bm = BitMapView((BitMap::bm_word_t*) storage.start(), _covered.word_size() >> _shifter);
rkennke@52321 45 }
rkennke@52321 46
rkennke@52321 47 void MarkBitMap::clear_range(MemRegion mr) {
rkennke@52321 48 MemRegion intersection = mr.intersection(_covered);
rkennke@52321 49 assert(!intersection.is_empty(),
rkennke@52321 50 "Given range from " PTR_FORMAT " to " PTR_FORMAT " is completely outside the heap",
rkennke@52321 51 p2i(mr.start()), p2i(mr.end()));
rkennke@52321 52 // convert address range into offset range
rkennke@52321 53 _bm.at_put_range(addr_to_offset(intersection.start()),
rkennke@52321 54 addr_to_offset(intersection.end()), false);
rkennke@52321 55 }
rkennke@52321 56
rkennke@52321 57 #ifdef ASSERT
rkennke@52321 58 void MarkBitMap::check_mark(HeapWord* addr) {
rkennke@52321 59 assert(Universe::heap()->is_in_reserved(addr),
rkennke@52321 60 "Trying to access bitmap " PTR_FORMAT " for address " PTR_FORMAT " not in the heap.",
rkennke@52321 61 p2i(this), p2i(addr));
rkennke@52321 62 }
rkennke@52321 63 #endif