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