src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp

Print this page
rev 5918 : 8035326: Assume non-NULL references in G1CollectedHeap::in_cset_fast_test
Summary: Remove the assumption that G1CollectedHeap::in_cset_fast_test needs to check for NULL references. Most of the time this is not required, making the code doing this check multiple times.
Reviewed-by:

@@ -696,27 +696,24 @@
     assert(!_in_cset_fast_test_base[index], "invariant");
     _in_cset_fast_test_base[index] = true;
   }
 
   // This is a fast test on whether a reference points into the
-  // collection set or not. It does not assume that the reference
-  // points into the heap; if it doesn't, it will return false.
+  // collection set or not. Assume that the reference
+  // points into the heap.
   bool in_cset_fast_test(oop obj) {
     assert(_in_cset_fast_test != NULL, "sanity");
-    if (_g1_committed.contains((HeapWord*) obj)) {
+    assert(_g1_committed.contains((HeapWord*) obj), err_msg("Given reference outside of heap, is "PTR_FORMAT, obj));
       // no need to subtract the bottom of the heap from obj,
       // _in_cset_fast_test is biased
       uintx index = cast_from_oop<uintx>(obj) >> HeapRegion::LogOfHRGrainBytes;
       bool ret = _in_cset_fast_test[index];
       // let's make sure the result is consistent with what the slower
       // test returns
       assert( ret || !obj_in_cs(obj), "sanity");
       assert(!ret ||  obj_in_cs(obj), "sanity");
       return ret;
-    } else {
-      return false;
-    }
   }
 
   void clear_cset_fast_test() {
     assert(_in_cset_fast_test_base != NULL, "sanity");
     memset(_in_cset_fast_test_base, false,