src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp

Print this page




4772       _scanner.set_region(_g1->heap_region_containing_raw(obj));
4773       obj->oop_iterate_backwards(&_scanner);
4774     }
4775   } else {
4776     _par_scan_state->undo_allocation(alloc_purpose, obj_ptr, word_sz);
4777     obj = forward_ptr;
4778   }
4779   return obj;
4780 }
4781 
4782 template <class T>
4783 void G1ParCopyHelper::do_klass_barrier(T* p, oop new_obj) {
4784   if (_g1->heap_region_containing_raw(new_obj)->is_young()) {
4785     _scanned_klass->record_modified_oops();
4786   }
4787 }
4788 
4789 template <G1Barrier barrier, bool do_mark_object>
4790 template <class T>
4791 void G1ParCopyClosure<barrier, do_mark_object>::do_oop_work(T* p) {
4792   oop obj = oopDesc::load_decode_heap_oop(p);






4793 
4794   assert(_worker_id == _par_scan_state->queue_num(), "sanity");
4795 
4796   // here the null check is implicit in the cset_fast_test() test
4797   if (_g1->in_cset_fast_test(obj)) {
4798     oop forwardee;
4799     if (obj->is_forwarded()) {
4800       forwardee = obj->forwardee();
4801     } else {
4802       forwardee = copy_to_survivor_space(obj);
4803     }
4804     assert(forwardee != NULL, "forwardee should not be NULL");
4805     oopDesc::encode_store_heap_oop(p, forwardee);
4806     if (do_mark_object && forwardee != obj) {
4807       // If the object is self-forwarded we don't need to explicitly
4808       // mark it, the evacuation failure protocol will do so.
4809       mark_forwarded_object(obj, forwardee);
4810     }
4811 
4812     if (barrier == G1BarrierKlass) {
4813       do_klass_barrier(p, forwardee);
4814     }
4815   } else {
4816     // The object is not in collection set. If we're a root scanning
4817     // closure during an initial mark pause (i.e. do_mark_object will
4818     // be true) then attempt to mark the object.
4819     if (do_mark_object && _g1->is_in_g1_reserved(obj)) {
4820       mark_object(obj);
4821     }
4822   }
4823 
4824   if (barrier == G1BarrierEvac && obj != NULL) {
4825     _par_scan_state->update_rs(_from, p, _worker_id);
4826   }
4827 }
4828 
4829 template void G1ParCopyClosure<G1BarrierEvac, false>::do_oop_work(oop* p);
4830 template void G1ParCopyClosure<G1BarrierEvac, false>::do_oop_work(narrowOop* p);
4831 
4832 template <class T> void G1ParScanPartialArrayClosure::do_oop_nv(T* p) {
4833   assert(has_partial_array_mask(p), "invariant");
4834   oop from_obj = clear_partial_array_mask(p);
4835 
4836   assert(Universe::heap()->is_in_reserved(from_obj), "must be in heap.");
4837   assert(from_obj->is_objArray(), "must be obj array");
4838   objArrayOop from_obj_array = objArrayOop(from_obj);
4839   // The from-space object contains the real length.
4840   int length                 = from_obj_array->length();
4841 
4842   assert(from_obj->is_forwarded(), "must be forwarded");
4843   oop to_obj                 = from_obj->forwardee();
4844   assert(from_obj != to_obj, "should not be chunking self-forwarded objects");




4772       _scanner.set_region(_g1->heap_region_containing_raw(obj));
4773       obj->oop_iterate_backwards(&_scanner);
4774     }
4775   } else {
4776     _par_scan_state->undo_allocation(alloc_purpose, obj_ptr, word_sz);
4777     obj = forward_ptr;
4778   }
4779   return obj;
4780 }
4781 
4782 template <class T>
4783 void G1ParCopyHelper::do_klass_barrier(T* p, oop new_obj) {
4784   if (_g1->heap_region_containing_raw(new_obj)->is_young()) {
4785     _scanned_klass->record_modified_oops();
4786   }
4787 }
4788 
4789 template <G1Barrier barrier, bool do_mark_object>
4790 template <class T>
4791 void G1ParCopyClosure<barrier, do_mark_object>::do_oop_work(T* p) {
4792   T heap_oop = oopDesc::load_heap_oop(p);
4793 
4794   if (oopDesc::is_null(heap_oop)) {
4795     return;
4796   }
4797 
4798   oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
4799 
4800   assert(_worker_id == _par_scan_state->queue_num(), "sanity");
4801 

4802   if (_g1->in_cset_fast_test(obj)) {
4803     oop forwardee;
4804     if (obj->is_forwarded()) {
4805       forwardee = obj->forwardee();
4806     } else {
4807       forwardee = copy_to_survivor_space(obj);
4808     }
4809     assert(forwardee != NULL, "forwardee should not be NULL");
4810     oopDesc::encode_store_heap_oop(p, forwardee);
4811     if (do_mark_object && forwardee != obj) {
4812       // If the object is self-forwarded we don't need to explicitly
4813       // mark it, the evacuation failure protocol will do so.
4814       mark_forwarded_object(obj, forwardee);
4815     }
4816 
4817     if (barrier == G1BarrierKlass) {
4818       do_klass_barrier(p, forwardee);
4819     }
4820   } else {
4821     // The object is not in collection set. If we're a root scanning
4822     // closure during an initial mark pause (i.e. do_mark_object will
4823     // be true) then attempt to mark the object.
4824     if (do_mark_object) {
4825       mark_object(obj);
4826     }
4827   }
4828 
4829   if (barrier == G1BarrierEvac) {
4830     _par_scan_state->update_rs(_from, p, _worker_id);
4831   }
4832 }
4833 
4834 template void G1ParCopyClosure<G1BarrierEvac, false>::do_oop_work(oop* p);
4835 template void G1ParCopyClosure<G1BarrierEvac, false>::do_oop_work(narrowOop* p);
4836 
4837 template <class T> void G1ParScanPartialArrayClosure::do_oop_nv(T* p) {
4838   assert(has_partial_array_mask(p), "invariant");
4839   oop from_obj = clear_partial_array_mask(p);
4840 
4841   assert(Universe::heap()->is_in_reserved(from_obj), "must be in heap.");
4842   assert(from_obj->is_objArray(), "must be obj array");
4843   objArrayOop from_obj_array = objArrayOop(from_obj);
4844   // The from-space object contains the real length.
4845   int length                 = from_obj_array->length();
4846 
4847   assert(from_obj->is_forwarded(), "must be forwarded");
4848   oop to_obj                 = from_obj->forwardee();
4849   assert(from_obj != to_obj, "should not be chunking self-forwarded objects");