< prev index next >

src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp

Print this page
rev 8039 : [mq]: simplify

@@ -257,18 +257,21 @@
                _local_max_size = tmp_size;
              }
              ++_local_pushes );
 }
 
-// This determines whether the method below will check both the local
-// and global fingers when determining whether to push on the stack a
-// gray object (value 1) or whether it will only check the global one
-// (value 0). The tradeoffs are that the former will be a bit more
-// accurate and possibly push less on the stack, but it might also be
-// a little bit slower.
-
-#define _CHECK_BOTH_FINGERS_      1
+inline void CMTask::deal_with_reference_below_finger(
+  oop obj, HeapWord* finger, bool is_global_finger)
+{
+  if (_cm->verbose_high()) {
+    gclog_or_tty->print_cr(
+      "[%u] below the %s finger (" PTR_FORMAT ") pushing " PTR_FORMAT,
+      _worker_id, (is_global_finger ? "global" : "local"),
+      p2i(finger), p2i((void*)obj));
+  }
+  push(obj);
+}
 
 inline void CMTask::deal_with_reference(oop obj) {
   if (_cm->verbose_high()) {
     gclog_or_tty->print_cr("[%u] we're dealing with reference = "PTR_FORMAT,
                            _worker_id, p2i((void*) obj));

@@ -295,54 +298,46 @@
         if (_cm->par_mark_and_count(obj, hr, _marked_bytes_array, _card_bm)) {
           // No OrderAccess:store_load() is needed. It is implicit in the
           // CAS done in CMBitMap::parMark() call in the routine above.
           HeapWord* global_finger = _cm->finger();
 
-#if _CHECK_BOTH_FINGERS_
-          // we will check both the local and global fingers
-
-          if (_finger != NULL && objAddr < _finger) {
-            if (_cm->verbose_high()) {
-              gclog_or_tty->print_cr("[%u] below the local finger ("PTR_FORMAT"), "
-                                     "pushing it", _worker_id, p2i(_finger));
-            }
-            push(obj);
-          } else if (_curr_region != NULL && objAddr < _region_limit) {
-            // do nothing
-          } else if (objAddr < global_finger) {
+          // If we have a current region, check against it first to
+          // decide whether to push a freshly grey object on the mark
+          // stack or leave it to the mark bit processor.  The
+          // tradeoff vs only checking the global finger is that the
+          // local check will be a bit more accurate and possibly push
+          // less on the stack, but might also be a little bit slower.
+          if (_finger != NULL) {
+            // We have a current region.
+            assert(_curr_region != NULL, "invariant");
+            assert(_region_limit != NULL, "invariant");
+            // If object is before the local finger, push it onto the
+            // mark stack.  If it's between the local finger and the
+            // end of the region, leave it to mark bit processing to
+            // take care of.  Otherwise, check against the global
+            // finger.
+            if (objAddr < _finger) {
+              deal_with_reference_below_finger(obj, _finger, false);
+              return;
+            } else if (objAddr < _region_limit) {
+              return;
+            }
+          }
+          // No current region, or object is after the current region.
+          // Push onto mark stack if below global finger.
+          //
             // Notice that the global finger might be moving forward
             // concurrently. This is not a problem. In the worst case, we
             // mark the object while it is above the global finger and, by
             // the time we read the global finger, it has moved forward
             // passed this object. In this case, the object will probably
             // be visited when a task is scanning the region and will also
             // be pushed on the stack. So, some duplicate work, but no
             // correctness problems.
-
-            if (_cm->verbose_high()) {
-              gclog_or_tty->print_cr("[%u] below the global finger "
-                                     "("PTR_FORMAT"), pushing it",
-                                     _worker_id, p2i(global_finger));
-            }
-            push(obj);
-          } else {
-            // do nothing
-          }
-#else // _CHECK_BOTH_FINGERS_
-          // we will only check the global finger
-
           if (objAddr < global_finger) {
-            // see long comment above
-
-            if (_cm->verbose_high()) {
-              gclog_or_tty->print_cr("[%u] below the global finger "
-                                     "("PTR_FORMAT"), pushing it",
-                                     _worker_id, p2i(global_finger));
-            }
-            push(obj);
+            deal_with_reference_below_finger(obj, global_finger, true);
           }
-#endif // _CHECK_BOTH_FINGERS_
         }
       }
     }
   }
 }
< prev index next >