src/share/vm/gc_implementation/g1/g1HotCardCache.hpp

Thu, 14 Jun 2018 09:15:08 -0700

author
kevinw
date
Thu, 14 Jun 2018 09:15:08 -0700
changeset 9327
f96fcd9e1e1b
parent 7653
b6a1bf5222c5
child 7994
04ff2f6cd0eb
permissions
-rw-r--r--

8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
Summary: Need to add a space between macro identifier and string literal
Reviewed-by: bpittore, stefank, dholmes, kbarrett

johnc@5078 1 /*
redestad@7653 2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
johnc@5078 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
johnc@5078 4 *
johnc@5078 5 * This code is free software; you can redistribute it and/or modify it
johnc@5078 6 * under the terms of the GNU General Public License version 2 only, as
johnc@5078 7 * published by the Free Software Foundation.
johnc@5078 8 *
johnc@5078 9 * This code is distributed in the hope that it will be useful, but WITHOUT
johnc@5078 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
johnc@5078 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
johnc@5078 12 * version 2 for more details (a copy is included in the LICENSE file that
johnc@5078 13 * accompanied this code).
johnc@5078 14 *
johnc@5078 15 * You should have received a copy of the GNU General Public License version
johnc@5078 16 * 2 along with this work; if not, write to the Free Software Foundation,
johnc@5078 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
johnc@5078 18 *
johnc@5078 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
johnc@5078 20 * or visit www.oracle.com if you need additional information or have any
johnc@5078 21 * questions.
johnc@5078 22 *
johnc@5078 23 */
johnc@5078 24
johnc@5078 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1HOTCARDCACHE_HPP
johnc@5078 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1HOTCARDCACHE_HPP
johnc@5078 27
johnc@5078 28 #include "gc_implementation/g1/g1_globals.hpp"
johnc@5078 29 #include "gc_implementation/g1/g1CardCounts.hpp"
johnc@5078 30 #include "memory/allocation.hpp"
johnc@5078 31 #include "runtime/safepoint.hpp"
johnc@5078 32 #include "runtime/thread.inline.hpp"
johnc@5078 33 #include "utilities/globalDefinitions.hpp"
johnc@5078 34
johnc@5078 35 class DirtyCardQueue;
johnc@5078 36 class G1CollectedHeap;
johnc@5078 37 class G1RemSet;
johnc@5078 38 class HeapRegion;
johnc@5078 39
johnc@5078 40 // An evicting cache of cards that have been logged by the G1 post
johnc@5078 41 // write barrier. Placing a card in the cache delays the refinement
johnc@5078 42 // of the card until the card is evicted, or the cache is drained
johnc@5078 43 // during the next evacuation pause.
johnc@5078 44 //
johnc@5078 45 // The first thing the G1 post write barrier does is to check whether
johnc@5078 46 // the card containing the updated pointer is already dirty and, if
johnc@5078 47 // so, skips the remaining code in the barrier.
johnc@5078 48 //
johnc@5078 49 // Delaying the refinement of a card will make the card fail the
johnc@5078 50 // first is_dirty check in the write barrier, skipping the remainder
johnc@5078 51 // of the write barrier.
johnc@5078 52 //
johnc@5078 53 // This can significantly reduce the overhead of the write barrier
johnc@5078 54 // code, increasing throughput.
johnc@5078 55
johnc@5078 56 class G1HotCardCache: public CHeapObj<mtGC> {
redestad@7653 57
redestad@7653 58 G1CollectedHeap* _g1h;
redestad@7653 59
redestad@7653 60 bool _use_cache;
redestad@7653 61
redestad@7653 62 G1CardCounts _card_counts;
johnc@5078 63
johnc@5078 64 // The card cache table
redestad@7653 65 jbyte** _hot_cache;
johnc@5078 66
redestad@7653 67 size_t _hot_cache_size;
johnc@5078 68
redestad@7653 69 int _hot_cache_par_chunk_size;
johnc@5078 70
redestad@7653 71 // Avoids false sharing when concurrently updating _hot_cache_idx or
redestad@7653 72 // _hot_cache_par_claimed_idx. These are never updated at the same time
redestad@7653 73 // thus it's not necessary to separate them as well
redestad@7653 74 char _pad_before[DEFAULT_CACHE_LINE_SIZE];
johnc@5078 75
redestad@7653 76 volatile size_t _hot_cache_idx;
redestad@7653 77
redestad@7653 78 volatile size_t _hot_cache_par_claimed_idx;
redestad@7653 79
redestad@7653 80 char _pad_after[DEFAULT_CACHE_LINE_SIZE];
johnc@5078 81
mlarsson@7652 82 // The number of cached cards a thread claims when flushing the cache
mlarsson@7652 83 static const int ClaimChunkSize = 32;
mlarsson@7652 84
johnc@5078 85 bool default_use_cache() const {
johnc@5078 86 return (G1ConcRSLogCacheSize > 0);
johnc@5078 87 }
johnc@5078 88
johnc@5078 89 public:
johnc@5078 90 G1HotCardCache(G1CollectedHeap* g1h);
johnc@5078 91 ~G1HotCardCache();
johnc@5078 92
tschatzl@7051 93 void initialize(G1RegionToSpaceMapper* card_counts_storage);
johnc@5078 94
johnc@5078 95 bool use_cache() { return _use_cache; }
johnc@5078 96
johnc@5078 97 void set_use_cache(bool b) {
johnc@5078 98 _use_cache = (b ? default_use_cache() : false);
johnc@5078 99 }
johnc@5078 100
johnc@5078 101 // Returns the card to be refined or NULL.
johnc@5078 102 //
johnc@5078 103 // Increments the count for given the card. if the card is not 'hot',
johnc@5078 104 // it is returned for immediate refining. Otherwise the card is
johnc@5078 105 // added to the hot card cache.
johnc@5078 106 // If there is enough room in the hot card cache for the card we're
johnc@5078 107 // adding, NULL is returned and no further action in needed.
johnc@5078 108 // If we evict a card from the cache to make room for the new card,
johnc@5078 109 // the evicted card is then returned for refinement.
johnc@5078 110 jbyte* insert(jbyte* card_ptr);
johnc@5078 111
johnc@5078 112 // Refine the cards that have delayed as a result of
johnc@5078 113 // being in the cache.
vkempik@6552 114 void drain(uint worker_i, G1RemSet* g1rs, DirtyCardQueue* into_cset_dcq);
johnc@5078 115
johnc@5078 116 // Set up for parallel processing of the cards in the hot cache
johnc@5078 117 void reset_hot_cache_claimed_index() {
johnc@5078 118 _hot_cache_par_claimed_idx = 0;
johnc@5078 119 }
johnc@5078 120
johnc@5078 121 // Resets the hot card cache and discards the entries.
johnc@5078 122 void reset_hot_cache() {
johnc@5078 123 assert(SafepointSynchronize::is_at_safepoint(), "Should be at a safepoint");
johnc@5078 124 assert(Thread::current()->is_VM_thread(), "Current thread should be the VMthread");
redestad@7653 125 if (default_use_cache()) {
redestad@7653 126 reset_hot_cache_internal();
redestad@7653 127 }
johnc@5078 128 }
johnc@5078 129
johnc@5078 130 // Zeros the values in the card counts table for entire committed heap
johnc@5078 131 void reset_card_counts();
johnc@5078 132
johnc@5078 133 // Zeros the values in the card counts table for the given region
johnc@5078 134 void reset_card_counts(HeapRegion* hr);
redestad@7653 135
redestad@7653 136 private:
redestad@7653 137 void reset_hot_cache_internal() {
redestad@7653 138 assert(_hot_cache != NULL, "Logic");
redestad@7653 139 _hot_cache_idx = 0;
redestad@7653 140 for (size_t i = 0; i < _hot_cache_size; i++) {
redestad@7653 141 _hot_cache[i] = NULL;
redestad@7653 142 }
redestad@7653 143 }
johnc@5078 144 };
johnc@5078 145
johnc@5078 146 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1HOTCARDCACHE_HPP

mercurial