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