src/share/vm/gc/g1/g1SATBCardTableModRefBS.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/gc/g1

src/share/vm/gc/g1/g1SATBCardTableModRefBS.cpp

Print this page




 237             *byte = dirty_card;
 238             jt->dirty_card_queue().enqueue(byte);
 239           }
 240         }
 241       } else {
 242         MutexLockerEx x(Shared_DirtyCardQ_lock,
 243                         Mutex::_no_safepoint_check_flag);
 244         for (; byte <= last_byte; byte++) {
 245           if (*byte == g1_young_gen) {
 246             continue;
 247           }
 248           if (*byte != dirty_card) {
 249             *byte = dirty_card;
 250             _dcqs.shared_dirty_card_queue()->enqueue(byte);
 251           }
 252         }
 253       }
 254     }
 255   }
 256 }



















































 237             *byte = dirty_card;
 238             jt->dirty_card_queue().enqueue(byte);
 239           }
 240         }
 241       } else {
 242         MutexLockerEx x(Shared_DirtyCardQ_lock,
 243                         Mutex::_no_safepoint_check_flag);
 244         for (; byte <= last_byte; byte++) {
 245           if (*byte == g1_young_gen) {
 246             continue;
 247           }
 248           if (*byte != dirty_card) {
 249             *byte = dirty_card;
 250             _dcqs.shared_dirty_card_queue()->enqueue(byte);
 251           }
 252         }
 253       }
 254     }
 255   }
 256 }
 257 
 258 void G1SATBCardTableModRefBS::write_ref_nmethod_post(oop* dst, nmethod* nm) {
 259   oop obj = oopDesc::load_heap_oop(dst);
 260   if (obj != NULL) {
 261     G1CollectedHeap* g1h = G1CollectedHeap::heap();
 262     HeapRegion* hr = g1h->heap_region_containing(obj);
 263     hr->add_strong_code_root(nm);
 264   }
 265 }
 266 
 267 class G1EnsureLastRefToRegion : public OopClosure {
 268   G1CollectedHeap* _g1h;
 269   HeapRegion* _hr;
 270   oop* _dst;
 271 
 272   bool _value;
 273 public:
 274   G1EnsureLastRefToRegion(G1CollectedHeap* g1h, HeapRegion* hr, oop* dst) :
 275     _g1h(g1h), _hr(hr), _dst(dst), _value(true) {}
 276 
 277   void do_oop(oop* p) {
 278     if (_value && p != _dst) {
 279       oop obj = oopDesc::load_heap_oop(p);
 280       if (obj != NULL) {
 281         HeapRegion* hr = _g1h->heap_region_containing(obj);
 282         if (hr == _hr) {
 283           // Another reference to the same region.
 284           _value = false;
 285         }
 286       }
 287     }
 288   }
 289   void do_oop(narrowOop* p) { ShouldNotReachHere(); }
 290   bool value() const        { return _value;  }
 291 };
 292 
 293 void G1SATBCardTableModRefBS::write_ref_nmethod_pre(oop* dst, nmethod* nm) {
 294   oop obj = oopDesc::load_heap_oop(dst);
 295   if (obj != NULL) {
 296     G1CollectedHeap* g1h = G1CollectedHeap::heap();
 297     HeapRegion* hr = g1h->heap_region_containing(obj);
 298     G1EnsureLastRefToRegion ensure_last_ref(g1h, hr, dst);
 299     nm->oops_do(&ensure_last_ref);
 300     if (ensure_last_ref.value()) {
 301       // Last reference to this region, remove the nmethod from the rset.
 302       hr->remove_strong_code_root(nm);
 303     }
 304   }
 305 }
src/share/vm/gc/g1/g1SATBCardTableModRefBS.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File