1 /* 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 // Concurrent marking bit map wrapper 26 27 #include "precompiled.hpp" 28 #include "gc_implementation/shared/markBitMap.inline.hpp" 29 #include "utilities/bitMap.inline.hpp" 30 31 MarkBitMapRO::MarkBitMapRO(int shifter) : 32 _bm(), 33 _shifter(shifter) { 34 _bmStartWord = 0; 35 _bmWordSize = 0; 36 } 37 38 #ifndef PRODUCT 39 bool MarkBitMapRO::covers(MemRegion heap_rs) const { 40 // assert(_bm.map() == _virtual_space.low(), "map inconsistency"); 41 assert(((size_t)_bm.size() * ((size_t)1 << _shifter)) == _bmWordSize, 42 "size inconsistency"); 43 return _bmStartWord == (HeapWord*)(heap_rs.start()) && 44 _bmWordSize == heap_rs.word_size(); 45 } 46 #endif 47 48 void MarkBitMapRO::print_on_error(outputStream* st, const char* prefix) const { 49 _bm.print_on_error(st, prefix); 50 } 51 52 size_t MarkBitMap::compute_size(size_t heap_size) { 53 return ReservedSpace::allocation_align_size_up(heap_size / mark_distance()); 54 } 55 56 size_t MarkBitMap::mark_distance() { 57 return MinObjAlignmentInBytes * BitsPerByte; 58 } 59 60 void MarkBitMap::initialize(MemRegion heap, MemRegion bitmap) { 61 _bmStartWord = heap.start(); 62 _bmWordSize = heap.word_size(); 63 64 _bm.set_map((BitMap::bm_word_t*) bitmap.start()); 65 _bm.set_size(_bmWordSize >> _shifter); 66 _covered = heap; 67 } 68 69 void MarkBitMap::do_clear(MemRegion mr, bool large) { 70 MemRegion intersection = mr.intersection(_covered); 71 assert(!intersection.is_empty(), 72 err_msg("Given range from " PTR_FORMAT " to " PTR_FORMAT " is completely outside the heap", 73 p2i(mr.start()), p2i(mr.end()))); 74 // convert address range into offset range 75 size_t beg = heapWordToOffset(intersection.start()); 76 size_t end = heapWordToOffset(intersection.end()); 77 if (large) { 78 _bm.clear_large_range(beg, end); 79 } else { 80 _bm.clear_range(beg, end); 81 } 82 }