4632N/A * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 4632N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4632N/A * This code is free software; you can redistribute it and/or modify it 4632N/A * under the terms of the GNU General Public License version 2 only, as 4632N/A * published by the Free Software Foundation. 4632N/A * This code is distributed in the hope that it will be useful, but WITHOUT 4632N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4632N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4632N/A * version 2 for more details (a copy is included in the LICENSE file that 4632N/A * You should have received a copy of the GNU General Public License version 4632N/A * 2 along with this work; if not, write to the Free Software Foundation, 4632N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4632N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4632N/A // Mangle newly committed space immediately because it 4632N/A // can be done here more simply that after the new 4632N/A // spaces have been computed. 4632N/A // Allocate the mark sweep views of spaces 4632N/A " of the young generation");
4632N/A // Generation Counters - generation 0, 3 subspaces 4632N/A // Compute maximum space sizes for performance counters // 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. // 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. // ... but never less than an alignment // Young generation is eden + 2 survivor spaces // Now go ahead and set 'em. // 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. // Currently, our eden size cannot shrink to zero // Relationship of spaces to each other // Check whether from space is below to space // More checks that the virtual space is consistent with the spaces // 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 // 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 return false;
// Error if we fail to resize! // Mangle newly committed space immediately because it // can be done here more simply that after the new // spaces have been computed. // 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. // +--------+ +----+ +---+ // +--------+ +----+ +---+ // 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 // We require eden and to space to be empty // There's nothing to do if the new sizes are the same as the current // Check whether from space is below to space // "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). // 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. // 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 // First calculate an optimal to-space // 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! // Now update to_start with the new from_end // 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. // 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. // Could choose to not let eden shrink // to_start = MAX2(to_start, eden_end); // Don't let eden shrink down to 0 or less. "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 // 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 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. // Now update the decorators. // Mark sweep stores preserved markOops in to space, don't disturb! // This method assumes that from-space has live data and that // any shrinkage of the young gen is limited by location of // Include any space that is committed but not included in "Survivor space beyond high end");
// Don't let the space shrink to 0 // Return the number of bytes available for resizing down the young // generation. This is the minimum of // 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 // 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.. "Eden is assumed to be below the survivor spaces");