asParNewGeneration.cpp revision 196
/*
* Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*
*/
# include "incls/_precompiled.incl"
# include "incls/_asParNewGeneration.cpp.incl"
int level) :
const char* ASParNewGeneration::name() const {
return "adaptive size par new generation";
}
"Should only be used with UseAdaptiveSizePolicy");
}
// Resize the generation if needed. If the generation resize
// reports false, do not attempt to resize the spaces.
// Then we lay out the spaces inside the generation
if (PrintAdaptiveSizePolicy && Verbose) {
max_gen_size(), min_gen_size());
}
}
}
}
// This method assumes that from-space has live data and that
// any shrinkage of the young gen is limited by location of
// from-space.
#ifdef SHRINKS_AT_END_OF_EDEN
size_t delta_in_survivor = 0;
} else {
space_shrinking = to_space();
}
// Include any space that is committed but not included in
// the survivor spaces.
"Survivor space beyond high end");
space_shrinking->end(), sizeof(char));
if (space_shrinking->is_empty()) {
// Don't let the space shrink to 0
"Space is too small");
} else {
space_shrinking->top(),
sizeof(char));
}
return delta_in_bytes;
#else
// The only space available for shrinking is in to-space if it
// is above from-space.
return 0;
} else {
}
} else {
return 0;
}
#endif
}
// Return the number of bytes available for resizing down the young
// generation. This is the minimum of
// input "bytes"
// bytes to the minimum young gen size
// bytes to the size currently being used + some small extra
// Allow shrinkage into the current eden but keep eden large enough
// to maintain the minimum young gen size
}
// Note that the the alignment used is the OS page size as
// opposed to an alignment associated with the virtual space
// (as is done in the ASPSYoungGen/ASPSOldGen)
bool size_changed = false;
// There used to be this guarantee there.
// guarantee ((eden_size + 2*survivor_size) <= _max_gen_size, "incorrect input arguments");
// Code below forces this requirement. In addition the desired eden
// size and disired survivor sizes are desired goals and may
// exceed the total generation size.
"just checking");
// Adjust new generation size
const size_t eden_plus_survivors =
min_gen_size());
if (desired_size > orig_size) {
// Grow the generation
return false; // Error if we fail to resize!
}
size_changed = true;
} else if (desired_size < orig_size) {
if (desired_change > 0) {
size_changed = true;
}
} else {
if (orig_size == max_gen_size()) {
} else if (orig_size == min_gen_size()) {
}
}
}
if (size_changed) {
orig_size/K, current_size/K);
}
}
return true;
}
} else {
// Was there a shrink of the survivor space?
}
}
}
"just checking");
// We require eden and to space to be empty
return;
}
if (PrintAdaptiveSizePolicy && Verbose) {
sizeof(char)));
sizeof(char)));
sizeof(char)));
}
// There's nothing to do if the new sizes are the same as the current
if (PrintAdaptiveSizePolicy && Verbose) {
}
return;
}
const bool maintain_minimum =
// Check whether from space is below to space
if (from_start < to_start) {
// Eden, from, to
if (PrintAdaptiveSizePolicy && Verbose) {
}
// Set eden
// "requested_eden_size" is a goal for the size of eden
// and may not be attainable. "eden_size" below is
// calculated based on the location of from-space and
// the goal for the size of eden. from-space is
// fixed in place because it contains live data.
// The calculation is done this way to avoid 32bit
// overflow (i.e., eden_start + requested_eden_size
// may too large for representation in 32bits).
if (maintain_minimum) {
// Only make eden larger than the requested size if
// the minimum size of the generation has to be maintained.
// This could be done in general but policy at a higher
// level is determining a requested size for eden and that
// should be honored unless there is a fundamental reason.
sizeof(char));
} else {
}
// tty->print_cr("eden_size before: " SIZE_FORMAT, eden_size);
// tty->print_cr("eden_size after: " SIZE_FORMAT, eden_size);
// To may resize into from space as long as it is clear of live data.
// From space must remain page aligned, though, so we need to do some
// extra calculations.
// First calculate an optimal to-space
sizeof(char));
// Does the optimal to-space overlap from-space?
// Calculate the minimum offset possible for from_end
// Should we be in this method if from_space is empty? Why not the set_space method? FIX ME!
if (from_size == 0) {
} else {
}
// Now update to_start with the new from_end
} else {
// If shrinking, move to-space down to abut the end of from-space
// so that shrinking will move to-space down. If not shrinking
// to-space is moving up to allow for growth on the next expansion.
if (requested_eden_size <= cur_eden_size) {
}
}
// else leave to_end pointing to the high end of the virtual space.
}
if (PrintAdaptiveSizePolicy && Verbose) {
}
} else {
// Eden, to, from
if (PrintAdaptiveSizePolicy && Verbose) {
}
// Calculate the to-space boundaries based on
// the start of from-space.
to_end = from_start;
(char*)requested_survivor_size,
sizeof(char));
// Calculate the ideal eden boundaries.
// eden_end is already at the bottom of the generation
"Eden is not starting at the low end of the virtual space");
} else {
}
// Does eden intrude into to-space? to-space
// gets priority but eden is not allowed to shrink
// to 0.
}
// Don't let eden shrink down to 0 or less.
if (maintain_minimum) {
// Use all the space available.
} else {
}
"Eden size is too large");
// Move to-space down to eden.
if (requested_eden_size < cur_eden_size) {
} else {
to_end = from_start;
}
}
// eden_end may have moved so again make sure
// the to-space and eden don't overlap.
// from-space
if (requested_survivor_size > from_used) {
}
}
}
if (PrintAdaptiveSizePolicy && Verbose) {
}
}
"from start moved to the right");
"from end moved into live data");
// Let's make sure the call to initialize doesn't reset "top"!
// For PrintAdaptiveSizePolicy block below
// The call to initialize NULL's the next compaction space
if (PrintAdaptiveSizePolicy) {
"collection: %d "
gch->total_collections(),
gclog_or_tty->cr();
}
}
void ASParNewGeneration::compute_new_size() {
"not a CMS generational heap");
"Wrong type of size policy");
if (!survivor_overflow()) {
// Keep running averages on how much survived
} else {
}
max_gen_size());
if (UsePerfData) {
"Wrong kind of counters");
}
}
#ifndef PRODUCT
// Changes from PSYoungGen version
// value of "alignment"
void ASParNewGeneration::space_invariants() {
// Currently, our eden size cannot shrink to zero
// Relationship of spaces to each other
// Check whether from space is below to space
if (from_start < to_start) {
// Eden, from, to
} else {
// Eden, to, from
}
// More checks that the virtual space is consistent with the spaces
"Space invariant");
}
#endif