< prev index next >

src/hotspot/share/gc/g1/g1OopClosures.inline.hpp

Print this page
rev 52675 : 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
Reviewed-by:
Contributed-by: erik.helin@oracle.com, stefan.johansson@oracle.com
rev 52676 : imported patch AMGC-impl


  47   // we might need to install the forwarding reference) and we'll
  48   // get back to it when pop it from the queue
  49   Prefetch::write(obj->mark_addr_raw(), 0);
  50   Prefetch::read(obj->mark_addr_raw(), (HeapWordSize*2));
  51 
  52   // slightly paranoid test; I'm trying to catch potential
  53   // problems before we go into push_on_queue to know where the
  54   // problem is coming from
  55   assert((obj == RawAccess<>::oop_load(p)) ||
  56          (obj->is_forwarded() &&
  57          obj->forwardee() == RawAccess<>::oop_load(p)),
  58          "p should still be pointing to obj or to its forwardee");
  59 
  60   _par_scan_state->push_on_queue(p);
  61 }
  62 
  63 template <class T>
  64 inline void G1ScanClosureBase::handle_non_cset_obj_common(InCSetState const state, T* p, oop const obj) {
  65   if (state.is_humongous()) {
  66     _g1h->set_humongous_is_live(obj);


  67   }
  68 }
  69 
  70 inline void G1ScanClosureBase::trim_queue_partially() {
  71   _par_scan_state->trim_queue_partially();
  72 }
  73 
  74 template <class T>
  75 inline void G1ScanEvacuatedObjClosure::do_oop_work(T* p) {
  76   T heap_oop = RawAccess<>::oop_load(p);
  77 
  78   if (CompressedOops::is_null(heap_oop)) {
  79     return;
  80   }
  81   oop obj = CompressedOops::decode_not_null(heap_oop);
  82   const InCSetState state = _g1h->in_cset_state(obj);
  83   if (state.is_in_cset()) {
  84     prefetch_and_push(p, obj);
  85   } else if (!HeapRegion::is_in_same_region(p, obj)) {
  86     handle_non_cset_obj_common(state, p, obj);


 178     _par_scan_state->enqueue_card_if_tracked(p, obj);
 179   }
 180 }
 181 
 182 template <class T>
 183 inline void G1ScanObjsDuringScanRSClosure::do_oop_work(T* p) {
 184   T heap_oop = RawAccess<>::oop_load(p);
 185   if (CompressedOops::is_null(heap_oop)) {
 186     return;
 187   }
 188   oop obj = CompressedOops::decode_not_null(heap_oop);
 189 
 190   const InCSetState state = _g1h->in_cset_state(obj);
 191   if (state.is_in_cset()) {
 192     prefetch_and_push(p, obj);
 193   } else if (!HeapRegion::is_in_same_region(p, obj)) {
 194     handle_non_cset_obj_common(state, p, obj);
 195   }
 196 }
 197 






 198 void G1ParCopyHelper::do_cld_barrier(oop new_obj) {
 199   if (_g1h->heap_region_containing(new_obj)->is_young()) {
 200     _scanned_cld->record_modified_oops();
 201   }
 202 }
 203 
 204 void G1ParCopyHelper::mark_object(oop obj) {
 205   assert(!_g1h->heap_region_containing(obj)->in_collection_set(), "should not mark objects in the CSet");
 206 
 207   // We know that the object is not moving so it's safe to read its size.
 208   _cm->mark_in_next_bitmap(_worker_id, obj);
 209 }
 210 
 211 void G1ParCopyHelper::mark_forwarded_object(oop from_obj, oop to_obj) {
 212   assert(from_obj->is_forwarded(), "from obj should be forwarded");
 213   assert(from_obj->forwardee() == to_obj, "to obj should be the forwardee");
 214   assert(from_obj != to_obj, "should not be self-forwarded");
 215 
 216   assert(_g1h->heap_region_containing(from_obj)->in_collection_set(), "from obj should be in the CSet");
 217   assert(!_g1h->heap_region_containing(to_obj)->in_collection_set(), "should not mark objects in the CSet");


 246     markOop m = obj->mark_raw();
 247     if (m->is_marked()) {
 248       forwardee = (oop) m->decode_pointer();
 249     } else {
 250       forwardee = _par_scan_state->copy_to_survivor_space(state, obj, m);
 251     }
 252     assert(forwardee != NULL, "forwardee should not be NULL");
 253     RawAccess<IS_NOT_NULL>::oop_store(p, forwardee);
 254     if (do_mark_object != G1MarkNone && forwardee != obj) {
 255       // If the object is self-forwarded we don't need to explicitly
 256       // mark it, the evacuation failure protocol will do so.
 257       mark_forwarded_object(obj, forwardee);
 258     }
 259 
 260     if (barrier == G1BarrierCLD) {
 261       do_cld_barrier(forwardee);
 262     }
 263   } else {
 264     if (state.is_humongous()) {
 265       _g1h->set_humongous_is_live(obj);


 266     }
 267 
 268     // The object is not in collection set. If we're a root scanning
 269     // closure during an initial mark pause then attempt to mark the object.
 270     if (do_mark_object == G1MarkFromRoot) {
 271       mark_object(obj);
 272     }
 273   }
 274   trim_queue_partially();
 275 }
 276 
 277 template <class T> void G1RebuildRemSetClosure::do_oop_work(T* p) {
 278   oop const obj = RawAccess<MO_VOLATILE>::oop_load(p);
 279   if (obj == NULL) {
 280     return;
 281   }
 282 
 283   if (HeapRegion::is_in_same_region(p, obj)) {
 284     return;
 285   }


  47   // we might need to install the forwarding reference) and we'll
  48   // get back to it when pop it from the queue
  49   Prefetch::write(obj->mark_addr_raw(), 0);
  50   Prefetch::read(obj->mark_addr_raw(), (HeapWordSize*2));
  51 
  52   // slightly paranoid test; I'm trying to catch potential
  53   // problems before we go into push_on_queue to know where the
  54   // problem is coming from
  55   assert((obj == RawAccess<>::oop_load(p)) ||
  56          (obj->is_forwarded() &&
  57          obj->forwardee() == RawAccess<>::oop_load(p)),
  58          "p should still be pointing to obj or to its forwardee");
  59 
  60   _par_scan_state->push_on_queue(p);
  61 }
  62 
  63 template <class T>
  64 inline void G1ScanClosureBase::handle_non_cset_obj_common(InCSetState const state, T* p, oop const obj) {
  65   if (state.is_humongous()) {
  66     _g1h->set_humongous_is_live(obj);
  67   } else if (state.is_optional()) {
  68     _par_scan_state->remember_reference_into_optional_region(p);
  69   }
  70 }
  71 
  72 inline void G1ScanClosureBase::trim_queue_partially() {
  73   _par_scan_state->trim_queue_partially();
  74 }
  75 
  76 template <class T>
  77 inline void G1ScanEvacuatedObjClosure::do_oop_work(T* p) {
  78   T heap_oop = RawAccess<>::oop_load(p);
  79 
  80   if (CompressedOops::is_null(heap_oop)) {
  81     return;
  82   }
  83   oop obj = CompressedOops::decode_not_null(heap_oop);
  84   const InCSetState state = _g1h->in_cset_state(obj);
  85   if (state.is_in_cset()) {
  86     prefetch_and_push(p, obj);
  87   } else if (!HeapRegion::is_in_same_region(p, obj)) {
  88     handle_non_cset_obj_common(state, p, obj);


 180     _par_scan_state->enqueue_card_if_tracked(p, obj);
 181   }
 182 }
 183 
 184 template <class T>
 185 inline void G1ScanObjsDuringScanRSClosure::do_oop_work(T* p) {
 186   T heap_oop = RawAccess<>::oop_load(p);
 187   if (CompressedOops::is_null(heap_oop)) {
 188     return;
 189   }
 190   oop obj = CompressedOops::decode_not_null(heap_oop);
 191 
 192   const InCSetState state = _g1h->in_cset_state(obj);
 193   if (state.is_in_cset()) {
 194     prefetch_and_push(p, obj);
 195   } else if (!HeapRegion::is_in_same_region(p, obj)) {
 196     handle_non_cset_obj_common(state, p, obj);
 197   }
 198 }
 199 
 200 template <class T>
 201 inline void G1ScanRSForOptionalClosure::do_oop_work(T* p) {
 202   _scan_cl->do_oop_work(p);
 203   _scan_cl->trim_queue_partially();
 204 }
 205 
 206 void G1ParCopyHelper::do_cld_barrier(oop new_obj) {
 207   if (_g1h->heap_region_containing(new_obj)->is_young()) {
 208     _scanned_cld->record_modified_oops();
 209   }
 210 }
 211 
 212 void G1ParCopyHelper::mark_object(oop obj) {
 213   assert(!_g1h->heap_region_containing(obj)->in_collection_set(), "should not mark objects in the CSet");
 214 
 215   // We know that the object is not moving so it's safe to read its size.
 216   _cm->mark_in_next_bitmap(_worker_id, obj);
 217 }
 218 
 219 void G1ParCopyHelper::mark_forwarded_object(oop from_obj, oop to_obj) {
 220   assert(from_obj->is_forwarded(), "from obj should be forwarded");
 221   assert(from_obj->forwardee() == to_obj, "to obj should be the forwardee");
 222   assert(from_obj != to_obj, "should not be self-forwarded");
 223 
 224   assert(_g1h->heap_region_containing(from_obj)->in_collection_set(), "from obj should be in the CSet");
 225   assert(!_g1h->heap_region_containing(to_obj)->in_collection_set(), "should not mark objects in the CSet");


 254     markOop m = obj->mark_raw();
 255     if (m->is_marked()) {
 256       forwardee = (oop) m->decode_pointer();
 257     } else {
 258       forwardee = _par_scan_state->copy_to_survivor_space(state, obj, m);
 259     }
 260     assert(forwardee != NULL, "forwardee should not be NULL");
 261     RawAccess<IS_NOT_NULL>::oop_store(p, forwardee);
 262     if (do_mark_object != G1MarkNone && forwardee != obj) {
 263       // If the object is self-forwarded we don't need to explicitly
 264       // mark it, the evacuation failure protocol will do so.
 265       mark_forwarded_object(obj, forwardee);
 266     }
 267 
 268     if (barrier == G1BarrierCLD) {
 269       do_cld_barrier(forwardee);
 270     }
 271   } else {
 272     if (state.is_humongous()) {
 273       _g1h->set_humongous_is_live(obj);
 274     } else if (state.is_optional()) {
 275       _par_scan_state->remember_root_into_optional_region(p);
 276     }
 277 
 278     // The object is not in collection set. If we're a root scanning
 279     // closure during an initial mark pause then attempt to mark the object.
 280     if (do_mark_object == G1MarkFromRoot) {
 281       mark_object(obj);
 282     }
 283   }
 284   trim_queue_partially();
 285 }
 286 
 287 template <class T> void G1RebuildRemSetClosure::do_oop_work(T* p) {
 288   oop const obj = RawAccess<MO_VOLATILE>::oop_load(p);
 289   if (obj == NULL) {
 290     return;
 291   }
 292 
 293   if (HeapRegion::is_in_same_region(p, obj)) {
 294     return;
 295   }
< prev index next >