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