366 }
367
368 return success;
369 }
370
371
372 void DefNewGeneration::compute_new_size() {
373 // This is called after a gc that includes the following generation
374 // (which is required to exist.) So from-space will normally be empty.
375 // Note that we check both spaces, since if scavenge failed they revert roles.
376 // If not we bail out (otherwise we would have to relocate the objects)
377 if (!from()->is_empty() || !to()->is_empty()) {
378 return;
379 }
380
381 int next_level = level() + 1;
382 GenCollectedHeap* gch = GenCollectedHeap::heap();
383 assert(next_level < gch->_n_gens,
384 "DefNewGeneration cannot be an oldest gen");
385
386 Generation* next_gen = gch->_gens[next_level];
387 size_t old_size = next_gen->capacity();
388 size_t new_size_before = _virtual_space.committed_size();
389 size_t min_new_size = spec()->init_size();
390 size_t max_new_size = reserved().byte_size();
391 assert(min_new_size <= new_size_before &&
392 new_size_before <= max_new_size,
393 "just checking");
394 // All space sizes must be multiples of Generation::GenGrain.
395 size_t alignment = Generation::GenGrain;
396
397 // Compute desired new generation size based on NewRatio and
398 // NewSizeThreadIncrease
399 size_t desired_new_size = old_size/NewRatio;
400 int threads_count = Threads::number_of_non_daemon_threads();
401 size_t thread_increase_size = threads_count * NewSizeThreadIncrease;
402 desired_new_size = align_size_up(desired_new_size + thread_increase_size, alignment);
403
404 // Adjust new generation size
405 desired_new_size = MAX2(MIN2(desired_new_size, max_new_size), min_new_size);
406 assert(desired_new_size <= max_new_size, "just checking");
|
366 }
367
368 return success;
369 }
370
371
372 void DefNewGeneration::compute_new_size() {
373 // This is called after a gc that includes the following generation
374 // (which is required to exist.) So from-space will normally be empty.
375 // Note that we check both spaces, since if scavenge failed they revert roles.
376 // If not we bail out (otherwise we would have to relocate the objects)
377 if (!from()->is_empty() || !to()->is_empty()) {
378 return;
379 }
380
381 int next_level = level() + 1;
382 GenCollectedHeap* gch = GenCollectedHeap::heap();
383 assert(next_level < gch->_n_gens,
384 "DefNewGeneration cannot be an oldest gen");
385
386 Generation* next_gen = gch->get_gen(next_level);
387 size_t old_size = next_gen->capacity();
388 size_t new_size_before = _virtual_space.committed_size();
389 size_t min_new_size = spec()->init_size();
390 size_t max_new_size = reserved().byte_size();
391 assert(min_new_size <= new_size_before &&
392 new_size_before <= max_new_size,
393 "just checking");
394 // All space sizes must be multiples of Generation::GenGrain.
395 size_t alignment = Generation::GenGrain;
396
397 // Compute desired new generation size based on NewRatio and
398 // NewSizeThreadIncrease
399 size_t desired_new_size = old_size/NewRatio;
400 int threads_count = Threads::number_of_non_daemon_threads();
401 size_t thread_increase_size = threads_count * NewSizeThreadIncrease;
402 desired_new_size = align_size_up(desired_new_size + thread_increase_size, alignment);
403
404 // Adjust new generation size
405 desired_new_size = MAX2(MIN2(desired_new_size, max_new_size), min_new_size);
406 assert(desired_new_size <= max_new_size, "just checking");
|