< prev index next >

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

Print this page
rev 12513 : 8071278: Fix the closure mess in G1RemSet::refine_card()
Summary: Remove the use of many nested closure in the code to refine a card.
Reviewed-by: kbarrett, sjohanss

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -53,14 +53,10 @@
                                  G1ParPushHeapRSClosure* cl,
                                  CardTableModRefBS::PrecisionStyle precision) :
   DirtyCardToOopClosure(hr, cl, precision, NULL),
   _hr(hr), _rs_scan(cl), _g1(g1) { }
 
-FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r,
-                                                   OopClosure* oc) :
-  _r_bottom(r->bottom()), _r_end(r->end()), _oc(oc) { }
-
 void HeapRegionDCTOC::walk_mem_region(MemRegion mr,
                                       HeapWord* bottom,
                                       HeapWord* top) {
   G1CollectedHeap* g1h = _g1;
   size_t oop_size;

@@ -351,11 +347,11 @@
 
 // Humongous objects are allocated directly in the old-gen.  Need
 // special handling for concurrent processing encountering an
 // in-progress allocation.
 static bool do_oops_on_card_in_humongous(MemRegion mr,
-                                         FilterOutOfRegionClosure* cl,
+                                         G1UpdateRSOrPushRefOopClosure* cl,
                                          HeapRegion* hr,
                                          G1CollectedHeap* g1h) {
   assert(hr->is_humongous(), "precondition");
   HeapRegion* sr = hr->humongous_start_region();
   oop obj = oop(sr->bottom());

@@ -392,11 +388,11 @@
   }
   return true;
 }
 
 bool HeapRegion::oops_on_card_seq_iterate_careful(MemRegion mr,
-                                                  FilterOutOfRegionClosure* cl) {
+                                                  G1UpdateRSOrPushRefOopClosure* cl) {
   assert(MemRegion(bottom(), end()).contains(mr), "Card region not in heap region");
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 
   // Special handling for humongous regions.
   if (is_humongous()) {

@@ -763,10 +759,25 @@
       }
     }
   }
 };
 
+// Closure that applies the given two closures in sequence.
+class G1Mux2Closure : public OopClosure {
+  OopClosure* _c1;
+  OopClosure* _c2;
+public:
+  G1Mux2Closure(OopClosure *c1, OopClosure *c2) { _c1 = c1; _c2 = c2; }
+  template <class T> inline void do_oop_work(T* p) {
+    // Apply first closure; then apply the second.
+    _c1->do_oop(p);
+    _c2->do_oop(p);
+  }
+  virtual inline void do_oop(oop* p) { do_oop_work(p); }
+  virtual inline void do_oop(narrowOop* p) { do_oop_work(p); }
+};
+
 // This really ought to be commoned up into OffsetTableContigSpace somehow.
 // We would need a mechanism to make that code skip dead objects.
 
 void HeapRegion::verify(VerifyOption vo,
                         bool* failures) const {
< prev index next >