24 |
24 |
25 #ifndef SHARE_VM_GC_G1_G1CONCURRENTMARKBITMAP_HPP |
25 #ifndef SHARE_VM_GC_G1_G1CONCURRENTMARKBITMAP_HPP |
26 #define SHARE_VM_GC_G1_G1CONCURRENTMARKBITMAP_HPP |
26 #define SHARE_VM_GC_G1_G1CONCURRENTMARKBITMAP_HPP |
27 |
27 |
28 #include "gc/g1/g1RegionToSpaceMapper.hpp" |
28 #include "gc/g1/g1RegionToSpaceMapper.hpp" |
|
29 #include "gc/shared/markBitMap.hpp" |
29 #include "memory/memRegion.hpp" |
30 #include "memory/memRegion.hpp" |
30 #include "oops/oopsHierarchy.hpp" |
31 #include "oops/oopsHierarchy.hpp" |
31 #include "utilities/bitMap.hpp" |
32 #include "utilities/bitMap.hpp" |
32 #include "utilities/globalDefinitions.hpp" |
33 #include "utilities/globalDefinitions.hpp" |
33 #include "utilities/macros.hpp" |
34 #include "utilities/macros.hpp" |
57 virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled); |
58 virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled); |
58 }; |
59 }; |
59 |
60 |
60 // A generic mark bitmap for concurrent marking. This is essentially a wrapper |
61 // A generic mark bitmap for concurrent marking. This is essentially a wrapper |
61 // around the BitMap class that is based on HeapWords, with one bit per (1 << _shifter) HeapWords. |
62 // around the BitMap class that is based on HeapWords, with one bit per (1 << _shifter) HeapWords. |
62 class G1CMBitMap { |
63 class G1CMBitMap : public MarkBitMap { |
63 MemRegion _covered; // The heap area covered by this bitmap. |
|
64 |
|
65 const int _shifter; // Shift amount from heap index to bit index in the bitmap. |
|
66 |
|
67 BitMapView _bm; // The actual bitmap. |
|
68 |
64 |
69 G1CMBitMapMappingChangedListener _listener; |
65 G1CMBitMapMappingChangedListener _listener; |
70 |
66 |
71 inline void check_mark(HeapWord* addr) NOT_DEBUG_RETURN; |
67 protected: |
72 |
68 |
73 // Convert from bit offset to address. |
69 virtual void check_mark(HeapWord* addr) NOT_DEBUG_RETURN; |
74 HeapWord* offset_to_addr(size_t offset) const { |
70 |
75 return _covered.start() + (offset << _shifter); |
|
76 } |
|
77 // Convert from address to bit offset. |
|
78 size_t addr_to_offset(const HeapWord* addr) const { |
|
79 return pointer_delta(addr, _covered.start()) >> _shifter; |
|
80 } |
|
81 public: |
71 public: |
82 static size_t compute_size(size_t heap_size); |
|
83 // Returns the amount of bytes on the heap between two marks in the bitmap. |
|
84 static size_t mark_distance(); |
|
85 // Returns how many bytes (or bits) of the heap a single byte (or bit) of the |
|
86 // mark bitmap corresponds to. This is the same as the mark distance above. |
|
87 static size_t heap_map_factor() { |
|
88 return mark_distance(); |
|
89 } |
|
90 |
72 |
91 G1CMBitMap() : _covered(), _shifter(LogMinObjAlignment), _bm(), _listener() { _listener.set_bitmap(this); } |
73 G1CMBitMap() : MarkBitMap(), _listener() { _listener.set_bitmap(this); } |
92 |
74 |
93 // Initializes the underlying BitMap to cover the given area. |
75 // Initializes the underlying BitMap to cover the given area. |
94 void initialize(MemRegion heap, G1RegionToSpaceMapper* storage); |
76 void initialize(MemRegion heap, G1RegionToSpaceMapper* storage); |
95 |
77 |
96 // Read marks |
|
97 bool is_marked(oop obj) const; |
|
98 bool is_marked(HeapWord* addr) const { |
|
99 assert(_covered.contains(addr), |
|
100 "Address " PTR_FORMAT " is outside underlying space from " PTR_FORMAT " to " PTR_FORMAT, |
|
101 p2i(addr), p2i(_covered.start()), p2i(_covered.end())); |
|
102 return _bm.at(addr_to_offset(addr)); |
|
103 } |
|
104 |
|
105 // Apply the closure to the addresses that correspond to marked bits in the bitmap. |
78 // Apply the closure to the addresses that correspond to marked bits in the bitmap. |
106 inline bool iterate(G1CMBitMapClosure* cl, MemRegion mr); |
79 inline bool iterate(G1CMBitMapClosure* cl, MemRegion mr); |
107 |
80 |
108 // Return the address corresponding to the next marked bit at or after |
|
109 // "addr", and before "limit", if "limit" is non-NULL. If there is no |
|
110 // such bit, returns "limit" if that is non-NULL, or else "endWord()". |
|
111 inline HeapWord* get_next_marked_addr(const HeapWord* addr, |
|
112 const HeapWord* limit) const; |
|
113 |
|
114 void print_on_error(outputStream* st, const char* prefix) const; |
|
115 |
|
116 // Write marks. |
|
117 inline void mark(HeapWord* addr); |
|
118 inline void clear(HeapWord* addr); |
|
119 inline void clear(oop obj); |
|
120 inline bool par_mark(HeapWord* addr); |
|
121 inline bool par_mark(oop obj); |
|
122 |
|
123 void clear_range(MemRegion mr); |
|
124 void clear_region(HeapRegion* hr); |
81 void clear_region(HeapRegion* hr); |
125 }; |
82 }; |
126 |
83 |
127 #endif // SHARE_VM_GC_G1_G1CONCURRENTMARKBITMAP_HPP |
84 #endif // SHARE_VM_GC_G1_G1CONCURRENTMARKBITMAP_HPP |