1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Wed Oct 07 19:01:55 2009 -0400 1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Fri Oct 16 02:05:46 2009 -0700 1.3 @@ -992,11 +992,39 @@ 1.4 1.5 // Can a compiler initialize a new object without store barriers? 1.6 // This permission only extends from the creation of a new object 1.7 - // via a TLAB up to the first subsequent safepoint. 1.8 + // via a TLAB up to the first subsequent safepoint. If such permission 1.9 + // is granted for this heap type, the compiler promises to call 1.10 + // defer_store_barrier() below on any slow path allocation of 1.11 + // a new object for which such initializing store barriers will 1.12 + // have been elided. G1, like CMS, allows this, but should be 1.13 + // ready to provide a compensating write barrier as necessary 1.14 + // if that storage came out of a non-young region. The efficiency 1.15 + // of this implementation depends crucially on being able to 1.16 + // answer very efficiently in constant time whether a piece of 1.17 + // storage in the heap comes from a young region or not. 1.18 + // See ReduceInitialCardMarks. 1.19 virtual bool can_elide_tlab_store_barriers() const { 1.20 - // Since G1's TLAB's may, on occasion, come from non-young regions 1.21 - // as well. (Is there a flag controlling that? XXX) 1.22 - return false; 1.23 + return true; 1.24 + } 1.25 + 1.26 + bool is_in_young(oop obj) { 1.27 + HeapRegion* hr = heap_region_containing(obj); 1.28 + return hr != NULL && hr->is_young(); 1.29 + } 1.30 + 1.31 + // We don't need barriers for initializing stores to objects 1.32 + // in the young gen: for the SATB pre-barrier, there is no 1.33 + // pre-value that needs to be remembered; for the remembered-set 1.34 + // update logging post-barrier, we don't maintain remembered set 1.35 + // information for young gen objects. Note that non-generational 1.36 + // G1 does not have any "young" objects, should not elide 1.37 + // the rs logging barrier and so should always answer false below. 1.38 + // However, non-generational G1 (-XX:-G1Gen) appears to have 1.39 + // bit-rotted so was not tested below. 1.40 + virtual bool can_elide_initializing_store_barrier(oop new_obj) { 1.41 + assert(G1Gen || !is_in_young(new_obj), 1.42 + "Non-generational G1 should never return true below"); 1.43 + return is_in_young(new_obj); 1.44 } 1.45 1.46 // Can a compiler elide a store barrier when it writes