128 case GenRemSet::CardTable: { 129 CardTableRS* res = new CardTableRS(whole_heap, max_covered_regions); 130 return res; 131 } 132 default: 133 guarantee(false, "unrecognized GenRemSet::Name"); 134 return NULL; 135 } 136 } 137 138 void CollectorPolicy::cleared_all_soft_refs() { 139 // If near gc overhear limit, continue to clear SoftRefs. SoftRefs may 140 // have been cleared in the last collection but if the gc overhear 141 // limit continues to be near, SoftRefs should still be cleared. 142 if (size_policy() != NULL) { 143 _should_clear_all_soft_refs = size_policy()->gc_overhead_limit_near(); 144 } 145 _all_soft_refs_clear = true; 146 } 147 148 149 // GenCollectorPolicy methods. 150 151 size_t GenCollectorPolicy::scale_by_NewRatio_aligned(size_t base_size) { 152 size_t x = base_size / (NewRatio+1); 153 size_t new_gen_size = x > min_alignment() ? 154 align_size_down(x, min_alignment()) : 155 min_alignment(); 156 return new_gen_size; 157 } 158 159 size_t GenCollectorPolicy::bound_minus_alignment(size_t desired_size, 160 size_t maximum_size) { 161 size_t alignment = min_alignment(); 162 size_t max_minus = maximum_size - alignment; 163 return desired_size < max_minus ? desired_size : max_minus; 164 } 165 166 167 void GenCollectorPolicy::initialize_size_policy(size_t init_eden_size, 168 size_t init_promo_size, 169 size_t init_survivor_size) { 170 const double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0; 171 _size_policy = new AdaptiveSizePolicy(init_eden_size, 172 init_promo_size, 173 init_survivor_size, 174 max_gc_pause_sec, 175 GCTimeRatio); 176 } 177 178 size_t GenCollectorPolicy::compute_max_alignment() { 179 // The card marking array and the offset arrays for old generations are 180 // committed in os pages as well. Make sure they are entirely full (to 181 // avoid partial page problems), e.g. if 512 bytes heap corresponds to 1 182 // byte entry and the os page size is 4096, the maximum heap size should 183 // be 512*4096 = 2MB aligned. 184 size_t alignment = GenRemSet::max_alignment_constraint(rem_set_name()); 185 186 // Parallel GC does its own alignment of the generations to avoid requiring a 187 // large page (256M on some platforms) for the permanent generation. The 188 // other collectors should also be updated to do their own alignment and then 189 // this use of lcm() should be removed. 190 if (UseLargePages && !UseParallelGC) { 191 // in presence of large pages we have to make sure that our 192 // alignment is large page aware 193 alignment = lcm(os::large_page_size(), alignment); 194 } 195 196 return alignment; 197 } 198 199 void GenCollectorPolicy::initialize_flags() { 200 // All sizes must be multiples of the generation granularity. 201 set_min_alignment((uintx) Generation::GenGrain); 202 set_max_alignment(compute_max_alignment()); 203 204 CollectorPolicy::initialize_flags(); 205 206 // All generational heaps have a youngest gen; handle those flags here. 207 208 // Adjust max size parameters 209 if (NewSize > MaxNewSize) { 210 MaxNewSize = NewSize; 211 } 212 NewSize = align_size_down(NewSize, min_alignment()); 213 MaxNewSize = align_size_down(MaxNewSize, min_alignment()); 214 215 // Check validity of heap flags 216 assert(NewSize % min_alignment() == 0, "eden space alignment"); | 128 case GenRemSet::CardTable: { 129 CardTableRS* res = new CardTableRS(whole_heap, max_covered_regions); 130 return res; 131 } 132 default: 133 guarantee(false, "unrecognized GenRemSet::Name"); 134 return NULL; 135 } 136 } 137 138 void CollectorPolicy::cleared_all_soft_refs() { 139 // If near gc overhear limit, continue to clear SoftRefs. SoftRefs may 140 // have been cleared in the last collection but if the gc overhear 141 // limit continues to be near, SoftRefs should still be cleared. 142 if (size_policy() != NULL) { 143 _should_clear_all_soft_refs = size_policy()->gc_overhead_limit_near(); 144 } 145 _all_soft_refs_clear = true; 146 } 147 148 size_t CollectorPolicy::compute_max_alignment() { 149 // The card marking array and the offset arrays for old generations are 150 // committed in os pages as well. Make sure they are entirely full (to 151 // avoid partial page problems), e.g. if 512 bytes heap corresponds to 1 152 // byte entry and the os page size is 4096, the maximum heap size should 153 // be 512*4096 = 2MB aligned. 154 155 // there is only the GenRemSet in Hotspot and only the GenRemSet::CardTable 156 // is supported. 157 return GenRemSet::max_alignment_constraint(GenRemSet::CardTable); 158 } 159 160 // GenCollectorPolicy methods. 161 162 size_t GenCollectorPolicy::scale_by_NewRatio_aligned(size_t base_size) { 163 size_t x = base_size / (NewRatio+1); 164 size_t new_gen_size = x > min_alignment() ? 165 align_size_down(x, min_alignment()) : 166 min_alignment(); 167 return new_gen_size; 168 } 169 170 size_t GenCollectorPolicy::bound_minus_alignment(size_t desired_size, 171 size_t maximum_size) { 172 size_t alignment = min_alignment(); 173 size_t max_minus = maximum_size - alignment; 174 return desired_size < max_minus ? desired_size : max_minus; 175 } 176 177 178 void GenCollectorPolicy::initialize_size_policy(size_t init_eden_size, 179 size_t init_promo_size, 180 size_t init_survivor_size) { 181 const double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0; 182 _size_policy = new AdaptiveSizePolicy(init_eden_size, 183 init_promo_size, 184 init_survivor_size, 185 max_gc_pause_sec, 186 GCTimeRatio); 187 } 188 189 void GenCollectorPolicy::initialize_flags() { 190 // All sizes must be multiples of the generation granularity. 191 set_min_alignment((uintx) Generation::GenGrain); 192 set_max_alignment(compute_max_alignment()); 193 194 CollectorPolicy::initialize_flags(); 195 196 // All generational heaps have a youngest gen; handle those flags here. 197 198 // Adjust max size parameters 199 if (NewSize > MaxNewSize) { 200 MaxNewSize = NewSize; 201 } 202 NewSize = align_size_down(NewSize, min_alignment()); 203 MaxNewSize = align_size_down(MaxNewSize, min_alignment()); 204 205 // Check validity of heap flags 206 assert(NewSize % min_alignment() == 0, "eden space alignment"); |