Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 12343:d55c004e1d4d
8025305: Cleanup CardTableModRefBS usage in G1
Summary: Move some G1 specific code from CardTableModRefBS to G1SATBCardTableModRefBS.
Reviewed-by: brutisso, tschatzl, ehelin
author | mgerdin |
---|---|
date | Tue, 24 Sep 2013 14:46:29 +0200 |
parents | c319b188c7b2 |
children | 9de9169ddde6 |
comparison
equal
deleted
inserted
replaced
12342:ccef6e165e8b | 12343:d55c004e1d4d |
---|---|
123 G1CollectedHeap* _g1h; | 123 G1CollectedHeap* _g1h; |
124 CardTableModRefBS* _ctbs; | 124 CardTableModRefBS* _ctbs; |
125 int _histo[256]; | 125 int _histo[256]; |
126 public: | 126 public: |
127 ClearLoggedCardTableEntryClosure() : | 127 ClearLoggedCardTableEntryClosure() : |
128 _calls(0) | 128 _calls(0), _g1h(G1CollectedHeap::heap()), _ctbs(_g1h->g1_barrier_set()) |
129 { | 129 { |
130 _g1h = G1CollectedHeap::heap(); | |
131 _ctbs = (CardTableModRefBS*)_g1h->barrier_set(); | |
132 for (int i = 0; i < 256; i++) _histo[i] = 0; | 130 for (int i = 0; i < 256; i++) _histo[i] = 0; |
133 } | 131 } |
134 bool do_card_ptr(jbyte* card_ptr, int worker_i) { | 132 bool do_card_ptr(jbyte* card_ptr, int worker_i) { |
135 if (_g1h->is_in_reserved(_ctbs->addr_for(card_ptr))) { | 133 if (_g1h->is_in_reserved(_ctbs->addr_for(card_ptr))) { |
136 _calls++; | 134 _calls++; |
156 int _calls; | 154 int _calls; |
157 G1CollectedHeap* _g1h; | 155 G1CollectedHeap* _g1h; |
158 CardTableModRefBS* _ctbs; | 156 CardTableModRefBS* _ctbs; |
159 public: | 157 public: |
160 RedirtyLoggedCardTableEntryClosure() : | 158 RedirtyLoggedCardTableEntryClosure() : |
161 _calls(0) | 159 _calls(0), _g1h(G1CollectedHeap::heap()), _ctbs(_g1h->g1_barrier_set()) {} |
162 { | 160 |
163 _g1h = G1CollectedHeap::heap(); | |
164 _ctbs = (CardTableModRefBS*)_g1h->barrier_set(); | |
165 } | |
166 bool do_card_ptr(jbyte* card_ptr, int worker_i) { | 161 bool do_card_ptr(jbyte* card_ptr, int worker_i) { |
167 if (_g1h->is_in_reserved(_ctbs->addr_for(card_ptr))) { | 162 if (_g1h->is_in_reserved(_ctbs->addr_for(card_ptr))) { |
168 _calls++; | 163 _calls++; |
169 *card_ptr = 0; | 164 *card_ptr = 0; |
170 } | 165 } |
476 } | 471 } |
477 } | 472 } |
478 | 473 |
479 void G1CollectedHeap::check_ct_logs_at_safepoint() { | 474 void G1CollectedHeap::check_ct_logs_at_safepoint() { |
480 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); | 475 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); |
481 CardTableModRefBS* ct_bs = (CardTableModRefBS*)barrier_set(); | 476 CardTableModRefBS* ct_bs = g1_barrier_set(); |
482 | 477 |
483 // Count the dirty cards at the start. | 478 // Count the dirty cards at the start. |
484 CountNonCleanMemRegionClosure count1(this); | 479 CountNonCleanMemRegionClosure count1(this); |
485 ct_bs->mod_card_iterate(&count1); | 480 ct_bs->mod_card_iterate(&count1); |
486 int orig_count = count1.n(); | 481 int orig_count = count1.n(); |
1203 return false; | 1198 return false; |
1204 } | 1199 } |
1205 }; | 1200 }; |
1206 | 1201 |
1207 void G1CollectedHeap::clear_rsets_post_compaction() { | 1202 void G1CollectedHeap::clear_rsets_post_compaction() { |
1208 PostMCRemSetClearClosure rs_clear(this, mr_bs()); | 1203 PostMCRemSetClearClosure rs_clear(this, g1_barrier_set()); |
1209 heap_region_iterate(&rs_clear); | 1204 heap_region_iterate(&rs_clear); |
1210 } | 1205 } |
1211 | 1206 |
1212 class RebuildRSOutOfRegionClosure: public HeapRegionClosure { | 1207 class RebuildRSOutOfRegionClosure: public HeapRegionClosure { |
1213 G1CollectedHeap* _g1h; | 1208 G1CollectedHeap* _g1h; |
2043 _expansion_regions = (uint) (max_byte_size / HeapRegion::GrainBytes); | 2038 _expansion_regions = (uint) (max_byte_size / HeapRegion::GrainBytes); |
2044 | 2039 |
2045 // Create the gen rem set (and barrier set) for the entire reserved region. | 2040 // Create the gen rem set (and barrier set) for the entire reserved region. |
2046 _rem_set = collector_policy()->create_rem_set(_reserved, 2); | 2041 _rem_set = collector_policy()->create_rem_set(_reserved, 2); |
2047 set_barrier_set(rem_set()->bs()); | 2042 set_barrier_set(rem_set()->bs()); |
2048 if (barrier_set()->is_a(BarrierSet::ModRef)) { | 2043 if (!barrier_set()->is_a(BarrierSet::G1SATBCTLogging)) { |
2049 _mr_bs = (ModRefBarrierSet*)_barrier_set; | 2044 vm_exit_during_initialization("G1 requires a G1SATBLoggingCardTableModRefBS"); |
2050 } else { | |
2051 vm_exit_during_initialization("G1 requires a mod ref bs."); | |
2052 return JNI_ENOMEM; | 2045 return JNI_ENOMEM; |
2053 } | 2046 } |
2054 | 2047 |
2055 // Also create a G1 rem set. | 2048 // Also create a G1 rem set. |
2056 if (mr_bs()->is_a(BarrierSet::CardTableModRef)) { | 2049 _g1_rem_set = new G1RemSet(this, g1_barrier_set()); |
2057 _g1_rem_set = new G1RemSet(this, (CardTableModRefBS*)mr_bs()); | |
2058 } else { | |
2059 vm_exit_during_initialization("G1 requires a cardtable mod ref bs."); | |
2060 return JNI_ENOMEM; | |
2061 } | |
2062 | 2050 |
2063 // Carve out the G1 part of the heap. | 2051 // Carve out the G1 part of the heap. |
2064 | 2052 |
2065 ReservedSpace g1_rs = heap_rs.first_part(max_byte_size); | 2053 ReservedSpace g1_rs = heap_rs.first_part(max_byte_size); |
2066 _g1_reserved = MemRegion((HeapWord*)g1_rs.base(), | 2054 _g1_reserved = MemRegion((HeapWord*)g1_rs.base(), |
4553 | 4541 |
4554 G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num) | 4542 G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num) |
4555 : _g1h(g1h), | 4543 : _g1h(g1h), |
4556 _refs(g1h->task_queue(queue_num)), | 4544 _refs(g1h->task_queue(queue_num)), |
4557 _dcq(&g1h->dirty_card_queue_set()), | 4545 _dcq(&g1h->dirty_card_queue_set()), |
4558 _ct_bs((CardTableModRefBS*)_g1h->barrier_set()), | 4546 _ct_bs(g1h->g1_barrier_set()), |
4559 _g1_rem(g1h->g1_rem_set()), | 4547 _g1_rem(g1h->g1_rem_set()), |
4560 _hash_seed(17), _queue_num(queue_num), | 4548 _hash_seed(17), _queue_num(queue_num), |
4561 _term_attempts(0), | 4549 _term_attempts(0), |
4562 _surviving_alloc_buffer(g1h->desired_plab_sz(GCAllocForSurvived)), | 4550 _surviving_alloc_buffer(g1h->desired_plab_sz(GCAllocForSurvived)), |
4563 _tenured_alloc_buffer(g1h->desired_plab_sz(GCAllocForTenured)), | 4551 _tenured_alloc_buffer(g1h->desired_plab_sz(GCAllocForTenured)), |
5982 _humongous_set.update_from_proxy(humongous_proxy_set); | 5970 _humongous_set.update_from_proxy(humongous_proxy_set); |
5983 } | 5971 } |
5984 } | 5972 } |
5985 | 5973 |
5986 class G1ParCleanupCTTask : public AbstractGangTask { | 5974 class G1ParCleanupCTTask : public AbstractGangTask { |
5987 CardTableModRefBS* _ct_bs; | 5975 G1SATBCardTableModRefBS* _ct_bs; |
5988 G1CollectedHeap* _g1h; | 5976 G1CollectedHeap* _g1h; |
5989 HeapRegion* volatile _su_head; | 5977 HeapRegion* volatile _su_head; |
5990 public: | 5978 public: |
5991 G1ParCleanupCTTask(CardTableModRefBS* ct_bs, | 5979 G1ParCleanupCTTask(G1SATBCardTableModRefBS* ct_bs, |
5992 G1CollectedHeap* g1h) : | 5980 G1CollectedHeap* g1h) : |
5993 AbstractGangTask("G1 Par Cleanup CT Task"), | 5981 AbstractGangTask("G1 Par Cleanup CT Task"), |
5994 _ct_bs(ct_bs), _g1h(g1h) { } | 5982 _ct_bs(ct_bs), _g1h(g1h) { } |
5995 | 5983 |
5996 void work(uint worker_id) { | 5984 void work(uint worker_id) { |
6009 }; | 5997 }; |
6010 | 5998 |
6011 #ifndef PRODUCT | 5999 #ifndef PRODUCT |
6012 class G1VerifyCardTableCleanup: public HeapRegionClosure { | 6000 class G1VerifyCardTableCleanup: public HeapRegionClosure { |
6013 G1CollectedHeap* _g1h; | 6001 G1CollectedHeap* _g1h; |
6014 CardTableModRefBS* _ct_bs; | 6002 G1SATBCardTableModRefBS* _ct_bs; |
6015 public: | 6003 public: |
6016 G1VerifyCardTableCleanup(G1CollectedHeap* g1h, CardTableModRefBS* ct_bs) | 6004 G1VerifyCardTableCleanup(G1CollectedHeap* g1h, G1SATBCardTableModRefBS* ct_bs) |
6017 : _g1h(g1h), _ct_bs(ct_bs) { } | 6005 : _g1h(g1h), _ct_bs(ct_bs) { } |
6018 virtual bool doHeapRegion(HeapRegion* r) { | 6006 virtual bool doHeapRegion(HeapRegion* r) { |
6019 if (r->is_survivor()) { | 6007 if (r->is_survivor()) { |
6020 _g1h->verify_dirty_region(r); | 6008 _g1h->verify_dirty_region(r); |
6021 } else { | 6009 } else { |
6025 } | 6013 } |
6026 }; | 6014 }; |
6027 | 6015 |
6028 void G1CollectedHeap::verify_not_dirty_region(HeapRegion* hr) { | 6016 void G1CollectedHeap::verify_not_dirty_region(HeapRegion* hr) { |
6029 // All of the region should be clean. | 6017 // All of the region should be clean. |
6030 CardTableModRefBS* ct_bs = (CardTableModRefBS*)barrier_set(); | 6018 G1SATBCardTableModRefBS* ct_bs = g1_barrier_set(); |
6031 MemRegion mr(hr->bottom(), hr->end()); | 6019 MemRegion mr(hr->bottom(), hr->end()); |
6032 ct_bs->verify_not_dirty_region(mr); | 6020 ct_bs->verify_not_dirty_region(mr); |
6033 } | 6021 } |
6034 | 6022 |
6035 void G1CollectedHeap::verify_dirty_region(HeapRegion* hr) { | 6023 void G1CollectedHeap::verify_dirty_region(HeapRegion* hr) { |
6038 // retires each region and replaces it with a new one will do a | 6026 // retires each region and replaces it with a new one will do a |
6039 // maximal allocation to fill in [pre_dummy_top(),end()] but will | 6027 // maximal allocation to fill in [pre_dummy_top(),end()] but will |
6040 // not dirty that area (one less thing to have to do while holding | 6028 // not dirty that area (one less thing to have to do while holding |
6041 // a lock). So we can only verify that [bottom(),pre_dummy_top()] | 6029 // a lock). So we can only verify that [bottom(),pre_dummy_top()] |
6042 // is dirty. | 6030 // is dirty. |
6043 CardTableModRefBS* ct_bs = (CardTableModRefBS*) barrier_set(); | 6031 G1SATBCardTableModRefBS* ct_bs = g1_barrier_set(); |
6044 MemRegion mr(hr->bottom(), hr->pre_dummy_top()); | 6032 MemRegion mr(hr->bottom(), hr->pre_dummy_top()); |
6045 ct_bs->verify_dirty_region(mr); | 6033 ct_bs->verify_dirty_region(mr); |
6046 } | 6034 } |
6047 | 6035 |
6048 void G1CollectedHeap::verify_dirty_young_list(HeapRegion* head) { | 6036 void G1CollectedHeap::verify_dirty_young_list(HeapRegion* head) { |
6049 CardTableModRefBS* ct_bs = (CardTableModRefBS*) barrier_set(); | 6037 G1SATBCardTableModRefBS* ct_bs = g1_barrier_set(); |
6050 for (HeapRegion* hr = head; hr != NULL; hr = hr->get_next_young_region()) { | 6038 for (HeapRegion* hr = head; hr != NULL; hr = hr->get_next_young_region()) { |
6051 verify_dirty_region(hr); | 6039 verify_dirty_region(hr); |
6052 } | 6040 } |
6053 } | 6041 } |
6054 | 6042 |
6056 verify_dirty_young_list(_young_list->first_region()); | 6044 verify_dirty_young_list(_young_list->first_region()); |
6057 } | 6045 } |
6058 #endif | 6046 #endif |
6059 | 6047 |
6060 void G1CollectedHeap::cleanUpCardTable() { | 6048 void G1CollectedHeap::cleanUpCardTable() { |
6061 CardTableModRefBS* ct_bs = (CardTableModRefBS*) (barrier_set()); | 6049 G1SATBCardTableModRefBS* ct_bs = g1_barrier_set(); |
6062 double start = os::elapsedTime(); | 6050 double start = os::elapsedTime(); |
6063 | 6051 |
6064 { | 6052 { |
6065 // Iterate over the dirty cards region list. | 6053 // Iterate over the dirty cards region list. |
6066 G1ParCleanupCTTask cleanup_task(ct_bs, this); | 6054 G1ParCleanupCTTask cleanup_task(ct_bs, this); |