comparison src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp @ 17758:ae7336d6337e

8034868: Extract G1 From Card Cache into separate class Summary: Refactor the From Card Cache into a separate class. Reviewed-by: jmasa
author tschatzl
date Mon, 24 Mar 2014 15:30:50 +0100
parents d7070f371770
children 52b4284cb496 82693fb204a5
comparison
equal deleted inserted replaced
17757:eff02b5bd56c 17758:ae7336d6337e
43 // Essentially a wrapper around SparsePRTCleanupTask. See 43 // Essentially a wrapper around SparsePRTCleanupTask. See
44 // sparsePRT.hpp for more details. 44 // sparsePRT.hpp for more details.
45 class HRRSCleanupTask : public SparsePRTCleanupTask { 45 class HRRSCleanupTask : public SparsePRTCleanupTask {
46 }; 46 };
47 47
48 // The FromCardCache remembers the most recently processed card on the heap on
49 // a per-region and per-thread basis.
50 class FromCardCache : public AllStatic {
51 private:
52 // Array of card indices. Indexed by thread X and heap region to minimize
53 // thread contention.
54 static int** _cache;
55 static uint _max_regions;
56 static size_t _static_mem_size;
57
58 public:
59 enum {
60 InvalidCard = -1 // Card value of an invalid card, i.e. a card index not otherwise used.
61 };
62
63 static void clear(uint region_idx);
64
65 // Returns true if the given card is in the cache at the given location, or
66 // replaces the card at that location and returns false.
67 static bool contains_or_replace(uint worker_id, uint region_idx, int card) {
68 int card_in_cache = at(worker_id, region_idx);
69 if (card_in_cache == card) {
70 return true;
71 } else {
72 set(worker_id, region_idx, card);
73 return false;
74 }
75 }
76
77 static int at(uint worker_id, uint region_idx) {
78 return _cache[worker_id][region_idx];
79 }
80
81 static void set(uint worker_id, uint region_idx, int val) {
82 _cache[worker_id][region_idx] = val;
83 }
84
85 static void initialize(uint n_par_rs, uint max_num_regions);
86
87 static void shrink(uint new_num_regions);
88
89 static void print(outputStream* out = gclog_or_tty) PRODUCT_RETURN;
90
91 static size_t static_mem_size() {
92 return _static_mem_size;
93 }
94 };
95
48 // The "_coarse_map" is a bitmap with one bit for each region, where set 96 // The "_coarse_map" is a bitmap with one bit for each region, where set
49 // bits indicate that the corresponding region may contain some pointer 97 // bits indicate that the corresponding region may contain some pointer
50 // into the owning region. 98 // into the owning region.
51 99
52 // The "_fine_grain_entries" array is an open hash table of PerRegionTables 100 // The "_fine_grain_entries" array is an open hash table of PerRegionTables
117 // If a PRT for "hr" is in the bucket list indicated by "ind" (which must 165 // If a PRT for "hr" is in the bucket list indicated by "ind" (which must
118 // be the correct index for "hr"), delete it and return true; else return 166 // be the correct index for "hr"), delete it and return true; else return
119 // false. 167 // false.
120 bool del_single_region_table(size_t ind, HeapRegion* hr); 168 bool del_single_region_table(size_t ind, HeapRegion* hr);
121 169
122 // Indexed by thread X heap region, to minimize thread contention.
123 static int** _from_card_cache;
124 static uint _from_card_cache_max_regions;
125 static size_t _from_card_cache_mem_size;
126
127 // link/add the given fine grain remembered set into the "all" list 170 // link/add the given fine grain remembered set into the "all" list
128 void link_to_all(PerRegionTable * prt); 171 void link_to_all(PerRegionTable * prt);
129 // unlink/remove the given fine grain remembered set into the "all" list 172 // unlink/remove the given fine grain remembered set into the "all" list
130 void unlink_from_all(PerRegionTable * prt); 173 void unlink_from_all(PerRegionTable * prt);
131 174
172 // (Uses it to initialize from_card_cache). 215 // (Uses it to initialize from_card_cache).
173 static void init_from_card_cache(uint max_regions); 216 static void init_from_card_cache(uint max_regions);
174 217
175 // Declares that only regions i s.t. 0 <= i < new_n_regs are in use. 218 // Declares that only regions i s.t. 0 <= i < new_n_regs are in use.
176 // Make sure any entries for higher regions are invalid. 219 // Make sure any entries for higher regions are invalid.
177 static void shrink_from_card_cache(uint new_n_regs); 220 static void shrink_from_card_cache(uint new_num_regions);
178 221
179 static void print_from_card_cache(); 222 static void print_from_card_cache();
180 }; 223 };
181 224
182 class HeapRegionRemSet : public CHeapObj<mtGC> { 225 class HeapRegionRemSet : public CHeapObj<mtGC> {