165 if (yellow < config) {
166 size = MAX2(size, config - yellow);
167 }
168 }
169 return MIN2(yellow + size, max_red_zone);
170 }
171
172 G1ConcurrentRefine* G1ConcurrentRefine::create(jint* ecode) {
173 size_t min_yellow_zone_size = calc_min_yellow_zone_size();
174 size_t green_zone = calc_init_green_zone();
175 size_t yellow_zone = calc_init_yellow_zone(green_zone, min_yellow_zone_size);
176 size_t red_zone = calc_init_red_zone(green_zone, yellow_zone);
177
178 LOG_ZONES("Initial Refinement Zones: "
179 "green: " SIZE_FORMAT ", "
180 "yellow: " SIZE_FORMAT ", "
181 "red: " SIZE_FORMAT ", "
182 "min yellow size: " SIZE_FORMAT,
183 green_zone, yellow_zone, red_zone, min_yellow_zone_size);
184
185 G1ConcurrentRefine* cg1r = new G1ConcurrentRefine(green_zone,
186 yellow_zone,
187 red_zone,
188 min_yellow_zone_size);
189
190 if (cg1r == NULL) {
191 *ecode = JNI_ENOMEM;
192 vm_shutdown_during_initialization("Could not create G1ConcurrentRefine");
193 return NULL;
194 }
195
196 cg1r->_threads = NEW_C_HEAP_ARRAY_RETURN_NULL(G1ConcurrentRefineThread*, cg1r->_n_worker_threads, mtGC);
197 if (cg1r->_threads == NULL) {
198 *ecode = JNI_ENOMEM;
199 vm_shutdown_during_initialization("Could not allocate an array for G1ConcurrentRefineThread");
200 return NULL;
201 }
202
203 uint worker_id_offset = DirtyCardQueueSet::num_par_ids();
204
205 G1ConcurrentRefineThread *next = NULL;
206 for (uint i = cg1r->_n_worker_threads - 1; i != UINT_MAX; i--) {
207 Thresholds thresholds = calc_thresholds(green_zone, yellow_zone, i);
208 G1ConcurrentRefineThread* t =
209 new G1ConcurrentRefineThread(cg1r,
210 next,
211 worker_id_offset,
212 i,
213 activation_level(thresholds),
214 deactivation_level(thresholds));
215 assert(t != NULL, "Conc refine should have been created");
216 if (t->osthread() == NULL) {
217 *ecode = JNI_ENOMEM;
218 vm_shutdown_during_initialization("Could not create G1ConcurrentRefineThread");
219 return NULL;
220 }
221
222 assert(t->cg1r() == cg1r, "Conc refine thread should refer to this");
223 cg1r->_threads[i] = t;
224 next = t;
225 }
226
227 cg1r->_sample_thread = new G1YoungRemSetSamplingThread();
228 if (cg1r->_sample_thread->osthread() == NULL) {
229 *ecode = JNI_ENOMEM;
230 vm_shutdown_during_initialization("Could not create G1YoungRemSetSamplingThread");
231 return NULL;
232 }
233
234 *ecode = JNI_OK;
235 return cg1r;
236 }
237
238 void G1ConcurrentRefine::stop() {
239 for (uint i = 0; i < _n_worker_threads; i++) {
240 _threads[i]->stop();
241 }
242 _sample_thread->stop();
243 }
244
245 void G1ConcurrentRefine::update_thread_thresholds() {
246 for (uint i = 0; i < _n_worker_threads; i++) {
247 Thresholds thresholds = calc_thresholds(_green_zone, _yellow_zone, i);
248 _threads[i]->update_thresholds(activation_level(thresholds),
249 deactivation_level(thresholds));
250 }
251 }
252
253 G1ConcurrentRefine::~G1ConcurrentRefine() {
254 for (uint i = 0; i < _n_worker_threads; i++) {
255 delete _threads[i];
|
165 if (yellow < config) {
166 size = MAX2(size, config - yellow);
167 }
168 }
169 return MIN2(yellow + size, max_red_zone);
170 }
171
172 G1ConcurrentRefine* G1ConcurrentRefine::create(jint* ecode) {
173 size_t min_yellow_zone_size = calc_min_yellow_zone_size();
174 size_t green_zone = calc_init_green_zone();
175 size_t yellow_zone = calc_init_yellow_zone(green_zone, min_yellow_zone_size);
176 size_t red_zone = calc_init_red_zone(green_zone, yellow_zone);
177
178 LOG_ZONES("Initial Refinement Zones: "
179 "green: " SIZE_FORMAT ", "
180 "yellow: " SIZE_FORMAT ", "
181 "red: " SIZE_FORMAT ", "
182 "min yellow size: " SIZE_FORMAT,
183 green_zone, yellow_zone, red_zone, min_yellow_zone_size);
184
185 G1ConcurrentRefine* cr = new G1ConcurrentRefine(green_zone,
186 yellow_zone,
187 red_zone,
188 min_yellow_zone_size);
189
190 if (cr == NULL) {
191 *ecode = JNI_ENOMEM;
192 vm_shutdown_during_initialization("Could not create G1ConcurrentRefine");
193 return NULL;
194 }
195
196 cr->_threads = NEW_C_HEAP_ARRAY_RETURN_NULL(G1ConcurrentRefineThread*, cr->_n_worker_threads, mtGC);
197 if (cr->_threads == NULL) {
198 *ecode = JNI_ENOMEM;
199 vm_shutdown_during_initialization("Could not allocate an array for G1ConcurrentRefineThread");
200 return NULL;
201 }
202
203 uint worker_id_offset = DirtyCardQueueSet::num_par_ids();
204
205 G1ConcurrentRefineThread *next = NULL;
206 for (uint i = cr->_n_worker_threads - 1; i != UINT_MAX; i--) {
207 Thresholds thresholds = calc_thresholds(green_zone, yellow_zone, i);
208 G1ConcurrentRefineThread* t =
209 new G1ConcurrentRefineThread(cr,
210 next,
211 worker_id_offset,
212 i,
213 activation_level(thresholds),
214 deactivation_level(thresholds));
215 assert(t != NULL, "Conc refine should have been created");
216 if (t->osthread() == NULL) {
217 *ecode = JNI_ENOMEM;
218 vm_shutdown_during_initialization("Could not create G1ConcurrentRefineThread");
219 return NULL;
220 }
221
222 assert(t->cr() == cr, "Conc refine thread should refer to this");
223 cr->_threads[i] = t;
224 next = t;
225 }
226
227 cr->_sample_thread = new G1YoungRemSetSamplingThread();
228 if (cr->_sample_thread->osthread() == NULL) {
229 *ecode = JNI_ENOMEM;
230 vm_shutdown_during_initialization("Could not create G1YoungRemSetSamplingThread");
231 return NULL;
232 }
233
234 *ecode = JNI_OK;
235 return cr;
236 }
237
238 void G1ConcurrentRefine::stop() {
239 for (uint i = 0; i < _n_worker_threads; i++) {
240 _threads[i]->stop();
241 }
242 _sample_thread->stop();
243 }
244
245 void G1ConcurrentRefine::update_thread_thresholds() {
246 for (uint i = 0; i < _n_worker_threads; i++) {
247 Thresholds thresholds = calc_thresholds(_green_zone, _yellow_zone, i);
248 _threads[i]->update_thresholds(activation_level(thresholds),
249 deactivation_level(thresholds));
250 }
251 }
252
253 G1ConcurrentRefine::~G1ConcurrentRefine() {
254 for (uint i = 0; i < _n_worker_threads; i++) {
255 delete _threads[i];
|