|
49 | 49 |
|
50 | 50 | HeapWord* DirtyCardToOopClosure::get_actual_top(HeapWord* top,
|
51 | 51 | HeapWord* top_obj) {
|
52 |
| - if (top_obj != NULL) { |
53 |
| - if (_sp->block_is_obj(top_obj)) { |
54 |
| - if (cast_to_oop(top_obj)->is_objArray() || cast_to_oop(top_obj)->is_typeArray()) { |
55 |
| - // An arrayOop is starting on the dirty card - since we do exact |
56 |
| - // store checks for objArrays we are done. |
57 |
| - } else { |
58 |
| - // Otherwise, it is possible that the object starting on the dirty |
59 |
| - // card spans the entire card, and that the store happened on a |
60 |
| - // later card. Figure out where the object ends. |
61 |
| - top = top_obj + cast_to_oop(top_obj)->size(); |
62 |
| - } |
| 52 | + if (top_obj != NULL && top_obj < (_sp->toContiguousSpace())->top()) { |
| 53 | + if (cast_to_oop(top_obj)->is_objArray() || cast_to_oop(top_obj)->is_typeArray()) { |
| 54 | + // An arrayOop is starting on the dirty card - since we do exact |
| 55 | + // store checks for objArrays we are done. |
63 | 56 | } else {
|
64 |
| - top = top_obj; |
| 57 | + // Otherwise, it is possible that the object starting on the dirty |
| 58 | + // card spans the entire card, and that the store happened on a |
| 59 | + // later card. Figure out where the object ends. |
| 60 | + assert(_sp->block_size(top_obj) == cast_to_oop(top_obj)->size(), |
| 61 | + "Block size and object size mismatch"); |
| 62 | + top = top_obj + cast_to_oop(top_obj)->size(); |
65 | 63 | }
|
66 | 64 | } else {
|
67 |
| - assert(top == _sp->end(), "only case where top_obj == NULL"); |
| 65 | + top = (_sp->toContiguousSpace())->top(); |
68 | 66 | }
|
69 | 67 | return top;
|
70 | 68 | }
|
71 | 69 |
|
72 | 70 | void DirtyCardToOopClosure::walk_mem_region(MemRegion mr,
|
73 | 71 | HeapWord* bottom,
|
74 | 72 | HeapWord* top) {
|
75 |
| - // 1. Blocks may or may not be objects. |
76 |
| - // 2. Even when a block_is_obj(), it may not entirely |
77 |
| - // occupy the block if the block quantum is larger than |
78 |
| - // the object size. |
79 |
| - // We can and should try to optimize by calling the non-MemRegion |
80 |
| - // version of oop_iterate() for all but the extremal objects |
81 |
| - // (for which we need to call the MemRegion version of |
82 |
| - // oop_iterate()) To be done post-beta XXX |
83 |
| - for (; bottom < top; bottom += _sp->block_size(bottom)) { |
84 |
| - // As in the case of contiguous space above, we'd like to |
85 |
| - // just use the value returned by oop_iterate to increment the |
86 |
| - // current pointer; unfortunately, that won't work in CMS because |
87 |
| - // we'd need an interface change (it seems) to have the space |
88 |
| - // "adjust the object size" (for instance pad it up to its |
89 |
| - // block alignment or minimum block size restrictions. XXX |
90 |
| - if (_sp->block_is_obj(bottom) && |
91 |
| - !_sp->obj_allocated_since_save_marks(cast_to_oop(bottom))) { |
92 |
| - cast_to_oop(bottom)->oop_iterate(_cl, mr); |
93 |
| - } |
| 73 | + // Note that this assumption won't hold if we have a concurrent |
| 74 | + // collector in this space, which may have freed up objects after |
| 75 | + // they were dirtied and before the stop-the-world GC that is |
| 76 | + // examining cards here. |
| 77 | + assert(bottom < top, "ought to be at least one obj on a dirty card."); |
| 78 | + |
| 79 | + if (_boundary != NULL) { |
| 80 | + // We have a boundary outside of which we don't want to look |
| 81 | + // at objects, so create a filtering closure around the |
| 82 | + // oop closure before walking the region. |
| 83 | + FilteringClosure filter(_boundary, _cl); |
| 84 | + walk_mem_region_with_cl(mr, bottom, top, &filter); |
| 85 | + } else { |
| 86 | + // No boundary, simply walk the heap with the oop closure. |
| 87 | + walk_mem_region_with_cl(mr, bottom, top, _cl); |
94 | 88 | }
|
95 | 89 | }
|
96 | 90 |
|
@@ -146,80 +140,38 @@ void DirtyCardToOopClosure::do_MemRegion(MemRegion mr) {
|
146 | 140 | _min_done = bottom;
|
147 | 141 | }
|
148 | 142 |
|
149 |
| -HeapWord* ContiguousSpaceDCTOC::get_actual_top(HeapWord* top, |
150 |
| - HeapWord* top_obj) { |
151 |
| - if (top_obj != NULL && top_obj < (_sp->toContiguousSpace())->top()) { |
152 |
| - if (cast_to_oop(top_obj)->is_objArray() || cast_to_oop(top_obj)->is_typeArray()) { |
153 |
| - // An arrayOop is starting on the dirty card - since we do exact |
154 |
| - // store checks for objArrays we are done. |
155 |
| - } else { |
156 |
| - // Otherwise, it is possible that the object starting on the dirty |
157 |
| - // card spans the entire card, and that the store happened on a |
158 |
| - // later card. Figure out where the object ends. |
159 |
| - assert(_sp->block_size(top_obj) == cast_to_oop(top_obj)->size(), |
160 |
| - "Block size and object size mismatch"); |
161 |
| - top = top_obj + cast_to_oop(top_obj)->size(); |
162 |
| - } |
163 |
| - } else { |
164 |
| - top = (_sp->toContiguousSpace())->top(); |
165 |
| - } |
166 |
| - return top; |
167 |
| -} |
168 |
| - |
169 |
| -void ContiguousSpaceDCTOC::walk_mem_region(MemRegion mr, |
170 |
| - HeapWord* bottom, |
171 |
| - HeapWord* top) { |
172 |
| - // Note that this assumption won't hold if we have a concurrent |
173 |
| - // collector in this space, which may have freed up objects after |
174 |
| - // they were dirtied and before the stop-the-world GC that is |
175 |
| - // examining cards here. |
176 |
| - assert(bottom < top, "ought to be at least one obj on a dirty card."); |
177 |
| - |
178 |
| - if (_boundary != NULL) { |
179 |
| - // We have a boundary outside of which we don't want to look |
180 |
| - // at objects, so create a filtering closure around the |
181 |
| - // oop closure before walking the region. |
182 |
| - FilteringClosure filter(_boundary, _cl); |
183 |
| - walk_mem_region_with_cl(mr, bottom, top, &filter); |
184 |
| - } else { |
185 |
| - // No boundary, simply walk the heap with the oop closure. |
186 |
| - walk_mem_region_with_cl(mr, bottom, top, _cl); |
187 |
| - } |
188 |
| - |
189 |
| -} |
190 |
| - |
191 | 143 | // We must replicate this so that the static type of "FilteringClosure"
|
192 | 144 | // (see above) is apparent at the oop_iterate calls.
|
193 |
| -#define ContiguousSpaceDCTOC__walk_mem_region_with_cl_DEFN(ClosureType) \ |
194 |
| -void ContiguousSpaceDCTOC::walk_mem_region_with_cl(MemRegion mr, \ |
195 |
| - HeapWord* bottom, \ |
196 |
| - HeapWord* top, \ |
197 |
| - ClosureType* cl) { \ |
198 |
| - bottom += cast_to_oop(bottom)->oop_iterate_size(cl, mr); \ |
199 |
| - if (bottom < top) { \ |
200 |
| - HeapWord* next_obj = bottom + cast_to_oop(bottom)->size(); \ |
201 |
| - while (next_obj < top) { \ |
202 |
| - /* Bottom lies entirely below top, so we can call the */ \ |
203 |
| - /* non-memRegion version of oop_iterate below. */ \ |
204 |
| - cast_to_oop(bottom)->oop_iterate(cl); \ |
205 |
| - bottom = next_obj; \ |
206 |
| - next_obj = bottom + cast_to_oop(bottom)->size(); \ |
207 |
| - } \ |
208 |
| - /* Last object. */ \ |
209 |
| - cast_to_oop(bottom)->oop_iterate(cl, mr); \ |
210 |
| - } \ |
| 145 | +#define DirtyCardToOopClosure__walk_mem_region_with_cl_DEFN(ClosureType) \ |
| 146 | +void DirtyCardToOopClosure::walk_mem_region_with_cl(MemRegion mr, \ |
| 147 | + HeapWord* bottom, \ |
| 148 | + HeapWord* top, \ |
| 149 | + ClosureType* cl) { \ |
| 150 | + bottom += cast_to_oop(bottom)->oop_iterate_size(cl, mr); \ |
| 151 | + if (bottom < top) { \ |
| 152 | + HeapWord* next_obj = bottom + cast_to_oop(bottom)->size(); \ |
| 153 | + while (next_obj < top) { \ |
| 154 | + /* Bottom lies entirely below top, so we can call the */ \ |
| 155 | + /* non-memRegion version of oop_iterate below. */ \ |
| 156 | + cast_to_oop(bottom)->oop_iterate(cl); \ |
| 157 | + bottom = next_obj; \ |
| 158 | + next_obj = bottom + cast_to_oop(bottom)->size(); \ |
| 159 | + } \ |
| 160 | + /* Last object. */ \ |
| 161 | + cast_to_oop(bottom)->oop_iterate(cl, mr); \ |
| 162 | + } \ |
211 | 163 | }
|
212 | 164 |
|
213 | 165 | // (There are only two of these, rather than N, because the split is due
|
214 | 166 | // only to the introduction of the FilteringClosure, a local part of the
|
215 | 167 | // impl of this abstraction.)
|
216 |
| -ContiguousSpaceDCTOC__walk_mem_region_with_cl_DEFN(OopIterateClosure) |
217 |
| -ContiguousSpaceDCTOC__walk_mem_region_with_cl_DEFN(FilteringClosure) |
| 168 | +DirtyCardToOopClosure__walk_mem_region_with_cl_DEFN(OopIterateClosure) |
| 169 | +DirtyCardToOopClosure__walk_mem_region_with_cl_DEFN(FilteringClosure) |
218 | 170 |
|
219 | 171 | DirtyCardToOopClosure*
|
220 | 172 | ContiguousSpace::new_dcto_cl(OopIterateClosure* cl,
|
221 | 173 | HeapWord* boundary) {
|
222 |
| - return new ContiguousSpaceDCTOC(this, cl, boundary); |
| 174 | + return new DirtyCardToOopClosure(this, cl, boundary); |
223 | 175 | }
|
224 | 176 |
|
225 | 177 | void Space::initialize(MemRegion mr,
|
|
0 commit comments