src/share/vm/gc_implementation/parallelScavenge/asPSOldGen.cpp

Mon, 09 Mar 2009 13:28:46 -0700

author
xdono
date
Mon, 09 Mar 2009 13:28:46 -0700
changeset 1014
0fbdb4381b99
parent 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6814575: Update copyright year
Summary: Update copyright for files that have been modified in 2009, up to 03/09
Reviewed-by: katleman, tbell, ohair

duke@435 1 /*
duke@435 2 * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 # include "incls/_precompiled.incl"
duke@435 26 # include "incls/_asPSOldGen.cpp.incl"
duke@435 27
duke@435 28 // Whereas PSOldGen takes the maximum size of the generation
duke@435 29 // (which doesn't change in the case of PSOldGen) as a parameter,
duke@435 30 // ASPSOldGen takes the upper limit on the size of
duke@435 31 // the generation as a parameter. In ASPSOldGen the
duke@435 32 // maximum size of the generation can change as the boundary
duke@435 33 // moves. The "maximum size of the generation" is still a valid
duke@435 34 // concept since the generation can grow and shrink within that
duke@435 35 // maximum. There are lots of useful checks that use that
duke@435 36 // maximum. In PSOldGen the method max_gen_size() returns
duke@435 37 // _max_gen_size (as set by the PSOldGen constructor). This
duke@435 38 // is how it always worked. In ASPSOldGen max_gen_size()
duke@435 39 // returned the size of the reserved space for the generation.
duke@435 40 // That can change as the boundary moves. Below the limit of
duke@435 41 // the size of the generation is passed to the PSOldGen constructor
duke@435 42 // for "_max_gen_size" (have to pass something) but it is not used later.
duke@435 43 //
duke@435 44 ASPSOldGen::ASPSOldGen(size_t initial_size,
duke@435 45 size_t min_size,
duke@435 46 size_t size_limit,
duke@435 47 const char* gen_name,
duke@435 48 int level) :
duke@435 49 PSOldGen(initial_size, min_size, size_limit, gen_name, level),
duke@435 50 _gen_size_limit(size_limit)
duke@435 51
duke@435 52 {}
duke@435 53
duke@435 54 ASPSOldGen::ASPSOldGen(PSVirtualSpace* vs,
duke@435 55 size_t initial_size,
duke@435 56 size_t min_size,
duke@435 57 size_t size_limit,
duke@435 58 const char* gen_name,
duke@435 59 int level) :
duke@435 60 PSOldGen(initial_size, min_size, size_limit, gen_name, level),
duke@435 61 _gen_size_limit(size_limit)
duke@435 62
duke@435 63 {
duke@435 64 _virtual_space = vs;
duke@435 65 }
duke@435 66
duke@435 67 void ASPSOldGen::reset_after_change() {
duke@435 68 _reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(),
duke@435 69 (HeapWord*)virtual_space()->high_boundary());
duke@435 70 post_resize();
duke@435 71 }
duke@435 72
duke@435 73
duke@435 74 size_t ASPSOldGen::available_for_expansion() {
duke@435 75 assert(virtual_space()->is_aligned(gen_size_limit()), "not aligned");
duke@435 76 assert(gen_size_limit() >= virtual_space()->committed_size(), "bad gen size");
duke@435 77
duke@435 78 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
duke@435 79 size_t result = gen_size_limit() - virtual_space()->committed_size();
duke@435 80 size_t result_aligned = align_size_down(result, heap->old_gen_alignment());
duke@435 81 return result_aligned;
duke@435 82 }
duke@435 83
duke@435 84 size_t ASPSOldGen::available_for_contraction() {
duke@435 85 size_t uncommitted_bytes = virtual_space()->uncommitted_size();
duke@435 86 if (uncommitted_bytes != 0) {
duke@435 87 return uncommitted_bytes;
duke@435 88 }
duke@435 89
duke@435 90 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
duke@435 91 const size_t gen_alignment = heap->old_gen_alignment();
duke@435 92 PSAdaptiveSizePolicy* policy = heap->size_policy();
duke@435 93 const size_t working_size =
duke@435 94 used_in_bytes() + (size_t) policy->avg_promoted()->padded_average();
duke@435 95 const size_t working_aligned = align_size_up(working_size, gen_alignment);
duke@435 96 const size_t working_or_min = MAX2(working_aligned, min_gen_size());
duke@435 97 if (working_or_min > reserved().byte_size()) {
duke@435 98 // If the used or minimum gen size (aligned up) is greater
duke@435 99 // than the total reserved size, then the space available
duke@435 100 // for contraction should (after proper alignment) be 0
duke@435 101 return 0;
duke@435 102 }
duke@435 103 const size_t max_contraction =
duke@435 104 reserved().byte_size() - working_or_min;
duke@435 105
duke@435 106 // Use the "increment" fraction instead of the "decrement" fraction
duke@435 107 // to allow the other gen to expand more aggressively. The
duke@435 108 // "decrement" fraction is conservative because its intent is to
duke@435 109 // only reduce the footprint.
duke@435 110
duke@435 111 size_t result = policy->promo_increment_aligned_down(max_contraction);
duke@435 112 // Also adjust for inter-generational alignment
duke@435 113 size_t result_aligned = align_size_down(result, gen_alignment);
duke@435 114 if (PrintAdaptiveSizePolicy && Verbose) {
duke@435 115 gclog_or_tty->print_cr("\nASPSOldGen::available_for_contraction:"
duke@435 116 " %d K / 0x%x", result_aligned/K, result_aligned);
duke@435 117 gclog_or_tty->print_cr(" reserved().byte_size() %d K / 0x%x ",
duke@435 118 reserved().byte_size()/K, reserved().byte_size());
duke@435 119 size_t working_promoted = (size_t) policy->avg_promoted()->padded_average();
duke@435 120 gclog_or_tty->print_cr(" padded promoted %d K / 0x%x",
duke@435 121 working_promoted/K, working_promoted);
duke@435 122 gclog_or_tty->print_cr(" used %d K / 0x%x",
duke@435 123 used_in_bytes()/K, used_in_bytes());
duke@435 124 gclog_or_tty->print_cr(" min_gen_size() %d K / 0x%x",
duke@435 125 min_gen_size()/K, min_gen_size());
duke@435 126 gclog_or_tty->print_cr(" max_contraction %d K / 0x%x",
duke@435 127 max_contraction/K, max_contraction);
duke@435 128 gclog_or_tty->print_cr(" without alignment %d K / 0x%x",
duke@435 129 policy->promo_increment(max_contraction)/K,
duke@435 130 policy->promo_increment(max_contraction));
duke@435 131 gclog_or_tty->print_cr(" alignment 0x%x", gen_alignment);
duke@435 132 }
duke@435 133 assert(result_aligned <= max_contraction, "arithmetic is wrong");
duke@435 134 return result_aligned;
duke@435 135 }

mercurial