Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/g1RemSet.cpp @ 845:df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
Summary: Modifications to G1 so as to allow the use of compressed oops.
Reviewed-by: apetrusenko, coleenp, jmasa, kvn, never, phh, tonyp
author | ysr |
---|---|
date | Tue, 14 Jul 2009 15:40:39 -0700 |
parents | 29e7d79232b9 |
children | 6cb8e9df7174 |
comparison
equal
deleted
inserted
replaced
839:bb18957ad21e | 845:df6caf649ff7 |
---|---|
63 IntoCSOopClosure(G1CollectedHeap* g1, OopsInHeapRegionClosure* blk) : | 63 IntoCSOopClosure(G1CollectedHeap* g1, OopsInHeapRegionClosure* blk) : |
64 _g1(g1), _blk(blk) {} | 64 _g1(g1), _blk(blk) {} |
65 void set_region(HeapRegion* from) { | 65 void set_region(HeapRegion* from) { |
66 _blk->set_region(from); | 66 _blk->set_region(from); |
67 } | 67 } |
68 virtual void do_oop(narrowOop* p) { | 68 virtual void do_oop(narrowOop* p) { do_oop_work(p); } |
69 guarantee(false, "NYI"); | 69 virtual void do_oop( oop* p) { do_oop_work(p); } |
70 } | 70 template <class T> void do_oop_work(T* p) { |
71 virtual void do_oop(oop* p) { | 71 oop obj = oopDesc::load_decode_heap_oop(p); |
72 oop obj = *p; | |
73 if (_g1->obj_in_cs(obj)) _blk->do_oop(p); | 72 if (_g1->obj_in_cs(obj)) _blk->do_oop(p); |
74 } | 73 } |
75 bool apply_to_weak_ref_discovered_field() { return true; } | 74 bool apply_to_weak_ref_discovered_field() { return true; } |
76 bool idempotent() { return true; } | 75 bool idempotent() { return true; } |
77 }; | 76 }; |
108 class VerifyRSCleanCardOopClosure: public OopClosure { | 107 class VerifyRSCleanCardOopClosure: public OopClosure { |
109 G1CollectedHeap* _g1; | 108 G1CollectedHeap* _g1; |
110 public: | 109 public: |
111 VerifyRSCleanCardOopClosure(G1CollectedHeap* g1) : _g1(g1) {} | 110 VerifyRSCleanCardOopClosure(G1CollectedHeap* g1) : _g1(g1) {} |
112 | 111 |
113 virtual void do_oop(narrowOop* p) { | 112 virtual void do_oop(narrowOop* p) { do_oop_work(p); } |
114 guarantee(false, "NYI"); | 113 virtual void do_oop( oop* p) { do_oop_work(p); } |
115 } | 114 template <class T> void do_oop_work(T* p) { |
116 virtual void do_oop(oop* p) { | 115 oop obj = oopDesc::load_decode_heap_oop(p); |
117 oop obj = *p; | |
118 HeapRegion* to = _g1->heap_region_containing(obj); | 116 HeapRegion* to = _g1->heap_region_containing(obj); |
119 guarantee(to == NULL || !to->in_collection_set(), | 117 guarantee(to == NULL || !to->in_collection_set(), |
120 "Missed a rem set member."); | 118 "Missed a rem set member."); |
121 } | 119 } |
122 }; | 120 }; |
127 _par_traversal_in_progress(false), _new_refs(NULL), | 125 _par_traversal_in_progress(false), _new_refs(NULL), |
128 _cards_scanned(NULL), _total_cards_scanned(0) | 126 _cards_scanned(NULL), _total_cards_scanned(0) |
129 { | 127 { |
130 _seq_task = new SubTasksDone(NumSeqTasks); | 128 _seq_task = new SubTasksDone(NumSeqTasks); |
131 guarantee(n_workers() > 0, "There should be some workers"); | 129 guarantee(n_workers() > 0, "There should be some workers"); |
132 _new_refs = NEW_C_HEAP_ARRAY(GrowableArray<oop*>*, n_workers()); | 130 _new_refs = NEW_C_HEAP_ARRAY(GrowableArray<OopOrNarrowOopStar>*, n_workers()); |
133 for (uint i = 0; i < n_workers(); i++) { | 131 for (uint i = 0; i < n_workers(); i++) { |
134 _new_refs[i] = new (ResourceObj::C_HEAP) GrowableArray<oop*>(8192,true); | 132 _new_refs[i] = new (ResourceObj::C_HEAP) GrowableArray<OopOrNarrowOopStar>(8192,true); |
135 } | 133 } |
136 } | 134 } |
137 | 135 |
138 HRInto_G1RemSet::~HRInto_G1RemSet() { | 136 HRInto_G1RemSet::~HRInto_G1RemSet() { |
139 delete _seq_task; | 137 delete _seq_task; |
140 for (uint i = 0; i < n_workers(); i++) { | 138 for (uint i = 0; i < n_workers(); i++) { |
141 delete _new_refs[i]; | 139 delete _new_refs[i]; |
142 } | 140 } |
143 FREE_C_HEAP_ARRAY(GrowableArray<oop*>*, _new_refs); | 141 FREE_C_HEAP_ARRAY(GrowableArray<OopOrNarrowOopStar>*, _new_refs); |
144 } | 142 } |
145 | 143 |
146 void CountNonCleanMemRegionClosure::do_MemRegion(MemRegion mr) { | 144 void CountNonCleanMemRegionClosure::do_MemRegion(MemRegion mr) { |
147 if (_g1->is_in_g1_reserved(mr.start())) { | 145 if (_g1->is_in_g1_reserved(mr.start())) { |
148 _n += (int) ((mr.byte_size() / CardTableModRefBS::card_size)); | 146 _n += (int) ((mr.byte_size() / CardTableModRefBS::card_size)); |
426 } | 424 } |
427 gclog_or_tty->print_cr(" > %8d %8d", (1 << (MIN+mx-2))+1, _histo[mx-1]); | 425 gclog_or_tty->print_cr(" > %8d %8d", (1 << (MIN+mx-2))+1, _histo[mx-1]); |
428 } | 426 } |
429 }; | 427 }; |
430 | 428 |
431 void | 429 template <class T> void |
432 HRInto_G1RemSet::scanNewRefsRS(OopsInHeapRegionClosure* oc, | 430 HRInto_G1RemSet::scanNewRefsRS_work(OopsInHeapRegionClosure* oc, |
433 int worker_i) { | 431 int worker_i) { |
434 double scan_new_refs_start_sec = os::elapsedTime(); | 432 double scan_new_refs_start_sec = os::elapsedTime(); |
435 G1CollectedHeap* g1h = G1CollectedHeap::heap(); | 433 G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
436 CardTableModRefBS* ct_bs = (CardTableModRefBS*) (g1h->barrier_set()); | 434 CardTableModRefBS* ct_bs = (CardTableModRefBS*) (g1h->barrier_set()); |
437 for (int i = 0; i < _new_refs[worker_i]->length(); i++) { | 435 for (int i = 0; i < _new_refs[worker_i]->length(); i++) { |
438 oop* p = _new_refs[worker_i]->at(i); | 436 T* p = (T*) _new_refs[worker_i]->at(i); |
439 oop obj = *p; | 437 oop obj = oopDesc::load_decode_heap_oop(p); |
440 // *p was in the collection set when p was pushed on "_new_refs", but | 438 // *p was in the collection set when p was pushed on "_new_refs", but |
441 // another thread may have processed this location from an RS, so it | 439 // another thread may have processed this location from an RS, so it |
442 // might not point into the CS any longer. If so, it's obviously been | 440 // might not point into the CS any longer. If so, it's obviously been |
443 // processed, and we don't need to do anything further. | 441 // processed, and we don't need to do anything further. |
444 if (g1h->obj_in_cs(obj)) { | 442 if (g1h->obj_in_cs(obj)) { |
547 | 545 |
548 class UpdateRSetOopsIntoCSImmediate : public OopClosure { | 546 class UpdateRSetOopsIntoCSImmediate : public OopClosure { |
549 G1CollectedHeap* _g1; | 547 G1CollectedHeap* _g1; |
550 public: | 548 public: |
551 UpdateRSetOopsIntoCSImmediate(G1CollectedHeap* g1) : _g1(g1) { } | 549 UpdateRSetOopsIntoCSImmediate(G1CollectedHeap* g1) : _g1(g1) { } |
552 virtual void do_oop(narrowOop* p) { | 550 virtual void do_oop(narrowOop* p) { do_oop_work(p); } |
553 guarantee(false, "NYI"); | 551 virtual void do_oop( oop* p) { do_oop_work(p); } |
554 } | 552 template <class T> void do_oop_work(T* p) { |
555 virtual void do_oop(oop* p) { | 553 HeapRegion* to = _g1->heap_region_containing(oopDesc::load_decode_heap_oop(p)); |
556 HeapRegion* to = _g1->heap_region_containing(*p); | |
557 if (to->in_collection_set()) { | 554 if (to->in_collection_set()) { |
558 to->rem_set()->add_reference(p, 0); | 555 to->rem_set()->add_reference(p, 0); |
559 } | 556 } |
560 } | 557 } |
561 }; | 558 }; |
565 CardTableModRefBS* _ct_bs; | 562 CardTableModRefBS* _ct_bs; |
566 DirtyCardQueue* _dcq; | 563 DirtyCardQueue* _dcq; |
567 public: | 564 public: |
568 UpdateRSetOopsIntoCSDeferred(G1CollectedHeap* g1, DirtyCardQueue* dcq) : | 565 UpdateRSetOopsIntoCSDeferred(G1CollectedHeap* g1, DirtyCardQueue* dcq) : |
569 _g1(g1), _ct_bs((CardTableModRefBS*)_g1->barrier_set()), _dcq(dcq) { } | 566 _g1(g1), _ct_bs((CardTableModRefBS*)_g1->barrier_set()), _dcq(dcq) { } |
570 virtual void do_oop(narrowOop* p) { | 567 virtual void do_oop(narrowOop* p) { do_oop_work(p); } |
571 guarantee(false, "NYI"); | 568 virtual void do_oop( oop* p) { do_oop_work(p); } |
572 } | 569 template <class T> void do_oop_work(T* p) { |
573 virtual void do_oop(oop* p) { | 570 oop obj = oopDesc::load_decode_heap_oop(p); |
574 oop obj = *p; | |
575 if (_g1->obj_in_cs(obj)) { | 571 if (_g1->obj_in_cs(obj)) { |
576 size_t card_index = _ct_bs->index_for(p); | 572 size_t card_index = _ct_bs->index_for(p); |
577 if (_ct_bs->mark_card_deferred(card_index)) { | 573 if (_ct_bs->mark_card_deferred(card_index)) { |
578 _dcq->enqueue((jbyte*)_ct_bs->byte_for_index(card_index)); | 574 _dcq->enqueue((jbyte*)_ct_bs->byte_for_index(card_index)); |
579 } | 575 } |
580 } | 576 } |
581 } | 577 } |
582 }; | 578 }; |
583 | 579 |
584 void HRInto_G1RemSet::new_refs_iterate(OopClosure* cl) { | 580 template <class T> void HRInto_G1RemSet::new_refs_iterate_work(OopClosure* cl) { |
585 for (size_t i = 0; i < n_workers(); i++) { | 581 for (size_t i = 0; i < n_workers(); i++) { |
586 for (int j = 0; j < _new_refs[i]->length(); j++) { | 582 for (int j = 0; j < _new_refs[i]->length(); j++) { |
587 oop* p = _new_refs[i]->at(j); | 583 T* p = (T*) _new_refs[i]->at(j); |
588 cl->do_oop(p); | 584 cl->do_oop(p); |
589 } | 585 } |
590 } | 586 } |
591 } | 587 } |
592 | 588 |