1 | /* |
2 | * Copyright (c) 2015, 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 | #ifndef SHARE_GC_Z_ZLIVEMAP_HPP |
25 | #define SHARE_GC_Z_ZLIVEMAP_HPP |
26 | |
27 | #include "gc/z/zBitMap.hpp" |
28 | #include "memory/allocation.hpp" |
29 | |
30 | class ObjectClosure; |
31 | |
32 | class ZLiveMap { |
33 | friend class ZLiveMapTest; |
34 | |
35 | private: |
36 | static const size_t nsegments = 64; |
37 | |
38 | volatile uint32_t _seqnum; |
39 | volatile uint32_t _live_objects; |
40 | volatile size_t _live_bytes; |
41 | BitMap::bm_word_t _segment_live_bits; |
42 | BitMap::bm_word_t _segment_claim_bits; |
43 | ZBitMap _bitmap; |
44 | size_t _segment_shift; |
45 | |
46 | const BitMapView segment_live_bits() const; |
47 | const BitMapView segment_claim_bits() const; |
48 | |
49 | BitMapView segment_live_bits(); |
50 | BitMapView segment_claim_bits(); |
51 | |
52 | BitMap::idx_t segment_size() const; |
53 | |
54 | BitMap::idx_t segment_start(BitMap::idx_t segment) const; |
55 | BitMap::idx_t segment_end(BitMap::idx_t segment) const; |
56 | |
57 | bool is_segment_live(BitMap::idx_t segment) const; |
58 | bool set_segment_live_atomic(BitMap::idx_t segment); |
59 | |
60 | BitMap::idx_t first_live_segment() const; |
61 | BitMap::idx_t next_live_segment(BitMap::idx_t segment) const; |
62 | BitMap::idx_t index_to_segment(BitMap::idx_t index) const; |
63 | |
64 | bool claim_segment(BitMap::idx_t segment); |
65 | |
66 | void reset(size_t index); |
67 | void reset_segment(BitMap::idx_t segment); |
68 | |
69 | void iterate_segment(ObjectClosure* cl, BitMap::idx_t segment, uintptr_t page_start, size_t page_object_alignment_shift); |
70 | |
71 | public: |
72 | ZLiveMap(uint32_t size); |
73 | |
74 | void reset(); |
75 | void resize(uint32_t size); |
76 | |
77 | bool is_marked() const; |
78 | |
79 | uint32_t live_objects() const; |
80 | size_t live_bytes() const; |
81 | |
82 | bool get(size_t index) const; |
83 | bool set_atomic(size_t index, bool finalizable, bool& inc_live); |
84 | |
85 | void inc_live_atomic(uint32_t objects, size_t bytes); |
86 | |
87 | void iterate(ObjectClosure* cl, uintptr_t page_start, size_t page_object_alignment_shift); |
88 | }; |
89 | |
90 | #endif // SHARE_GC_Z_ZLIVEMAP_HPP |
91 | |