< prev index next >

src/hotspot/share/gc/g1/g1BarrierSet.hpp

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_G1BARRIERSET_HPP
  26 #define SHARE_VM_GC_G1_G1BARRIERSET_HPP
  27 


  28 #include "gc/shared/cardTableBarrierSet.hpp"
  29 
  30 class DirtyCardQueueSet;
  31 class CardTable;
  32 class G1CardTable;
  33 
  34 // This barrier is specialized to use a logging barrier to support
  35 // snapshot-at-the-beginning marking.
  36 
  37 class G1BarrierSet: public CardTableBarrierSet {
  38   friend class VMStructs;
  39  private:
  40   DirtyCardQueueSet& _dcqs;

  41 
  42  public:
  43   G1BarrierSet(G1CardTable* table);
  44   ~G1BarrierSet() { }
  45 
  46   // Add "pre_val" to a set of objects that may have been disconnected from the
  47   // pre-marking object graph.
  48   static void enqueue(oop pre_val);
  49 
  50   static void enqueue_if_weak_or_archive(DecoratorSet decorators, oop value);
  51 
  52   template <class T> void write_ref_array_pre_work(T* dst, size_t count);
  53   virtual void write_ref_array_pre(oop* dst, size_t count, bool dest_uninitialized);
  54   virtual void write_ref_array_pre(narrowOop* dst, size_t count, bool dest_uninitialized);
  55 
  56   static void write_ref_array_pre_oop_entry(oop* dst, size_t length);
  57   static void write_ref_array_pre_narrow_oop_entry(narrowOop* dst, size_t length);
  58   static void write_ref_array_post_entry(HeapWord* dst, size_t length);
  59 
  60   template <DecoratorSet decorators, typename T>
  61   void write_ref_field_pre(T* field);
  62 
  63   // NB: if you do a whole-heap invalidation, the "usual invariant" defined
  64   // above no longer applies.
  65   void invalidate(MemRegion mr);
  66 
  67   void write_region(MemRegion mr)         { invalidate(mr); }
  68   void write_ref_array_work(MemRegion mr) { invalidate(mr); }
  69 
  70   template <DecoratorSet decorators, typename T>
  71   void write_ref_field_post(T* field, oop new_val);
  72   void write_ref_field_post_slow(volatile jbyte* byte);
  73 
  74   virtual void on_thread_attach(JavaThread* thread);
  75   virtual void on_thread_detach(JavaThread* thread);








  76 
  77   // Callbacks for runtime accesses.
  78   template <DecoratorSet decorators, typename BarrierSetT = G1BarrierSet>
  79   class AccessBarrier: public ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> {
  80     typedef ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> ModRef;
  81     typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
  82 
  83   public:
  84     // Needed for loads on non-heap weak references
  85     template <typename T>
  86     static oop oop_load_not_in_heap(T* addr);
  87 
  88     // Needed for non-heap stores
  89     template <typename T>
  90     static void oop_store_not_in_heap(T* addr, oop new_value);
  91 
  92     // Needed for weak references
  93     static oop oop_load_in_heap_at(oop base, ptrdiff_t offset);
  94 
  95     // Defensive: will catch weak oops at addresses in heap


   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_G1BARRIERSET_HPP
  26 #define SHARE_VM_GC_G1_G1BARRIERSET_HPP
  27 
  28 #include "gc/g1/dirtyCardQueue.hpp"
  29 #include "gc/g1/satbMarkQueue.hpp"
  30 #include "gc/shared/cardTableBarrierSet.hpp"
  31 
  32 class DirtyCardQueueSet;
  33 class CardTable;
  34 class G1CardTable;
  35 
  36 // This barrier is specialized to use a logging barrier to support
  37 // snapshot-at-the-beginning marking.
  38 
  39 class G1BarrierSet: public CardTableBarrierSet {
  40   friend class VMStructs;
  41  private:
  42   static SATBMarkQueueSet  _satb_mark_queue_set;
  43   static DirtyCardQueueSet _dirty_card_queue_set;
  44 
  45  public:
  46   G1BarrierSet(G1CardTable* table);
  47   ~G1BarrierSet() { }
  48 
  49   // Add "pre_val" to a set of objects that may have been disconnected from the
  50   // pre-marking object graph.
  51   static void enqueue(oop pre_val);
  52 
  53   static void enqueue_if_weak_or_archive(DecoratorSet decorators, oop value);
  54 
  55   template <class T> void write_ref_array_pre_work(T* dst, size_t count);
  56   virtual void write_ref_array_pre(oop* dst, size_t count, bool dest_uninitialized);
  57   virtual void write_ref_array_pre(narrowOop* dst, size_t count, bool dest_uninitialized);
  58 
  59   static void write_ref_array_pre_oop_entry(oop* dst, size_t length);
  60   static void write_ref_array_pre_narrow_oop_entry(narrowOop* dst, size_t length);
  61   static void write_ref_array_post_entry(HeapWord* dst, size_t length);
  62 
  63   template <DecoratorSet decorators, typename T>
  64   void write_ref_field_pre(T* field);
  65 
  66   // NB: if you do a whole-heap invalidation, the "usual invariant" defined
  67   // above no longer applies.
  68   void invalidate(MemRegion mr);
  69 
  70   void write_region(MemRegion mr)         { invalidate(mr); }
  71   void write_ref_array_work(MemRegion mr) { invalidate(mr); }
  72 
  73   template <DecoratorSet decorators, typename T>
  74   void write_ref_field_post(T* field, oop new_val);
  75   void write_ref_field_post_slow(volatile jbyte* byte);
  76 
  77   virtual void on_thread_attach(JavaThread* thread);
  78   virtual void on_thread_detach(JavaThread* thread);
  79 
  80   static SATBMarkQueueSet& satb_mark_queue_set() {
  81     return _satb_mark_queue_set;
  82   }
  83 
  84   static DirtyCardQueueSet& dirty_card_queue_set() {
  85     return _dirty_card_queue_set;
  86   }
  87 
  88   // Callbacks for runtime accesses.
  89   template <DecoratorSet decorators, typename BarrierSetT = G1BarrierSet>
  90   class AccessBarrier: public ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> {
  91     typedef ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> ModRef;
  92     typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
  93 
  94   public:
  95     // Needed for loads on non-heap weak references
  96     template <typename T>
  97     static oop oop_load_not_in_heap(T* addr);
  98 
  99     // Needed for non-heap stores
 100     template <typename T>
 101     static void oop_store_not_in_heap(T* addr, oop new_value);
 102 
 103     // Needed for weak references
 104     static oop oop_load_in_heap_at(oop base, ptrdiff_t offset);
 105 
 106     // Defensive: will catch weak oops at addresses in heap
< prev index next >