Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/shared/markBitMap.cpp
38921 views
/*1* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324// Concurrent marking bit map wrapper2526#include "precompiled.hpp"27#include "gc_implementation/shared/markBitMap.inline.hpp"28#include "utilities/bitMap.inline.hpp"2930MarkBitMapRO::MarkBitMapRO(int shifter) :31_bm(),32_shifter(shifter) {33_bmStartWord = 0;34_bmWordSize = 0;35}3637#ifndef PRODUCT38bool MarkBitMapRO::covers(MemRegion heap_rs) const {39// assert(_bm.map() == _virtual_space.low(), "map inconsistency");40assert(((size_t)_bm.size() * ((size_t)1 << _shifter)) == _bmWordSize,41"size inconsistency");42return _bmStartWord == (HeapWord*)(heap_rs.start()) &&43_bmWordSize == heap_rs.word_size();44}45#endif4647void MarkBitMapRO::print_on_error(outputStream* st, const char* prefix) const {48_bm.print_on_error(st, prefix);49}5051size_t MarkBitMap::compute_size(size_t heap_size) {52return ReservedSpace::allocation_align_size_up(heap_size / mark_distance());53}5455size_t MarkBitMap::mark_distance() {56return MinObjAlignmentInBytes * BitsPerByte;57}5859void MarkBitMap::initialize(MemRegion heap, MemRegion bitmap) {60_bmStartWord = heap.start();61_bmWordSize = heap.word_size();6263_bm.set_map((BitMap::bm_word_t*) bitmap.start());64_bm.set_size(_bmWordSize >> _shifter);65_covered = heap;66}6768void MarkBitMap::do_clear(MemRegion mr, bool large) {69MemRegion intersection = mr.intersection(_covered);70assert(!intersection.is_empty(),71err_msg("Given range from " PTR_FORMAT " to " PTR_FORMAT " is completely outside the heap",72p2i(mr.start()), p2i(mr.end())));73// convert address range into offset range74size_t beg = heapWordToOffset(intersection.start());75size_t end = heapWordToOffset(intersection.end());76if (large) {77_bm.clear_large_range(beg, end);78} else {79_bm.clear_range(beg, end);80}81}828384