src/share/vm/memory/compactingPermGenGen.hpp

Fri, 23 Mar 2012 11:16:05 -0400

author
coleenp
date
Fri, 23 Mar 2012 11:16:05 -0400
changeset 3682
fc9d8850ab8b
parent 2658
c7f3d0b4570f
child 3711
b632e80fc9dc
permissions
-rw-r--r--

7150058: Allocate symbols from null boot loader to an arena for NMT
Summary: Move symbol allocation to an arena so NMT doesn't have to track them at startup.
Reviewed-by: never, kamg, zgu

duke@435 1 /*
never@2658 2 * Copyright (c) 2003, 2011, 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_MEMORY_COMPACTINGPERMGENGEN_HPP
stefank@2314 26 #define SHARE_VM_MEMORY_COMPACTINGPERMGENGEN_HPP
stefank@2314 27
stefank@2314 28 #include "gc_implementation/shared/generationCounters.hpp"
stefank@2314 29 #include "memory/space.hpp"
stefank@2314 30
duke@435 31 // All heaps contains a "permanent generation," containing permanent
duke@435 32 // (reflective) objects. This is like a regular generation in some ways,
duke@435 33 // but unlike one in others, and so is split apart.
duke@435 34
duke@435 35 class PermanentGenerationSpec;
duke@435 36
duke@435 37 // This is the "generation" view of a CompactingPermGen.
ysr@1486 38 // NOTE: the shared spaces used for CDS are here handled in
ysr@1486 39 // a somewhat awkward and potentially buggy fashion, see CR 6801625.
ysr@1486 40 // This infelicity should be fixed, see CR 6897789.
duke@435 41 class CompactingPermGenGen: public OneContigSpaceCardGeneration {
duke@435 42 friend class VMStructs;
duke@435 43 // Abstractly, this is a subtype that gets access to protected fields.
duke@435 44 friend class CompactingPermGen;
duke@435 45
duke@435 46 private:
duke@435 47 // Shared spaces
duke@435 48 PermanentGenerationSpec* _spec;
duke@435 49 size_t _shared_space_size;
duke@435 50 VirtualSpace _ro_vs;
duke@435 51 VirtualSpace _rw_vs;
duke@435 52 VirtualSpace _md_vs;
duke@435 53 VirtualSpace _mc_vs;
duke@435 54 BlockOffsetSharedArray* _ro_bts;
duke@435 55 BlockOffsetSharedArray* _rw_bts;
duke@435 56 OffsetTableContigSpace* _ro_space;
duke@435 57 OffsetTableContigSpace* _rw_space;
duke@435 58
ysr@1486 59 // With shared spaces there is a dichotomy in the use of the
duke@435 60 // _virtual_space of the generation. There is a portion of the
duke@435 61 // _virtual_space that is used for the unshared part of the
duke@435 62 // permanent generation and a portion that is reserved for the shared part.
duke@435 63 // The _reserved field in the generation represents both the
duke@435 64 // unshared and shared parts of the generation. The _reserved
duke@435 65 // variable is initialized for only the unshared part but is
duke@435 66 // later extended to include the shared part during initialization
duke@435 67 // if shared spaces are being used.
duke@435 68 // The reserved size for the _virtual_space for CompactingPermGenGen
duke@435 69 // is the size of the space for the permanent generation including the
duke@435 70 // the shared spaces. This can be seen by the use of MaxPermSize
duke@435 71 // in the allocation of PermanentGenerationSpec. The space for the
duke@435 72 // shared spaces is committed separately (???).
duke@435 73 // In general at initialization only a part of the
duke@435 74 // space for the unshared part of the permanent generation is
duke@435 75 // committed and more is committed as the permanent generation is
duke@435 76 // grown. In growing the permanent generation the capacity() and
duke@435 77 // max_capacity() of the generation are used. For the permanent
duke@435 78 // generation (implemented with a CompactingPermGenGen) the capacity()
duke@435 79 // is taken from the capacity of the space (_the_space variable used for the
duke@435 80 // unshared part of the generation) and the max_capacity() is based
duke@435 81 // on the size of the _reserved variable (which includes the size of the
duke@435 82 // shared spaces) minus the size of the shared spaces.
duke@435 83
duke@435 84 // These values are redundant, but are called out separately to avoid
duke@435 85 // going through heap/space/gen pointers for performance.
duke@435 86 static HeapWord* unshared_bottom;
duke@435 87 static HeapWord* unshared_end;
duke@435 88 static HeapWord* shared_bottom;
duke@435 89 static HeapWord* readonly_bottom;
duke@435 90 static HeapWord* readonly_end;
duke@435 91 static HeapWord* readwrite_bottom;
duke@435 92 static HeapWord* readwrite_end;
duke@435 93 static HeapWord* miscdata_bottom;
duke@435 94 static HeapWord* miscdata_end;
duke@435 95 static HeapWord* misccode_bottom;
duke@435 96 static HeapWord* misccode_end;
duke@435 97 static HeapWord* shared_end;
duke@435 98
duke@435 99 // Performance Counters
duke@435 100 GenerationCounters* _gen_counters;
duke@435 101 CSpaceCounters* _space_counters;
duke@435 102
duke@435 103 void initialize_performance_counters();
duke@435 104
duke@435 105 public:
duke@435 106
duke@435 107 enum {
never@2658 108 vtbl_list_size = 17, // number of entries in the shared space vtable list.
acorn@843 109 num_virtuals = 200 // number of virtual methods in Klass (or
duke@435 110 // subclass) objects, or greater.
duke@435 111 };
duke@435 112
duke@435 113 enum {
duke@435 114 ro = 0, // read-only shared space in the heap
duke@435 115 rw = 1, // read-write shared space in the heap
duke@435 116 md = 2, // miscellaneous data for initializing tables, etc.
duke@435 117 mc = 3, // miscellaneous code - vtable replacement.
duke@435 118 n_regions = 4
duke@435 119 };
duke@435 120
duke@435 121 CompactingPermGenGen(ReservedSpace rs, ReservedSpace shared_rs,
duke@435 122 size_t initial_byte_size, int level, GenRemSet* remset,
duke@435 123 ContiguousSpace* space,
duke@435 124 PermanentGenerationSpec* perm_spec);
duke@435 125
duke@435 126 const char* name() const {
duke@435 127 return "compacting perm gen";
duke@435 128 }
duke@435 129
duke@435 130 const char* short_name() const {
duke@435 131 return "Perm";
duke@435 132 }
duke@435 133
duke@435 134 // Return the maximum capacity for the object space. This
duke@435 135 // explicitly does not include the shared spaces.
duke@435 136 size_t max_capacity() const;
duke@435 137
duke@435 138 void update_counters();
duke@435 139
duke@435 140 void compute_new_size() {
duke@435 141 assert(false, "Should not call this -- handled at PermGen level.");
duke@435 142 }
duke@435 143
duke@435 144 bool must_be_youngest() const { return false; }
duke@435 145 bool must_be_oldest() const { return false; }
duke@435 146
duke@435 147 OffsetTableContigSpace* ro_space() const { return _ro_space; }
duke@435 148 OffsetTableContigSpace* rw_space() const { return _rw_space; }
duke@435 149 VirtualSpace* md_space() { return &_md_vs; }
duke@435 150 VirtualSpace* mc_space() { return &_mc_vs; }
duke@435 151 ContiguousSpace* unshared_space() const { return _the_space; }
duke@435 152
coleenp@2497 153 static bool inline is_shared(const void* p) {
coleenp@2497 154 return p >= shared_bottom && p < shared_end;
duke@435 155 }
duke@435 156 // RedefineClasses note: this tester is used to check residence of
duke@435 157 // the specified oop in the shared readonly space and not whether
duke@435 158 // the oop is readonly.
coleenp@2497 159 static bool inline is_shared_readonly(const void* p) {
coleenp@2497 160 return p >= readonly_bottom && p < readonly_end;
duke@435 161 }
duke@435 162 // RedefineClasses note: this tester is used to check residence of
duke@435 163 // the specified oop in the shared readwrite space and not whether
duke@435 164 // the oop is readwrite.
coleenp@2497 165 static bool inline is_shared_readwrite(const void* p) {
coleenp@2497 166 return p >= readwrite_bottom && p < readwrite_end;
duke@435 167 }
duke@435 168
coleenp@2497 169 // Checks if the pointer is either in unshared space or in shared space
duke@435 170 inline bool is_in(const void* p) const {
coleenp@2497 171 return OneContigSpaceCardGeneration::is_in(p) || is_shared(p);
duke@435 172 }
duke@435 173
duke@435 174 inline PermanentGenerationSpec* spec() const { return _spec; }
duke@435 175 inline void set_spec(PermanentGenerationSpec* spec) { _spec = spec; }
duke@435 176
duke@435 177 void pre_adjust_pointers();
duke@435 178 void adjust_pointers();
duke@435 179 void space_iterate(SpaceClosure* blk, bool usedOnly = false);
duke@435 180 void print_on(outputStream* st) const;
duke@435 181 void younger_refs_iterate(OopsInGenClosure* blk);
duke@435 182 void compact();
duke@435 183 void post_compact();
duke@435 184 size_t contiguous_available() const;
duke@435 185
duke@435 186 void clear_remembered_set();
duke@435 187 void invalidate_remembered_set();
duke@435 188
duke@435 189 inline bool block_is_obj(const HeapWord* addr) const {
duke@435 190 if (addr < the_space()->top()) return true;
duke@435 191 else if (addr < the_space()->end()) return false;
duke@435 192 else if (addr < ro_space()->top()) return true;
duke@435 193 else if (addr < ro_space()->end()) return false;
duke@435 194 else if (addr < rw_space()->top()) return true;
duke@435 195 else return false;
duke@435 196 }
duke@435 197
duke@435 198
duke@435 199 inline size_t block_size(const HeapWord* addr) const {
duke@435 200 if (addr < the_space()->top()) {
duke@435 201 return oop(addr)->size();
duke@435 202 }
duke@435 203 else if (addr < the_space()->end()) {
duke@435 204 assert(addr == the_space()->top(), "non-block head arg to block_size");
duke@435 205 return the_space()->end() - the_space()->top();
duke@435 206 }
duke@435 207
duke@435 208 else if (addr < ro_space()->top()) {
duke@435 209 return oop(addr)->size();
duke@435 210 }
duke@435 211 else if (addr < ro_space()->end()) {
duke@435 212 assert(addr == ro_space()->top(), "non-block head arg to block_size");
duke@435 213 return ro_space()->end() - ro_space()->top();
duke@435 214 }
duke@435 215
duke@435 216 else if (addr < rw_space()->top()) {
duke@435 217 return oop(addr)->size();
duke@435 218 }
duke@435 219 else {
duke@435 220 assert(addr == rw_space()->top(), "non-block head arg to block_size");
duke@435 221 return rw_space()->end() - rw_space()->top();
duke@435 222 }
duke@435 223 }
duke@435 224
duke@435 225 static void generate_vtable_methods(void** vtbl_list,
duke@435 226 void** vtable,
duke@435 227 char** md_top, char* md_end,
duke@435 228 char** mc_top, char* mc_end);
coleenp@2497 229 static void* find_matching_vtbl_ptr(void** vtbl_list,
coleenp@2497 230 void* new_vtable_start,
coleenp@2497 231 void* obj);
duke@435 232
duke@435 233 void verify(bool allow_dirty);
duke@435 234
duke@435 235 // Serialization
duke@435 236 static void initialize_oops() KERNEL_RETURN;
duke@435 237 static void serialize_oops(SerializeOopClosure* soc);
duke@435 238 void serialize_bts(SerializeOopClosure* soc);
duke@435 239
duke@435 240 // Initiate dumping of shared file.
duke@435 241 static jint dump_shared(GrowableArray<oop>* class_promote_order, TRAPS);
duke@435 242
duke@435 243 // JVM/TI RedefineClasses() support:
duke@435 244 // Remap the shared readonly space to shared readwrite, private if
duke@435 245 // sharing is enabled. Simply returns true if sharing is not enabled
duke@435 246 // or if the remapping has already been done by a prior call.
duke@435 247 static bool remap_shared_readonly_as_readwrite();
duke@435 248 };
stefank@2314 249
stefank@2314 250 #endif // SHARE_VM_MEMORY_COMPACTINGPERMGENGEN_HPP

mercurial