101 return ContiguousSpaceDCTOC::get_actual_top(top, top_obj);
102 }
103
104 // Walk the given memory region from bottom to (actual) top
105 // looking for objects and applying the oop closure (_cl) to
106 // them. The base implementation of this treats the area as
107 // blocks, where a block may or may not be an object. Sub-
108 // classes should override this to provide more accurate
109 // or possibly more efficient walking.
110 void walk_mem_region(MemRegion mr, HeapWord* bottom, HeapWord* top) {
111 Filtering_DCTOC::walk_mem_region(mr, bottom, top);
112 }
113
114 public:
115 HeapRegionDCTOC(G1CollectedHeap* g1,
116 HeapRegion* hr, OopClosure* cl,
117 CardTableModRefBS::PrecisionStyle precision,
118 FilterKind fk);
119 };
120
121
122 // The complicating factor is that BlockOffsetTable diverged
123 // significantly, and we need functionality that is only in the G1 version.
124 // So I copied that code, which led to an alternate G1 version of
125 // OffsetTableContigSpace. If the two versions of BlockOffsetTable could
126 // be reconciled, then G1OffsetTableContigSpace could go away.
127
128 // The idea behind time stamps is the following. Doing a save_marks on
129 // all regions at every GC pause is time consuming (if I remember
130 // well, 10ms or so). So, we would like to do that only for regions
131 // that are GC alloc regions. To achieve this, we use time
132 // stamps. For every evacuation pause, G1CollectedHeap generates a
133 // unique time stamp (essentially a counter that gets
134 // incremented). Every time we want to call save_marks on a region,
135 // we set the saved_mark_word to top and also copy the current GC
136 // time stamp to the time stamp field of the space. Reading the
137 // saved_mark_word involves checking the time stamp of the
138 // region. If it is the same as the current GC time stamp, then we
139 // can safely read the saved_mark_word field, as it is valid. If the
140 // time stamp of the region is not the same as the current GC time
141 // stamp, then we instead read top, as the saved_mark_word field is
206
207 void update_bot_for_object(HeapWord* start, size_t word_size) {
208 _offsets.alloc_block(start, word_size);
209 }
210
211 void print_bot_on(outputStream* out) {
212 _offsets.print_on(out);
213 }
214 };
215
216 class HeapRegion: public G1OffsetTableContigSpace {
217 friend class VMStructs;
218 private:
219
220 enum HumongousType {
221 NotHumongous = 0,
222 StartsHumongous,
223 ContinuesHumongous
224 };
225
226 // The next filter kind that should be used for a "new_dcto_cl" call with
227 // the "traditional" signature.
228 HeapRegionDCTOC::FilterKind _next_fk;
229
230 // Requires that the region "mr" be dense with objects, and begin and end
231 // with an object.
232 void oops_in_mr_iterate(MemRegion mr, OopClosure* cl);
233
234 // The remembered set for this region.
235 // (Might want to make this "inline" later, to avoid some alloc failure
236 // issues.)
237 HeapRegionRemSet* _rem_set;
238
239 G1BlockOffsetArrayContigSpace* offsets() { return &_offsets; }
240
241 protected:
242 // The index of this region in the heap region sequence.
243 size_t _hrs_index;
244
245 HumongousType _humongous_type;
246 // For a humongous region, region in which it starts.
247 HeapRegion* _humongous_start_region;
248 // For the start region of a humongous sequence, it's original end().
249 HeapWord* _orig_end;
556
557 HeapWord* orig_end() { return _orig_end; }
558
559 // Allows logical separation between objects allocated before and after.
560 void save_marks();
561
562 // Reset HR stuff to default values.
563 void hr_clear(bool par, bool clear_space);
564 void par_clear();
565
566 void initialize(MemRegion mr, bool clear_space, bool mangle_space);
567
568 // Get the start of the unmarked area in this region.
569 HeapWord* prev_top_at_mark_start() const { return _prev_top_at_mark_start; }
570 HeapWord* next_top_at_mark_start() const { return _next_top_at_mark_start; }
571
572 // Apply "cl->do_oop" to (the addresses of) all reference fields in objects
573 // allocated in the current region before the last call to "save_mark".
574 void oop_before_save_marks_iterate(OopClosure* cl);
575
576 // This call determines the "filter kind" argument that will be used for
577 // the next call to "new_dcto_cl" on this region with the "traditional"
578 // signature (i.e., the call below.) The default, in the absence of a
579 // preceding call to this method, is "NoFilterKind", and a call to this
580 // method is necessary for each such call, or else it reverts to the
581 // default.
582 // (This is really ugly, but all other methods I could think of changed a
583 // lot of main-line code for G1.)
584 void set_next_filter_kind(HeapRegionDCTOC::FilterKind nfk) {
585 _next_fk = nfk;
586 }
587
588 DirtyCardToOopClosure*
589 new_dcto_closure(OopClosure* cl,
590 CardTableModRefBS::PrecisionStyle precision,
591 HeapRegionDCTOC::FilterKind fk);
592
593 #if WHASSUP
594 DirtyCardToOopClosure*
595 new_dcto_closure(OopClosure* cl,
596 CardTableModRefBS::PrecisionStyle precision,
597 HeapWord* boundary) {
598 assert(boundary == NULL, "This arg doesn't make sense here.");
599 DirtyCardToOopClosure* res = new_dcto_closure(cl, precision, _next_fk);
600 _next_fk = HeapRegionDCTOC::NoFilterKind;
601 return res;
602 }
603 #endif
604
605 //
606 // Note the start or end of marking. This tells the heap region
607 // that the collector is about to start or has finished (concurrently)
608 // marking the heap.
609 //
610
611 // Note the start of a marking phase. Record the
612 // start of the unmarked area of the region here.
613 void note_start_of_marking(bool during_initial_mark) {
614 init_top_at_conc_mark_count();
615 _next_marked_bytes = 0;
616 if (during_initial_mark && is_young() && !is_survivor())
617 _next_top_at_mark_start = bottom();
618 else
619 _next_top_at_mark_start = top();
620 }
621
622 // Note the end of a marking phase. Install the start of
623 // the unmarked area that was captured at start of marking.
624 void note_end_of_marking() {
625 _prev_top_at_mark_start = _next_top_at_mark_start;
626 _prev_marked_bytes = _next_marked_bytes;
627 _next_marked_bytes = 0;
628
629 guarantee(_prev_marked_bytes <=
|
101 return ContiguousSpaceDCTOC::get_actual_top(top, top_obj);
102 }
103
104 // Walk the given memory region from bottom to (actual) top
105 // looking for objects and applying the oop closure (_cl) to
106 // them. The base implementation of this treats the area as
107 // blocks, where a block may or may not be an object. Sub-
108 // classes should override this to provide more accurate
109 // or possibly more efficient walking.
110 void walk_mem_region(MemRegion mr, HeapWord* bottom, HeapWord* top) {
111 Filtering_DCTOC::walk_mem_region(mr, bottom, top);
112 }
113
114 public:
115 HeapRegionDCTOC(G1CollectedHeap* g1,
116 HeapRegion* hr, OopClosure* cl,
117 CardTableModRefBS::PrecisionStyle precision,
118 FilterKind fk);
119 };
120
121 // The complicating factor is that BlockOffsetTable diverged
122 // significantly, and we need functionality that is only in the G1 version.
123 // So I copied that code, which led to an alternate G1 version of
124 // OffsetTableContigSpace. If the two versions of BlockOffsetTable could
125 // be reconciled, then G1OffsetTableContigSpace could go away.
126
127 // The idea behind time stamps is the following. Doing a save_marks on
128 // all regions at every GC pause is time consuming (if I remember
129 // well, 10ms or so). So, we would like to do that only for regions
130 // that are GC alloc regions. To achieve this, we use time
131 // stamps. For every evacuation pause, G1CollectedHeap generates a
132 // unique time stamp (essentially a counter that gets
133 // incremented). Every time we want to call save_marks on a region,
134 // we set the saved_mark_word to top and also copy the current GC
135 // time stamp to the time stamp field of the space. Reading the
136 // saved_mark_word involves checking the time stamp of the
137 // region. If it is the same as the current GC time stamp, then we
138 // can safely read the saved_mark_word field, as it is valid. If the
139 // time stamp of the region is not the same as the current GC time
140 // stamp, then we instead read top, as the saved_mark_word field is
205
206 void update_bot_for_object(HeapWord* start, size_t word_size) {
207 _offsets.alloc_block(start, word_size);
208 }
209
210 void print_bot_on(outputStream* out) {
211 _offsets.print_on(out);
212 }
213 };
214
215 class HeapRegion: public G1OffsetTableContigSpace {
216 friend class VMStructs;
217 private:
218
219 enum HumongousType {
220 NotHumongous = 0,
221 StartsHumongous,
222 ContinuesHumongous
223 };
224
225 // Requires that the region "mr" be dense with objects, and begin and end
226 // with an object.
227 void oops_in_mr_iterate(MemRegion mr, OopClosure* cl);
228
229 // The remembered set for this region.
230 // (Might want to make this "inline" later, to avoid some alloc failure
231 // issues.)
232 HeapRegionRemSet* _rem_set;
233
234 G1BlockOffsetArrayContigSpace* offsets() { return &_offsets; }
235
236 protected:
237 // The index of this region in the heap region sequence.
238 size_t _hrs_index;
239
240 HumongousType _humongous_type;
241 // For a humongous region, region in which it starts.
242 HeapRegion* _humongous_start_region;
243 // For the start region of a humongous sequence, it's original end().
244 HeapWord* _orig_end;
551
552 HeapWord* orig_end() { return _orig_end; }
553
554 // Allows logical separation between objects allocated before and after.
555 void save_marks();
556
557 // Reset HR stuff to default values.
558 void hr_clear(bool par, bool clear_space);
559 void par_clear();
560
561 void initialize(MemRegion mr, bool clear_space, bool mangle_space);
562
563 // Get the start of the unmarked area in this region.
564 HeapWord* prev_top_at_mark_start() const { return _prev_top_at_mark_start; }
565 HeapWord* next_top_at_mark_start() const { return _next_top_at_mark_start; }
566
567 // Apply "cl->do_oop" to (the addresses of) all reference fields in objects
568 // allocated in the current region before the last call to "save_mark".
569 void oop_before_save_marks_iterate(OopClosure* cl);
570
571 DirtyCardToOopClosure*
572 new_dcto_closure(OopClosure* cl,
573 CardTableModRefBS::PrecisionStyle precision,
574 HeapRegionDCTOC::FilterKind fk);
575
576 // Note the start or end of marking. This tells the heap region
577 // that the collector is about to start or has finished (concurrently)
578 // marking the heap.
579
580 // Note the start of a marking phase. Record the
581 // start of the unmarked area of the region here.
582 void note_start_of_marking(bool during_initial_mark) {
583 init_top_at_conc_mark_count();
584 _next_marked_bytes = 0;
585 if (during_initial_mark && is_young() && !is_survivor())
586 _next_top_at_mark_start = bottom();
587 else
588 _next_top_at_mark_start = top();
589 }
590
591 // Note the end of a marking phase. Install the start of
592 // the unmarked area that was captured at start of marking.
593 void note_end_of_marking() {
594 _prev_top_at_mark_start = _next_top_at_mark_start;
595 _prev_marked_bytes = _next_marked_bytes;
596 _next_marked_bytes = 0;
597
598 guarantee(_prev_marked_bytes <=
|