50 class HeapRegionRemSetIterator;
51 class HeapRegion;
52 class HeapRegionSetBase;
53 class nmethod;
54
55 #define HR_FORMAT "%u:(%s)["PTR_FORMAT","PTR_FORMAT","PTR_FORMAT"]"
56 #define HR_FORMAT_PARAMS(_hr_) \
57 (_hr_)->hrm_index(), \
58 (_hr_)->get_short_type_str(), \
59 p2i((_hr_)->bottom()), p2i((_hr_)->top()), p2i((_hr_)->end())
60
61 // sentinel value for hrm_index
62 #define G1_NO_HRM_INDEX ((uint) -1)
63
64 // A dirty card to oop closure for heap regions. It
65 // knows how to get the G1 heap and how to use the bitmap
66 // in the concurrent marker used by G1 to filter remembered
67 // sets.
68
69 class HeapRegionDCTOC : public DirtyCardToOopClosure {
70 public:
71 // Specification of possible DirtyCardToOopClosure filtering.
72 enum FilterKind {
73 NoFilterKind,
74 IntoCSFilterKind,
75 OutOfRegionFilterKind
76 };
77
78 protected:
79 HeapRegion* _hr;
80 FilterKind _fk;
81 G1CollectedHeap* _g1;
82
83 // Walk the given memory region from bottom to (actual) top
84 // looking for objects and applying the oop closure (_cl) to
85 // them. The base implementation of this treats the area as
86 // blocks, where a block may or may not be an object. Sub-
87 // classes should override this to provide more accurate
88 // or possibly more efficient walking.
89 void walk_mem_region(MemRegion mr, HeapWord* bottom, HeapWord* top);
90
91 public:
92 HeapRegionDCTOC(G1CollectedHeap* g1,
93 HeapRegion* hr, ExtendedOopClosure* cl,
94 CardTableModRefBS::PrecisionStyle precision,
95 FilterKind fk);
96 };
97
98 // The complicating factor is that BlockOffsetTable diverged
99 // significantly, and we need functionality that is only in the G1 version.
100 // So I copied that code, which led to an alternate G1 version of
101 // OffsetTableContigSpace. If the two versions of BlockOffsetTable could
102 // be reconciled, then G1OffsetTableContigSpace could go away.
103
104 // The idea behind time stamps is the following. We want to keep track of
105 // the highest address where it's safe to scan objects for each region.
106 // This is only relevant for current GC alloc regions so we keep a time stamp
107 // per region to determine if the region has been allocated during the current
108 // GC or not. If the time stamp is current we report a scan_top value which
109 // was saved at the end of the previous GC for retained alloc regions and which is
110 // equal to the bottom for all other regions.
111 // There is a race between card scanners and allocating gc workers where we must ensure
112 // that card scanners do not read the memory allocated by the gc workers.
113 // In order to enforce that, we must not return a value of _top which is more recent than the
114 // time stamp. This is due to the fact that a region may become a gc alloc region at
115 // some point after we've read the timestamp value as being < the current time stamp.
|
50 class HeapRegionRemSetIterator;
51 class HeapRegion;
52 class HeapRegionSetBase;
53 class nmethod;
54
55 #define HR_FORMAT "%u:(%s)["PTR_FORMAT","PTR_FORMAT","PTR_FORMAT"]"
56 #define HR_FORMAT_PARAMS(_hr_) \
57 (_hr_)->hrm_index(), \
58 (_hr_)->get_short_type_str(), \
59 p2i((_hr_)->bottom()), p2i((_hr_)->top()), p2i((_hr_)->end())
60
61 // sentinel value for hrm_index
62 #define G1_NO_HRM_INDEX ((uint) -1)
63
64 // A dirty card to oop closure for heap regions. It
65 // knows how to get the G1 heap and how to use the bitmap
66 // in the concurrent marker used by G1 to filter remembered
67 // sets.
68
69 class HeapRegionDCTOC : public DirtyCardToOopClosure {
70 private:
71 HeapRegion* _hr;
72 G1ParPushHeapRSClosure* _rs_scan;
73 G1CollectedHeap* _g1;
74
75 // Walk the given memory region from bottom to (actual) top
76 // looking for objects and applying the oop closure (_cl) to
77 // them. The base implementation of this treats the area as
78 // blocks, where a block may or may not be an object. Sub-
79 // classes should override this to provide more accurate
80 // or possibly more efficient walking.
81 void walk_mem_region(MemRegion mr, HeapWord* bottom, HeapWord* top);
82
83 public:
84 HeapRegionDCTOC(G1CollectedHeap* g1,
85 HeapRegion* hr,
86 G1ParPushHeapRSClosure* cl,
87 CardTableModRefBS::PrecisionStyle precision);
88 };
89
90 // The complicating factor is that BlockOffsetTable diverged
91 // significantly, and we need functionality that is only in the G1 version.
92 // So I copied that code, which led to an alternate G1 version of
93 // OffsetTableContigSpace. If the two versions of BlockOffsetTable could
94 // be reconciled, then G1OffsetTableContigSpace could go away.
95
96 // The idea behind time stamps is the following. We want to keep track of
97 // the highest address where it's safe to scan objects for each region.
98 // This is only relevant for current GC alloc regions so we keep a time stamp
99 // per region to determine if the region has been allocated during the current
100 // GC or not. If the time stamp is current we report a scan_top value which
101 // was saved at the end of the previous GC for retained alloc regions and which is
102 // equal to the bottom for all other regions.
103 // There is a race between card scanners and allocating gc workers where we must ensure
104 // that card scanners do not read the memory allocated by the gc workers.
105 // In order to enforce that, we must not return a value of _top which is more recent than the
106 // time stamp. This is due to the fact that a region may become a gc alloc region at
107 // some point after we've read the timestamp value as being < the current time stamp.
|