1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psOldGen.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,188 @@ 1.4 +/* 1.5 + * Copyright 2001-2006 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +class PSMarkSweepDecorator; 1.29 + 1.30 +class PSOldGen : public CHeapObj { 1.31 + friend class VMStructs; 1.32 + friend class PSPromotionManager; // Uses the cas_allocate methods 1.33 + friend class ParallelScavengeHeap; 1.34 + friend class AdjoiningGenerations; 1.35 + 1.36 + protected: 1.37 + MemRegion _reserved; // Used for simple containment tests 1.38 + PSVirtualSpace* _virtual_space; // Controls mapping and unmapping of virtual mem 1.39 + ObjectStartArray _start_array; // Keeps track of where objects start in a 512b block 1.40 + MutableSpace* _object_space; // Where all the objects live 1.41 + PSMarkSweepDecorator* _object_mark_sweep; // The mark sweep view of _object_space 1.42 + const char* const _name; // Name of this generation. 1.43 + 1.44 + // Performance Counters 1.45 + PSGenerationCounters* _gen_counters; 1.46 + SpaceCounters* _space_counters; 1.47 + 1.48 + // Sizing information, in bytes, set in constructor 1.49 + const size_t _init_gen_size; 1.50 + const size_t _min_gen_size; 1.51 + const size_t _max_gen_size; 1.52 + 1.53 + // Used when initializing the _name field. 1.54 + static inline const char* select_name(); 1.55 + 1.56 + HeapWord* allocate_noexpand(size_t word_size, bool is_tlab) { 1.57 + // We assume the heap lock is held here. 1.58 + assert(!is_tlab, "Does not support TLAB allocation"); 1.59 + assert_locked_or_safepoint(Heap_lock); 1.60 + HeapWord* res = object_space()->allocate(word_size); 1.61 + if (res != NULL) { 1.62 + _start_array.allocate_block(res); 1.63 + } 1.64 + return res; 1.65 + } 1.66 + 1.67 + // Support for MT garbage collection. CAS allocation is lower overhead than grabbing 1.68 + // and releasing the heap lock, which is held during gc's anyway. This method is not 1.69 + // safe for use at the same time as allocate_noexpand()! 1.70 + HeapWord* cas_allocate_noexpand(size_t word_size) { 1.71 + assert(SafepointSynchronize::is_at_safepoint(), "Must only be called at safepoint") 1.72 + HeapWord* res = object_space()->cas_allocate(word_size); 1.73 + if (res != NULL) { 1.74 + _start_array.allocate_block(res); 1.75 + } 1.76 + return res; 1.77 + } 1.78 + 1.79 + // Support for MT garbage collection. See above comment. 1.80 + HeapWord* cas_allocate(size_t word_size) { 1.81 + HeapWord* res = cas_allocate_noexpand(word_size); 1.82 + return (res == NULL) ? expand_and_cas_allocate(word_size) : res; 1.83 + } 1.84 + 1.85 + HeapWord* expand_and_allocate(size_t word_size, bool is_tlab); 1.86 + HeapWord* expand_and_cas_allocate(size_t word_size); 1.87 + void expand(size_t bytes); 1.88 + bool expand_by(size_t bytes); 1.89 + bool expand_to_reserved(); 1.90 + 1.91 + void shrink(size_t bytes); 1.92 + 1.93 + void post_resize(); 1.94 + 1.95 + public: 1.96 + // Initialize the generation. 1.97 + PSOldGen(ReservedSpace rs, size_t alignment, 1.98 + size_t initial_size, size_t min_size, size_t max_size, 1.99 + const char* perf_data_name, int level); 1.100 + 1.101 + PSOldGen(size_t initial_size, size_t min_size, size_t max_size, 1.102 + const char* perf_data_name, int level); 1.103 + 1.104 + void initialize(ReservedSpace rs, size_t alignment, 1.105 + const char* perf_data_name, int level); 1.106 + void initialize_virtual_space(ReservedSpace rs, size_t alignment); 1.107 + void initialize_work(const char* perf_data_name, int level); 1.108 + 1.109 + MemRegion reserved() const { return _reserved; } 1.110 + virtual size_t max_gen_size() { return _max_gen_size; } 1.111 + size_t min_gen_size() { return _min_gen_size; } 1.112 + 1.113 + // Returns limit on the maximum size of the generation. This 1.114 + // is the same as _max_gen_size for PSOldGen but need not be 1.115 + // for a derived class. 1.116 + virtual size_t gen_size_limit(); 1.117 + 1.118 + bool is_in(const void* p) const { 1.119 + return _virtual_space->contains((void *)p); 1.120 + } 1.121 + 1.122 + bool is_in_reserved(const void* p) const { 1.123 + return reserved().contains(p); 1.124 + } 1.125 + 1.126 + MutableSpace* object_space() const { return _object_space; } 1.127 + PSMarkSweepDecorator* object_mark_sweep() const { return _object_mark_sweep; } 1.128 + ObjectStartArray* start_array() { return &_start_array; } 1.129 + PSVirtualSpace* virtual_space() const { return _virtual_space;} 1.130 + 1.131 + // Has the generation been successfully allocated? 1.132 + bool is_allocated(); 1.133 + 1.134 + // MarkSweep methods 1.135 + virtual void precompact(); 1.136 + void adjust_pointers(); 1.137 + void compact(); 1.138 + 1.139 + // Parallel old 1.140 + virtual void move_and_update(ParCompactionManager* cm); 1.141 + 1.142 + // Size info 1.143 + size_t capacity_in_bytes() const { return object_space()->capacity_in_bytes(); } 1.144 + size_t used_in_bytes() const { return object_space()->used_in_bytes(); } 1.145 + size_t free_in_bytes() const { return object_space()->free_in_bytes(); } 1.146 + 1.147 + size_t capacity_in_words() const { return object_space()->capacity_in_words(); } 1.148 + size_t used_in_words() const { return object_space()->used_in_words(); } 1.149 + size_t free_in_words() const { return object_space()->free_in_words(); } 1.150 + 1.151 + // Includes uncommitted memory 1.152 + size_t contiguous_available() const; 1.153 + 1.154 + bool is_maximal_no_gc() const { 1.155 + return virtual_space()->uncommitted_size() == 0; 1.156 + } 1.157 + 1.158 + // Calculating new sizes 1.159 + void resize(size_t desired_free_space); 1.160 + 1.161 + // Allocation. We report all successful allocations to the size policy 1.162 + // Note that the perm gen does not use this method, and should not! 1.163 + HeapWord* allocate(size_t word_size, bool is_tlab); 1.164 + 1.165 + // Iteration. 1.166 + void oop_iterate(OopClosure* cl) { object_space()->oop_iterate(cl); } 1.167 + void object_iterate(ObjectClosure* cl) { object_space()->object_iterate(cl); } 1.168 + 1.169 + // Debugging - do not use for time critical operations 1.170 + virtual void print() const; 1.171 + virtual void print_on(outputStream* st) const; 1.172 + void print_used_change(size_t prev_used) const; 1.173 + 1.174 + void verify(bool allow_dirty); 1.175 + void verify_object_start_array(); 1.176 + 1.177 + // These should not used 1.178 + virtual void reset_after_change(); 1.179 + 1.180 + // These should not used 1.181 + virtual size_t available_for_expansion(); 1.182 + virtual size_t available_for_contraction(); 1.183 + 1.184 + void space_invariants() PRODUCT_RETURN; 1.185 + 1.186 + // Performace Counter support 1.187 + void update_counters(); 1.188 + 1.189 + // Printing support 1.190 + virtual const char* name() const { return _name; } 1.191 +};