362 cur_addr = *(HeapWord**) cur_addr;
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_elements_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);
|
362 cur_addr = *(HeapWord**) cur_addr;
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(objArrayOop obj, size_t index) {
383 assert(obj->is_array_with_oops(), "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 assert(array->is_array_with_oops(), "Must be");
391
392 mark_and_push_closure.do_klass(array->klass());
393
394 // Don't push empty arrays to avoid unnecessary work.
395 if (array->length() > 0) {
396 SerialFullGC::push_objarray(array, 0);
397 }
398 }
399
400 void SerialFullGC::follow_object(oop obj) {
401 assert(obj->is_gc_marked(), "should be marked");
402 if (obj->is_array_with_oops()) {
403 // Handle object arrays explicitly to allow them to
404 // be split into chunks if needed.
405 SerialFullGC::follow_array((objArrayOop)obj);
406 } else {
407 obj->oop_iterate(&mark_and_push_closure);
408 }
409 }
410
411 void SerialFullGC::follow_array_chunk(objArrayOop array, int index) {
412 assert(array->is_array_with_oops(), "Must be");
413 const int len = array->length();
414 const int beg_index = index;
415 assert(beg_index < len || len == 0, "index too large");
416
417 const int stride = MIN2(len - beg_index, (int) ObjArrayMarkingStride);
418 const int end_index = beg_index + stride;
419
420 array->oop_iterate_elements_range(&mark_and_push_closure, beg_index, end_index);
421
422 if (end_index < len) {
423 SerialFullGC::push_objarray(array, end_index); // Push the continuation.
424 }
425 }
426
427 void SerialFullGC::follow_stack() {
428 do {
429 while (!_marking_stack.is_empty()) {
430 oop obj = _marking_stack.pop();
431 assert (obj->is_gc_marked(), "p must be marked");
432 follow_object(obj);
|