16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24
25 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHCOLLECTIONSET_HPP
26 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHCOLLECTIONSET_HPP
27
28 #include "memory/allocation.hpp"
29
30 class ShenandoahHeap;
31 class ShenandoahHeapRegion;
32
33 class ShenandoahCollectionSet : public CHeapObj<mtGC> {
34 friend class ShenandoahHeap;
35 private:
36 jbyte* _cset_map;
37 jbyte* _biased_cset_map;
38 size_t _map_size;
39
40 ShenandoahHeap* const _heap;
41
42 size_t _garbage;
43 size_t _live_data;
44 size_t _region_count;
45
46 volatile jint _current_index;
47 public:
48 ShenandoahCollectionSet(ShenandoahHeap* heap, HeapWord* heap_base);
49
50 // Add region to collection set
51 void add_region(ShenandoahHeapRegion* r);
52
53 // Bring per-region statuses to consistency with this collection.
54 // TODO: This is a transitional interface that bridges the gap between
55 // region statuses and this collection. Should go away after we merge them.
56 void update_region_status();
57
58 // Remove region from collection set
59 void remove_region(ShenandoahHeapRegion* r);
60
61 // MT version
62 ShenandoahHeapRegion* claim_next();
63
64 // Single-thread version
65 ShenandoahHeapRegion* next();
66
67 size_t count() const { return _region_count; }
68 bool is_empty() const { return _region_count == 0; }
69
70 void clear_current_index() {
71 _current_index = 0;
72 }
73
74 inline bool is_in(ShenandoahHeapRegion* r) const;
75 inline bool is_in(size_t region_number) const;
76 inline bool is_in(HeapWord* p) const;
77
78 void print_on(outputStream* out) const;
79
80 size_t live_data() const { return _live_data; }
81 size_t garbage() const { return _garbage; }
82 void clear();
83
84 private:
85 jbyte* biased_map_address() const {
86 return _biased_cset_map;
87 }
88 };
89
90 #endif //SHARE_VM_GC_SHENANDOAH_SHENANDOAHCOLLECTIONSET_HPP
|
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24
25 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHCOLLECTIONSET_HPP
26 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHCOLLECTIONSET_HPP
27
28 #include "memory/allocation.hpp"
29
30 class ShenandoahHeap;
31 class ShenandoahHeapRegion;
32
33 class ShenandoahCollectionSet : public CHeapObj<mtGC> {
34 friend class ShenandoahHeap;
35 private:
36 size_t const _map_size;
37 size_t const _region_size_bytes_shift;
38 jbyte* const _cset_map;
39 // Bias cset map's base address for fast test if an oop is in cset
40 jbyte* const _biased_cset_map;
41
42 ShenandoahHeap* const _heap;
43
44 size_t _garbage;
45 size_t _live_data;
46 size_t _used;
47 size_t _region_count;
48
49 volatile jint _current_index;
50 public:
51 ShenandoahCollectionSet(ShenandoahHeap* heap, HeapWord* heap_base);
52
53 // Add region to collection set
54 void add_region(ShenandoahHeapRegion* r);
55
56 // Bring per-region statuses to consistency with this collection.
57 // TODO: This is a transitional interface that bridges the gap between
58 // region statuses and this collection. Should go away after we merge them.
59 void update_region_status();
60
61 // Remove region from collection set
62 void remove_region(ShenandoahHeapRegion* r);
63
64 // MT version
65 ShenandoahHeapRegion* claim_next();
66
67 // Single-thread version
68 ShenandoahHeapRegion* next();
69
70 size_t count() const { return _region_count; }
71 bool is_empty() const { return _region_count == 0; }
72
73 void clear_current_index() {
74 _current_index = 0;
75 }
76
77 inline bool is_in(ShenandoahHeapRegion* r) const;
78 inline bool is_in(size_t region_number) const;
79 inline bool is_in(HeapWord* p) const;
80
81 void print_on(outputStream* out) const;
82
83 size_t used() const { return _used; }
84 size_t live_data() const { return _live_data; }
85 size_t garbage() const { return _garbage; }
86 void clear();
87
88 private:
89 jbyte* biased_map_address() const {
90 return _biased_cset_map;
91 }
92 };
93
94 #endif //SHARE_VM_GC_SHENANDOAH_SHENANDOAHCOLLECTIONSET_HPP
|