src/share/vm/gc_implementation/g1/heapRegion.cpp

changeset 7655
8e9ede9dd2cd
parent 7654
36c7518fd486
child 7990
1f646daf0d67
equal deleted inserted replaced
7654:36c7518fd486 7655:8e9ede9dd2cd
45 size_t HeapRegion::GrainBytes = 0; 45 size_t HeapRegion::GrainBytes = 0;
46 size_t HeapRegion::GrainWords = 0; 46 size_t HeapRegion::GrainWords = 0;
47 size_t HeapRegion::CardsPerRegion = 0; 47 size_t HeapRegion::CardsPerRegion = 0;
48 48
49 HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1, 49 HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
50 HeapRegion* hr, ExtendedOopClosure* cl, 50 HeapRegion* hr,
51 CardTableModRefBS::PrecisionStyle precision, 51 G1ParPushHeapRSClosure* cl,
52 FilterKind fk) : 52 CardTableModRefBS::PrecisionStyle precision) :
53 DirtyCardToOopClosure(hr, cl, precision, NULL), 53 DirtyCardToOopClosure(hr, cl, precision, NULL),
54 _hr(hr), _fk(fk), _g1(g1) { } 54 _hr(hr), _rs_scan(cl), _g1(g1) { }
55 55
56 FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r, 56 FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r,
57 OopClosure* oc) : 57 OopClosure* oc) :
58 _r_bottom(r->bottom()), _r_end(r->end()), _oc(oc) { } 58 _r_bottom(r->bottom()), _r_end(r->end()), _oc(oc) { }
59
60 template<class ClosureType>
61 HeapWord* walk_mem_region_loop(ClosureType* cl, G1CollectedHeap* g1h,
62 HeapRegion* hr,
63 HeapWord* cur, HeapWord* top) {
64 oop cur_oop = oop(cur);
65 size_t oop_size = hr->block_size(cur);
66 HeapWord* next_obj = cur + oop_size;
67 while (next_obj < top) {
68 // Keep filtering the remembered set.
69 if (!g1h->is_obj_dead(cur_oop, hr)) {
70 // Bottom lies entirely below top, so we can call the
71 // non-memRegion version of oop_iterate below.
72 cur_oop->oop_iterate(cl);
73 }
74 cur = next_obj;
75 cur_oop = oop(cur);
76 oop_size = hr->block_size(cur);
77 next_obj = cur + oop_size;
78 }
79 return cur;
80 }
81 59
82 void HeapRegionDCTOC::walk_mem_region(MemRegion mr, 60 void HeapRegionDCTOC::walk_mem_region(MemRegion mr,
83 HeapWord* bottom, 61 HeapWord* bottom,
84 HeapWord* top) { 62 HeapWord* top) {
85 G1CollectedHeap* g1h = _g1; 63 G1CollectedHeap* g1h = _g1;
86 size_t oop_size; 64 size_t oop_size;
87 ExtendedOopClosure* cl2 = NULL; 65 HeapWord* cur = bottom;
88
89 FilterIntoCSClosure intoCSFilt(this, g1h, _cl);
90 FilterOutOfRegionClosure outOfRegionFilt(_hr, _cl);
91
92 switch (_fk) {
93 case NoFilterKind: cl2 = _cl; break;
94 case IntoCSFilterKind: cl2 = &intoCSFilt; break;
95 case OutOfRegionFilterKind: cl2 = &outOfRegionFilt; break;
96 default: ShouldNotReachHere();
97 }
98 66
99 // Start filtering what we add to the remembered set. If the object is 67 // Start filtering what we add to the remembered set. If the object is
100 // not considered dead, either because it is marked (in the mark bitmap) 68 // not considered dead, either because it is marked (in the mark bitmap)
101 // or it was allocated after marking finished, then we add it. Otherwise 69 // or it was allocated after marking finished, then we add it. Otherwise
102 // we can safely ignore the object. 70 // we can safely ignore the object.
103 if (!g1h->is_obj_dead(oop(bottom), _hr)) { 71 if (!g1h->is_obj_dead(oop(cur), _hr)) {
104 oop_size = oop(bottom)->oop_iterate(cl2, mr); 72 oop_size = oop(cur)->oop_iterate(_rs_scan, mr);
105 } else { 73 } else {
106 oop_size = _hr->block_size(bottom); 74 oop_size = _hr->block_size(cur);
107 } 75 }
108 76
109 bottom += oop_size; 77 cur += oop_size;
110 78
111 if (bottom < top) { 79 if (cur < top) {
112 // We replicate the loop below for several kinds of possible filters. 80 oop cur_oop = oop(cur);
113 switch (_fk) { 81 oop_size = _hr->block_size(cur);
114 case NoFilterKind: 82 HeapWord* next_obj = cur + oop_size;
115 bottom = walk_mem_region_loop(_cl, g1h, _hr, bottom, top); 83 while (next_obj < top) {
116 break; 84 // Keep filtering the remembered set.
117 85 if (!g1h->is_obj_dead(cur_oop, _hr)) {
118 case IntoCSFilterKind: { 86 // Bottom lies entirely below top, so we can call the
119 FilterIntoCSClosure filt(this, g1h, _cl); 87 // non-memRegion version of oop_iterate below.
120 bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top); 88 cur_oop->oop_iterate(_rs_scan);
121 break; 89 }
122 } 90 cur = next_obj;
123 91 cur_oop = oop(cur);
124 case OutOfRegionFilterKind: { 92 oop_size = _hr->block_size(cur);
125 FilterOutOfRegionClosure filt(_hr, _cl); 93 next_obj = cur + oop_size;
126 bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top);
127 break;
128 }
129
130 default:
131 ShouldNotReachHere();
132 } 94 }
133 95
134 // Last object. Need to do dead-obj filtering here too. 96 // Last object. Need to do dead-obj filtering here too.
135 if (!g1h->is_obj_dead(oop(bottom), _hr)) { 97 if (!g1h->is_obj_dead(oop(cur), _hr)) {
136 oop(bottom)->oop_iterate(cl2, mr); 98 oop(cur)->oop_iterate(_rs_scan, mr);
137 } 99 }
138 } 100 }
139 } 101 }
140 102
141 size_t HeapRegion::max_region_size() { 103 size_t HeapRegion::max_region_size() {

mercurial