changeset 9766:3abcb0c82f67

Only push marked objects on task queue.
author rkennke
date Wed, 07 Oct 2015 18:06:30 +0200
parents edd77b2146e0
children 41ee7801dbc1
files src/share/vm/gc/shenandoah/shenandoahConcurrentMark.cpp src/share/vm/gc/shenandoah/shenandoahConcurrentMark.inline.hpp
diffstat 2 files changed, 49 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc/shenandoah/shenandoahConcurrentMark.cpp	Tue Oct 06 16:37:53 2015 +0200
+++ b/src/share/vm/gc/shenandoah/shenandoahConcurrentMark.cpp	Wed Oct 07 18:06:30 2015 +0200
@@ -131,7 +131,7 @@
     AbstractGangTask("Root Region Scan"), _cm(cm), _terminator(terminator), _update_refs(update_refs), _seed(17) {
   }
 
-      
+
   void work(uint worker_id) {
 
     SCMObjToScanQueue* q = _cm->get_queue(worker_id);
@@ -233,14 +233,14 @@
     rp->enable_discovery(true /*verify_no_refs*/);
     rp->setup_policy(false); // snapshot the soft ref policy to be used in this cycle
   }
-  
+
   SCMConcurrentMarkingTask markingTask = SCMConcurrentMarkingTask(this, &terminator, update_refs);
   sh->conc_workers()->set_active_workers(_max_conc_worker_id);
   sh->conc_workers()->run_task(&markingTask);
 
   if (ShenandoahGCVerbose) {
-    tty->print("total workers = %u active workers = %u\n", 
-	       sh->conc_workers()->total_workers(), 
+    tty->print("total workers = %u active workers = %u\n",
+	       sh->conc_workers()->total_workers(),
 	       sh->conc_workers()->active_workers());
     TASKQUEUE_STATS_ONLY(print_taskqueue_stats());
     TASKQUEUE_STATS_ONLY(reset_taskqueue_stats());
@@ -306,7 +306,7 @@
     sh->conc_workers()->run_task(&drain_satb_buffers);
     sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::drain_satb);
   }
-  
+
   // Finally mark everything else we've got in our queues during the previous steps.
   {
     sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::drain_queues);
@@ -387,10 +387,10 @@
 class ShenandoahSATBBufferClosure : public SATBBufferClosure {
 private:
   SCMObjToScanQueue* _queue;
-
+  ShenandoahHeap* _heap;
 public:
   ShenandoahSATBBufferClosure(SCMObjToScanQueue* q) :
-    _queue(q)
+    _queue(q), _heap(ShenandoahHeap::heap())
   {
   }
 
@@ -402,8 +402,10 @@
       // tty->print_cr("satb buffer entry: "PTR_FORMAT, p2i((HeapWord*) obj));
       if (!oopDesc::is_null(obj)) {
 	obj = ShenandoahBarrierSet::resolve_oop_static_not_null(obj);
-	bool pushed = _queue->push(obj);
-	assert(pushed, "overflow queue should always succeed pushing");
+        if (_heap->mark_current(obj)) {
+          bool pushed = _queue->push(obj);
+          assert(pushed, "overflow queue should always succeed pushing");
+        }
       }
     }
   }
@@ -476,7 +478,7 @@
   TaskQueueStats totals;
   const int n = sh->max_conc_workers();
   for (int i = 0; i < n; ++i) {
-    st->print(INT32_FORMAT_W(3), i); 
+    st->print(INT32_FORMAT_W(3), i);
     _task_queues->queue(i)->stats.print(st);
     st->print("\n");
     totals += _task_queues->queue(i)->stats;
@@ -492,7 +494,7 @@
   TaskQueueStats totals;
   const int n = sh->max_conc_workers();
   for (int i = 0; i < n; ++i) {
-    st->print(INT32_FORMAT_W(3), i); 
+    st->print(INT32_FORMAT_W(3), i);
     _task_queues->queue(i)->stats.print(st);
     st->print("\n");
     totals += _task_queues->queue(i)->stats;
@@ -524,7 +526,7 @@
     _scm = _sh->concurrentMark();
   }
 
-      
+
   void do_void() {
 
     SCMObjToScanQueue* q = _scm->get_queue(_worker_id);
@@ -556,12 +558,12 @@
   }
 
   virtual void do_oop(oop* p){ do_oop_work(p);}
-  virtual void do_oop(narrowOop* p) {  
+  virtual void do_oop(narrowOop* p) {
     assert(false, "narrowOops Aren't implemented");
   }
 
 
-  void do_oop_work(oop* p) {  
+  void do_oop_work(oop* p) {
 
     oop obj;
     if (_sh->need_update_refs()) {
@@ -579,11 +581,12 @@
 			       p2i(p), p2i((void*) obj));
 	obj->print();
       }
-      bool pushed = _queue->push(obj);
-      assert(pushed, "overflow queue should always succeed pushing");
-
+      if (_sh->mark_current(obj)) {
+        bool pushed = _queue->push(obj);
+        assert(pushed, "overflow queue should always succeed pushing");
+      }
       _ref_count++;
-    }    
+    }
   }
 
   size_t ref_count() { return _ref_count; }
@@ -674,11 +677,11 @@
      gclog_or_tty->print_cr("start processing references");
    }
 
-   rp->process_discovered_references(&is_alive, &keep_alive, 
-				     &complete_gc, &par_task_executor, 
+   rp->process_discovered_references(&is_alive, &keep_alive,
+				     &complete_gc, &par_task_executor,
 				     NULL,
                                      ShenandoahHeap::heap()->tracer()->gc_id());
-   
+
    if (ShenandoahTraceWeakReferences) {
      gclog_or_tty->print_cr("finished processing references, processed "SIZE_FORMAT" refs", keep_alive.ref_count());
      gclog_or_tty->print_cr("start enqueuing references");
@@ -735,4 +738,3 @@
   worker_id = worker_id % _max_conc_worker_id;
   return _task_queues->queue(worker_id);
 }
-
--- a/src/share/vm/gc/shenandoah/shenandoahConcurrentMark.inline.hpp	Tue Oct 06 16:37:53 2015 +0200
+++ b/src/share/vm/gc/shenandoah/shenandoahConcurrentMark.inline.hpp	Wed Oct 07 18:06:30 2015 +0200
@@ -45,7 +45,7 @@
 
 #ifdef ASSERT
   if (ShenandoahTraceUpdates) {
-    if (p != old) 
+    if (p != old)
       tty->print_cr("Update "PTR_FORMAT" => "PTR_FORMAT"  to "PTR_FORMAT" => "PTR_FORMAT, p2i(p), p2i((HeapWord*) *p), p2i(old), p2i((HeapWord*) *old));
     else
       tty->print_cr("Not updating "PTR_FORMAT" => "PTR_FORMAT"  to "PTR_FORMAT" => "PTR_FORMAT, p2i(p), p2i((HeapWord*) *p), p2i(old), p2i((HeapWord*) *old));
@@ -73,9 +73,21 @@
     ShenandoahHeapRegion* r = _heap->heap_regions()[region_idx];
     assert(r->bottom() < (HeapWord*) obj && r->top() > (HeapWord*) obj, "object must be in region");
 #endif
-
-    bool pushed = _queue->push(obj);
-    assert(pushed, "overflow queue should always succeed pushing");
+    if (_heap->mark_current(obj)) {
+      if (ShenandoahTraceConcurrentMarking) {
+        tty->print_cr("marked obj: "PTR_FORMAT, p2i((HeapWord*) obj));
+      }
+      bool pushed = _queue->push(obj);
+      assert(pushed, "overflow queue should always succeed pushing");
+    }
+#ifdef ASSERT
+    else {
+      if (ShenandoahTraceConcurrentMarking) {
+        tty->print_cr("failed to mark obj (already marked): "PTR_FORMAT, p2i((HeapWord*) obj));
+      }
+      assert(_heap->is_marked_current(obj), "make sure object is marked");
+    }
+#endif
   }
 }
 
@@ -96,31 +108,17 @@
 	 || ! _heap->heap_region_containing(obj)->is_in_collection_set(),
 	 "we don't want to mark objects in from-space");
   assert(_heap->is_in(obj), "referenced objects must be in the heap. No?");
-  if (_heap->mark_current(obj)) {
+  assert(_heap->is_marked_current(obj), "only marked objects on task queue");
+
+  // Calculate liveness of heap region containing object.
+  uint region_idx  = _heap->heap_region_index_containing(obj);
 #ifdef ASSERT
-    if (ShenandoahTraceConcurrentMarking) {
-      tty->print_cr("marked obj: "PTR_FORMAT, p2i((HeapWord*) obj));
-    }
-#endif
-
-    // Calculate liveness of heap region containing object.
-    uint region_idx  = _heap->heap_region_index_containing(obj);
-#ifdef ASSERT
-    ShenandoahHeapRegion* r = _heap->heap_regions()[region_idx];
-    assert(r->bottom() < (HeapWord*) obj && r->top() > (HeapWord*) obj, "object must be in region");
+  ShenandoahHeapRegion* r = _heap->heap_regions()[region_idx];
+  assert(r->bottom() < (HeapWord*) obj && r->top() > (HeapWord*) obj, "object must be in region");
 #endif
-    _live_data[region_idx] += (obj->size() + BrooksPointer::BROOKS_POINTER_OBJ_SIZE) * HeapWordSize;
-    obj->oop_iterate(&_mark_refs);
-  }
+  _live_data[region_idx] += (obj->size() + BrooksPointer::BROOKS_POINTER_OBJ_SIZE) * HeapWordSize;
+  obj->oop_iterate(&_mark_refs);
 
-#ifdef ASSERT
-  else {
-    if (ShenandoahTraceConcurrentMarking) {
-      tty->print_cr("failed to mark obj (already marked): "PTR_FORMAT, p2i((HeapWord*) obj));
-    }
-    assert(_heap->is_marked_current(obj), "make sure object is marked");
-  }
-#endif
 }
 
 inline bool ShenandoahConcurrentMark::try_queue(SCMObjToScanQueue* q, ShenandoahMarkObjsClosure* cl) {
@@ -142,7 +140,7 @@
   if (task_queues()->steal(worker_id, seed, obj)) {
     cl->do_object(obj);
     return true;
-  } else 
+  } else
     return false;
 }