15 * 2 along with this work; if not, write to the Free Software Foundation,
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 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHHEAPREGIONSET_HPP
25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHHEAPREGIONSET_HPP
26
27 #include "memory/allocation.hpp"
28
29 class ShenandoahHeap;
30 class ShenandoahHeapRegion;
31 class ShenandoahHeapRegionSet;
32
33 class ShenandoahHeapRegionSetIterator : public StackObj {
34 private:
35 const ShenandoahHeapRegionSet* const _set;
36 volatile jint _current_index;
37 ShenandoahHeap* const _heap;
38
39 // No implicit copying: iterators should be passed by reference to capture the state,
40 // or be copied explicitly by "=" operator
41 ShenandoahHeapRegionSetIterator(const ShenandoahHeapRegionSetIterator& that);
42
43 public:
44 ShenandoahHeapRegionSetIterator(const ShenandoahHeapRegionSet* const set);
45
46 ShenandoahHeapRegionSetIterator& operator=(const ShenandoahHeapRegionSetIterator& o);
47
48 // MT version
49 ShenandoahHeapRegion* claim_next();
50
51 // Single-thread version
52 ShenandoahHeapRegion* next();
53
54 };
55
56 class ShenandoahHeapRegionSet : public CHeapObj<mtGC> {
57 friend class ShenandoahHeap;
58 private:
59 ShenandoahHeap* const _heap;
60 size_t const _map_size;
61 jbyte* const _set_map;
62 jbyte* const _biased_set_map;
63 size_t _region_count;
64
65 public:
66
67 ShenandoahHeapRegionSet();
68 ~ShenandoahHeapRegionSet();
69
70 // Add region to set
71 void add_region(ShenandoahHeapRegion* r);
72 bool add_region_check_for_duplicates(ShenandoahHeapRegion* r);
73
74 // Remove region from set
75 void remove_region(ShenandoahHeapRegion* r);
76
77 size_t count() const { return _region_count; }
78 bool is_empty() const { return _region_count == 0; }
79
80 inline bool is_in(ShenandoahHeapRegion* r) const;
81 inline bool is_in(size_t region_number) const;
|
15 * 2 along with this work; if not, write to the Free Software Foundation,
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 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHHEAPREGIONSET_HPP
25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHHEAPREGIONSET_HPP
26
27 #include "memory/allocation.hpp"
28
29 class ShenandoahHeap;
30 class ShenandoahHeapRegion;
31 class ShenandoahHeapRegionSet;
32
33 class ShenandoahHeapRegionSetIterator : public StackObj {
34 private:
35 const ShenandoahHeapRegionSet* _set;
36 volatile jint _current_index;
37 ShenandoahHeap* const _heap;
38
39 // No implicit copying: iterators should be passed by reference to capture the state
40 ShenandoahHeapRegionSetIterator(const ShenandoahHeapRegionSetIterator& that);
41 ShenandoahHeapRegionSetIterator& operator=(const ShenandoahHeapRegionSetIterator& o);
42
43 public:
44 ShenandoahHeapRegionSetIterator(const ShenandoahHeapRegionSet* const set);
45
46 // Reset existing iterator to new set
47 void reset(const ShenandoahHeapRegionSet* const set);
48
49 // MT version
50 ShenandoahHeapRegion* claim_next();
51
52 // Single-thread version
53 ShenandoahHeapRegion* next();
54 };
55
56 class ShenandoahHeapRegionSet : public CHeapObj<mtGC> {
57 friend class ShenandoahHeap;
58 private:
59 ShenandoahHeap* const _heap;
60 size_t const _map_size;
61 size_t const _region_size_bytes_shift;
62 jbyte* const _set_map;
63 // Bias set map's base address for fast test if an oop is in set
64 jbyte* const _biased_set_map;
65 size_t _region_count;
66
67 public:
68
69 ShenandoahHeapRegionSet();
70 ~ShenandoahHeapRegionSet();
71
72 // Add region to set
73 void add_region(ShenandoahHeapRegion* r);
74 bool add_region_check_for_duplicates(ShenandoahHeapRegion* r);
75
76 // Remove region from set
77 void remove_region(ShenandoahHeapRegion* r);
78
79 size_t count() const { return _region_count; }
80 bool is_empty() const { return _region_count == 0; }
81
82 inline bool is_in(ShenandoahHeapRegion* r) const;
83 inline bool is_in(size_t region_number) const;
|