1 /* |
|
2 * Copyright (c) 2016, 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 #ifndef SHARE_VM_GC_G1_G1CARDLIVEDATA_HPP |
|
26 #define SHARE_VM_GC_G1_G1CARDLIVEDATA_HPP |
|
27 |
|
28 #include "gc/g1/g1CollectedHeap.hpp" |
|
29 #include "utilities/bitMap.hpp" |
|
30 #include "utilities/globalDefinitions.hpp" |
|
31 |
|
32 class G1CollectedHeap; |
|
33 class G1CMBitMap; |
|
34 class WorkGang; |
|
35 |
|
36 // Information about object liveness on the Java heap on a "card" basis. |
|
37 // Can be used for various purposes, like as remembered set for completely |
|
38 // coarsened remembered sets, scrubbing remembered sets or estimating liveness. |
|
39 // This information is created as part of the concurrent marking cycle. |
|
40 class G1CardLiveData { |
|
41 friend class G1CardLiveDataHelper; |
|
42 friend class G1VerifyCardLiveDataTask; |
|
43 private: |
|
44 typedef BitMap::bm_word_t bm_word_t; |
|
45 // Store some additional information about the covered area to be able to test. |
|
46 size_t _max_capacity; |
|
47 size_t _cards_per_region; |
|
48 |
|
49 // Regions may be reclaimed while concurrently creating live data (e.g. due to humongous |
|
50 // eager reclaim). This results in wrong live data for these regions at the end. |
|
51 // So we need to somehow detect these regions, and during live data finalization completely |
|
52 // recreate their information. |
|
53 // This _gc_timestamp_at_create tracks the global timestamp when live data creation |
|
54 // has started. Any regions with a higher time stamp have been cleared after that |
|
55 // point in time, and need re-finalization. |
|
56 // Unsynchronized access to this variable is okay, since this value is only set during a |
|
57 // concurrent phase, and read only at the Cleanup safepoint. I.e. there is always |
|
58 // full memory synchronization inbetween. |
|
59 uint _gc_timestamp_at_create; |
|
60 // The per-card liveness bitmap. |
|
61 bm_word_t* _live_cards; |
|
62 size_t _live_cards_size_in_bits; |
|
63 // The per-region liveness bitmap. |
|
64 bm_word_t* _live_regions; |
|
65 size_t _live_regions_size_in_bits; |
|
66 // The bits in this bitmap contain for every card whether it contains |
|
67 // at least part of at least one live object. |
|
68 BitMapView live_cards_bm() const { return BitMapView(_live_cards, _live_cards_size_in_bits); } |
|
69 // The bits in this bitmap indicate that a given region contains some live objects. |
|
70 BitMapView live_regions_bm() const { return BitMapView(_live_regions, _live_regions_size_in_bits); } |
|
71 |
|
72 // Allocate a "large" bitmap from virtual memory with the given size in bits. |
|
73 bm_word_t* allocate_large_bitmap(size_t size_in_bits); |
|
74 void free_large_bitmap(bm_word_t* map, size_t size_in_bits); |
|
75 |
|
76 inline BitMapView live_card_bitmap(uint region); |
|
77 |
|
78 inline bool is_card_live_at(BitMap::idx_t idx) const; |
|
79 |
|
80 size_t live_region_bitmap_size_in_bits() const; |
|
81 size_t live_card_bitmap_size_in_bits() const; |
|
82 public: |
|
83 uint gc_timestamp_at_create() const { return _gc_timestamp_at_create; } |
|
84 |
|
85 inline bool is_region_live(uint region) const; |
|
86 |
|
87 inline void remove_nonlive_cards(uint region, BitMap* bm); |
|
88 inline void remove_nonlive_regions(BitMap* bm); |
|
89 |
|
90 G1CardLiveData(); |
|
91 ~G1CardLiveData(); |
|
92 |
|
93 void initialize(size_t max_capacity, uint num_max_regions); |
|
94 void pretouch(); |
|
95 |
|
96 // Create the initial liveness data based on the marking result from the bottom |
|
97 // to the ntams of every region in the heap and the marks in the given bitmap. |
|
98 void create(WorkGang* workers, G1CMBitMap* mark_bitmap); |
|
99 // Finalize the liveness data. |
|
100 void finalize(WorkGang* workers, G1CMBitMap* mark_bitmap); |
|
101 |
|
102 // Verify that the liveness count data created concurrently matches one created |
|
103 // during this safepoint. |
|
104 void verify(WorkGang* workers, G1CMBitMap* actual_bitmap); |
|
105 // Clear all data structures, prepare for next processing. |
|
106 void clear(WorkGang* workers); |
|
107 |
|
108 void verify_is_clear() PRODUCT_RETURN; |
|
109 }; |
|
110 |
|
111 #endif /* SHARE_VM_GC_G1_G1CARDLIVEDATA_HPP */ |
|
112 |
|