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