1 /* |
1 /* |
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
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. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
26 #include "gc/g1/g1CollectedHeap.inline.hpp" |
26 #include "gc/g1/g1CollectedHeap.inline.hpp" |
27 #include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp" |
27 #include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp" |
28 #include "gc/g1/heapRegion.hpp" |
28 #include "gc/g1/heapRegion.hpp" |
29 #include "memory/virtualspace.hpp" |
29 #include "memory/virtualspace.hpp" |
30 |
30 |
31 void G1CMBitMap::print_on_error(outputStream* st, const char* prefix) const { |
|
32 _bm.print_on_error(st, prefix); |
|
33 } |
|
34 |
|
35 size_t G1CMBitMap::compute_size(size_t heap_size) { |
|
36 return ReservedSpace::allocation_align_size_up(heap_size / mark_distance()); |
|
37 } |
|
38 |
|
39 size_t G1CMBitMap::mark_distance() { |
|
40 return MinObjAlignmentInBytes * BitsPerByte; |
|
41 } |
|
42 |
|
43 void G1CMBitMap::initialize(MemRegion heap, G1RegionToSpaceMapper* storage) { |
31 void G1CMBitMap::initialize(MemRegion heap, G1RegionToSpaceMapper* storage) { |
44 _covered = heap; |
32 MarkBitMap::initialize(heap, storage->reserved()); |
45 |
|
46 _bm = BitMapView((BitMap::bm_word_t*) storage->reserved().start(), _covered.word_size() >> _shifter); |
|
47 |
|
48 storage->set_mapping_changed_listener(&_listener); |
33 storage->set_mapping_changed_listener(&_listener); |
49 } |
34 } |
50 |
35 |
51 void G1CMBitMapMappingChangedListener::on_commit(uint start_region, size_t num_regions, bool zero_filled) { |
36 void G1CMBitMapMappingChangedListener::on_commit(uint start_region, size_t num_regions, bool zero_filled) { |
52 if (zero_filled) { |
37 if (zero_filled) { |
55 // We need to clear the bitmap on commit, removing any existing information. |
40 // We need to clear the bitmap on commit, removing any existing information. |
56 MemRegion mr(G1CollectedHeap::heap()->bottom_addr_for_region(start_region), num_regions * HeapRegion::GrainWords); |
41 MemRegion mr(G1CollectedHeap::heap()->bottom_addr_for_region(start_region), num_regions * HeapRegion::GrainWords); |
57 _bm->clear_range(mr); |
42 _bm->clear_range(mr); |
58 } |
43 } |
59 |
44 |
60 void G1CMBitMap::clear_range(MemRegion mr) { |
|
61 MemRegion intersection = mr.intersection(_covered); |
|
62 assert(!intersection.is_empty(), |
|
63 "Given range from " PTR_FORMAT " to " PTR_FORMAT " is completely outside the heap", |
|
64 p2i(mr.start()), p2i(mr.end())); |
|
65 // convert address range into offset range |
|
66 _bm.at_put_range(addr_to_offset(intersection.start()), |
|
67 addr_to_offset(intersection.end()), false); |
|
68 } |
|
69 |
|
70 void G1CMBitMap::clear_region(HeapRegion* region) { |
45 void G1CMBitMap::clear_region(HeapRegion* region) { |
71 if (!region->is_empty()) { |
46 if (!region->is_empty()) { |
72 MemRegion mr(region->bottom(), region->top()); |
47 MemRegion mr(region->bottom(), region->top()); |
73 clear_range(mr); |
48 clear_range(mr); |
74 } |
49 } |
75 } |
50 } |
|
51 |
|
52 #ifdef ASSERT |
|
53 void 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 |