129
130 _garbage = 0;
131 _live_data = 0;
132 _used = 0;
133
134 _region_count = 0;
135 _current_index = 0;
136 }
137
138 ShenandoahHeapRegion* ShenandoahCollectionSet::claim_next() {
139 size_t num_regions = _heap->num_regions();
140 if (_current_index >= (jint)num_regions) {
141 return NULL;
142 }
143
144 jint saved_current = _current_index;
145 size_t index = (size_t)saved_current;
146
147 while(index < num_regions) {
148 if (is_in(index)) {
149 jint cur = Atomic::cmpxchg((jint)(index + 1), &_current_index, saved_current);
150 assert(cur >= (jint)saved_current, "Must move forward");
151 if (cur == saved_current) {
152 assert(is_in(index), "Invariant");
153 return _heap->get_region(index);
154 } else {
155 index = (size_t)cur;
156 saved_current = cur;
157 }
158 } else {
159 index ++;
160 }
161 }
162 return NULL;
163 }
164
165 ShenandoahHeapRegion* ShenandoahCollectionSet::next() {
166 assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
167 assert(Thread::current()->is_VM_thread(), "Must be VMThread");
168 size_t num_regions = _heap->num_regions();
169 for (size_t index = (size_t)_current_index; index < num_regions; index ++) {
|
129
130 _garbage = 0;
131 _live_data = 0;
132 _used = 0;
133
134 _region_count = 0;
135 _current_index = 0;
136 }
137
138 ShenandoahHeapRegion* ShenandoahCollectionSet::claim_next() {
139 size_t num_regions = _heap->num_regions();
140 if (_current_index >= (jint)num_regions) {
141 return NULL;
142 }
143
144 jint saved_current = _current_index;
145 size_t index = (size_t)saved_current;
146
147 while(index < num_regions) {
148 if (is_in(index)) {
149 jint cur = Atomic::cmpxchg(&_current_index, saved_current, (jint)(index + 1));
150 assert(cur >= (jint)saved_current, "Must move forward");
151 if (cur == saved_current) {
152 assert(is_in(index), "Invariant");
153 return _heap->get_region(index);
154 } else {
155 index = (size_t)cur;
156 saved_current = cur;
157 }
158 } else {
159 index ++;
160 }
161 }
162 return NULL;
163 }
164
165 ShenandoahHeapRegion* ShenandoahCollectionSet::next() {
166 assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
167 assert(Thread::current()->is_VM_thread(), "Must be VMThread");
168 size_t num_regions = _heap->num_regions();
169 for (size_t index = (size_t)_current_index; index < num_regions; index ++) {
|