Thu, 14 Mar 2013 09:37:38 +0100
6733980: par compact - TraceGen1Time always shows 0.0000 seconds
Summary: Use the correct collector to retrieve accumulated gen1 trace time
Reviewed-by: johnc, jmasa
duke@435 | 1 | /* |
brutisso@3711 | 2 | * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP |
stefank@2314 | 26 | #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "gc_implementation/parallelScavenge/objectStartArray.hpp" |
stefank@2314 | 29 | #include "gc_implementation/parallelScavenge/psGenerationCounters.hpp" |
stefank@2314 | 30 | #include "gc_implementation/parallelScavenge/psVirtualspace.hpp" |
stefank@2314 | 31 | #include "gc_implementation/shared/mutableSpace.hpp" |
stefank@2314 | 32 | #include "gc_implementation/shared/spaceCounters.hpp" |
stefank@2314 | 33 | #include "runtime/safepoint.hpp" |
stefank@2314 | 34 | |
duke@435 | 35 | class PSMarkSweepDecorator; |
duke@435 | 36 | |
zgu@3900 | 37 | class PSOldGen : public CHeapObj<mtGC> { |
duke@435 | 38 | friend class VMStructs; |
duke@435 | 39 | friend class PSPromotionManager; // Uses the cas_allocate methods |
duke@435 | 40 | friend class ParallelScavengeHeap; |
duke@435 | 41 | friend class AdjoiningGenerations; |
duke@435 | 42 | |
duke@435 | 43 | protected: |
duke@435 | 44 | MemRegion _reserved; // Used for simple containment tests |
duke@435 | 45 | PSVirtualSpace* _virtual_space; // Controls mapping and unmapping of virtual mem |
duke@435 | 46 | ObjectStartArray _start_array; // Keeps track of where objects start in a 512b block |
duke@435 | 47 | MutableSpace* _object_space; // Where all the objects live |
duke@435 | 48 | PSMarkSweepDecorator* _object_mark_sweep; // The mark sweep view of _object_space |
duke@435 | 49 | const char* const _name; // Name of this generation. |
duke@435 | 50 | |
duke@435 | 51 | // Performance Counters |
duke@435 | 52 | PSGenerationCounters* _gen_counters; |
duke@435 | 53 | SpaceCounters* _space_counters; |
duke@435 | 54 | |
duke@435 | 55 | // Sizing information, in bytes, set in constructor |
duke@435 | 56 | const size_t _init_gen_size; |
duke@435 | 57 | const size_t _min_gen_size; |
duke@435 | 58 | const size_t _max_gen_size; |
duke@435 | 59 | |
duke@435 | 60 | // Used when initializing the _name field. |
duke@435 | 61 | static inline const char* select_name(); |
duke@435 | 62 | |
tonyp@2971 | 63 | HeapWord* allocate_noexpand(size_t word_size) { |
duke@435 | 64 | // We assume the heap lock is held here. |
duke@435 | 65 | assert_locked_or_safepoint(Heap_lock); |
duke@435 | 66 | HeapWord* res = object_space()->allocate(word_size); |
duke@435 | 67 | if (res != NULL) { |
duke@435 | 68 | _start_array.allocate_block(res); |
duke@435 | 69 | } |
duke@435 | 70 | return res; |
duke@435 | 71 | } |
duke@435 | 72 | |
duke@435 | 73 | // Support for MT garbage collection. CAS allocation is lower overhead than grabbing |
duke@435 | 74 | // and releasing the heap lock, which is held during gc's anyway. This method is not |
duke@435 | 75 | // safe for use at the same time as allocate_noexpand()! |
duke@435 | 76 | HeapWord* cas_allocate_noexpand(size_t word_size) { |
jcoomes@1844 | 77 | assert(SafepointSynchronize::is_at_safepoint(), "Must only be called at safepoint"); |
duke@435 | 78 | HeapWord* res = object_space()->cas_allocate(word_size); |
duke@435 | 79 | if (res != NULL) { |
duke@435 | 80 | _start_array.allocate_block(res); |
duke@435 | 81 | } |
duke@435 | 82 | return res; |
duke@435 | 83 | } |
duke@435 | 84 | |
duke@435 | 85 | // Support for MT garbage collection. See above comment. |
duke@435 | 86 | HeapWord* cas_allocate(size_t word_size) { |
duke@435 | 87 | HeapWord* res = cas_allocate_noexpand(word_size); |
duke@435 | 88 | return (res == NULL) ? expand_and_cas_allocate(word_size) : res; |
duke@435 | 89 | } |
duke@435 | 90 | |
tonyp@2971 | 91 | HeapWord* expand_and_allocate(size_t word_size); |
duke@435 | 92 | HeapWord* expand_and_cas_allocate(size_t word_size); |
duke@435 | 93 | void expand(size_t bytes); |
duke@435 | 94 | bool expand_by(size_t bytes); |
duke@435 | 95 | bool expand_to_reserved(); |
duke@435 | 96 | |
duke@435 | 97 | void shrink(size_t bytes); |
duke@435 | 98 | |
duke@435 | 99 | void post_resize(); |
duke@435 | 100 | |
duke@435 | 101 | public: |
duke@435 | 102 | // Initialize the generation. |
duke@435 | 103 | PSOldGen(ReservedSpace rs, size_t alignment, |
duke@435 | 104 | size_t initial_size, size_t min_size, size_t max_size, |
duke@435 | 105 | const char* perf_data_name, int level); |
duke@435 | 106 | |
duke@435 | 107 | PSOldGen(size_t initial_size, size_t min_size, size_t max_size, |
duke@435 | 108 | const char* perf_data_name, int level); |
duke@435 | 109 | |
coleenp@4037 | 110 | virtual void initialize(ReservedSpace rs, size_t alignment, |
duke@435 | 111 | const char* perf_data_name, int level); |
duke@435 | 112 | void initialize_virtual_space(ReservedSpace rs, size_t alignment); |
duke@435 | 113 | void initialize_work(const char* perf_data_name, int level); |
coleenp@4037 | 114 | virtual void initialize_performance_counters(const char* perf_data_name, int level); |
duke@435 | 115 | |
duke@435 | 116 | MemRegion reserved() const { return _reserved; } |
duke@435 | 117 | virtual size_t max_gen_size() { return _max_gen_size; } |
duke@435 | 118 | size_t min_gen_size() { return _min_gen_size; } |
duke@435 | 119 | |
duke@435 | 120 | // Returns limit on the maximum size of the generation. This |
duke@435 | 121 | // is the same as _max_gen_size for PSOldGen but need not be |
duke@435 | 122 | // for a derived class. |
duke@435 | 123 | virtual size_t gen_size_limit(); |
duke@435 | 124 | |
duke@435 | 125 | bool is_in(const void* p) const { |
duke@435 | 126 | return _virtual_space->contains((void *)p); |
duke@435 | 127 | } |
duke@435 | 128 | |
duke@435 | 129 | bool is_in_reserved(const void* p) const { |
duke@435 | 130 | return reserved().contains(p); |
duke@435 | 131 | } |
duke@435 | 132 | |
duke@435 | 133 | MutableSpace* object_space() const { return _object_space; } |
duke@435 | 134 | PSMarkSweepDecorator* object_mark_sweep() const { return _object_mark_sweep; } |
duke@435 | 135 | ObjectStartArray* start_array() { return &_start_array; } |
duke@435 | 136 | PSVirtualSpace* virtual_space() const { return _virtual_space;} |
duke@435 | 137 | |
duke@435 | 138 | // Has the generation been successfully allocated? |
duke@435 | 139 | bool is_allocated(); |
duke@435 | 140 | |
duke@435 | 141 | // MarkSweep methods |
duke@435 | 142 | virtual void precompact(); |
duke@435 | 143 | void adjust_pointers(); |
duke@435 | 144 | void compact(); |
duke@435 | 145 | |
duke@435 | 146 | // Size info |
duke@435 | 147 | size_t capacity_in_bytes() const { return object_space()->capacity_in_bytes(); } |
duke@435 | 148 | size_t used_in_bytes() const { return object_space()->used_in_bytes(); } |
duke@435 | 149 | size_t free_in_bytes() const { return object_space()->free_in_bytes(); } |
duke@435 | 150 | |
duke@435 | 151 | size_t capacity_in_words() const { return object_space()->capacity_in_words(); } |
duke@435 | 152 | size_t used_in_words() const { return object_space()->used_in_words(); } |
duke@435 | 153 | size_t free_in_words() const { return object_space()->free_in_words(); } |
duke@435 | 154 | |
duke@435 | 155 | // Includes uncommitted memory |
duke@435 | 156 | size_t contiguous_available() const; |
duke@435 | 157 | |
duke@435 | 158 | bool is_maximal_no_gc() const { |
duke@435 | 159 | return virtual_space()->uncommitted_size() == 0; |
duke@435 | 160 | } |
duke@435 | 161 | |
duke@435 | 162 | // Calculating new sizes |
duke@435 | 163 | void resize(size_t desired_free_space); |
duke@435 | 164 | |
duke@435 | 165 | // Allocation. We report all successful allocations to the size policy |
duke@435 | 166 | // Note that the perm gen does not use this method, and should not! |
tonyp@2971 | 167 | HeapWord* allocate(size_t word_size); |
duke@435 | 168 | |
duke@435 | 169 | // Iteration. |
coleenp@4037 | 170 | void oop_iterate_no_header(OopClosure* cl) { object_space()->oop_iterate_no_header(cl); } |
duke@435 | 171 | void object_iterate(ObjectClosure* cl) { object_space()->object_iterate(cl); } |
duke@435 | 172 | |
duke@435 | 173 | // Debugging - do not use for time critical operations |
duke@435 | 174 | virtual void print() const; |
duke@435 | 175 | virtual void print_on(outputStream* st) const; |
duke@435 | 176 | void print_used_change(size_t prev_used) const; |
duke@435 | 177 | |
brutisso@3711 | 178 | void verify(); |
duke@435 | 179 | void verify_object_start_array(); |
duke@435 | 180 | |
duke@435 | 181 | // These should not used |
duke@435 | 182 | virtual void reset_after_change(); |
duke@435 | 183 | |
duke@435 | 184 | // These should not used |
duke@435 | 185 | virtual size_t available_for_expansion(); |
duke@435 | 186 | virtual size_t available_for_contraction(); |
duke@435 | 187 | |
duke@435 | 188 | void space_invariants() PRODUCT_RETURN; |
duke@435 | 189 | |
duke@435 | 190 | // Performace Counter support |
duke@435 | 191 | void update_counters(); |
duke@435 | 192 | |
duke@435 | 193 | // Printing support |
duke@435 | 194 | virtual const char* name() const { return _name; } |
jmasa@698 | 195 | |
jmasa@698 | 196 | // Debugging support |
jmasa@698 | 197 | // Save the tops of all spaces for later use during mangling. |
jmasa@698 | 198 | void record_spaces_top() PRODUCT_RETURN; |
duke@435 | 199 | }; |
stefank@2314 | 200 | |
stefank@2314 | 201 | #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP |