annotate agent/src/share/classes/sun/jvm/hotspot/memory/Generation.java @ 12825:c90e76575b03

8019375: Internal symbol table size should be tunable. Reviewed-by: coleenp, kamg
author kevinw
date Tue, 08 Oct 2013 09:33:51 +0100
parents da91efe96a93
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.memory;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 /** <P> The (supported) Generation hierarchy currently looks like this: </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 <ul>
a61af66fc99e Initial load
duke
parents:
diff changeset
36 <li> Generation
a61af66fc99e Initial load
duke
parents:
diff changeset
37 <ul>
a61af66fc99e Initial load
duke
parents:
diff changeset
38 <li> CardGeneration
a61af66fc99e Initial load
duke
parents:
diff changeset
39 <ul>
a61af66fc99e Initial load
duke
parents:
diff changeset
40 <li> OneContigSpaceCardGeneration
a61af66fc99e Initial load
duke
parents:
diff changeset
41 <ul>
a61af66fc99e Initial load
duke
parents:
diff changeset
42 <li> TenuredGeneration
a61af66fc99e Initial load
duke
parents:
diff changeset
43 </ul>
a61af66fc99e Initial load
duke
parents:
diff changeset
44 </ul>
a61af66fc99e Initial load
duke
parents:
diff changeset
45 <li> DefNewGeneration
a61af66fc99e Initial load
duke
parents:
diff changeset
46 </ul>
a61af66fc99e Initial load
duke
parents:
diff changeset
47 </ul>
a61af66fc99e Initial load
duke
parents:
diff changeset
48 */
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 public abstract class Generation extends VMObject {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 private static long reservedFieldOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 private static long virtualSpaceFieldOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 private static CIntegerField levelField;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 protected static final int K = 1024;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // Fields for class StatRecord
a61af66fc99e Initial load
duke
parents:
diff changeset
57 private static Field statRecordField;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 private static CIntegerField invocationField;
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // constants from Name enum
a61af66fc99e Initial load
duke
parents:
diff changeset
61 private static int NAME_DEF_NEW;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 private static int NAME_PAR_NEW;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 private static int NAME_MARK_SWEEP_COMPACT;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 private static int NAME_CONCURRENT_MARK_SWEEP;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 private static int NAME_OTHER;
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 });
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 private static synchronized void initialize(TypeDataBase db) {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 Type type = db.lookupType("Generation");
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 reservedFieldOffset = type.getField("_reserved").getOffset();
a61af66fc99e Initial load
duke
parents:
diff changeset
79 virtualSpaceFieldOffset = type.getField("_virtual_space").getOffset();
a61af66fc99e Initial load
duke
parents:
diff changeset
80 levelField = type.getCIntegerField("_level");
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // StatRecord
a61af66fc99e Initial load
duke
parents:
diff changeset
82 statRecordField = type.getField("_stat_record");
a61af66fc99e Initial load
duke
parents:
diff changeset
83 type = db.lookupType("Generation::StatRecord");
a61af66fc99e Initial load
duke
parents:
diff changeset
84 invocationField = type.getCIntegerField("invocations");
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // constants from Generation::Name
a61af66fc99e Initial load
duke
parents:
diff changeset
87 NAME_DEF_NEW = db.lookupIntConstant("Generation::DefNew").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
88 NAME_PAR_NEW = db.lookupIntConstant("Generation::ParNew").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
89 NAME_MARK_SWEEP_COMPACT = db.lookupIntConstant("Generation::MarkSweepCompact").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
90 NAME_CONCURRENT_MARK_SWEEP = db.lookupIntConstant("Generation::ConcurrentMarkSweep").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
91 NAME_OTHER = db.lookupIntConstant("Generation::Other").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 public Generation(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 super(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 public static class Name {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 public static final Name DEF_NEW = new Name("DefNew");
a61af66fc99e Initial load
duke
parents:
diff changeset
100 public static final Name PAR_NEW = new Name("ParNew");
a61af66fc99e Initial load
duke
parents:
diff changeset
101 public static final Name MARK_SWEEP_COMPACT = new Name("MarkSweepCompact");
a61af66fc99e Initial load
duke
parents:
diff changeset
102 public static final Name CONCURRENT_MARK_SWEEP = new Name("ConcurrentMarkSweep");
a61af66fc99e Initial load
duke
parents:
diff changeset
103 public static final Name OTHER = new Name("Other");
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 private Name(String value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 this.value = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 private String value;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 public String toString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 return value;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 public Generation.Name kind() {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 return Generation.Name.OTHER;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 static Generation.Name nameForEnum(int value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 if (value == NAME_DEF_NEW) {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 return Name.DEF_NEW;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 } else if (value == NAME_PAR_NEW) {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 return Name.PAR_NEW;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 } else if (value == NAME_MARK_SWEEP_COMPACT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 return Name.MARK_SWEEP_COMPACT;
a61af66fc99e Initial load
duke
parents:
diff changeset
126 } else if (value == NAME_CONCURRENT_MARK_SWEEP) {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 return Name.CONCURRENT_MARK_SWEEP;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 } else if (value == NAME_OTHER) {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 return Name.OTHER;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 throw new RuntimeException("should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 public GenerationSpec spec() {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 return ((GenCollectedHeap) VM.getVM().getUniverse().heap()).spec(level());
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 public int level() {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 return (int) levelField.getValue(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 public int invocations() {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 return getStatRecord().getInvocations();
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 /** The maximum number of object bytes the generation can currently
a61af66fc99e Initial load
duke
parents:
diff changeset
148 hold. */
a61af66fc99e Initial load
duke
parents:
diff changeset
149 public abstract long capacity();
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 /** The number of used bytes in the gen. */
a61af66fc99e Initial load
duke
parents:
diff changeset
152 public abstract long used();
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 /** The number of free bytes in the gen. */
a61af66fc99e Initial load
duke
parents:
diff changeset
155 public abstract long free();
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 /** The largest number of contiguous free words in the generation,
a61af66fc99e Initial load
duke
parents:
diff changeset
158 including expansion. (VM's version assumes it is called at a
a61af66fc99e Initial load
duke
parents:
diff changeset
159 safepoint.) */
a61af66fc99e Initial load
duke
parents:
diff changeset
160 public abstract long contiguousAvailable();
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 public MemRegion reserved() {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 return new MemRegion(addr.addOffsetTo(reservedFieldOffset));
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 /** Returns a region guaranteed to contain all the objects in the
a61af66fc99e Initial load
duke
parents:
diff changeset
167 generation. */
a61af66fc99e Initial load
duke
parents:
diff changeset
168 public MemRegion usedRegion() {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 return reserved();
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 /* Returns "TRUE" iff "p" points into an allocated object in the
a61af66fc99e Initial load
duke
parents:
diff changeset
173 generation. */
a61af66fc99e Initial load
duke
parents:
diff changeset
174 public boolean isIn(Address p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 GenerationIsInClosure blk = new GenerationIsInClosure(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
176 spaceIterate(blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
177 return (blk.space() != null);
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 /** Returns "TRUE" iff "p" points into the reserved area of the
a61af66fc99e Initial load
duke
parents:
diff changeset
181 generation. */
a61af66fc99e Initial load
duke
parents:
diff changeset
182 public boolean isInReserved(Address p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 return reserved().contains(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 protected VirtualSpace virtualSpace() {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 return (VirtualSpace) VMObjectFactory.newObject(VirtualSpace.class, addr.addOffsetTo(virtualSpaceFieldOffset));
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 public abstract String name();
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 /** Equivalent to spaceIterate(blk, false) */
a61af66fc99e Initial load
duke
parents:
diff changeset
193 public void spaceIterate(SpaceClosure blk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 spaceIterate(blk, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 /** Iteration - do not use for time critical operations */
a61af66fc99e Initial load
duke
parents:
diff changeset
198 public abstract void spaceIterate(SpaceClosure blk, boolean usedOnly);
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 public void print() { printOn(System.out); }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 public abstract void printOn(PrintStream tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 public static class StatRecord extends VMObject {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 public StatRecord(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 super(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
206 }
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 public int getInvocations() {
a61af66fc99e Initial load
duke
parents:
diff changeset
209 return (int) invocationField.getValue(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 private StatRecord getStatRecord() {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 return (StatRecord) VMObjectFactory.newObject(Generation.StatRecord.class, addr.addOffsetTo(statRecordField.getOffset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }