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