comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @ 1027:39b01ab7035a

6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning 6889757: G1: enable card mark elision for initializing writes from compiled code (ReduceInitialCardMarks) Summary: Defer the (compiler-elided) card-mark upon a slow-path allocation until after the store and before the next subsequent safepoint; G1 now answers yes to can_elide_tlab_write_barriers(). Reviewed-by: jcoomes, kvn, never
author ysr
date Fri, 16 Oct 2009 02:05:46 -0700
parents 2c79770d1f6e
children ed52bcc32739
comparison
equal deleted inserted replaced
1025:1ee412f7fec9 1027:39b01ab7035a
990 virtual size_t unsafe_max_tlab_alloc(Thread* thr) const; 990 virtual size_t unsafe_max_tlab_alloc(Thread* thr) const;
991 virtual HeapWord* allocate_new_tlab(size_t size); 991 virtual HeapWord* allocate_new_tlab(size_t size);
992 992
993 // Can a compiler initialize a new object without store barriers? 993 // Can a compiler initialize a new object without store barriers?
994 // This permission only extends from the creation of a new object 994 // This permission only extends from the creation of a new object
995 // via a TLAB up to the first subsequent safepoint. 995 // via a TLAB up to the first subsequent safepoint. If such permission
996 // is granted for this heap type, the compiler promises to call
997 // defer_store_barrier() below on any slow path allocation of
998 // a new object for which such initializing store barriers will
999 // have been elided. G1, like CMS, allows this, but should be
1000 // ready to provide a compensating write barrier as necessary
1001 // if that storage came out of a non-young region. The efficiency
1002 // of this implementation depends crucially on being able to
1003 // answer very efficiently in constant time whether a piece of
1004 // storage in the heap comes from a young region or not.
1005 // See ReduceInitialCardMarks.
996 virtual bool can_elide_tlab_store_barriers() const { 1006 virtual bool can_elide_tlab_store_barriers() const {
997 // Since G1's TLAB's may, on occasion, come from non-young regions 1007 return true;
998 // as well. (Is there a flag controlling that? XXX) 1008 }
999 return false; 1009
1010 bool is_in_young(oop obj) {
1011 HeapRegion* hr = heap_region_containing(obj);
1012 return hr != NULL && hr->is_young();
1013 }
1014
1015 // We don't need barriers for initializing stores to objects
1016 // in the young gen: for the SATB pre-barrier, there is no
1017 // pre-value that needs to be remembered; for the remembered-set
1018 // update logging post-barrier, we don't maintain remembered set
1019 // information for young gen objects. Note that non-generational
1020 // G1 does not have any "young" objects, should not elide
1021 // the rs logging barrier and so should always answer false below.
1022 // However, non-generational G1 (-XX:-G1Gen) appears to have
1023 // bit-rotted so was not tested below.
1024 virtual bool can_elide_initializing_store_barrier(oop new_obj) {
1025 assert(G1Gen || !is_in_young(new_obj),
1026 "Non-generational G1 should never return true below");
1027 return is_in_young(new_obj);
1000 } 1028 }
1001 1029
1002 // Can a compiler elide a store barrier when it writes 1030 // Can a compiler elide a store barrier when it writes
1003 // a permanent oop into the heap? Applies when the compiler 1031 // a permanent oop into the heap? Applies when the compiler
1004 // is storing x to the heap, where x->is_perm() is true. 1032 // is storing x to the heap, where x->is_perm() is true.