1 /* 2 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_GC_SERIAL_TENUREDGENERATION_HPP 26 #define SHARE_GC_SERIAL_TENUREDGENERATION_HPP 27 28 #include "gc/serial/cSpaceCounters.hpp" 29 #include "gc/shared/cardGeneration.hpp" 30 #include "gc/shared/gcStats.hpp" 31 #include "gc/shared/generationCounters.hpp" 32 #include "utilities/macros.hpp" 33 34 // TenuredGeneration models the heap containing old (promoted/tenured) objects 35 // contained in a single contiguous space. 36 // 37 // Garbage collection is performed using mark-compact. 38 39 class TenuredGeneration: public CardGeneration { 40 friend class VMStructs; 41 // Abstractly, this is a subtype that gets access to protected fields. 42 friend class VM_PopulateDumpSharedSpace; 43 44 protected: 45 ContiguousSpace* _the_space; // Actual space holding objects 46 47 GenerationCounters* _gen_counters; 48 CSpaceCounters* _space_counters; 49 50 // Allocation failure 51 virtual bool expand(size_t bytes, size_t expand_bytes); 52 53 // Accessing spaces space() const54 ContiguousSpace* space() const { return _the_space; } 55 56 void assert_correct_size_change_locking(); 57 58 public: 59 TenuredGeneration(ReservedSpace rs, 60 size_t initial_byte_size, 61 size_t min_byte_size, 62 size_t max_byte_size, 63 CardTableRS* remset); 64 kind()65 Generation::Name kind() { return Generation::MarkSweepCompact; } 66 67 // Printing name() const68 const char* name() const { return "tenured generation"; } short_name() const69 const char* short_name() const { return "Tenured"; } 70 71 size_t unsafe_max_alloc_nogc() const; 72 size_t contiguous_available() const; 73 74 // Iteration 75 void object_iterate(ObjectClosure* blk); 76 77 virtual inline HeapWord* allocate(size_t word_size, bool is_tlab); 78 virtual inline HeapWord* par_allocate(size_t word_size, bool is_tlab); 79 80 template <typename OopClosureType> 81 void oop_since_save_marks_iterate(OopClosureType* cl); 82 83 void save_marks(); 84 void reset_saved_marks(); 85 bool no_allocs_since_save_marks(); 86 87 inline size_t block_size(const HeapWord* addr) const; 88 89 inline bool block_is_obj(const HeapWord* addr) const; 90 91 virtual void collect(bool full, 92 bool clear_all_soft_refs, 93 size_t size, 94 bool is_tlab); 95 96 HeapWord* expand_and_allocate(size_t size, 97 bool is_tlab, 98 bool parallel = false); 99 100 virtual void prepare_for_verify(); 101 102 virtual void gc_prologue(bool full); 103 virtual void gc_epilogue(bool full); 104 105 bool should_collect(bool full, 106 size_t word_size, 107 bool is_tlab); 108 109 virtual void compute_new_size(); 110 111 // Performance Counter support 112 void update_counters(); 113 114 virtual void record_spaces_top(); 115 116 // Statistics 117 118 virtual void update_gc_stats(Generation* current_generation, bool full); 119 120 virtual bool promotion_attempt_is_safe(size_t max_promoted_in_bytes) const; 121 122 virtual void verify(); 123 virtual void print_on(outputStream* st) const; 124 }; 125 126 #endif // SHARE_GC_SERIAL_TENUREDGENERATION_HPP 127