188 }
189
190 // Only used by oldgen allocation.
191 bool MutableSpace::needs_expand(size_t word_size) const {
192 assert_lock_strong(PSOldGenExpand_lock);
193 // Holding the lock means end is stable. So while top may be advancing
194 // via concurrent allocations, there is no need to order the reads of top
195 // and end here, unlike in cas_allocate.
196 return pointer_delta(end(), top()) < word_size;
197 }
198
199 void MutableSpace::oop_iterate(OopIterateClosure* cl) {
200 HeapWord* obj_addr = bottom();
201 HeapWord* t = top();
202 // Could call objects iterate, but this is easier.
203 while (obj_addr < t) {
204 obj_addr += cast_to_oop(obj_addr)->oop_iterate_size(cl);
205 }
206 }
207
208 void MutableSpace::object_iterate(ObjectClosure* cl) {
209 HeapWord* p = bottom();
210 while (p < top()) {
211 oop obj = cast_to_oop(p);
212 // When promotion-failure occurs during Young GC, eden/from space is not cleared,
213 // so we can encounter objects with "forwarded" markword.
214 // They are essentially dead, so skipping them
215 if (!obj->is_forwarded()) {
216 cl->do_object(obj);
217 }
218 #ifdef ASSERT
219 else {
220 assert(obj->forwardee() != obj, "must not be self-forwarded");
221 }
222 #endif
223 p += obj->size();
224 }
225 }
226
227 void MutableSpace::print_short() const { print_short_on(tty); }
228 void MutableSpace::print_short_on( outputStream* st) const {
229 st->print(" space " SIZE_FORMAT "K, %d%% used", capacity_in_bytes() / K,
230 (int) ((double) used_in_bytes() * 100 / capacity_in_bytes()));
231 }
232
233 void MutableSpace::print() const { print_on(tty); }
234 void MutableSpace::print_on(outputStream* st) const {
235 MutableSpace::print_short_on(st);
236 st->print_cr(" [" PTR_FORMAT "," PTR_FORMAT "," PTR_FORMAT ")",
237 p2i(bottom()), p2i(top()), p2i(end()));
238 }
239
240 void MutableSpace::verify() {
241 HeapWord* p = bottom();
242 HeapWord* t = top();
243 while (p < t) {
|
188 }
189
190 // Only used by oldgen allocation.
191 bool MutableSpace::needs_expand(size_t word_size) const {
192 assert_lock_strong(PSOldGenExpand_lock);
193 // Holding the lock means end is stable. So while top may be advancing
194 // via concurrent allocations, there is no need to order the reads of top
195 // and end here, unlike in cas_allocate.
196 return pointer_delta(end(), top()) < word_size;
197 }
198
199 void MutableSpace::oop_iterate(OopIterateClosure* cl) {
200 HeapWord* obj_addr = bottom();
201 HeapWord* t = top();
202 // Could call objects iterate, but this is easier.
203 while (obj_addr < t) {
204 obj_addr += cast_to_oop(obj_addr)->oop_iterate_size(cl);
205 }
206 }
207
208 template<bool COMPACT_HEADERS>
209 void MutableSpace::object_iterate_impl(ObjectClosure* cl) {
210 HeapWord* p = bottom();
211 while (p < top()) {
212 oop obj = cast_to_oop(p);
213 // When promotion-failure occurs during Young GC, eden/from space is not cleared,
214 // so we can encounter objects with "forwarded" markword.
215 // They are essentially dead, so skipping them
216 if (!obj->is_forwarded()) {
217 cl->do_object(obj);
218 p += obj->size();
219 } else {
220 assert(obj->forwardee() != obj, "must not be self-forwarded");
221 if (COMPACT_HEADERS) {
222 // It is safe to use the forwardee here. Parallel GC only uses
223 // header-based forwarding during promotion. Full GC doesn't
224 // use the object header for forwarding at all.
225 p += obj->forwardee()->size();
226 } else {
227 p += obj->size();
228 }
229 }
230 }
231 }
232
233 void MutableSpace::object_iterate(ObjectClosure* cl) {
234 if (UseCompactObjectHeaders) {
235 object_iterate_impl<true>(cl);
236 } else {
237 object_iterate_impl<false>(cl);
238 }
239 }
240
241 void MutableSpace::print_short() const { print_short_on(tty); }
242 void MutableSpace::print_short_on( outputStream* st) const {
243 st->print(" space " SIZE_FORMAT "K, %d%% used", capacity_in_bytes() / K,
244 (int) ((double) used_in_bytes() * 100 / capacity_in_bytes()));
245 }
246
247 void MutableSpace::print() const { print_on(tty); }
248 void MutableSpace::print_on(outputStream* st) const {
249 MutableSpace::print_short_on(st);
250 st->print_cr(" [" PTR_FORMAT "," PTR_FORMAT "," PTR_FORMAT ")",
251 p2i(bottom()), p2i(top()), p2i(end()));
252 }
253
254 void MutableSpace::verify() {
255 HeapWord* p = bottom();
256 HeapWord* t = top();
257 while (p < t) {
|