/* * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. *
*/
class ContiguousSpace; class CSpaceCounters; class DefNewYoungerGenClosure; class DefNewScanClosure; class DefNewTracer; class ScanWeakRefClosure; class SerialHeap; class STWGCTimer;
// DefNewGeneration is a young generation containing eden, from- and // to-space.
class DefNewGeneration: public Generation { friendclass VMStructs;
protected:
Generation* _old_gen;
uint _tenuring_threshold; // Tenuring threshold for next collection.
AgeTable _age_table; // Size of object to pretenure in words; command line provides bytes
size_t _pretenure_size_threshold_words;
AgeTable* age_table() { return &_age_table; }
// Initialize state to optimistically assume no promotion failure will // happen. void init_assuming_no_promotion_failure(); // True iff a promotion has failed in the current collection. bool _promotion_failed; bool promotion_failed() { return _promotion_failed; }
PromotionFailedInfo _promotion_failed_info;
// Handling promotion failure. A young generation collection // can fail if a live object cannot be copied out of its // location in eden or from-space during the collection. If // a collection fails, the young generation is left in a // consistent state such that it can be collected by a // full collection. // Before the collection // Objects are in eden or from-space // All roots into the young generation point into eden or from-space. // // After a failed collection // Objects may be in eden, from-space, or to-space // An object A in eden or from-space may have a copy B // in to-space. If B exists, all roots that once pointed // to A must now point to B. // All objects in the young generation are unmarked. // Eden, from-space, and to-space will all be collected by // the full collection. void handle_promotion_failure(oop);
// In the absence of promotion failure, we wouldn't look at "from-space" // objects after a young-gen collection. When promotion fails, however, // the subsequent full collection will look at from-space objects: // therefore we must remove their forwarding pointers. void remove_forwarding_pointers();
virtualvoid restore_preserved_marks();
// Preserved marks
PreservedMarksSet _preserved_marks_set;
enum SomeProtectedConstants { // Generations are GenGrain-aligned and have size that are multiples of // GenGrain.
MinFreeScratchWords = 100
};
// Return the size of a survivor space if this generation were of size // gen_size.
size_t compute_survivor_size(size_t gen_size, size_t alignment) const {
size_t n = gen_size / (SurvivorRatio + 2); return n > alignment ? align_down(n, alignment) : alignment;
}
public: // was "protected" but caused compile error on win32 class IsAliveClosure: public BoolObjectClosure {
Generation* _young_gen; public:
IsAliveClosure(Generation* young_gen); bool do_object_b(oop p);
};
// Grow the generation by the specified number of bytes. // The size of bytes is assumed to be properly aligned. // Return true if the expansion was successful. bool expand(size_t bytes);
// DefNewGeneration cannot currently expand except at // a GC. virtualbool is_maximal_no_gc() const { returntrue; }
// Save the tops for eden, from, and to virtualvoid record_spaces_top();
// Accessing marks void save_marks(); void reset_saved_marks(); bool no_allocs_since_save_marks();
// Need to declare the full complement of closures, whether we'll // override them or not, or get message from the compiler: // oop_since_save_marks_iterate_nv hides virtual function... template <typename OopClosureType> void oop_since_save_marks_iterate(OopClosureType* cl);
// For non-youngest collection, the DefNewGeneration can contribute // "to-space". virtualvoid contribute_scratch(ScratchBlock*& list, Generation* requestor,
size_t max_alloc_words);
// Reset for contribution of "to-space". virtualvoid reset_scratch();
// GC support virtualvoid compute_new_size();
// Returns true if the collection is likely to be safely // completed. Even if this method returns true, a collection // may not be guaranteed to succeed, and the system should be // able to safely unwind and recover from that failure, albeit // at some additional cost. Override superclass's implementation. virtualbool collection_attempt_is_safe();
protected: // If clear_space is true, clear the survivor spaces. Eden is // cleared if the minimum size of eden is 0. If mangle_space // is true, also mangle the space in debug mode. void compute_space_boundaries(uintx minimum_eden_size, bool clear_space, bool mangle_space);
// Return adjusted new size for NewSizeThreadIncrease. // If any overflow happens, revert to previous new size.
size_t adjust_for_thread_increase(size_t new_size_candidate,
size_t new_size_before,
size_t alignment,
size_t thread_increase_size) const;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.