1/*
2 * Copyright (c) 2017, 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/g1/g1CollectedHeap.inline.hpp"
27#include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp"
28#include "gc/g1/heapRegion.hpp"
29#include "memory/virtualspace.hpp"
30
31void G1CMBitMap::initialize(MemRegion heap, G1RegionToSpaceMapper* storage) {
32 MarkBitMap::initialize(heap, storage->reserved());
33 storage->set_mapping_changed_listener(&_listener);
34}
35
36void G1CMBitMapMappingChangedListener::on_commit(uint start_region, size_t num_regions, bool zero_filled) {
37 if (zero_filled) {
38 return;
39 }
40 // We need to clear the bitmap on commit, removing any existing information.
41 MemRegion mr(G1CollectedHeap::heap()->bottom_addr_for_region(start_region), num_regions * HeapRegion::GrainWords);
42 _bm->clear_range(mr);
43}
44
45void G1CMBitMap::clear_region(HeapRegion* region) {
46 if (!region->is_empty()) {
47 MemRegion mr(region->bottom(), region->top());
48 clear_range(mr);
49 }
50}
51
52#ifdef ASSERT
53void G1CMBitMap::check_mark(HeapWord* addr) {
54 assert(G1CollectedHeap::heap()->is_in_exact(addr),
55 "Trying to access bitmap " PTR_FORMAT " for address " PTR_FORMAT " not in the heap.",
56 p2i(this), p2i(addr));
57}
58#endif
59