duke@435: /* stefank@2314: * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_MEMORY_TENUREDGENERATION_HPP stefank@2314: #define SHARE_VM_MEMORY_TENUREDGENERATION_HPP stefank@2314: stefank@2314: #include "gc_implementation/shared/cSpaceCounters.hpp" stefank@2314: #include "gc_implementation/shared/gcStats.hpp" stefank@2314: #include "gc_implementation/shared/generationCounters.hpp" stefank@2314: #include "memory/generation.hpp" jprovino@4542: #include "utilities/macros.hpp" stefank@2314: duke@435: // TenuredGeneration models the heap containing old (promoted/tenured) objects. duke@435: duke@435: class ParGCAllocBufferWithBOT; duke@435: duke@435: class TenuredGeneration: public OneContigSpaceCardGeneration { duke@435: friend class VMStructs; duke@435: protected: duke@435: // current shrinking effect: this damps shrinking when the heap gets empty. duke@435: size_t _shrink_factor; duke@435: // Some statistics from before gc started. duke@435: // These are gathered in the gc_prologue (and should_collect) duke@435: // to control growing/shrinking policy in spite of promotions. duke@435: size_t _capacity_at_prologue; duke@435: size_t _used_at_prologue; duke@435: jprovino@4542: #if INCLUDE_ALL_GCS duke@435: // To support parallel promotion: an array of parallel allocation duke@435: // buffers, one per thread, initially NULL. duke@435: ParGCAllocBufferWithBOT** _alloc_buffers; jprovino@4542: #endif // INCLUDE_ALL_GCS duke@435: duke@435: // Retire all alloc buffers before a full GC, so that they will be duke@435: // re-allocated at the start of the next young GC. duke@435: void retire_alloc_buffers_before_full_gc(); duke@435: duke@435: GenerationCounters* _gen_counters; duke@435: CSpaceCounters* _space_counters; duke@435: duke@435: public: duke@435: TenuredGeneration(ReservedSpace rs, size_t initial_byte_size, int level, duke@435: GenRemSet* remset); duke@435: duke@435: Generation::Name kind() { return Generation::MarkSweepCompact; } duke@435: duke@435: // Printing duke@435: const char* name() const; duke@435: const char* short_name() const { return "Tenured"; } duke@435: bool must_be_youngest() const { return false; } duke@435: bool must_be_oldest() const { return true; } duke@435: duke@435: // Does a "full" (forced) collection invoked on this generation collect duke@435: // all younger generations as well? Note that this is a duke@435: // hack to allow the collection of the younger gen first if the flag is duke@435: // set. This is better than using th policy's should_collect_gen0_first() duke@435: // since that causes us to do an extra unnecessary pair of restart-&-stop-world. duke@435: virtual bool full_collects_younger_generations() const { duke@435: return !CollectGen0First; duke@435: } duke@435: duke@435: // Mark sweep support duke@435: void compute_new_size(); duke@435: duke@435: virtual void gc_prologue(bool full); duke@435: virtual void gc_epilogue(bool full); duke@435: bool should_collect(bool full, duke@435: size_t word_size, duke@435: bool is_tlab); duke@435: duke@435: virtual void collect(bool full, duke@435: bool clear_all_soft_refs, duke@435: size_t size, duke@435: bool is_tlab); duke@435: jprovino@4542: #if INCLUDE_ALL_GCS duke@435: // Overrides. duke@435: virtual oop par_promote(int thread_num, duke@435: oop obj, markOop m, size_t word_sz); duke@435: virtual void par_promote_alloc_undo(int thread_num, duke@435: HeapWord* obj, size_t word_sz); duke@435: virtual void par_promote_alloc_done(int thread_num); jprovino@4542: #endif // INCLUDE_ALL_GCS duke@435: duke@435: // Performance Counter support duke@435: void update_counters(); duke@435: duke@435: // Statistics duke@435: duke@435: virtual void update_gc_stats(int level, bool full); duke@435: ysr@2243: virtual bool promotion_attempt_is_safe(size_t max_promoted_in_bytes) const; duke@435: duke@435: void verify_alloc_buffers_clean(); duke@435: }; stefank@2314: stefank@2314: #endif // SHARE_VM_MEMORY_TENUREDGENERATION_HPP