comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:a45e2698295e
1 /*
2 * Copyright (c) 2018, 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 #include "precompiled.hpp"
26 #include "gc/shared/markBitMap.inline.hpp"
27 #include "memory/virtualspace.hpp"
28
29 void MarkBitMap::print_on_error(outputStream* st, const char* prefix) const {
30 _bm.print_on_error(st, prefix);
31 }
32
33 size_t MarkBitMap::compute_size(size_t heap_size) {
34 return ReservedSpace::allocation_align_size_up(heap_size / mark_distance());
35 }
36
37 size_t MarkBitMap::mark_distance() {
38 return MinObjAlignmentInBytes * BitsPerByte;
39 }
40
41 void MarkBitMap::initialize(MemRegion heap, MemRegion storage) {
42 _covered = heap;
43
44 _bm = BitMapView((BitMap::bm_word_t*) storage.start(), _covered.word_size() >> _shifter);
45 }
46
47 void MarkBitMap::clear_range(MemRegion mr) {
48 MemRegion intersection = mr.intersection(_covered);
49 assert(!intersection.is_empty(),
50 "Given range from " PTR_FORMAT " to " PTR_FORMAT " is completely outside the heap",
51 p2i(mr.start()), p2i(mr.end()));
52 // convert address range into offset range
53 _bm.at_put_range(addr_to_offset(intersection.start()),
54 addr_to_offset(intersection.end()), false);
55 }
56
57 #ifdef ASSERT
58 void MarkBitMap::check_mark(HeapWord* addr) {
59 assert(Universe::heap()->is_in_reserved(addr),
60 "Trying to access bitmap " PTR_FORMAT " for address " PTR_FORMAT " not in the heap.",
61 p2i(this), p2i(addr));
62 }
63 #endif