31 #include "gc_implementation/g1/heapRegionBounds.inline.hpp"
32 #include "gc_implementation/g1/heapRegionRemSet.hpp"
33 #include "gc_implementation/g1/heapRegionManager.inline.hpp"
34 #include "gc_implementation/shared/liveRange.hpp"
35 #include "memory/genOopClosures.inline.hpp"
36 #include "memory/iterator.hpp"
37 #include "memory/space.inline.hpp"
38 #include "oops/oop.inline.hpp"
39 #include "runtime/atomic.inline.hpp"
40 #include "runtime/orderAccess.inline.hpp"
41
42 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
43
44 int HeapRegion::LogOfHRGrainBytes = 0;
45 int HeapRegion::LogOfHRGrainWords = 0;
46 size_t HeapRegion::GrainBytes = 0;
47 size_t HeapRegion::GrainWords = 0;
48 size_t HeapRegion::CardsPerRegion = 0;
49
50 HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
51 HeapRegion* hr, G1ParPushHeapRSClosure* cl,
52 CardTableModRefBS::PrecisionStyle precision) :
53 DirtyCardToOopClosure(hr, cl, precision, NULL),
54 _hr(hr), _rs_scan(cl), _g1(g1) { }
55
56 FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r,
57 OopClosure* oc) :
58 _r_bottom(r->bottom()), _r_end(r->end()), _oc(oc) { }
59
60 void HeapRegionDCTOC::walk_mem_region(MemRegion mr,
61 HeapWord* bottom,
62 HeapWord* top) {
63 G1CollectedHeap* g1h = _g1;
64 size_t oop_size;
65 HeapWord* cur = bottom;
66
67 // Start filtering what we add to the remembered set. If the object is
68 // not considered dead, either because it is marked (in the mark bitmap)
69 // or it was allocated after marking finished, then we add it. Otherwise
70 // we can safely ignore the object.
71 if (!g1h->is_obj_dead(oop(cur), _hr)) {
76
77 cur += oop_size;
78
79 if (cur < top) {
80 oop cur_oop = oop(cur);
81 oop_size = _hr->block_size(cur);
82 HeapWord* next_obj = cur + oop_size;
83 while (next_obj < top) {
84 // Keep filtering the remembered set.
85 if (!g1h->is_obj_dead(cur_oop, _hr)) {
86 // Bottom lies entirely below top, so we can call the
87 // non-memRegion version of oop_iterate below.
88 cur_oop->oop_iterate(_rs_scan);
89 }
90 cur = next_obj;
91 cur_oop = oop(cur);
92 oop_size = _hr->block_size(cur);
93 next_obj = cur + oop_size;
94 }
95
96 // Last object. Need to do pass a MemRegion here too.
97 if (!g1h->is_obj_dead(oop(cur), _hr)) {
98 oop(cur)->oop_iterate(_rs_scan, mr);
99 }
100 }
101 }
102
103 size_t HeapRegion::max_region_size() {
104 return HeapRegionBounds::max_size();
105 }
106
107 void HeapRegion::setup_heap_region_size(size_t initial_heap_size, size_t max_heap_size) {
108 uintx region_size = G1HeapRegionSize;
109 if (FLAG_IS_DEFAULT(G1HeapRegionSize)) {
110 size_t average_heap_size = (initial_heap_size + max_heap_size) / 2;
111 region_size = MAX2(average_heap_size / HeapRegionBounds::target_number(),
112 (uintx) HeapRegionBounds::min_size());
113 }
114
115 int region_size_log = log2_long((jlong) region_size);
116 // Recalculate the region size to make sure it's a power of
|
31 #include "gc_implementation/g1/heapRegionBounds.inline.hpp"
32 #include "gc_implementation/g1/heapRegionRemSet.hpp"
33 #include "gc_implementation/g1/heapRegionManager.inline.hpp"
34 #include "gc_implementation/shared/liveRange.hpp"
35 #include "memory/genOopClosures.inline.hpp"
36 #include "memory/iterator.hpp"
37 #include "memory/space.inline.hpp"
38 #include "oops/oop.inline.hpp"
39 #include "runtime/atomic.inline.hpp"
40 #include "runtime/orderAccess.inline.hpp"
41
42 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
43
44 int HeapRegion::LogOfHRGrainBytes = 0;
45 int HeapRegion::LogOfHRGrainWords = 0;
46 size_t HeapRegion::GrainBytes = 0;
47 size_t HeapRegion::GrainWords = 0;
48 size_t HeapRegion::CardsPerRegion = 0;
49
50 HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
51 HeapRegion* hr,
52 G1ParPushHeapRSClosure* cl,
53 CardTableModRefBS::PrecisionStyle precision) :
54 DirtyCardToOopClosure(hr, cl, precision, NULL),
55 _hr(hr), _rs_scan(cl), _g1(g1) { }
56
57 FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r,
58 OopClosure* oc) :
59 _r_bottom(r->bottom()), _r_end(r->end()), _oc(oc) { }
60
61 void HeapRegionDCTOC::walk_mem_region(MemRegion mr,
62 HeapWord* bottom,
63 HeapWord* top) {
64 G1CollectedHeap* g1h = _g1;
65 size_t oop_size;
66 HeapWord* cur = bottom;
67
68 // Start filtering what we add to the remembered set. If the object is
69 // not considered dead, either because it is marked (in the mark bitmap)
70 // or it was allocated after marking finished, then we add it. Otherwise
71 // we can safely ignore the object.
72 if (!g1h->is_obj_dead(oop(cur), _hr)) {
77
78 cur += oop_size;
79
80 if (cur < top) {
81 oop cur_oop = oop(cur);
82 oop_size = _hr->block_size(cur);
83 HeapWord* next_obj = cur + oop_size;
84 while (next_obj < top) {
85 // Keep filtering the remembered set.
86 if (!g1h->is_obj_dead(cur_oop, _hr)) {
87 // Bottom lies entirely below top, so we can call the
88 // non-memRegion version of oop_iterate below.
89 cur_oop->oop_iterate(_rs_scan);
90 }
91 cur = next_obj;
92 cur_oop = oop(cur);
93 oop_size = _hr->block_size(cur);
94 next_obj = cur + oop_size;
95 }
96
97 // Last object. Need to do dead-obj filtering here too.
98 if (!g1h->is_obj_dead(oop(cur), _hr)) {
99 oop(cur)->oop_iterate(_rs_scan, mr);
100 }
101 }
102 }
103
104 size_t HeapRegion::max_region_size() {
105 return HeapRegionBounds::max_size();
106 }
107
108 void HeapRegion::setup_heap_region_size(size_t initial_heap_size, size_t max_heap_size) {
109 uintx region_size = G1HeapRegionSize;
110 if (FLAG_IS_DEFAULT(G1HeapRegionSize)) {
111 size_t average_heap_size = (initial_heap_size + max_heap_size) / 2;
112 region_size = MAX2(average_heap_size / HeapRegionBounds::target_number(),
113 (uintx) HeapRegionBounds::min_size());
114 }
115
116 int region_size_log = log2_long((jlong) region_size);
117 // Recalculate the region size to make sure it's a power of
|