Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 20217:6b52700a896b
8040002: Clean up code and code duplication in re-diryting cards for verification
Summary: Card re-dirtying code for verification and actual redirtying uses two different, almost completely identical card closures. Also the verification code still assumes a perm gen.
Reviewed-by: brutisso, jmasa
author | tschatzl |
---|---|
date | Mon, 21 Jul 2014 09:40:19 +0200 |
parents | 570cb6369f17 |
children | b0c374311c4e |
comparison
equal
deleted
inserted
replaced
20216:570cb6369f17 | 20217:6b52700a896b |
---|---|
120 void set_concurrent(bool b) { _concurrent = b; } | 120 void set_concurrent(bool b) { _concurrent = b; } |
121 }; | 121 }; |
122 | 122 |
123 | 123 |
124 class ClearLoggedCardTableEntryClosure: public CardTableEntryClosure { | 124 class ClearLoggedCardTableEntryClosure: public CardTableEntryClosure { |
125 int _calls; | 125 size_t _num_processed; |
126 G1CollectedHeap* _g1h; | |
127 CardTableModRefBS* _ctbs; | 126 CardTableModRefBS* _ctbs; |
128 int _histo[256]; | 127 int _histo[256]; |
129 public: | 128 |
129 public: | |
130 ClearLoggedCardTableEntryClosure() : | 130 ClearLoggedCardTableEntryClosure() : |
131 _calls(0), _g1h(G1CollectedHeap::heap()), _ctbs(_g1h->g1_barrier_set()) | 131 _num_processed(0), _ctbs(G1CollectedHeap::heap()->g1_barrier_set()) |
132 { | 132 { |
133 for (int i = 0; i < 256; i++) _histo[i] = 0; | 133 for (int i = 0; i < 256; i++) _histo[i] = 0; |
134 } | 134 } |
135 | |
135 bool do_card_ptr(jbyte* card_ptr, uint worker_i) { | 136 bool do_card_ptr(jbyte* card_ptr, uint worker_i) { |
136 if (_g1h->is_in_reserved(_ctbs->addr_for(card_ptr))) { | 137 unsigned char* ujb = (unsigned char*)card_ptr; |
137 _calls++; | 138 int ind = (int)(*ujb); |
138 unsigned char* ujb = (unsigned char*)card_ptr; | 139 _histo[ind]++; |
139 int ind = (int)(*ujb); | 140 |
140 _histo[ind]++; | 141 *card_ptr = (jbyte)CardTableModRefBS::clean_card_val(); |
141 *card_ptr = -1; | 142 _num_processed++; |
142 } | 143 |
143 return true; | 144 return true; |
144 } | 145 } |
145 int calls() { return _calls; } | 146 |
147 size_t num_processed() { return _num_processed; } | |
148 | |
146 void print_histo() { | 149 void print_histo() { |
147 gclog_or_tty->print_cr("Card table value histogram:"); | 150 gclog_or_tty->print_cr("Card table value histogram:"); |
148 for (int i = 0; i < 256; i++) { | 151 for (int i = 0; i < 256; i++) { |
149 if (_histo[i] != 0) { | 152 if (_histo[i] != 0) { |
150 gclog_or_tty->print_cr(" %d: %d", i, _histo[i]); | 153 gclog_or_tty->print_cr(" %d: %d", i, _histo[i]); |
151 } | 154 } |
152 } | 155 } |
153 } | 156 } |
154 }; | 157 }; |
155 | 158 |
156 class RedirtyLoggedCardTableEntryClosure: public CardTableEntryClosure { | 159 class RedirtyLoggedCardTableEntryClosure : public CardTableEntryClosure { |
157 int _calls; | 160 private: |
158 G1CollectedHeap* _g1h; | 161 size_t _num_processed; |
159 CardTableModRefBS* _ctbs; | 162 |
160 public: | 163 public: |
161 RedirtyLoggedCardTableEntryClosure() : | 164 RedirtyLoggedCardTableEntryClosure() : CardTableEntryClosure(), _num_processed(0) { } |
162 _calls(0), _g1h(G1CollectedHeap::heap()), _ctbs(_g1h->g1_barrier_set()) {} | |
163 | 165 |
164 bool do_card_ptr(jbyte* card_ptr, uint worker_i) { | 166 bool do_card_ptr(jbyte* card_ptr, uint worker_i) { |
165 if (_g1h->is_in_reserved(_ctbs->addr_for(card_ptr))) { | 167 *card_ptr = CardTableModRefBS::dirty_card_val(); |
166 _calls++; | 168 _num_processed++; |
167 *card_ptr = 0; | |
168 } | |
169 return true; | 169 return true; |
170 } | 170 } |
171 int calls() { return _calls; } | 171 |
172 size_t num_processed() const { return _num_processed; } | |
172 }; | 173 }; |
173 | 174 |
174 YoungList::YoungList(G1CollectedHeap* g1h) : | 175 YoungList::YoungList(G1CollectedHeap* g1h) : |
175 _g1h(g1h), _head(NULL), _length(0), _last_sampled_rs_lengths(0), | 176 _g1h(g1h), _head(NULL), _length(0), _last_sampled_rs_lengths(0), |
176 _survivor_head(NULL), _survivor_tail(NULL), _survivor_length(0) { | 177 _survivor_head(NULL), _survivor_tail(NULL), _survivor_length(0) { |
487 | 488 |
488 RedirtyLoggedCardTableEntryClosure redirty; | 489 RedirtyLoggedCardTableEntryClosure redirty; |
489 dcqs.apply_closure_to_all_completed_buffers(&redirty); | 490 dcqs.apply_closure_to_all_completed_buffers(&redirty); |
490 dcqs.iterate_closure_all_threads(&redirty, false); | 491 dcqs.iterate_closure_all_threads(&redirty, false); |
491 gclog_or_tty->print_cr("Log entries = %d, dirty cards = %d.", | 492 gclog_or_tty->print_cr("Log entries = %d, dirty cards = %d.", |
492 clear.calls(), orig_count); | 493 clear.num_processed(), orig_count); |
493 guarantee(redirty.calls() == clear.calls(), | 494 guarantee(redirty.num_processed() == clear.num_processed(), |
494 "Or else mechanism is broken."); | 495 err_msg("Redirtied "SIZE_FORMAT" cards, bug cleared "SIZE_FORMAT, |
496 redirty.num_processed(), clear.num_processed())); | |
495 | 497 |
496 CountNonCleanMemRegionClosure count3(this); | 498 CountNonCleanMemRegionClosure count3(this); |
497 ct_bs->mod_card_iterate(&count3); | 499 ct_bs->mod_card_iterate(&count3); |
498 if (count3.n() != orig_count) { | 500 if (count3.n() != orig_count) { |
499 gclog_or_tty->print_cr("Should have restored them all: orig = %d, final = %d.", | 501 gclog_or_tty->print_cr("Should have restored them all: orig = %d, final = %d.", |
5274 if (G1StringDedup::is_enabled()) { | 5276 if (G1StringDedup::is_enabled()) { |
5275 G1StringDedup::unlink(is_alive); | 5277 G1StringDedup::unlink(is_alive); |
5276 } | 5278 } |
5277 } | 5279 } |
5278 | 5280 |
5279 class RedirtyLoggedCardTableEntryFastClosure : public CardTableEntryClosure { | |
5280 private: | |
5281 size_t _num_processed; | |
5282 | |
5283 public: | |
5284 RedirtyLoggedCardTableEntryFastClosure() : CardTableEntryClosure(), _num_processed(0) { } | |
5285 | |
5286 bool do_card_ptr(jbyte* card_ptr, uint worker_i) { | |
5287 *card_ptr = CardTableModRefBS::dirty_card_val(); | |
5288 _num_processed++; | |
5289 return true; | |
5290 } | |
5291 | |
5292 size_t num_processed() const { return _num_processed; } | |
5293 }; | |
5294 | |
5295 class G1RedirtyLoggedCardsTask : public AbstractGangTask { | 5281 class G1RedirtyLoggedCardsTask : public AbstractGangTask { |
5296 private: | 5282 private: |
5297 DirtyCardQueueSet* _queue; | 5283 DirtyCardQueueSet* _queue; |
5298 public: | 5284 public: |
5299 G1RedirtyLoggedCardsTask(DirtyCardQueueSet* queue) : AbstractGangTask("Redirty Cards"), _queue(queue) { } | 5285 G1RedirtyLoggedCardsTask(DirtyCardQueueSet* queue) : AbstractGangTask("Redirty Cards"), _queue(queue) { } |
5300 | 5286 |
5301 virtual void work(uint worker_id) { | 5287 virtual void work(uint worker_id) { |
5302 double start_time = os::elapsedTime(); | 5288 double start_time = os::elapsedTime(); |
5303 | 5289 |
5304 RedirtyLoggedCardTableEntryFastClosure cl; | 5290 RedirtyLoggedCardTableEntryClosure cl; |
5305 if (G1CollectedHeap::heap()->use_parallel_gc_threads()) { | 5291 if (G1CollectedHeap::heap()->use_parallel_gc_threads()) { |
5306 _queue->par_apply_closure_to_all_completed_buffers(&cl); | 5292 _queue->par_apply_closure_to_all_completed_buffers(&cl); |
5307 } else { | 5293 } else { |
5308 _queue->apply_closure_to_all_completed_buffers(&cl); | 5294 _queue->apply_closure_to_all_completed_buffers(&cl); |
5309 } | 5295 } |