src/hotspot/share/gc/shared/cardTableModRefBS.hpp
changeset 48961 120b61d50f85
parent 47998 fb0275c320a0
child 49007 82d9d5744e5f
equal deleted inserted replaced
48960:040293c73621 48961:120b61d50f85
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    55     claimed_card                =  2,
    55     claimed_card                =  2,
    56     deferred_card               =  4,
    56     deferred_card               =  4,
    57     last_card                   =  8,
    57     last_card                   =  8,
    58     CT_MR_BS_last_reserved      = 16
    58     CT_MR_BS_last_reserved      = 16
    59   };
    59   };
       
    60 
       
    61   // Used in support of ReduceInitialCardMarks; only consulted if COMPILER2
       
    62   // or INCLUDE_JVMCI is being used
       
    63   bool _defer_initial_card_mark;
    60 
    64 
    61   // a word's worth (row) of clean card values
    65   // a word's worth (row) of clean card values
    62   static const intptr_t clean_card_row = (intptr_t)(-1);
    66   static const intptr_t clean_card_row = (intptr_t)(-1);
    63 
    67 
    64   // The declaration order of these const fields is important; see the
    68   // The declaration order of these const fields is important; see the
   178 
   182 
   179  protected:
   183  protected:
   180   CardTableModRefBS(MemRegion whole_heap, const BarrierSet::FakeRtti& fake_rtti);
   184   CardTableModRefBS(MemRegion whole_heap, const BarrierSet::FakeRtti& fake_rtti);
   181   ~CardTableModRefBS();
   185   ~CardTableModRefBS();
   182 
   186 
   183  protected:
   187  public:
   184   void write_region_work(MemRegion mr) {
   188   void write_region(MemRegion mr) {
   185     dirty_MemRegion(mr);
   189     dirty_MemRegion(mr);
   186   }
   190   }
   187 
   191 
   188  protected:
   192  protected:
   189   void write_ref_array_work(MemRegion mr) {
   193   void write_ref_array_work(MemRegion mr) {
   312   // !val_equals -> it will check that all cards covered by mr do not equal val
   316   // !val_equals -> it will check that all cards covered by mr do not equal val
   313   void verify_region(MemRegion mr, jbyte val, bool val_equals) PRODUCT_RETURN;
   317   void verify_region(MemRegion mr, jbyte val, bool val_equals) PRODUCT_RETURN;
   314   void verify_not_dirty_region(MemRegion mr) PRODUCT_RETURN;
   318   void verify_not_dirty_region(MemRegion mr) PRODUCT_RETURN;
   315   void verify_dirty_region(MemRegion mr) PRODUCT_RETURN;
   319   void verify_dirty_region(MemRegion mr) PRODUCT_RETURN;
   316 
   320 
       
   321   // ReduceInitialCardMarks
       
   322   void initialize_deferred_card_mark_barriers();
       
   323 
       
   324   // If the CollectedHeap was asked to defer a store barrier above,
       
   325   // this informs it to flush such a deferred store barrier to the
       
   326   // remembered set.
       
   327   void flush_deferred_card_mark_barrier(JavaThread* thread);
       
   328 
       
   329   // Can a compiler initialize a new object without store barriers?
       
   330   // This permission only extends from the creation of a new object
       
   331   // via a TLAB up to the first subsequent safepoint. If such permission
       
   332   // is granted for this heap type, the compiler promises to call
       
   333   // defer_store_barrier() below on any slow path allocation of
       
   334   // a new object for which such initializing store barriers will
       
   335   // have been elided. G1, like CMS, allows this, but should be
       
   336   // ready to provide a compensating write barrier as necessary
       
   337   // if that storage came out of a non-young region. The efficiency
       
   338   // of this implementation depends crucially on being able to
       
   339   // answer very efficiently in constant time whether a piece of
       
   340   // storage in the heap comes from a young region or not.
       
   341   // See ReduceInitialCardMarks.
       
   342   virtual bool can_elide_tlab_store_barriers() const {
       
   343     return true;
       
   344   }
       
   345 
       
   346   // If a compiler is eliding store barriers for TLAB-allocated objects,
       
   347   // we will be informed of a slow-path allocation by a call
       
   348   // to on_slowpath_allocation_exit() below. Such a call precedes the
       
   349   // initialization of the object itself, and no post-store-barriers will
       
   350   // be issued. Some heap types require that the barrier strictly follows
       
   351   // the initializing stores. (This is currently implemented by deferring the
       
   352   // barrier until the next slow-path allocation or gc-related safepoint.)
       
   353   // This interface answers whether a particular barrier type needs the card
       
   354   // mark to be thus strictly sequenced after the stores.
       
   355   virtual bool card_mark_must_follow_store() const = 0;
       
   356 
       
   357   virtual bool is_in_young(oop obj) const = 0;
       
   358 
       
   359   virtual void on_slowpath_allocation_exit(JavaThread* thread, oop new_obj);
       
   360   virtual void flush_deferred_barriers(JavaThread* thread);
       
   361 
       
   362   virtual void make_parsable(JavaThread* thread) { flush_deferred_card_mark_barrier(thread); }
       
   363 
   317   template <DecoratorSet decorators, typename BarrierSetT = CardTableModRefBS>
   364   template <DecoratorSet decorators, typename BarrierSetT = CardTableModRefBS>
   318   class AccessBarrier: public ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> {};
   365   class AccessBarrier: public ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> {};
   319 };
   366 };
   320 
   367 
   321 template<>
   368 template<>