| 1 | /* |
| 2 | * Copyright (c) 2017, 2019, 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 | #ifndef SHARE_GC_G1_G1CONCURRENTMARKBITMAP_HPP |
| 26 | #define SHARE_GC_G1_G1CONCURRENTMARKBITMAP_HPP |
| 27 | |
| 28 | #include "gc/g1/g1RegionToSpaceMapper.hpp" |
| 29 | #include "gc/shared/markBitMap.hpp" |
| 30 | #include "memory/memRegion.hpp" |
| 31 | #include "oops/oopsHierarchy.hpp" |
| 32 | #include "utilities/bitMap.hpp" |
| 33 | #include "utilities/globalDefinitions.hpp" |
| 34 | #include "utilities/macros.hpp" |
| 35 | |
| 36 | class G1CMBitMap; |
| 37 | class G1CMTask; |
| 38 | class G1ConcurrentMark; |
| 39 | class HeapRegion; |
| 40 | |
| 41 | // Closure for iteration over bitmaps |
| 42 | class G1CMBitMapClosure { |
| 43 | G1ConcurrentMark* const _cm; |
| 44 | G1CMTask* const _task; |
| 45 | public: |
| 46 | G1CMBitMapClosure(G1CMTask *task, G1ConcurrentMark* cm) : _cm(cm), _task(task) { } |
| 47 | |
| 48 | bool do_addr(HeapWord* const addr); |
| 49 | }; |
| 50 | |
| 51 | class G1CMBitMapMappingChangedListener : public G1MappingChangedListener { |
| 52 | G1CMBitMap* _bm; |
| 53 | public: |
| 54 | G1CMBitMapMappingChangedListener() : _bm(NULL) {} |
| 55 | |
| 56 | void set_bitmap(G1CMBitMap* bm) { _bm = bm; } |
| 57 | |
| 58 | virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled); |
| 59 | }; |
| 60 | |
| 61 | // A generic mark bitmap for concurrent marking. This is essentially a wrapper |
| 62 | // around the BitMap class that is based on HeapWords, with one bit per (1 << _shifter) HeapWords. |
| 63 | class G1CMBitMap : public MarkBitMap { |
| 64 | |
| 65 | G1CMBitMapMappingChangedListener _listener; |
| 66 | |
| 67 | protected: |
| 68 | |
| 69 | virtual void check_mark(HeapWord* addr) NOT_DEBUG_RETURN; |
| 70 | |
| 71 | public: |
| 72 | |
| 73 | G1CMBitMap() : MarkBitMap(), _listener() { _listener.set_bitmap(this); } |
| 74 | |
| 75 | // Initializes the underlying BitMap to cover the given area. |
| 76 | void initialize(MemRegion heap, G1RegionToSpaceMapper* storage); |
| 77 | |
| 78 | // Apply the closure to the addresses that correspond to marked bits in the bitmap. |
| 79 | inline bool iterate(G1CMBitMapClosure* cl, MemRegion mr); |
| 80 | |
| 81 | void clear_region(HeapRegion* hr); |
| 82 | }; |
| 83 | |
| 84 | #endif // SHARE_GC_G1_G1CONCURRENTMARKBITMAP_HPP |
| 85 | |