< prev index next >

src/hotspot/share/gc/serial/serialFullGC.cpp

Print this page

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