1 /*
2 * Copyright (c) 2001, 2014, 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 *
98 int CMBitMapRO::heapWordDiffToOffsetDiff(size_t diff) const {
99 assert((diff & ((1 << _shifter) - 1)) == 0, "argument check");
100 return (int) (diff >> _shifter);
101 }
102
103 #ifndef PRODUCT
104 bool CMBitMapRO::covers(MemRegion heap_rs) const {
105 // assert(_bm.map() == _virtual_space.low(), "map inconsistency");
106 assert(((size_t)_bm.size() * ((size_t)1 << _shifter)) == _bmWordSize,
107 "size inconsistency");
108 return _bmStartWord == (HeapWord*)(heap_rs.start()) &&
109 _bmWordSize == heap_rs.word_size();
110 }
111 #endif
112
113 void CMBitMapRO::print_on_error(outputStream* st, const char* prefix) const {
114 _bm.print_on_error(st, prefix);
115 }
116
117 size_t CMBitMap::compute_size(size_t heap_size) {
118 return heap_size / mark_distance();
119 }
120
121 size_t CMBitMap::mark_distance() {
122 return MinObjAlignmentInBytes * BitsPerByte;
123 }
124
125 void CMBitMap::initialize(MemRegion heap, G1RegionToSpaceMapper* storage) {
126 _bmStartWord = heap.start();
127 _bmWordSize = heap.word_size();
128
129 _bm.set_map((BitMap::bm_word_t*) storage->reserved().start());
130 _bm.set_size(_bmWordSize >> _shifter);
131
132 storage->set_mapping_changed_listener(&_listener);
133 }
134
135 void CMBitMapMappingChangedListener::on_commit(uint start_region, size_t num_regions, bool zero_filled) {
136 if (zero_filled) {
137 return;
138 }
|
1 /*
2 * Copyright (c) 2001, 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 *
98 int CMBitMapRO::heapWordDiffToOffsetDiff(size_t diff) const {
99 assert((diff & ((1 << _shifter) - 1)) == 0, "argument check");
100 return (int) (diff >> _shifter);
101 }
102
103 #ifndef PRODUCT
104 bool CMBitMapRO::covers(MemRegion heap_rs) const {
105 // assert(_bm.map() == _virtual_space.low(), "map inconsistency");
106 assert(((size_t)_bm.size() * ((size_t)1 << _shifter)) == _bmWordSize,
107 "size inconsistency");
108 return _bmStartWord == (HeapWord*)(heap_rs.start()) &&
109 _bmWordSize == heap_rs.word_size();
110 }
111 #endif
112
113 void CMBitMapRO::print_on_error(outputStream* st, const char* prefix) const {
114 _bm.print_on_error(st, prefix);
115 }
116
117 size_t CMBitMap::compute_size(size_t heap_size) {
118 return ReservedSpace::allocation_align_size_up(heap_size / mark_distance());
119 }
120
121 size_t CMBitMap::mark_distance() {
122 return MinObjAlignmentInBytes * BitsPerByte;
123 }
124
125 void CMBitMap::initialize(MemRegion heap, G1RegionToSpaceMapper* storage) {
126 _bmStartWord = heap.start();
127 _bmWordSize = heap.word_size();
128
129 _bm.set_map((BitMap::bm_word_t*) storage->reserved().start());
130 _bm.set_size(_bmWordSize >> _shifter);
131
132 storage->set_mapping_changed_listener(&_listener);
133 }
134
135 void CMBitMapMappingChangedListener::on_commit(uint start_region, size_t num_regions, bool zero_filled) {
136 if (zero_filled) {
137 return;
138 }
|