80 }
81
82 void ShenandoahHeapRegionSet::clear() {
83 assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
84 Copy::zero_to_bytes(_set_map, _map_size);
85
86 _region_count = 0;
87 }
88
89 ShenandoahHeapRegion* ShenandoahHeapRegionSetIterator::claim_next() {
90 size_t num_regions = _heap->num_regions();
91 if (_current_index >= (jint)num_regions) {
92 return NULL;
93 }
94
95 jint saved_current = _current_index;
96 size_t index = (size_t)saved_current;
97
98 while(index < num_regions) {
99 if (_set->is_in(index)) {
100 jint cur = Atomic::cmpxchg((jint)(index + 1), &_current_index, saved_current);
101 assert(cur >= (jint)saved_current, "Must move forward");
102 if (cur == saved_current) {
103 assert(_set->is_in(index), "Invariant");
104 return _heap->get_region(index);
105 } else {
106 index = (size_t)cur;
107 saved_current = cur;
108 }
109 } else {
110 index ++;
111 }
112 }
113 return NULL;
114 }
115
116 ShenandoahHeapRegion* ShenandoahHeapRegionSetIterator::next() {
117 size_t num_regions = _heap->num_regions();
118 for (size_t index = (size_t)_current_index; index < num_regions; index ++) {
119 if (_set->is_in(index)) {
120 _current_index = (jint)(index + 1);
|
80 }
81
82 void ShenandoahHeapRegionSet::clear() {
83 assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
84 Copy::zero_to_bytes(_set_map, _map_size);
85
86 _region_count = 0;
87 }
88
89 ShenandoahHeapRegion* ShenandoahHeapRegionSetIterator::claim_next() {
90 size_t num_regions = _heap->num_regions();
91 if (_current_index >= (jint)num_regions) {
92 return NULL;
93 }
94
95 jint saved_current = _current_index;
96 size_t index = (size_t)saved_current;
97
98 while(index < num_regions) {
99 if (_set->is_in(index)) {
100 jint cur = Atomic::cmpxchg(&_current_index, saved_current, (jint)(index + 1));
101 assert(cur >= (jint)saved_current, "Must move forward");
102 if (cur == saved_current) {
103 assert(_set->is_in(index), "Invariant");
104 return _heap->get_region(index);
105 } else {
106 index = (size_t)cur;
107 saved_current = cur;
108 }
109 } else {
110 index ++;
111 }
112 }
113 return NULL;
114 }
115
116 ShenandoahHeapRegion* ShenandoahHeapRegionSetIterator::next() {
117 size_t num_regions = _heap->num_regions();
118 for (size_t index = (size_t)_current_index; index < num_regions; index ++) {
119 if (_set->is_in(index)) {
120 _current_index = (jint)(index + 1);
|