< prev index next >

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

Print this page
rev 53582 : imported patch rename


  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_GC_G1_G1HOTCARDCACHE_HPP
  26 #define SHARE_GC_G1_G1HOTCARDCACHE_HPP
  27 
  28 #include "gc/g1/g1CardCounts.hpp"
  29 #include "gc/g1/g1_globals.hpp"
  30 #include "memory/allocation.hpp"
  31 #include "runtime/safepoint.hpp"
  32 #include "runtime/thread.hpp"
  33 #include "utilities/globalDefinitions.hpp"
  34 
  35 class CardTableEntryClosure;
  36 class DirtyCardQueue;
  37 class G1CollectedHeap;
  38 class HeapRegion;
  39 
  40 // An evicting cache of cards that have been logged by the G1 post
  41 // write barrier. Placing a card in the cache delays the refinement
  42 // of the card until the card is evicted, or the cache is drained
  43 // during the next evacuation pause.
  44 //
  45 // The first thing the G1 post write barrier does is to check whether
  46 // the card containing the updated pointer is already dirty and, if
  47 // so, skips the remaining code in the barrier.
  48 //
  49 // Delaying the refinement of a card will make the card fail the
  50 // first is_dirty check in the write barrier, skipping the remainder
  51 // of the write barrier.
  52 //
  53 // This can significantly reduce the overhead of the write barrier
  54 // code, increasing throughput.
  55 
  56 class G1HotCardCache: public CHeapObj<mtGC> {


  95 
  96   bool use_cache() { return _use_cache; }
  97 
  98   void set_use_cache(bool b) {
  99     _use_cache = (b ? default_use_cache() : false);
 100   }
 101 
 102   // Returns the card to be refined or NULL.
 103   //
 104   // Increments the count for given the card. if the card is not 'hot',
 105   // it is returned for immediate refining. Otherwise the card is
 106   // added to the hot card cache.
 107   // If there is enough room in the hot card cache for the card we're
 108   // adding, NULL is returned and no further action in needed.
 109   // If we evict a card from the cache to make room for the new card,
 110   // the evicted card is then returned for refinement.
 111   jbyte* insert(jbyte* card_ptr);
 112 
 113   // Refine the cards that have delayed as a result of
 114   // being in the cache.
 115   void drain(CardTableEntryClosure* cl, uint worker_i);
 116 
 117   // Set up for parallel processing of the cards in the hot cache
 118   void reset_hot_cache_claimed_index() {
 119     _hot_cache_par_claimed_idx = 0;
 120   }
 121 
 122   // Resets the hot card cache and discards the entries.
 123   void reset_hot_cache() {
 124     assert(SafepointSynchronize::is_at_safepoint(), "Should be at a safepoint");
 125     assert(Thread::current()->is_VM_thread(), "Current thread should be the VMthread");
 126     if (default_use_cache()) {
 127         reset_hot_cache_internal();
 128     }
 129   }
 130 
 131   // Zeros the values in the card counts table for the given region
 132   void reset_card_counts(HeapRegion* hr);
 133 
 134  private:
 135   void reset_hot_cache_internal() {


  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_GC_G1_G1HOTCARDCACHE_HPP
  26 #define SHARE_GC_G1_G1HOTCARDCACHE_HPP
  27 
  28 #include "gc/g1/g1CardCounts.hpp"
  29 #include "gc/g1/g1_globals.hpp"
  30 #include "memory/allocation.hpp"
  31 #include "runtime/safepoint.hpp"
  32 #include "runtime/thread.hpp"
  33 #include "utilities/globalDefinitions.hpp"
  34 
  35 class G1CardTableEntryClosure;

  36 class G1CollectedHeap;
  37 class HeapRegion;
  38 
  39 // An evicting cache of cards that have been logged by the G1 post
  40 // write barrier. Placing a card in the cache delays the refinement
  41 // of the card until the card is evicted, or the cache is drained
  42 // during the next evacuation pause.
  43 //
  44 // The first thing the G1 post write barrier does is to check whether
  45 // the card containing the updated pointer is already dirty and, if
  46 // so, skips the remaining code in the barrier.
  47 //
  48 // Delaying the refinement of a card will make the card fail the
  49 // first is_dirty check in the write barrier, skipping the remainder
  50 // of the write barrier.
  51 //
  52 // This can significantly reduce the overhead of the write barrier
  53 // code, increasing throughput.
  54 
  55 class G1HotCardCache: public CHeapObj<mtGC> {


  94 
  95   bool use_cache() { return _use_cache; }
  96 
  97   void set_use_cache(bool b) {
  98     _use_cache = (b ? default_use_cache() : false);
  99   }
 100 
 101   // Returns the card to be refined or NULL.
 102   //
 103   // Increments the count for given the card. if the card is not 'hot',
 104   // it is returned for immediate refining. Otherwise the card is
 105   // added to the hot card cache.
 106   // If there is enough room in the hot card cache for the card we're
 107   // adding, NULL is returned and no further action in needed.
 108   // If we evict a card from the cache to make room for the new card,
 109   // the evicted card is then returned for refinement.
 110   jbyte* insert(jbyte* card_ptr);
 111 
 112   // Refine the cards that have delayed as a result of
 113   // being in the cache.
 114   void drain(G1CardTableEntryClosure* cl, uint worker_i);
 115 
 116   // Set up for parallel processing of the cards in the hot cache
 117   void reset_hot_cache_claimed_index() {
 118     _hot_cache_par_claimed_idx = 0;
 119   }
 120 
 121   // Resets the hot card cache and discards the entries.
 122   void reset_hot_cache() {
 123     assert(SafepointSynchronize::is_at_safepoint(), "Should be at a safepoint");
 124     assert(Thread::current()->is_VM_thread(), "Current thread should be the VMthread");
 125     if (default_use_cache()) {
 126         reset_hot_cache_internal();
 127     }
 128   }
 129 
 130   // Zeros the values in the card counts table for the given region
 131   void reset_card_counts(HeapRegion* hr);
 132 
 133  private:
 134   void reset_hot_cache_internal() {
< prev index next >