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 *
126 HeapRegion* new_hr = new_heap_region(i);
127 _regions.set_by_index(i, new_hr);
128 _allocated_heapregions_length = MAX2(_allocated_heapregions_length, i + 1);
129 }
130 }
131
132 _available_map.par_set_range(start, start + num_regions, BitMap::unknown_range);
133
134 for (uint i = start; i < start + num_regions; i++) {
135 assert(is_available(i), err_msg("Just made region %u available but is apparently not.", i));
136 HeapRegion* hr = at(i);
137 if (G1CollectedHeap::heap()->hr_printer()->is_active()) {
138 G1CollectedHeap::heap()->hr_printer()->commit(hr->bottom(), hr->end());
139 }
140 HeapWord* bottom = G1CollectedHeap::heap()->bottom_addr_for_region(i);
141 MemRegion mr(bottom, bottom + HeapRegion::GrainWords);
142
143 hr->initialize(mr);
144 insert_into_free_list(at(i));
145 }
146 }
147
148 uint HeapRegionManager::expand_by(uint num_regions) {
149 return expand_at(0, num_regions);
150 }
151
152 uint HeapRegionManager::expand_at(uint start, uint num_regions) {
153 if (num_regions == 0) {
154 return 0;
155 }
156
157 uint cur = start;
158 uint idx_last_found = 0;
159 uint num_last_found = 0;
160
161 uint expanded = 0;
162
163 while (expanded < num_regions &&
164 (num_last_found = find_unavailable_from_idx(cur, &idx_last_found)) > 0) {
165 uint to_expand = MIN2(num_regions - expanded, num_last_found);
|
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 *
126 HeapRegion* new_hr = new_heap_region(i);
127 _regions.set_by_index(i, new_hr);
128 _allocated_heapregions_length = MAX2(_allocated_heapregions_length, i + 1);
129 }
130 }
131
132 _available_map.par_set_range(start, start + num_regions, BitMap::unknown_range);
133
134 for (uint i = start; i < start + num_regions; i++) {
135 assert(is_available(i), err_msg("Just made region %u available but is apparently not.", i));
136 HeapRegion* hr = at(i);
137 if (G1CollectedHeap::heap()->hr_printer()->is_active()) {
138 G1CollectedHeap::heap()->hr_printer()->commit(hr->bottom(), hr->end());
139 }
140 HeapWord* bottom = G1CollectedHeap::heap()->bottom_addr_for_region(i);
141 MemRegion mr(bottom, bottom + HeapRegion::GrainWords);
142
143 hr->initialize(mr);
144 insert_into_free_list(at(i));
145 }
146 }
147
148 MemoryUsage HeapRegionManager::get_auxiliary_data_memory_usage() const {
149 size_t used_sz =
150 _prev_bitmap_mapper->committed_size() +
151 _next_bitmap_mapper->committed_size() +
152 _bot_mapper->committed_size() +
153 _cardtable_mapper->committed_size() +
154 _card_counts_mapper->committed_size(),
155
156 committed_sz =
157 _prev_bitmap_mapper->reserved_size() +
158 _next_bitmap_mapper->reserved_size() +
159 _bot_mapper->reserved_size() +
160 _cardtable_mapper->reserved_size() +
161 _card_counts_mapper->reserved_size();
162 return MemoryUsage(0, used_sz, committed_sz, committed_sz);
163 }
164
165 uint HeapRegionManager::expand_by(uint num_regions) {
166 return expand_at(0, num_regions);
167 }
168
169 uint HeapRegionManager::expand_at(uint start, uint num_regions) {
170 if (num_regions == 0) {
171 return 0;
172 }
173
174 uint cur = start;
175 uint idx_last_found = 0;
176 uint num_last_found = 0;
177
178 uint expanded = 0;
179
180 while (expanded < num_regions &&
181 (num_last_found = find_unavailable_from_idx(cur, &idx_last_found)) > 0) {
182 uint to_expand = MIN2(num_regions - expanded, num_last_found);
|