31 #include "gc_implementation/g1/heapRegionRemSet.hpp"
32 #include "gc_implementation/g1/heapRegionSeq.inline.hpp"
33 #include "memory/genOopClosures.inline.hpp"
34 #include "memory/iterator.hpp"
35 #include "memory/space.inline.hpp"
36 #include "oops/oop.inline.hpp"
37 #include "runtime/orderAccess.inline.hpp"
38
39 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
40
41 int HeapRegion::LogOfHRGrainBytes = 0;
42 int HeapRegion::LogOfHRGrainWords = 0;
43 size_t HeapRegion::GrainBytes = 0;
44 size_t HeapRegion::GrainWords = 0;
45 size_t HeapRegion::CardsPerRegion = 0;
46
47 HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
48 HeapRegion* hr, ExtendedOopClosure* cl,
49 CardTableModRefBS::PrecisionStyle precision,
50 FilterKind fk) :
51 ContiguousSpaceDCTOC(hr, cl, precision, NULL),
52 _hr(hr), _fk(fk), _g1(g1) { }
53
54 FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r,
55 OopClosure* oc) :
56 _r_bottom(r->bottom()), _r_end(r->end()), _oc(oc) { }
57
58 template<class ClosureType>
59 HeapWord* walk_mem_region_loop(ClosureType* cl, G1CollectedHeap* g1h,
60 HeapRegion* hr,
61 HeapWord* cur, HeapWord* top) {
62 oop cur_oop = oop(cur);
63 int oop_size = cur_oop->size();
64 HeapWord* next_obj = cur + oop_size;
65 while (next_obj < top) {
66 // Keep filtering the remembered set.
67 if (!g1h->is_obj_dead(cur_oop, hr)) {
68 // Bottom lies entirely below top, so we can call the
69 // non-memRegion version of oop_iterate below.
70 cur_oop->oop_iterate(cl);
71 }
72 cur = next_obj;
73 cur_oop = oop(cur);
74 oop_size = cur_oop->size();
75 next_obj = cur + oop_size;
76 }
77 return cur;
78 }
79
80 void HeapRegionDCTOC::walk_mem_region_with_cl(MemRegion mr,
81 HeapWord* bottom,
82 HeapWord* top,
83 ExtendedOopClosure* cl) {
84 G1CollectedHeap* g1h = _g1;
85 int oop_size;
86 ExtendedOopClosure* cl2 = NULL;
87
88 FilterIntoCSClosure intoCSFilt(this, g1h, cl);
89 FilterOutOfRegionClosure outOfRegionFilt(_hr, cl);
90
91 switch (_fk) {
92 case NoFilterKind: cl2 = cl; break;
93 case IntoCSFilterKind: cl2 = &intoCSFilt; break;
94 case OutOfRegionFilterKind: cl2 = &outOfRegionFilt; break;
95 default: ShouldNotReachHere();
96 }
97
98 // Start filtering what we add to the remembered set. If the object is
99 // not considered dead, either because it is marked (in the mark bitmap)
100 // or it was allocated after marking finished, then we add it. Otherwise
101 // we can safely ignore the object.
102 if (!g1h->is_obj_dead(oop(bottom), _hr)) {
103 oop_size = oop(bottom)->oop_iterate(cl2, mr);
104 } else {
105 oop_size = oop(bottom)->size();
106 }
107
108 bottom += oop_size;
109
110 if (bottom < top) {
111 // We replicate the loop below for several kinds of possible filters.
112 switch (_fk) {
113 case NoFilterKind:
114 bottom = walk_mem_region_loop(cl, g1h, _hr, bottom, top);
115 break;
116
117 case IntoCSFilterKind: {
118 FilterIntoCSClosure filt(this, g1h, cl);
119 bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top);
120 break;
121 }
122
123 case OutOfRegionFilterKind: {
124 FilterOutOfRegionClosure filt(_hr, cl);
125 bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top);
126 break;
127 }
128
129 default:
130 ShouldNotReachHere();
131 }
132
133 // Last object. Need to do dead-obj filtering here too.
134 if (!g1h->is_obj_dead(oop(bottom), _hr)) {
135 oop(bottom)->oop_iterate(cl2, mr);
136 }
137 }
138 }
139
140 // Minimum region size; we won't go lower than that.
141 // We might want to decrease this in the future, to deal with small
142 // heaps a bit more efficiently.
143 #define MIN_REGION_SIZE ( 1024 * 1024 )
144
|
31 #include "gc_implementation/g1/heapRegionRemSet.hpp"
32 #include "gc_implementation/g1/heapRegionSeq.inline.hpp"
33 #include "memory/genOopClosures.inline.hpp"
34 #include "memory/iterator.hpp"
35 #include "memory/space.inline.hpp"
36 #include "oops/oop.inline.hpp"
37 #include "runtime/orderAccess.inline.hpp"
38
39 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
40
41 int HeapRegion::LogOfHRGrainBytes = 0;
42 int HeapRegion::LogOfHRGrainWords = 0;
43 size_t HeapRegion::GrainBytes = 0;
44 size_t HeapRegion::GrainWords = 0;
45 size_t HeapRegion::CardsPerRegion = 0;
46
47 HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
48 HeapRegion* hr, ExtendedOopClosure* cl,
49 CardTableModRefBS::PrecisionStyle precision,
50 FilterKind fk) :
51 DirtyCardToOopClosure(hr, cl, precision, NULL),
52 _hr(hr), _fk(fk), _g1(g1) { }
53
54 FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r,
55 OopClosure* oc) :
56 _r_bottom(r->bottom()), _r_end(r->end()), _oc(oc) { }
57
58 template<class ClosureType>
59 HeapWord* walk_mem_region_loop(ClosureType* cl, G1CollectedHeap* g1h,
60 HeapRegion* hr,
61 HeapWord* cur, HeapWord* top) {
62 oop cur_oop = oop(cur);
63 int oop_size = cur_oop->size();
64 HeapWord* next_obj = cur + oop_size;
65 while (next_obj < top) {
66 // Keep filtering the remembered set.
67 if (!g1h->is_obj_dead(cur_oop, hr)) {
68 // Bottom lies entirely below top, so we can call the
69 // non-memRegion version of oop_iterate below.
70 cur_oop->oop_iterate(cl);
71 }
72 cur = next_obj;
73 cur_oop = oop(cur);
74 oop_size = cur_oop->size();
75 next_obj = cur + oop_size;
76 }
77 return cur;
78 }
79
80 void HeapRegionDCTOC::walk_mem_region(MemRegion mr,
81 HeapWord* bottom,
82 HeapWord* top) {
83 G1CollectedHeap* g1h = _g1;
84 int oop_size;
85 ExtendedOopClosure* cl2 = NULL;
86
87 FilterIntoCSClosure intoCSFilt(this, g1h, _cl);
88 FilterOutOfRegionClosure outOfRegionFilt(_hr, _cl);
89
90 switch (_fk) {
91 case NoFilterKind: cl2 = _cl; break;
92 case IntoCSFilterKind: cl2 = &intoCSFilt; break;
93 case OutOfRegionFilterKind: cl2 = &outOfRegionFilt; break;
94 default: ShouldNotReachHere();
95 }
96
97 // Start filtering what we add to the remembered set. If the object is
98 // not considered dead, either because it is marked (in the mark bitmap)
99 // or it was allocated after marking finished, then we add it. Otherwise
100 // we can safely ignore the object.
101 if (!g1h->is_obj_dead(oop(bottom), _hr)) {
102 oop_size = oop(bottom)->oop_iterate(cl2, mr);
103 } else {
104 oop_size = oop(bottom)->size();
105 }
106
107 bottom += oop_size;
108
109 if (bottom < top) {
110 // We replicate the loop below for several kinds of possible filters.
111 switch (_fk) {
112 case NoFilterKind:
113 bottom = walk_mem_region_loop(_cl, g1h, _hr, bottom, top);
114 break;
115
116 case IntoCSFilterKind: {
117 FilterIntoCSClosure filt(this, g1h, _cl);
118 bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top);
119 break;
120 }
121
122 case OutOfRegionFilterKind: {
123 FilterOutOfRegionClosure filt(_hr, _cl);
124 bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top);
125 break;
126 }
127
128 default:
129 ShouldNotReachHere();
130 }
131
132 // Last object. Need to do dead-obj filtering here too.
133 if (!g1h->is_obj_dead(oop(bottom), _hr)) {
134 oop(bottom)->oop_iterate(cl2, mr);
135 }
136 }
137 }
138
139 // Minimum region size; we won't go lower than that.
140 // We might want to decrease this in the future, to deal with small
141 // heaps a bit more efficiently.
142 #define MIN_REGION_SIZE ( 1024 * 1024 )
143
|