3200N/A * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A// DefNewGeneration functions. 0N/A// Methods of protected closure types. 0N/A // Compute the maximum eden and survivor space sizes. These sizes 0N/A // are computed assuming the entire reserved space is committed. 0N/A // These values are exported as performance counters. 0N/A // allocate the performance counters 0N/A // Generation counters -- generation 0, 3 subspaces 263N/A // If the spaces are being cleared (only done at heap initialization 263N/A // currently), the survivor spaces need not be empty. 263N/A // Otherwise, no care is taken for used areas in the survivor spaces 263N/A "Initialization of the survivor spaces assumes these are empty");
0N/A // May happen due to 64Kb rounding, if so adjust eden size back up 263N/A // A minimum eden size implies that there is a part of eden that 263N/A // is being used and that affects the initialization of any 263N/A // If not clearing the spaces, do some checking to verify that 263N/A // the space are already mangled. 263N/A // Must check mangling before the spaces are reshaped. Otherwise, 263N/A // the bottom or end of one space may have moved into another 263N/A // a failure of the check may not correctly indicate which space 263N/A // is not properly mangled. 263N/A // Reset the spaces for their new regions. 263N/A // If clear_space and live_in_eden, we will not have cleared any 0N/A // portion of eden above its top. This can cause newly 0N/A // expanded space not to be mangled if using ZapUnusedHeapArea. 0N/A // We explicitly do such mangling here. 263N/A // Set next compaction spaces. 0N/A // The to-space is normally empty before a compaction so need 0N/A // not be considered. The exception is during promotion 0N/A // failure handling when to-space can contain live objects. 0N/A // The to-space is normally empty before a compaction so need 0N/A // not be considered. The exception is during promotion 0N/A // failure handling when to-space can contain live objects. 263N/A // Mangle newly committed space immediately because it 263N/A // can be done here more simply that after the new 263N/A // spaces have been computed. 0N/A // Do not attempt an expand-to-the reserve size. The 0N/A // request should properly observe the maximum size of 0N/A // the generation so an expand-to-reserve should be 0N/A // unnecessary. Also a second call to expand-to-reserve 0N/A // value potentially can cause an undue expansion. 0N/A // For example if the first expand fail for unknown reasons, 0N/A // but the second succeeds and expands the heap to its maximum 263N/A "expanded heap instead");
0N/A // This is called after a gc that includes the following generation 0N/A // (which is required to exist.) So from-space will normally be empty. 0N/A // Note that we check both spaces, since if scavenge failed they revert roles. 0N/A // If not we bail out (otherwise we would have to relocate the objects) 0N/A "DefNewGeneration cannot be an oldest gen");
0N/A // All space sizes must be multiples of Generation::GenGrain. 0N/A // Compute desired new generation size based on NewRatio and 0N/A // NewSizeThreadIncrease 0N/A // Adjust new generation size 0N/A // If the heap failed to expand to the desired size, 0N/A // "changed" will be false. If the expansion failed 0N/A // (and at this point it was expected to succeed), 0N/A // ignore the failure (leaving "changed" as false). 0N/A // bail out of shrinking if objects in eden 263N/A // The spaces have already been mangled at this point but 263N/A // may not have been cleared (set top = bottom) and should be. 263N/A // Mangling was done when the heap was being expanded. 0N/A // $$$ This may be wrong in case of "scavenge failure"? 0N/A assert(
false,
"NYI -- are you sure you want to call this?");
0N/A// The last collection bailed out, we are running out of heap space, 0N/A// so we try to allocate the from-space, too. 0N/A // If the Heap_lock is not locked by this thread, this will be called 0N/A // again later with the Heap_lock held. 0N/A // We don't attempt to expand the young generation (but perhaps we should.) 0N/A "This must be the youngest gen, and not the only gen");
4302N/A // If the next generation is too full to accommodate promotion 0N/A // from this generation, pass on collection; let the next generation 0N/A // Capture heap used before collection (for printing). 0N/A // These can be shared for all code paths 0N/A "save marks have not been newly set.");
0N/A "save marks have not been newly set.");
989N/A true,
// Process younger gens, if any, 989N/A true,
// activate StrongRootsScope 989N/A false,
// not collecting perm generation. 989N/A true,
// walk *all* scavengable nmethods 0N/A // "evacuate followers". 0N/A // Swap the survivor spaces. 263N/A // This is now done here because of the piece-meal mangling which 263N/A // can check for valid mangling at intermediate points in the 263N/A // collection(s). When a minor collection fails to collect 263N/A // sufficient space resizing of the young generation can occur 263N/A // an redistribute the spaces in the young generation. Mangle 263N/A // here so that unzapped regions don't get distributed to 0N/A // Set the desired survivor size to half the real survivor space 1387N/A // A successful scavenge should restart the GC time limit count which is 0N/A // Add to-space to the list of space to compact 0N/A // when a promotion failure has occurred. In that 0N/A // case there can be live objects in to-space 0N/A // as a result of a partial evacuation of eden 1145N/A // Inform the next generation that a promotion failure occurred. 0N/A // Reset the PromotionFailureALot counters. 0N/A // set new iteration safe limit for the survivor spaces 4302N/A // We need to use a monotonically non-decreasing time in ms 3200N/A // or we will see time-warp warnings and os::javaTimeMillis() 3200N/A // does not guarantee monotonicity. 0N/A // Now restore saved marks, if any. 0N/A // prevent recursion in copy_to_survivor_space() 0N/A "shouldn't be scavenging this oop");
0N/A // Try allocating obj in to-space (unless too old) 0N/A // Otherwise try allocating obj tenured 0N/A // Prefetch beyond obj 0N/A // Increment age if obj still in new generation 0N/A // Done, insert forward pointer to obj in this header 0N/A /* $$$ Assert this? "trace" is a "MarkSweep" function so that's not appropriate. 0N/A if (to_space->top() > to_space->bottom()) { 0N/A trace("to_space not empty when contribute_scratch called"); 263N/A // If contributing scratch in to_space, mangle all of 263N/A // to_space if ZapUnusedHeapArea. This is needed because 263N/A // top is not maintained while using to-space as scratch. 0N/A "This must be the youngest gen, and not the only gen");
0N/A // Check if the heap is approaching full after a collection has 0N/A // been done. Generally the young generation is empty at 0N/A // a minimum at the end of a collection. If it is not, then 0N/A // the heap is approaching full. 1809N/A // It is possible that incremental_collection_failed() == true 1809N/A // here, because an attempted scavenge did not succeed. The policy 1809N/A // is normally expected to cause a full collection which should 1809N/A // clear that condition, so we should not be here twice in a row 1809N/A // with incremental_collection_failed() == true without having done 1809N/A // a full collection in between. 0N/A // update the generation and space performance counters 0N/A return "def new generation";
113N/A// Moved from inline file as they are not called inline 113N/A // This is the slow-path allocation for the DefNewGeneration. 113N/A // Most allocations are fast-path in compiled code. 113N/A // We try to allocate from the eden. If that works, we are happy. 113N/A // Note that since DefNewGeneration supports lock-free allocation, we 113N/A // have to use it here, as well. 113N/A // Tell the next generation we reached a limit. 113N/A "invalid state after allocation_limit_reached returned null");
113N/A // The allocation failed and the soft limit is equal to the hard limit, 113N/A // there are no reasons to do an attempt to allocate 113N/A // Try to allocate until succeeded or the soft limit can't be adjusted 113N/A // If the eden is full and the last collection bailed out, we are running 113N/A // out of heap space, and we try to allocate the from-space, too. 113N/A // allocate_from_space can't be inlined because that would introduce a 113N/A // circular dependency at compile time. 113N/A // Ensure that _end and _soft_end are the same in eden space.