提交 91d63f06 编写于 作者: T tschatzl

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
上级 6195261b
...@@ -122,27 +122,30 @@ public: ...@@ -122,27 +122,30 @@ public:
class ClearLoggedCardTableEntryClosure: public CardTableEntryClosure { class ClearLoggedCardTableEntryClosure: public CardTableEntryClosure {
int _calls; size_t _num_processed;
G1CollectedHeap* _g1h;
CardTableModRefBS* _ctbs; CardTableModRefBS* _ctbs;
int _histo[256]; int _histo[256];
public:
public:
ClearLoggedCardTableEntryClosure() : ClearLoggedCardTableEntryClosure() :
_calls(0), _g1h(G1CollectedHeap::heap()), _ctbs(_g1h->g1_barrier_set()) _num_processed(0), _ctbs(G1CollectedHeap::heap()->g1_barrier_set())
{ {
for (int i = 0; i < 256; i++) _histo[i] = 0; for (int i = 0; i < 256; i++) _histo[i] = 0;
} }
bool do_card_ptr(jbyte* card_ptr, uint worker_i) { bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
if (_g1h->is_in_reserved(_ctbs->addr_for(card_ptr))) { unsigned char* ujb = (unsigned char*)card_ptr;
_calls++; int ind = (int)(*ujb);
unsigned char* ujb = (unsigned char*)card_ptr; _histo[ind]++;
int ind = (int)(*ujb);
_histo[ind]++; *card_ptr = (jbyte)CardTableModRefBS::clean_card_val();
*card_ptr = -1; _num_processed++;
}
return true; return true;
} }
int calls() { return _calls; }
size_t num_processed() { return _num_processed; }
void print_histo() { void print_histo() {
gclog_or_tty->print_cr("Card table value histogram:"); gclog_or_tty->print_cr("Card table value histogram:");
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
...@@ -153,22 +156,20 @@ public: ...@@ -153,22 +156,20 @@ public:
} }
}; };
class RedirtyLoggedCardTableEntryClosure: public CardTableEntryClosure { class RedirtyLoggedCardTableEntryClosure : public CardTableEntryClosure {
int _calls; private:
G1CollectedHeap* _g1h; size_t _num_processed;
CardTableModRefBS* _ctbs;
public: public:
RedirtyLoggedCardTableEntryClosure() : RedirtyLoggedCardTableEntryClosure() : CardTableEntryClosure(), _num_processed(0) { }
_calls(0), _g1h(G1CollectedHeap::heap()), _ctbs(_g1h->g1_barrier_set()) {}
bool do_card_ptr(jbyte* card_ptr, uint worker_i) { bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
if (_g1h->is_in_reserved(_ctbs->addr_for(card_ptr))) { *card_ptr = CardTableModRefBS::dirty_card_val();
_calls++; _num_processed++;
*card_ptr = 0;
}
return true; return true;
} }
int calls() { return _calls; }
size_t num_processed() const { return _num_processed; }
}; };
YoungList::YoungList(G1CollectedHeap* g1h) : YoungList::YoungList(G1CollectedHeap* g1h) :
...@@ -489,9 +490,10 @@ void G1CollectedHeap::check_ct_logs_at_safepoint() { ...@@ -489,9 +490,10 @@ void G1CollectedHeap::check_ct_logs_at_safepoint() {
dcqs.apply_closure_to_all_completed_buffers(&redirty); dcqs.apply_closure_to_all_completed_buffers(&redirty);
dcqs.iterate_closure_all_threads(&redirty, false); dcqs.iterate_closure_all_threads(&redirty, false);
gclog_or_tty->print_cr("Log entries = %d, dirty cards = %d.", gclog_or_tty->print_cr("Log entries = %d, dirty cards = %d.",
clear.calls(), orig_count); clear.num_processed(), orig_count);
guarantee(redirty.calls() == clear.calls(), guarantee(redirty.num_processed() == clear.num_processed(),
"Or else mechanism is broken."); err_msg("Redirtied "SIZE_FORMAT" cards, bug cleared "SIZE_FORMAT,
redirty.num_processed(), clear.num_processed()));
CountNonCleanMemRegionClosure count3(this); CountNonCleanMemRegionClosure count3(this);
ct_bs->mod_card_iterate(&count3); ct_bs->mod_card_iterate(&count3);
...@@ -5276,22 +5278,6 @@ void G1CollectedHeap::unlink_string_and_symbol_table(BoolObjectClosure* is_alive ...@@ -5276,22 +5278,6 @@ void G1CollectedHeap::unlink_string_and_symbol_table(BoolObjectClosure* is_alive
} }
} }
class RedirtyLoggedCardTableEntryFastClosure : public CardTableEntryClosure {
private:
size_t _num_processed;
public:
RedirtyLoggedCardTableEntryFastClosure() : CardTableEntryClosure(), _num_processed(0) { }
bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
*card_ptr = CardTableModRefBS::dirty_card_val();
_num_processed++;
return true;
}
size_t num_processed() const { return _num_processed; }
};
class G1RedirtyLoggedCardsTask : public AbstractGangTask { class G1RedirtyLoggedCardsTask : public AbstractGangTask {
private: private:
DirtyCardQueueSet* _queue; DirtyCardQueueSet* _queue;
...@@ -5301,7 +5287,7 @@ class G1RedirtyLoggedCardsTask : public AbstractGangTask { ...@@ -5301,7 +5287,7 @@ class G1RedirtyLoggedCardsTask : public AbstractGangTask {
virtual void work(uint worker_id) { virtual void work(uint worker_id) {
double start_time = os::elapsedTime(); double start_time = os::elapsedTime();
RedirtyLoggedCardTableEntryFastClosure cl; RedirtyLoggedCardTableEntryClosure cl;
if (G1CollectedHeap::heap()->use_parallel_gc_threads()) { if (G1CollectedHeap::heap()->use_parallel_gc_threads()) {
_queue->par_apply_closure_to_all_completed_buffers(&cl); _queue->par_apply_closure_to_all_completed_buffers(&cl);
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册