363 continue;
364 }
365 cur_addr += relocate(cur_addr);
366 }
367
368 // Reset top and unused memory
369 HeapWord* new_top = get_compaction_top(i);
370 space->set_top(new_top);
371 if (ZapUnusedHeapArea && new_top < top) {
372 space->mangle_unused_area(MemRegion(new_top, top));
373 }
374 }
375 }
376 };
377
378 template <class T> void SerialFullGC::KeepAliveClosure::do_oop_work(T* p) {
379 mark_and_push(p);
380 }
381
382 void SerialFullGC::push_objarray(oop obj, size_t index) {
383 ObjArrayTask task(obj, index);
384 assert(task.is_valid(), "bad ObjArrayTask");
385 _objarray_stack.push(task);
386 }
387
388 void SerialFullGC::follow_array(objArrayOop array) {
389 mark_and_push_closure.do_klass(array->klass());
390 // Don't push empty arrays to avoid unnecessary work.
391 if (array->length() > 0) {
392 SerialFullGC::push_objarray(array, 0);
393 }
394 }
395
396 void SerialFullGC::follow_object(oop obj) {
397 assert(obj->is_gc_marked(), "should be marked");
398 if (obj->is_objArray()) {
399 // Handle object arrays explicitly to allow them to
400 // be split into chunks if needed.
401 SerialFullGC::follow_array((objArrayOop)obj);
402 } else {
403 obj->oop_iterate(&mark_and_push_closure);
404 }
405 }
406
407 void SerialFullGC::follow_array_chunk(objArrayOop array, int index) {
408 const int len = array->length();
409 const int beg_index = index;
410 assert(beg_index < len || len == 0, "index too large");
411
412 const int stride = MIN2(len - beg_index, (int) ObjArrayMarkingStride);
413 const int end_index = beg_index + stride;
414
415 array->oop_iterate_range(&mark_and_push_closure, beg_index, end_index);
416
417 if (end_index < len) {
418 SerialFullGC::push_objarray(array, end_index); // Push the continuation.
419 }
420 }
421
422 void SerialFullGC::follow_stack() {
423 do {
424 while (!_marking_stack.is_empty()) {
425 oop obj = _marking_stack.pop();
426 assert (obj->is_gc_marked(), "p must be marked");
427 follow_object(obj);
428 }
429 // Process ObjArrays one at a time to avoid marking stack bloat.
430 if (!_objarray_stack.is_empty()) {
431 ObjArrayTask task = _objarray_stack.pop();
432 follow_array_chunk(objArrayOop(task.obj()), task.index());
433 }
434 } while (!_marking_stack.is_empty() || !_objarray_stack.is_empty());
435 }
|
363 continue;
364 }
365 cur_addr += relocate(cur_addr);
366 }
367
368 // Reset top and unused memory
369 HeapWord* new_top = get_compaction_top(i);
370 space->set_top(new_top);
371 if (ZapUnusedHeapArea && new_top < top) {
372 space->mangle_unused_area(MemRegion(new_top, top));
373 }
374 }
375 }
376 };
377
378 template <class T> void SerialFullGC::KeepAliveClosure::do_oop_work(T* p) {
379 mark_and_push(p);
380 }
381
382 void SerialFullGC::push_objarray(oop obj, size_t index) {
383 assert(obj->is_refArray(), "Must be");
384 ObjArrayTask task(obj, index);
385 assert(task.is_valid(), "bad ObjArrayTask");
386 _objarray_stack.push(task);
387 }
388
389 void SerialFullGC::follow_array(objArrayOop array) {
390 mark_and_push_closure.do_klass(array->klass());
391 // Don't push empty arrays to avoid unnecessary work.
392 if (array->length() > 0) {
393 SerialFullGC::push_objarray(array, 0);
394 }
395 }
396
397 void SerialFullGC::follow_object(oop obj) {
398 assert(obj->is_gc_marked(), "should be marked");
399 if (obj->is_refArray()) {
400 // Handle object arrays explicitly to allow them to
401 // be split into chunks if needed.
402 SerialFullGC::follow_array((objArrayOop)obj);
403 } else {
404 obj->oop_iterate(&mark_and_push_closure);
405 }
406 }
407
408 void SerialFullGC::follow_array_chunk(objArrayOop array, int index) {
409 const int len = array->length();
410 const int beg_index = index;
411 assert(beg_index < len || len == 0, "index too large");
412
413 const int stride = MIN2(len - beg_index, (int) ObjArrayMarkingStride);
414 const int end_index = beg_index + stride;
415
416 refArrayOop(array)->oop_iterate_range(&mark_and_push_closure, beg_index, end_index);
417
418 if (end_index < len) {
419 SerialFullGC::push_objarray(array, end_index); // Push the continuation.
420 }
421 }
422
423 void SerialFullGC::follow_stack() {
424 do {
425 while (!_marking_stack.is_empty()) {
426 oop obj = _marking_stack.pop();
427 assert (obj->is_gc_marked(), "p must be marked");
428 follow_object(obj);
429 }
430 // Process ObjArrays one at a time to avoid marking stack bloat.
431 if (!_objarray_stack.is_empty()) {
432 ObjArrayTask task = _objarray_stack.pop();
433 follow_array_chunk(objArrayOop(task.obj()), task.index());
434 }
435 } while (!_marking_stack.is_empty() || !_objarray_stack.is_empty());
436 }
|