94
95 size_t _regions_per_page;
96
97 CommitRefcountArray _refcounts;
98
99 uintptr_t region_idx_to_page_idx(uint region) const {
100 return region / _regions_per_page;
101 }
102
103 public:
104 G1RegionsSmallerThanCommitSizeMapper(ReservedSpace rs,
105 size_t actual_size,
106 size_t page_size,
107 size_t alloc_granularity,
108 size_t commit_factor,
109 MemoryType type) :
110 G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type),
111 _regions_per_page((page_size * commit_factor) / alloc_granularity), _refcounts() {
112
113 guarantee((page_size * commit_factor) >= alloc_granularity, "allocation granularity smaller than commit granularity");
114 _refcounts.initialize((HeapWord*)rs.base(), (HeapWord*)(rs.base() + align_size_up(rs.size(), page_size)), page_size);
115 }
116
117 virtual void commit_regions(uint start_idx, size_t num_regions, WorkGang* pretouch_gang) {
118 size_t const NoPage = ~(size_t)0;
119
120 size_t first_committed = NoPage;
121 size_t num_committed = 0;
122
123 bool all_zero_filled = true;
124
125 for (uint i = start_idx; i < start_idx + num_regions; i++) {
126 assert(!_commit_map.at(i), "Trying to commit storage at region %u that is already committed", i);
127 size_t idx = region_idx_to_page_idx(i);
128 uint old_refcount = _refcounts.get_by_index(idx);
129
130 bool zero_filled = false;
131 if (old_refcount == 0) {
132 if (first_committed == NoPage) {
133 first_committed = idx;
134 num_committed = 1;
|
94
95 size_t _regions_per_page;
96
97 CommitRefcountArray _refcounts;
98
99 uintptr_t region_idx_to_page_idx(uint region) const {
100 return region / _regions_per_page;
101 }
102
103 public:
104 G1RegionsSmallerThanCommitSizeMapper(ReservedSpace rs,
105 size_t actual_size,
106 size_t page_size,
107 size_t alloc_granularity,
108 size_t commit_factor,
109 MemoryType type) :
110 G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type),
111 _regions_per_page((page_size * commit_factor) / alloc_granularity), _refcounts() {
112
113 guarantee((page_size * commit_factor) >= alloc_granularity, "allocation granularity smaller than commit granularity");
114 _refcounts.initialize((HeapWord*)rs.base(), (HeapWord*)(rs.base() + align_up(rs.size(), page_size)), page_size);
115 }
116
117 virtual void commit_regions(uint start_idx, size_t num_regions, WorkGang* pretouch_gang) {
118 size_t const NoPage = ~(size_t)0;
119
120 size_t first_committed = NoPage;
121 size_t num_committed = 0;
122
123 bool all_zero_filled = true;
124
125 for (uint i = start_idx; i < start_idx + num_regions; i++) {
126 assert(!_commit_map.at(i), "Trying to commit storage at region %u that is already committed", i);
127 size_t idx = region_idx_to_page_idx(i);
128 uint old_refcount = _refcounts.get_by_index(idx);
129
130 bool zero_filled = false;
131 if (old_refcount == 0) {
132 if (first_committed == NoPage) {
133 first_committed = idx;
134 num_committed = 1;
|