/*
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "gc_implementation/parallelScavenge/psScavenge.hpp"
#include "gc_implementation/parallelScavenge/psYoungGen.hpp"
#include "gc_implementation/shared/gcUtil.hpp"
#include "gc_implementation/shared/mutableNUMASpace.hpp"
#include "gc_implementation/shared/spaceDecorator.hpp"
#include "oops/oop.inline.hpp"
{}
vm_exit_during_initialization("Could not reserve enough space for "
"object heap");
}
}
}
if (ZapUnusedHeapArea) {
// Mangle newly committed space immediately because it
// can be done here more simply that after the new
// spaces have been computed.
}
if (UseNUMA) {
} else {
}
vm_exit_during_initialization("Could not allocate a young gen space");
}
// Allocate the mark sweep views of spaces
if (_eden_mark_sweep == NULL ||
_from_mark_sweep == NULL ||
_to_mark_sweep == NULL) {
vm_exit_during_initialization("Could not complete allocation"
" of the young generation");
}
// Generation Counters - generation 0, 3 subspaces
// Compute maximum space sizes for performance counters
if (UseAdaptiveSizePolicy) {
// round the survivor space size down to the nearest alignment
// and make sure its size is greater than 0.
// set the maximum size of eden to be the size of the young gen
// less two times the minimum survivor size. The minimum survivor
// size for UseAdaptiveSizePolicy is one alignment.
} else {
// round the survivor space size down to the nearest alignment
// and make sure its size is greater than 0.
// set the maximum size of eden to be the size of the young gen
// less two times the survivor size when the generation is 100%
// committed. The minimum survivor size for -UseAdaptiveSizePolicy
// is dependent on the committed portion (current capacity) of the
// generation - the less space committed, the smaller the survivor
// space, possibly as small as an alignment. However, we are interested
// in the case where the young generation is 100% committed, as this
// is the point where eden reachs its maximum size. At this point,
// the size of a survivor space is max_survivor_size.
}
}
// Compute sizes
// ... but never less than an alignment
// Young generation is eden + 2 survivor spaces
// Now go ahead and set 'em.
if (UsePerfData) {
}
}
// Initial layout is Eden, to, from. After swapping survivor spaces,
// that leaves us with Eden, from, to, which is step one in our two
// step resize-with-live-data procedure.
}
#ifndef PRODUCT
// 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
(eden_space()->capacity_in_bytes() +
to_space()->capacity_in_bytes() +
"Space invariant");
virtual_space()->verify();
}
#endif
// 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) {
}
}
}
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.
// Adjust new generation size
min_gen_size());
if (desired_size > orig_size) {
// Grow the generation
return false; // Error if we fail to resize!
}
if (ZapUnusedHeapArea) {
// Mangle newly committed space immediately because it
// can be done here more simply that after the new
// spaces have been computed.
}
size_changed = true;
} else if (desired_size < orig_size) {
if (desired_change > 0) {
size_changed = true;
}
} else {
if (orig_size == gen_size_limit()) {
} else if (orig_size == min_gen_size()) {
}
}
}
if (size_changed) {
post_resize();
orig_size/K, current_size/K);
}
}
return true;
}
#ifndef PRODUCT
// In the numa case eden is not mangled so a survivor space
// moving into a region previously occupied by a survivor
// may find an unmangled region. Also in the PS case eden
// to-space and from-space may not touch (i.e., there may be
// gaps between them due to movement while resizing the
// spaces). Those gaps must be mangled.
// Check eden and gap between eden and from-space, in deciding
// what to mangle in from-space. Check the gap between from-space
// and to-space when deciding what to mangle.
//
// +--------+ +----+ +---+
// | eden | |s1 | |s2 |
// +--------+ +----+ +---+
// +-------+ +-----+
// |s1MR | |s2MR |
// +-------+ +-----+
// All of survivor-space is properly mangled so find the
// upper bound on the mangling for any portion above current s1.
}
// Find any portion to the right of the current s1.
}
// Similarly for the second survivor space except that
// any of the new region that overlaps with the current
// region of the first survivor space has already been
// mangled.
}
}
if (TraceZapUnusedHeapArea) {
// s1
delta1_right.end());
// s2
delta2_right.end());
}
}
#endif // NOT PRODUCT
"just checking");
// We require eden and to space to be empty
return;
}
if (PrintAdaptiveSizePolicy && Verbose) {
eden_space()->bottom(),
eden_space()->end(),
eden_space()->bottom(),
sizeof(char)));
from_space()->bottom(),
from_space()->end(),
from_space()->bottom(),
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 (eden_from_to_order) {
// Eden, from, to
eden_from_to_order = true;
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 {
}
// 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
}
if (PrintAdaptiveSizePolicy && Verbose) {
}
} else {
// Eden, to, from
if (PrintAdaptiveSizePolicy && Verbose) {
}
// To space gets priority over eden resizing. Note that we position
// to space as if we were able to resize from space, even though from
// space is not modified.
// Giving eden priority was tried and gave poorer performance.
(char*)requested_survivor_size,
sizeof(char));
sizeof(char));
// if the space sizes are to be increased by several times then
// 'to_start' will point beyond the young generation. In this case
// 'to_start' should be adjusted.
// Compute how big eden can be, then adjust end.
// See comments above on calculating eden_end.
if (maintain_minimum) {
} else {
}
// Could choose to not let eden shrink
// to_start = MAX2(to_start, eden_end);
// Don't let eden shrink down to 0 or less.
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
if (ZapUnusedHeapArea) {
// NUMA is a special case because a numa space is not mangled
// in order to not prematurely bind its address to memory to
// the wrong memory (i.e., don't want the GC thread to first
// touch the memory). The survivor spaces are not numa
// spaces and are mangled.
if (UseNUMA) {
if (eden_from_to_order) {
} else {
}
}
// If not mangling the spaces, do some checking to verify that
// the spaces are already mangled.
// The spaces should be correctly mangled at this point so
// do some checking here. Note that they are not being mangled
// in the calls to initialize().
// Must check mangling before the spaces are reshaped. Otherwise,
// the bottom or end of one space may have moved into an area
// covered by another space and a failure of the check may
// not correctly indicate which space is not properly mangled.
}
// When an existing space is being initialized, it is not
// mangled because the space has been previously mangled.
if (PrintAdaptiveSizePolicy) {
"collection: %d "
from_space()->capacity_in_bytes(),
to_space()->capacity_in_bytes());
gclog_or_tty->cr();
}
}
void PSYoungGen::swap_spaces() {
MutableSpace* s = from_space();
_from_space = to_space();
_to_space = s;
// Now update the decorators.
_to_mark_sweep = md;
}
return eden_space()->capacity_in_bytes()
}
return eden_space()->used_in_bytes()
}
return eden_space()->free_in_bytes()
}
return eden_space()->capacity_in_words()
}
return eden_space()->used_in_words()
}
return eden_space()->free_in_words()
}
}
void PSYoungGen::precompact() {
eden_mark_sweep()->precompact();
from_mark_sweep()->precompact();
to_mark_sweep()->precompact();
}
void PSYoungGen::adjust_pointers() {
to_mark_sweep()->adjust_pointers();
}
void PSYoungGen::compact() {
// Mark sweep stores preserved markOops in to space, don't disturb!
to_mark_sweep()->compact(false);
}
if (PrintGCDetails && Verbose) {
capacity_in_bytes(), used_in_bytes());
} else {
capacity_in_bytes()/K, used_in_bytes()/K);
}
}
prev_used / K, used_in_bytes() / K,
capacity_in_bytes() / K);
}
return 0;
}
return 0;
}
}
// This method assumes that from-space has live data and that
// any shrinkage of the young gen is limited by location of
// from-space.
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;
}
// 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
}
void PSYoungGen::reset_after_change() {
}
void PSYoungGen::reset_survivors_after_shrink() {
} else {
space_shrinking = to_space();
}
// Was there a shrink of the survivor space?
}
}
// This method currently does not expect to expand into eden (i.e.,
// the virtual space boundaries is expected to be consistent
// with the eden boundaries..
void PSYoungGen::post_resize() {
"Eden is assumed to be below the survivor spaces");
}
void PSYoungGen::update_counters() {
if (UsePerfData) {
}
}
void PSYoungGen::verify() {
eden_space()->verify();
from_space()->verify();
}
#ifndef PRODUCT
void PSYoungGen::record_spaces_top() {
}
#endif