< prev index next >

src/hotspot/share/gc/g1/g1EvacFailure.cpp

Print this page

        

@@ -24,34 +24,30 @@
 
 #include "precompiled.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1CollectorState.hpp"
 #include "gc/g1/g1ConcurrentMark.inline.hpp"
+#include "gc/g1/g1DirtyCardQueue.hpp"
 #include "gc/g1/g1EvacFailure.hpp"
 #include "gc/g1/g1HeapVerifier.hpp"
 #include "gc/g1/g1OopClosures.inline.hpp"
-#include "gc/g1/g1RedirtyCardsQueue.hpp"
 #include "gc/g1/heapRegion.hpp"
 #include "gc/g1/heapRegionRemSet.hpp"
 #include "gc/shared/preservedMarks.inline.hpp"
 #include "oops/access.inline.hpp"
 #include "oops/compressedOops.inline.hpp"
 #include "oops/oop.inline.hpp"
 
-class UpdateLogBuffersDeferred : public BasicOopIterateClosure {
+class UpdateRSetDeferred : public BasicOopIterateClosure {
 private:
   G1CollectedHeap* _g1h;
-  G1RedirtyCardsQueue* _rdcq;
+  G1DirtyCardQueue* _dcq;
   G1CardTable*    _ct;
 
-  // Remember the last enqueued card to avoid enqueuing the same card over and over;
-  // since we only ever handle a card once, this is sufficient.
-  size_t _last_enqueued_card;
-
 public:
-  UpdateLogBuffersDeferred(G1RedirtyCardsQueue* rdcq) :
-    _g1h(G1CollectedHeap::heap()), _rdcq(rdcq), _ct(_g1h->card_table()), _last_enqueued_card(SIZE_MAX) {}
+  UpdateRSetDeferred(G1DirtyCardQueue* dcq) :
+    _g1h(G1CollectedHeap::heap()), _dcq(dcq), _ct(_g1h->card_table()) {}
 
   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
   virtual void do_oop(      oop* p) { do_oop_work(p); }
   template <class T> void do_oop_work(T* p) {
     assert(_g1h->heap_region_containing(p)->is_in_reserved(p), "paranoia");

@@ -64,37 +60,36 @@
 
     if (HeapRegion::is_in_same_region(p, CompressedOops::decode(o))) {
       return;
     }
     size_t card_index = _ct->index_for(p);
-    if (card_index != _last_enqueued_card) {
-      _rdcq->enqueue(_ct->byte_for_index(card_index));
-      _last_enqueued_card = card_index;
+    if (_ct->mark_card_deferred(card_index)) {
+      _dcq->enqueue(_ct->byte_for_index(card_index));
     }
   }
 };
 
 class RemoveSelfForwardPtrObjClosure: public ObjectClosure {
   G1CollectedHeap* _g1h;
   G1ConcurrentMark* _cm;
   HeapRegion* _hr;
   size_t _marked_bytes;
-  UpdateLogBuffersDeferred* _log_buffer_cl;
+  UpdateRSetDeferred* _update_rset_cl;
   bool _during_initial_mark;
   uint _worker_id;
   HeapWord* _last_forwarded_object_end;
 
 public:
   RemoveSelfForwardPtrObjClosure(HeapRegion* hr,
-                                 UpdateLogBuffersDeferred* log_buffer_cl,
+                                 UpdateRSetDeferred* update_rset_cl,
                                  bool during_initial_mark,
                                  uint worker_id) :
     _g1h(G1CollectedHeap::heap()),
     _cm(_g1h->concurrent_mark()),
     _hr(hr),
     _marked_bytes(0),
-    _log_buffer_cl(log_buffer_cl),
+    _update_rset_cl(update_rset_cl),
     _during_initial_mark(during_initial_mark),
     _worker_id(worker_id),
     _last_forwarded_object_end(hr->bottom()) { }
 
   size_t marked_bytes() { return _marked_bytes; }

@@ -147,11 +142,11 @@
       // involved scanning a card in the collection set and coming
       // across an array that was being chunked and looking malformed.
       // The problem is that, if evacuation fails, we might have
       // remembered set entries missing given that we skipped cards on
       // the collection set. So, we'll recreate such entries now.
-      obj->oop_iterate(_log_buffer_cl);
+      obj->oop_iterate(_update_rset_cl);
 
       HeapWord* obj_end = obj_addr + obj_size;
       _last_forwarded_object_end = obj_end;
       _hr->cross_threshold(obj_addr, obj_end);
     }

@@ -196,26 +191,29 @@
 };
 
 class RemoveSelfForwardPtrHRClosure: public HeapRegionClosure {
   G1CollectedHeap* _g1h;
   uint _worker_id;
+  HeapRegionClaimer* _hrclaimer;
 
-  G1RedirtyCardsQueue _rdcq;
-  UpdateLogBuffersDeferred _log_buffer_cl;
+  G1DirtyCardQueue _dcq;
+  UpdateRSetDeferred _update_rset_cl;
 
 public:
-  RemoveSelfForwardPtrHRClosure(G1RedirtyCardsQueueSet* rdcqs, uint worker_id) :
+  RemoveSelfForwardPtrHRClosure(uint worker_id,
+                                HeapRegionClaimer* hrclaimer) :
     _g1h(G1CollectedHeap::heap()),
     _worker_id(worker_id),
-    _rdcq(rdcqs),
-    _log_buffer_cl(&_rdcq) {
+    _hrclaimer(hrclaimer),
+    _dcq(&_g1h->dirty_card_queue_set()),
+    _update_rset_cl(&_dcq){
   }
 
   size_t remove_self_forward_ptr_by_walking_hr(HeapRegion* hr,
                                                bool during_initial_mark) {
     RemoveSelfForwardPtrObjClosure rspc(hr,
-                                        &_log_buffer_cl,
+                                        &_update_rset_cl,
                                         during_initial_mark,
                                         _worker_id);
     hr->object_iterate(&rspc);
     // Need to zap the remainder area of the processed region.
     rspc.zap_remainder();

@@ -225,39 +223,40 @@
 
   bool do_heap_region(HeapRegion *hr) {
     assert(!hr->is_pinned(), "Unexpected pinned region at index %u", hr->hrm_index());
     assert(hr->in_collection_set(), "bad CS");
 
-    if (hr->evacuation_failed()) {
-      hr->clear_index_in_opt_cset();
+    if (_hrclaimer->claim_region(hr->hrm_index())) {
+      if (hr->evacuation_failed()) {
+        hr->clear_index_in_opt_cset();
 
-      bool during_initial_mark = _g1h->collector_state()->in_initial_mark_gc();
-      bool during_conc_mark = _g1h->collector_state()->mark_or_rebuild_in_progress();
+        bool during_initial_mark = _g1h->collector_state()->in_initial_mark_gc();
+        bool during_conc_mark = _g1h->collector_state()->mark_or_rebuild_in_progress();
 
-      hr->note_self_forwarding_removal_start(during_initial_mark,
+        hr->note_self_forwarding_removal_start(during_initial_mark,
                                                during_conc_mark);
-      _g1h->verifier()->check_bitmaps("Self-Forwarding Ptr Removal", hr);
+        _g1h->verifier()->check_bitmaps("Self-Forwarding Ptr Removal", hr);
 
-      hr->reset_bot();
+        hr->reset_bot();
 
-      size_t live_bytes = remove_self_forward_ptr_by_walking_hr(hr, during_initial_mark);
+        size_t live_bytes = remove_self_forward_ptr_by_walking_hr(hr, during_initial_mark);
 
-      hr->rem_set()->clean_strong_code_roots(hr);
-      hr->rem_set()->clear_locked(true);
+        hr->rem_set()->clean_strong_code_roots(hr);
+        hr->rem_set()->clear_locked(true);
 
-      hr->note_self_forwarding_removal_end(live_bytes);
+        hr->note_self_forwarding_removal_end(live_bytes);
+      }
     }
     return false;
   }
 };
 
-G1ParRemoveSelfForwardPtrsTask::G1ParRemoveSelfForwardPtrsTask(G1RedirtyCardsQueueSet* rdcqs) :
+G1ParRemoveSelfForwardPtrsTask::G1ParRemoveSelfForwardPtrsTask() :
   AbstractGangTask("G1 Remove Self-forwarding Pointers"),
   _g1h(G1CollectedHeap::heap()),
-  _rdcqs(rdcqs),
   _hrclaimer(_g1h->workers()->active_workers()) { }
 
 void G1ParRemoveSelfForwardPtrsTask::work(uint worker_id) {
-  RemoveSelfForwardPtrHRClosure rsfp_cl(_rdcqs, worker_id);
+  RemoveSelfForwardPtrHRClosure rsfp_cl(worker_id, &_hrclaimer);
 
-  _g1h->collection_set_iterate_increment_from(&rsfp_cl, &_hrclaimer, worker_id);
+  _g1h->collection_set_iterate_increment_from(&rsfp_cl, worker_id);
 }
< prev index next >