8039042: G1: Phantom zeros in cardtable
authorpliden
Tue, 20 May 2014 10:24:30 +0200
changeset 24471 fef3080a658b
parent 24470 2291d267ff97
child 24472 e2485ae797a4
8039042: G1: Phantom zeros in cardtable Reviewed-by: tschatzl, mgerdin
hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp	Mon May 19 08:09:35 2014 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp	Tue May 20 10:24:30 2014 +0200
@@ -96,7 +96,15 @@
   jbyte *const first = byte_for(mr.start());
   jbyte *const last = byte_after(mr.last());
 
-  memset(first, g1_young_gen, last - first);
+  // Below we may use an explicit loop instead of memset() because on
+  // certain platforms memset() can give concurrent readers phantom zeros.
+  if (UseMemSetInBOT) {
+    memset(first, g1_young_gen, last - first);
+  } else {
+    for (jbyte* i = first; i < last; i++) {
+      *i = g1_young_gen;
+    }
+  }
 }
 
 #ifndef PRODUCT