src/share/vm/gc_implementation/parallelScavenge/psOldGen.hpp

Fri, 24 Jun 2016 17:12:13 +0800

author
aoqi<aoqi@loongson.cn>
date
Fri, 24 Jun 2016 17:12:13 +0800
changeset 25
873fd82b133d
parent 1
2d8a650513c2
child 6876
710a3c8b516e
permissions
-rw-r--r--

[Code Reorganization] Removed GC related modifications made by Loongson, for example, UseOldNUMA.

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@0 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP
aoqi@0 26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP
aoqi@0 27
aoqi@0 28 #include "gc_implementation/parallelScavenge/objectStartArray.hpp"
aoqi@0 29 #include "gc_implementation/parallelScavenge/psGenerationCounters.hpp"
aoqi@0 30 #include "gc_implementation/parallelScavenge/psVirtualspace.hpp"
aoqi@0 31 #include "gc_implementation/shared/mutableSpace.hpp"
aoqi@0 32 #include "gc_implementation/shared/spaceCounters.hpp"
aoqi@0 33 #include "runtime/safepoint.hpp"
aoqi@0 34
aoqi@0 35 class PSMarkSweepDecorator;
aoqi@0 36
aoqi@0 37 class PSOldGen : public CHeapObj<mtGC> {
aoqi@0 38 friend class VMStructs;
aoqi@0 39 friend class PSPromotionManager; // Uses the cas_allocate methods
aoqi@0 40 friend class ParallelScavengeHeap;
aoqi@0 41 friend class AdjoiningGenerations;
aoqi@0 42
aoqi@0 43 protected:
aoqi@0 44 MemRegion _reserved; // Used for simple containment tests
aoqi@0 45 PSVirtualSpace* _virtual_space; // Controls mapping and unmapping of virtual mem
aoqi@0 46 ObjectStartArray _start_array; // Keeps track of where objects start in a 512b block
aoqi@0 47 MutableSpace* _object_space; // Where all the objects live
aoqi@0 48 PSMarkSweepDecorator* _object_mark_sweep; // The mark sweep view of _object_space
aoqi@0 49 const char* const _name; // Name of this generation.
aoqi@0 50
aoqi@0 51 // Performance Counters
aoqi@0 52 PSGenerationCounters* _gen_counters;
aoqi@0 53 SpaceCounters* _space_counters;
aoqi@0 54
aoqi@0 55 // Sizing information, in bytes, set in constructor
aoqi@0 56 const size_t _init_gen_size;
aoqi@0 57 const size_t _min_gen_size;
aoqi@0 58 const size_t _max_gen_size;
aoqi@0 59
aoqi@0 60 // Used when initializing the _name field.
aoqi@0 61 static inline const char* select_name();
aoqi@0 62
aoqi@0 63 HeapWord* allocate_noexpand(size_t word_size) {
aoqi@0 64 // We assume the heap lock is held here.
aoqi@0 65 assert_locked_or_safepoint(Heap_lock);
aoqi@0 66 HeapWord* res = object_space()->allocate(word_size);
aoqi@0 67 if (res != NULL) {
aoqi@0 68 _start_array.allocate_block(res);
aoqi@0 69 }
aoqi@0 70 return res;
aoqi@0 71 }
aoqi@0 72
aoqi@0 73 // Support for MT garbage collection. CAS allocation is lower overhead than grabbing
aoqi@0 74 // and releasing the heap lock, which is held during gc's anyway. This method is not
aoqi@0 75 // safe for use at the same time as allocate_noexpand()!
aoqi@25 76 HeapWord* cas_allocate_noexpand(size_t word_size) {
aoqi@0 77 assert(SafepointSynchronize::is_at_safepoint(), "Must only be called at safepoint");
aoqi@25 78 HeapWord* res = object_space()->cas_allocate(word_size);
aoqi@0 79 if (res != NULL) {
aoqi@0 80 _start_array.allocate_block(res);
aoqi@0 81 }
aoqi@0 82 return res;
aoqi@0 83 }
aoqi@0 84
aoqi@0 85 // Support for MT garbage collection. See above comment.
aoqi@25 86 HeapWord* cas_allocate(size_t word_size) {
aoqi@25 87 HeapWord* res = cas_allocate_noexpand(word_size);
aoqi@25 88 return (res == NULL) ? expand_and_cas_allocate(word_size) : res;
aoqi@0 89 }
aoqi@0 90
aoqi@0 91 HeapWord* expand_and_allocate(size_t word_size);
aoqi@25 92 HeapWord* expand_and_cas_allocate(size_t word_size);
aoqi@0 93 void expand(size_t bytes);
aoqi@0 94 bool expand_by(size_t bytes);
aoqi@0 95 bool expand_to_reserved();
aoqi@0 96
aoqi@0 97 void shrink(size_t bytes);
aoqi@0 98
aoqi@0 99 void post_resize();
aoqi@0 100
aoqi@0 101 public:
aoqi@0 102 // Initialize the generation.
aoqi@0 103 PSOldGen(ReservedSpace rs, size_t alignment,
aoqi@0 104 size_t initial_size, size_t min_size, size_t max_size,
aoqi@0 105 const char* perf_data_name, int level);
aoqi@0 106
aoqi@0 107 PSOldGen(size_t initial_size, size_t min_size, size_t max_size,
aoqi@0 108 const char* perf_data_name, int level);
aoqi@0 109
aoqi@0 110 virtual void initialize(ReservedSpace rs, size_t alignment,
aoqi@0 111 const char* perf_data_name, int level);
aoqi@0 112 void initialize_virtual_space(ReservedSpace rs, size_t alignment);
aoqi@0 113 virtual void initialize_work(const char* perf_data_name, int level);
aoqi@0 114 virtual void initialize_performance_counters(const char* perf_data_name, int level);
aoqi@0 115
aoqi@0 116 MemRegion reserved() const { return _reserved; }
aoqi@0 117 virtual size_t max_gen_size() { return _max_gen_size; }
aoqi@0 118 size_t min_gen_size() { return _min_gen_size; }
aoqi@0 119
aoqi@0 120 // Returns limit on the maximum size of the generation. This
aoqi@0 121 // is the same as _max_gen_size for PSOldGen but need not be
aoqi@0 122 // for a derived class.
aoqi@0 123 virtual size_t gen_size_limit();
aoqi@0 124
aoqi@0 125 bool is_in(const void* p) const {
aoqi@0 126 return _virtual_space->contains((void *)p);
aoqi@0 127 }
aoqi@0 128
aoqi@0 129 bool is_in_reserved(const void* p) const {
aoqi@0 130 return reserved().contains(p);
aoqi@0 131 }
aoqi@0 132
aoqi@0 133 MutableSpace* object_space() const { return _object_space; }
aoqi@0 134 PSMarkSweepDecorator* object_mark_sweep() const { return _object_mark_sweep; }
aoqi@0 135 ObjectStartArray* start_array() { return &_start_array; }
aoqi@0 136 PSVirtualSpace* virtual_space() const { return _virtual_space;}
aoqi@0 137
aoqi@0 138 // Has the generation been successfully allocated?
aoqi@0 139 bool is_allocated();
aoqi@0 140
aoqi@0 141 // MarkSweep methods
aoqi@0 142 virtual void precompact();
aoqi@0 143 void adjust_pointers();
aoqi@0 144 void compact();
aoqi@0 145
aoqi@0 146 // Size info
aoqi@0 147 size_t capacity_in_bytes() const { return object_space()->capacity_in_bytes(); }
aoqi@0 148 size_t used_in_bytes() const { return object_space()->used_in_bytes(); }
aoqi@0 149 size_t free_in_bytes() const { return object_space()->free_in_bytes(); }
aoqi@0 150
aoqi@0 151 size_t capacity_in_words() const { return object_space()->capacity_in_words(); }
aoqi@0 152 size_t used_in_words() const { return object_space()->used_in_words(); }
aoqi@0 153 size_t free_in_words() const { return object_space()->free_in_words(); }
aoqi@0 154
aoqi@0 155 // Includes uncommitted memory
aoqi@0 156 size_t contiguous_available() const;
aoqi@0 157
aoqi@0 158 bool is_maximal_no_gc() const {
aoqi@0 159 return virtual_space()->uncommitted_size() == 0;
aoqi@0 160 }
aoqi@0 161
aoqi@0 162 // Calculating new sizes
aoqi@0 163 void resize(size_t desired_free_space);
aoqi@0 164
aoqi@0 165 // Allocation. We report all successful allocations to the size policy
aoqi@0 166 // Note that the perm gen does not use this method, and should not!
aoqi@0 167 HeapWord* allocate(size_t word_size);
aoqi@0 168
aoqi@0 169 // Iteration.
aoqi@0 170 void oop_iterate_no_header(OopClosure* cl) { object_space()->oop_iterate_no_header(cl); }
aoqi@0 171 void object_iterate(ObjectClosure* cl) { object_space()->object_iterate(cl); }
aoqi@0 172
aoqi@0 173 // Debugging - do not use for time critical operations
aoqi@0 174 virtual void print() const;
aoqi@0 175 virtual void print_on(outputStream* st) const;
aoqi@0 176 void print_used_change(size_t prev_used) const;
aoqi@0 177
aoqi@0 178 void verify();
aoqi@0 179 void verify_object_start_array();
aoqi@0 180
aoqi@0 181 // These should not used
aoqi@0 182 virtual void reset_after_change();
aoqi@0 183
aoqi@0 184 // These should not used
aoqi@0 185 virtual size_t available_for_expansion();
aoqi@0 186 virtual size_t available_for_contraction();
aoqi@0 187
aoqi@0 188 void space_invariants() PRODUCT_RETURN;
aoqi@0 189
aoqi@0 190 // Performace Counter support
aoqi@0 191 void update_counters();
aoqi@0 192
aoqi@0 193 // Printing support
aoqi@0 194 virtual const char* name() const { return _name; }
aoqi@0 195
aoqi@0 196 // Debugging support
aoqi@0 197 // Save the tops of all spaces for later use during mangling.
aoqi@0 198 void record_spaces_top() PRODUCT_RETURN;
aoqi@0 199 };
aoqi@0 200
aoqi@0 201 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP

mercurial