annotate agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java @ 2376:c7f3d0b4570f

7017732: move static fields into Class to prepare for perm gen removal Reviewed-by: kvn, coleenp, twisti, stefank
author never
date Fri, 18 Mar 2011 16:00:34 -0700
parents 0a8e0d4345b3
children 63997f575155
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2376
c7f3d0b4570f 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 2042
diff changeset
2 * Copyright (c) 2000, 2011, 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: 844
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
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: 844
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.runtime;
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.net.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import java.util.regex.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.code.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.c1.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.interpreter.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import sun.jvm.hotspot.memory.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 import sun.jvm.hotspot.utilities.*;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
39 import sun.jvm.hotspot.runtime.*;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 /** <P> This class encapsulates the global state of the VM; the
a61af66fc99e Initial load
duke
parents:
diff changeset
42 universe, object heap, interpreter, etc. It is a Singleton and
a61af66fc99e Initial load
duke
parents:
diff changeset
43 must be initialized with a call to initialize() before calling
a61af66fc99e Initial load
duke
parents:
diff changeset
44 getVM(). </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 <P> Many auxiliary classes (i.e., most of the VMObjects) keep
a61af66fc99e Initial load
duke
parents:
diff changeset
47 needed field offsets in the form of static Field objects. In a
a61af66fc99e Initial load
duke
parents:
diff changeset
48 debugging system, the VM might be shutdown and re-initialized (on
a61af66fc99e Initial load
duke
parents:
diff changeset
49 a differently-configured build, i.e., 32- vs. 64-bit), and all old
a61af66fc99e Initial load
duke
parents:
diff changeset
50 cached state (including fields and field offsets) must be
a61af66fc99e Initial load
duke
parents:
diff changeset
51 flushed. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 <P> An Observer pattern is used to implement the initialization of
a61af66fc99e Initial load
duke
parents:
diff changeset
54 such classes. Each such class, in its static initializer,
a61af66fc99e Initial load
duke
parents:
diff changeset
55 registers an Observer with the VM class via
a61af66fc99e Initial load
duke
parents:
diff changeset
56 VM.registerVMInitializedObserver(). This Observer is guaranteed to
a61af66fc99e Initial load
duke
parents:
diff changeset
57 be notified whenever the VM is initialized (or re-initialized). To
a61af66fc99e Initial load
duke
parents:
diff changeset
58 implement the first-time initialization, the observer is also
a61af66fc99e Initial load
duke
parents:
diff changeset
59 notified when it registers itself with the VM. (For bootstrapping
a61af66fc99e Initial load
duke
parents:
diff changeset
60 reasons, this implies that the constructor of VM can not
a61af66fc99e Initial load
duke
parents:
diff changeset
61 instantiate any such objects, since VM.soleInstance will not have
a61af66fc99e Initial load
duke
parents:
diff changeset
62 been set yet. This is a bootstrapping issue which may have to be
a61af66fc99e Initial load
duke
parents:
diff changeset
63 revisited later.) </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
64 */
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 public class VM {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 private static VM soleInstance;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 private static List vmInitializedObservers = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
69 private List vmResumedObservers = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
70 private List vmSuspendedObservers = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
71 private TypeDataBase db;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 private boolean isBigEndian;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 /** This is only present if in a debugging system */
a61af66fc99e Initial load
duke
parents:
diff changeset
74 private JVMDebugger debugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 private long stackBias;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 private long logAddressSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 private Universe universe;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 private ObjectHeap heap;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 private SymbolTable symbols;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 private StringTable strings;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 private SystemDictionary dict;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 private Threads threads;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 private ObjectSynchronizer synchronizer;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 private JNIHandles handles;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 private Interpreter interpreter;
a61af66fc99e Initial load
duke
parents:
diff changeset
86 private StubRoutines stubRoutines;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 private Bytes bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 /** Flags indicating whether we are attached to a core, C1, or C2 build */
a61af66fc99e Initial load
duke
parents:
diff changeset
89 private boolean usingClientCompiler;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 private boolean usingServerCompiler;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 /** Flag indicating whether UseTLAB is turned on */
a61af66fc99e Initial load
duke
parents:
diff changeset
92 private boolean useTLAB;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 /** alignment constants */
a61af66fc99e Initial load
duke
parents:
diff changeset
94 private boolean isLP64;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 private int bytesPerLong;
1571
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
96 private int objectAlignmentInBytes;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
97 private int minObjAlignmentInBytes;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
98 private int logMinObjAlignmentInBytes;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
99 private int heapWordSize;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
100 private int heapOopSize;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
101 private int oopSize;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
102 /** This is only present in a non-core build */
a61af66fc99e Initial load
duke
parents:
diff changeset
103 private CodeCache codeCache;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 /** This is only present in a C1 build */
a61af66fc99e Initial load
duke
parents:
diff changeset
105 private Runtime1 runtime1;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 /** These constants come from globalDefinitions.hpp */
a61af66fc99e Initial load
duke
parents:
diff changeset
107 private int invocationEntryBCI;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 private int invalidOSREntryBCI;
a61af66fc99e Initial load
duke
parents:
diff changeset
109 private ReversePtrs revPtrs;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 private VMRegImpl vmregImpl;
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // System.getProperties from debuggee VM
a61af66fc99e Initial load
duke
parents:
diff changeset
113 private Properties sysProps;
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // VM version strings come from Abstract_VM_Version class
a61af66fc99e Initial load
duke
parents:
diff changeset
116 private String vmRelease;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 private String vmInternalInfo;
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 private Flag[] commandLineFlags;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 private Map flagsMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 private static Type intxType;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 private static Type uintxType;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 private static CIntegerType boolType;
a61af66fc99e Initial load
duke
parents:
diff changeset
125 private Boolean sharingEnabled;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
126 private Boolean compressedOopsEnabled;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // command line flags supplied to VM - see struct Flag in globals.hpp
a61af66fc99e Initial load
duke
parents:
diff changeset
129 public static final class Flag {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 private String type;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 private String name;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 private Address addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 private String kind;
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 private Flag(String type, String name, Address addr, String kind) {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 this.type = type;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 this.name = name;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 this.addr = addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 this.kind = kind;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 public String getType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 return type;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 public String getName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 return name;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 public Address getAddress() {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 return addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 public String getKind() {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 return kind;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 public boolean isBool() {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 return type.equals("bool");
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 public boolean getBool() {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 Assert.that(isBool(), "not a bool flag!");
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166 return addr.getCIntegerAt(0, boolType.getSize(), boolType.isUnsigned())
a61af66fc99e Initial load
duke
parents:
diff changeset
167 != 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 public boolean isIntx() {
a61af66fc99e Initial load
duke
parents:
diff changeset
171 return type.equals("intx");
a61af66fc99e Initial load
duke
parents:
diff changeset
172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 public long getIntx() {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 Assert.that(isIntx(), "not a intx flag!");
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178 return addr.getCIntegerAt(0, intxType.getSize(), false);
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 public boolean isUIntx() {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 return type.equals("uintx");
a61af66fc99e Initial load
duke
parents:
diff changeset
183 }
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 public long getUIntx() {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 Assert.that(isUIntx(), "not a uintx flag!");
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 return addr.getCIntegerAt(0, uintxType.getSize(), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 public String getValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 if (isBool()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 return new Boolean(getBool()).toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
195 } else if (isIntx()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 return new Long(getIntx()).toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
197 } else if (isUIntx()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
198 return new Long(getUIntx()).toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
199 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203 };
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 private static void checkVMVersion(String vmRelease) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 if (System.getProperty("sun.jvm.hotspot.runtime.VM.disableVersionCheck") == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // read sa build version.
a61af66fc99e Initial load
duke
parents:
diff changeset
208 String versionProp = "sun.jvm.hotspot.runtime.VM.saBuildVersion";
a61af66fc99e Initial load
duke
parents:
diff changeset
209 String saVersion = saProps.getProperty(versionProp);
a61af66fc99e Initial load
duke
parents:
diff changeset
210 if (saVersion == null)
a61af66fc99e Initial load
duke
parents:
diff changeset
211 throw new RuntimeException("Missing property " + versionProp);
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // Strip nonproduct VM version substring (note: saVersion doesn't have it).
a61af66fc99e Initial load
duke
parents:
diff changeset
214 String vmVersion = vmRelease.replaceAll("(-fastdebug)|(-debug)|(-jvmg)|(-optimized)|(-profiled)","");
a61af66fc99e Initial load
duke
parents:
diff changeset
215
a61af66fc99e Initial load
duke
parents:
diff changeset
216 if (saVersion.equals(vmVersion)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // Exact match
a61af66fc99e Initial load
duke
parents:
diff changeset
218 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220 if (saVersion.indexOf('-') == saVersion.lastIndexOf('-') &&
a61af66fc99e Initial load
duke
parents:
diff changeset
221 vmVersion.indexOf('-') == vmVersion.lastIndexOf('-')) {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 // Throw exception if different release versions:
a61af66fc99e Initial load
duke
parents:
diff changeset
223 // <major>.<minor>-b<n>
a61af66fc99e Initial load
duke
parents:
diff changeset
224 throw new VMVersionMismatchException(saVersion, vmRelease);
a61af66fc99e Initial load
duke
parents:
diff changeset
225 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // Otherwise print warning to allow mismatch not release versions
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // during development.
a61af66fc99e Initial load
duke
parents:
diff changeset
228 System.err.println("WARNING: Hotspot VM version " + vmRelease +
a61af66fc99e Initial load
duke
parents:
diff changeset
229 " does not match with SA version " + saVersion +
a61af66fc99e Initial load
duke
parents:
diff changeset
230 "." + " You may see unexpected results. ");
a61af66fc99e Initial load
duke
parents:
diff changeset
231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
232 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 System.err.println("WARNING: You have disabled SA and VM version check. You may be " +
a61af66fc99e Initial load
duke
parents:
diff changeset
234 "using incompatible version of SA and you may see unexpected " +
a61af66fc99e Initial load
duke
parents:
diff changeset
235 "results.");
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 private static final boolean disableDerivedPrinterTableCheck;
a61af66fc99e Initial load
duke
parents:
diff changeset
240 private static final Properties saProps;
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
243 saProps = new Properties();
a61af66fc99e Initial load
duke
parents:
diff changeset
244 URL url = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
245 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 url = VM.class.getClassLoader().getResource("sa.properties");
a61af66fc99e Initial load
duke
parents:
diff changeset
247 saProps.load(new BufferedInputStream(url.openStream()));
a61af66fc99e Initial load
duke
parents:
diff changeset
248 } catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 throw new RuntimeException("Unable to load properties " +
a61af66fc99e Initial load
duke
parents:
diff changeset
250 (url == null ? "null" : url.toString()) +
a61af66fc99e Initial load
duke
parents:
diff changeset
251 ": " + e.getMessage());
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 disableDerivedPrinterTableCheck = System.getProperty("sun.jvm.hotspot.runtime.VM.disableDerivedPointerTableCheck") != null;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
256
a61af66fc99e Initial load
duke
parents:
diff changeset
257 private VM(TypeDataBase db, JVMDebugger debugger, boolean isBigEndian) {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 this.db = db;
a61af66fc99e Initial load
duke
parents:
diff changeset
259 this.debugger = debugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
260 this.isBigEndian = isBigEndian;
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // Note that we don't construct universe, heap, threads,
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // interpreter, or stubRoutines here (any more). The current
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // initialization mechanisms require that the VM be completely set
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // up (i.e., out of its constructor, with soleInstance assigned)
a61af66fc99e Initial load
duke
parents:
diff changeset
266 // before their static initializers are run.
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 if (db.getAddressSize() == 4) {
a61af66fc99e Initial load
duke
parents:
diff changeset
269 logAddressSize = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
270 } else if (db.getAddressSize() == 8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 logAddressSize = 3;
a61af66fc99e Initial load
duke
parents:
diff changeset
272 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
273 throw new RuntimeException("Address size " + db.getAddressSize() + " not yet supported");
a61af66fc99e Initial load
duke
parents:
diff changeset
274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276 // read VM version info
a61af66fc99e Initial load
duke
parents:
diff changeset
277 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 Type vmVersion = db.lookupType("Abstract_VM_Version");
a61af66fc99e Initial load
duke
parents:
diff changeset
279 Address releaseAddr = vmVersion.getAddressField("_s_vm_release").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
280 vmRelease = CStringUtilities.getString(releaseAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
281 Address vmInternalInfoAddr = vmVersion.getAddressField("_s_internal_vm_info_string").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
282 vmInternalInfo = CStringUtilities.getString(vmInternalInfoAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
283 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 throw new RuntimeException("can't determine target's VM version : " + exp.getMessage());
a61af66fc99e Initial load
duke
parents:
diff changeset
285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 checkVMVersion(vmRelease);
a61af66fc99e Initial load
duke
parents:
diff changeset
288
a61af66fc99e Initial load
duke
parents:
diff changeset
289 stackBias = db.lookupIntConstant("STACK_BIAS").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
290 invocationEntryBCI = db.lookupIntConstant("InvocationEntryBci").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
291 invalidOSREntryBCI = db.lookupIntConstant("InvalidOSREntryBci").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
292
a61af66fc99e Initial load
duke
parents:
diff changeset
293 // We infer the presence of C1 or C2 from a couple of fields we
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // already have present in the type database
a61af66fc99e Initial load
duke
parents:
diff changeset
295 {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 Type type = db.lookupType("methodOopDesc");
a61af66fc99e Initial load
duke
parents:
diff changeset
297 if (type.getField("_from_compiled_entry", false, false) == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // Neither C1 nor C2 is present
a61af66fc99e Initial load
duke
parents:
diff changeset
299 usingClientCompiler = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
300 usingServerCompiler = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
301 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 // Determine whether C2 is present
a61af66fc99e Initial load
duke
parents:
diff changeset
303 if (type.getField("_interpreter_invocation_count", false, false) != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
304 usingServerCompiler = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
305 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
306 usingClientCompiler = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
308 }
a61af66fc99e Initial load
duke
parents:
diff changeset
309 }
a61af66fc99e Initial load
duke
parents:
diff changeset
310
a61af66fc99e Initial load
duke
parents:
diff changeset
311 useTLAB = (db.lookupIntConstant("UseTLAB").intValue() != 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 if (debugger != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
314 isLP64 = debugger.getMachineDescription().isLP64();
a61af66fc99e Initial load
duke
parents:
diff changeset
315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
316 bytesPerLong = db.lookupIntConstant("BytesPerLong").intValue();
1576
4a2e260bb13a 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 1571
diff changeset
317 heapWordSize = db.lookupIntConstant("HeapWordSize").intValue();
4a2e260bb13a 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 1571
diff changeset
318 oopSize = db.lookupIntConstant("oopSize").intValue();
4a2e260bb13a 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 1571
diff changeset
319
4a2e260bb13a 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 1571
diff changeset
320 intxType = db.lookupType("intx");
4a2e260bb13a 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 1571
diff changeset
321 uintxType = db.lookupType("uintx");
4a2e260bb13a 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 1571
diff changeset
322 boolType = (CIntegerType) db.lookupType("bool");
4a2e260bb13a 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 1571
diff changeset
323
1571
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
324 minObjAlignmentInBytes = getObjectAlignmentInBytes();
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
325 if (minObjAlignmentInBytes == 8) {
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
326 logMinObjAlignmentInBytes = 3;
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
327 } else if (minObjAlignmentInBytes == 16) {
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
328 logMinObjAlignmentInBytes = 4;
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
329 } else {
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
330 throw new RuntimeException("Object alignment " + minObjAlignmentInBytes + " not yet supported");
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
331 }
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
332
749
81a249214991 6829234: Refix 6822407 and 6812971
poonam
parents: 692
diff changeset
333 if (isCompressedOopsEnabled()) {
81a249214991 6829234: Refix 6822407 and 6812971
poonam
parents: 692
diff changeset
334 // Size info for oops within java objects is fixed
81a249214991 6829234: Refix 6822407 and 6812971
poonam
parents: 692
diff changeset
335 heapOopSize = (int)getIntSize();
81a249214991 6829234: Refix 6822407 and 6812971
poonam
parents: 692
diff changeset
336 } else {
81a249214991 6829234: Refix 6822407 and 6812971
poonam
parents: 692
diff changeset
337 heapOopSize = (int)getOopSize();
81a249214991 6829234: Refix 6822407 and 6812971
poonam
parents: 692
diff changeset
338 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
339 }
a61af66fc99e Initial load
duke
parents:
diff changeset
340
a61af66fc99e Initial load
duke
parents:
diff changeset
341 /** This could be used by a reflective runtime system */
a61af66fc99e Initial load
duke
parents:
diff changeset
342 public static void initialize(TypeDataBase db, boolean isBigEndian) {
a61af66fc99e Initial load
duke
parents:
diff changeset
343 if (soleInstance != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 throw new RuntimeException("Attempt to initialize VM twice");
a61af66fc99e Initial load
duke
parents:
diff changeset
345 }
a61af66fc99e Initial load
duke
parents:
diff changeset
346 soleInstance = new VM(db, null, isBigEndian);
a61af66fc99e Initial load
duke
parents:
diff changeset
347 for (Iterator iter = vmInitializedObservers.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
348 ((Observer) iter.next()).update(null, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
349 }
a61af66fc99e Initial load
duke
parents:
diff changeset
350 }
a61af66fc99e Initial load
duke
parents:
diff changeset
351
a61af66fc99e Initial load
duke
parents:
diff changeset
352 /** This is used by the debugging system */
a61af66fc99e Initial load
duke
parents:
diff changeset
353 public static void initialize(TypeDataBase db, JVMDebugger debugger) {
a61af66fc99e Initial load
duke
parents:
diff changeset
354 if (soleInstance != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
355 throw new RuntimeException("Attempt to initialize VM twice");
a61af66fc99e Initial load
duke
parents:
diff changeset
356 }
a61af66fc99e Initial load
duke
parents:
diff changeset
357 soleInstance = new VM(db, debugger, debugger.getMachineDescription().isBigEndian());
689
f30ba3b36599 6822407: heapOopSize lookup is incorrect in Serviceability Agent.
poonam
parents: 655
diff changeset
358
0
a61af66fc99e Initial load
duke
parents:
diff changeset
359 for (Iterator iter = vmInitializedObservers.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
360 ((Observer) iter.next()).update(null, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
361 }
650
54782a4cd321 6812971: SA: re-attaching to process fails
poonam
parents: 331
diff changeset
362
749
81a249214991 6829234: Refix 6822407 and 6812971
poonam
parents: 692
diff changeset
363 debugger.putHeapConst(soleInstance.getHeapOopSize(), Universe.getNarrowOopBase(),
81a249214991 6829234: Refix 6822407 and 6812971
poonam
parents: 692
diff changeset
364 Universe.getNarrowOopShift());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
365 }
a61af66fc99e Initial load
duke
parents:
diff changeset
366
a61af66fc99e Initial load
duke
parents:
diff changeset
367 /** This is used by the debugging system */
a61af66fc99e Initial load
duke
parents:
diff changeset
368 public static void shutdown() {
a61af66fc99e Initial load
duke
parents:
diff changeset
369 soleInstance = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
370 }
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 /** This is used by both the debugger and any runtime system. It is
a61af66fc99e Initial load
duke
parents:
diff changeset
373 the basic mechanism by which classes which mimic underlying VM
a61af66fc99e Initial load
duke
parents:
diff changeset
374 functionality cause themselves to be initialized. The given
a61af66fc99e Initial load
duke
parents:
diff changeset
375 observer will be notified (with arguments (null, null)) when the
a61af66fc99e Initial load
duke
parents:
diff changeset
376 VM is re-initialized, as well as when it registers itself with
a61af66fc99e Initial load
duke
parents:
diff changeset
377 the VM. */
a61af66fc99e Initial load
duke
parents:
diff changeset
378 public static void registerVMInitializedObserver(Observer o) {
a61af66fc99e Initial load
duke
parents:
diff changeset
379 vmInitializedObservers.add(o);
a61af66fc99e Initial load
duke
parents:
diff changeset
380 o.update(null, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
381 }
a61af66fc99e Initial load
duke
parents:
diff changeset
382
a61af66fc99e Initial load
duke
parents:
diff changeset
383 /** This is the primary accessor used by both the debugger and any
a61af66fc99e Initial load
duke
parents:
diff changeset
384 potential runtime system */
a61af66fc99e Initial load
duke
parents:
diff changeset
385 public static VM getVM() {
a61af66fc99e Initial load
duke
parents:
diff changeset
386 if (soleInstance == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
387 throw new RuntimeException("VM.initialize() was not yet called");
a61af66fc99e Initial load
duke
parents:
diff changeset
388 }
a61af66fc99e Initial load
duke
parents:
diff changeset
389 return soleInstance;
a61af66fc99e Initial load
duke
parents:
diff changeset
390 }
a61af66fc99e Initial load
duke
parents:
diff changeset
391
a61af66fc99e Initial load
duke
parents:
diff changeset
392 /** This is only used by the debugging system. The given observer
a61af66fc99e Initial load
duke
parents:
diff changeset
393 will be notified if the underlying VM resumes execution. NOTE
a61af66fc99e Initial load
duke
parents:
diff changeset
394 that the given observer is not triggered if the VM is currently
a61af66fc99e Initial load
duke
parents:
diff changeset
395 running and therefore differs in behavior from {@link
a61af66fc99e Initial load
duke
parents:
diff changeset
396 #registerVMInitializedObserver} (because of the possibility of
a61af66fc99e Initial load
duke
parents:
diff changeset
397 race conditions if the observer is added while the VM is being
a61af66fc99e Initial load
duke
parents:
diff changeset
398 suspended or resumed). */
a61af66fc99e Initial load
duke
parents:
diff changeset
399 public void registerVMResumedObserver(Observer o) {
a61af66fc99e Initial load
duke
parents:
diff changeset
400 vmResumedObservers.add(o);
a61af66fc99e Initial load
duke
parents:
diff changeset
401 }
a61af66fc99e Initial load
duke
parents:
diff changeset
402
a61af66fc99e Initial load
duke
parents:
diff changeset
403 /** This is only used by the debugging system. The given observer
a61af66fc99e Initial load
duke
parents:
diff changeset
404 will be notified if the underlying VM suspends execution. NOTE
a61af66fc99e Initial load
duke
parents:
diff changeset
405 that the given observer is not triggered if the VM is currently
a61af66fc99e Initial load
duke
parents:
diff changeset
406 suspended and therefore differs in behavior from {@link
a61af66fc99e Initial load
duke
parents:
diff changeset
407 #registerVMInitializedObserver} (because of the possibility of
a61af66fc99e Initial load
duke
parents:
diff changeset
408 race conditions if the observer is added while the VM is being
a61af66fc99e Initial load
duke
parents:
diff changeset
409 suspended or resumed). */
a61af66fc99e Initial load
duke
parents:
diff changeset
410 public void registerVMSuspendedObserver(Observer o) {
a61af66fc99e Initial load
duke
parents:
diff changeset
411 vmSuspendedObservers.add(o);
a61af66fc99e Initial load
duke
parents:
diff changeset
412 }
a61af66fc99e Initial load
duke
parents:
diff changeset
413
a61af66fc99e Initial load
duke
parents:
diff changeset
414 /** This is only used by the debugging system. Informs all
a61af66fc99e Initial load
duke
parents:
diff changeset
415 registered resumption observers that the VM has been resumed.
a61af66fc99e Initial load
duke
parents:
diff changeset
416 The application is responsible for actually having performed the
a61af66fc99e Initial load
duke
parents:
diff changeset
417 resumption. No OopHandles must be used after this point, as they
a61af66fc99e Initial load
duke
parents:
diff changeset
418 may move in the target address space due to garbage
a61af66fc99e Initial load
duke
parents:
diff changeset
419 collection. */
a61af66fc99e Initial load
duke
parents:
diff changeset
420 public void fireVMResumed() {
a61af66fc99e Initial load
duke
parents:
diff changeset
421 for (Iterator iter = vmResumedObservers.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
422 ((Observer) iter.next()).update(null, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
423 }
a61af66fc99e Initial load
duke
parents:
diff changeset
424 }
a61af66fc99e Initial load
duke
parents:
diff changeset
425
a61af66fc99e Initial load
duke
parents:
diff changeset
426 /** This is only used by the debugging system. Informs all
a61af66fc99e Initial load
duke
parents:
diff changeset
427 registered suspension observers that the VM has been suspended.
a61af66fc99e Initial load
duke
parents:
diff changeset
428 The application is responsible for actually having performed the
a61af66fc99e Initial load
duke
parents:
diff changeset
429 suspension. Garbage collection must be forbidden at this point;
a61af66fc99e Initial load
duke
parents:
diff changeset
430 for example, a JPDA-level suspension is not adequate since the
a61af66fc99e Initial load
duke
parents:
diff changeset
431 VM thread may still be running. */
a61af66fc99e Initial load
duke
parents:
diff changeset
432 public void fireVMSuspended() {
a61af66fc99e Initial load
duke
parents:
diff changeset
433 for (Iterator iter = vmSuspendedObservers.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
434 ((Observer) iter.next()).update(null, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
435 }
a61af66fc99e Initial load
duke
parents:
diff changeset
436 }
a61af66fc99e Initial load
duke
parents:
diff changeset
437
a61af66fc99e Initial load
duke
parents:
diff changeset
438 /** Returns the OS this VM is running on. Notice that by delegating
a61af66fc99e Initial load
duke
parents:
diff changeset
439 to the debugger we can transparently support remote
a61af66fc99e Initial load
duke
parents:
diff changeset
440 debugging. */
a61af66fc99e Initial load
duke
parents:
diff changeset
441 public String getOS() {
a61af66fc99e Initial load
duke
parents:
diff changeset
442 if (debugger != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
443 return debugger.getOS();
a61af66fc99e Initial load
duke
parents:
diff changeset
444 }
a61af66fc99e Initial load
duke
parents:
diff changeset
445 return PlatformInfo.getOS();
a61af66fc99e Initial load
duke
parents:
diff changeset
446 }
a61af66fc99e Initial load
duke
parents:
diff changeset
447
a61af66fc99e Initial load
duke
parents:
diff changeset
448 /** Returns the CPU this VM is running on. Notice that by delegating
a61af66fc99e Initial load
duke
parents:
diff changeset
449 to the debugger we can transparently support remote
a61af66fc99e Initial load
duke
parents:
diff changeset
450 debugging. */
a61af66fc99e Initial load
duke
parents:
diff changeset
451 public String getCPU() {
a61af66fc99e Initial load
duke
parents:
diff changeset
452 if (debugger != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
453 return debugger.getCPU();
a61af66fc99e Initial load
duke
parents:
diff changeset
454 }
a61af66fc99e Initial load
duke
parents:
diff changeset
455 return PlatformInfo.getCPU();
a61af66fc99e Initial load
duke
parents:
diff changeset
456 }
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 public Type lookupType(String cTypeName) {
a61af66fc99e Initial load
duke
parents:
diff changeset
459 return db.lookupType(cTypeName);
a61af66fc99e Initial load
duke
parents:
diff changeset
460 }
a61af66fc99e Initial load
duke
parents:
diff changeset
461
a61af66fc99e Initial load
duke
parents:
diff changeset
462 public Integer lookupIntConstant(String name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
463 return db.lookupIntConstant(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
464 }
a61af66fc99e Initial load
duke
parents:
diff changeset
465
a61af66fc99e Initial load
duke
parents:
diff changeset
466 public long getAddressSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
467 return db.getAddressSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
468 }
a61af66fc99e Initial load
duke
parents:
diff changeset
469
a61af66fc99e Initial load
duke
parents:
diff changeset
470 public long getOopSize() {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
471 return oopSize;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
472 }
a61af66fc99e Initial load
duke
parents:
diff changeset
473
a61af66fc99e Initial load
duke
parents:
diff changeset
474 public long getLogAddressSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
475 return logAddressSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
476 }
a61af66fc99e Initial load
duke
parents:
diff changeset
477
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
478 public long getIntSize() {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
479 return db.getJIntType().getSize();
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
480 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
481
0
a61af66fc99e Initial load
duke
parents:
diff changeset
482 /** NOTE: this offset is in BYTES in this system! */
a61af66fc99e Initial load
duke
parents:
diff changeset
483 public long getStackBias() {
a61af66fc99e Initial load
duke
parents:
diff changeset
484 return stackBias;
a61af66fc99e Initial load
duke
parents:
diff changeset
485 }
a61af66fc99e Initial load
duke
parents:
diff changeset
486
a61af66fc99e Initial load
duke
parents:
diff changeset
487 /** Indicates whether the underlying machine supports the LP64 data
a61af66fc99e Initial load
duke
parents:
diff changeset
488 model. This is needed for conditionalizing code in a few places */
a61af66fc99e Initial load
duke
parents:
diff changeset
489 public boolean isLP64() {
a61af66fc99e Initial load
duke
parents:
diff changeset
490 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
491 Assert.that(isDebugging(), "Debugging system only for now");
a61af66fc99e Initial load
duke
parents:
diff changeset
492 }
a61af66fc99e Initial load
duke
parents:
diff changeset
493 return isLP64;
a61af66fc99e Initial load
duke
parents:
diff changeset
494 }
a61af66fc99e Initial load
duke
parents:
diff changeset
495
a61af66fc99e Initial load
duke
parents:
diff changeset
496 /** Get bytes-per-long == long/double natural alignment. */
a61af66fc99e Initial load
duke
parents:
diff changeset
497 public int getBytesPerLong() {
a61af66fc99e Initial load
duke
parents:
diff changeset
498 return bytesPerLong;
a61af66fc99e Initial load
duke
parents:
diff changeset
499 }
a61af66fc99e Initial load
duke
parents:
diff changeset
500
a61af66fc99e Initial load
duke
parents:
diff changeset
501 /** Get minimum object alignment in bytes. */
a61af66fc99e Initial load
duke
parents:
diff changeset
502 public int getMinObjAlignmentInBytes() {
a61af66fc99e Initial load
duke
parents:
diff changeset
503 return minObjAlignmentInBytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
504 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
505 public int getLogMinObjAlignmentInBytes() {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
506 return logMinObjAlignmentInBytes;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
507 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
508
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
509 public int getHeapWordSize() {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
510 return heapWordSize;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
511 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
512
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
513 public int getHeapOopSize() {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
514 return heapOopSize;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
515 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
516 /** Utility routine for getting data structure alignment correct */
a61af66fc99e Initial load
duke
parents:
diff changeset
517 public long alignUp(long size, long alignment) {
a61af66fc99e Initial load
duke
parents:
diff changeset
518 return (size + alignment - 1) & ~(alignment - 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
519 }
a61af66fc99e Initial load
duke
parents:
diff changeset
520
a61af66fc99e Initial load
duke
parents:
diff changeset
521 /** Utility routine for getting data structure alignment correct */
a61af66fc99e Initial load
duke
parents:
diff changeset
522 public long alignDown(long size, long alignment) {
a61af66fc99e Initial load
duke
parents:
diff changeset
523 return size & ~(alignment - 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
524 }
a61af66fc99e Initial load
duke
parents:
diff changeset
525
a61af66fc99e Initial load
duke
parents:
diff changeset
526 /** Utility routine for building an int from two "unsigned" 16-bit
a61af66fc99e Initial load
duke
parents:
diff changeset
527 shorts */
a61af66fc99e Initial load
duke
parents:
diff changeset
528 public int buildIntFromShorts(short low, short high) {
a61af66fc99e Initial load
duke
parents:
diff changeset
529 return (((int) high) << 16) | (((int) low) & 0xFFFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
530 }
a61af66fc99e Initial load
duke
parents:
diff changeset
531
a61af66fc99e Initial load
duke
parents:
diff changeset
532 /** Utility routine for building a long from two "unsigned" 32-bit
a61af66fc99e Initial load
duke
parents:
diff changeset
533 ints in <b>platform-dependent</b> order */
a61af66fc99e Initial load
duke
parents:
diff changeset
534 public long buildLongFromIntsPD(int oneHalf, int otherHalf) {
a61af66fc99e Initial load
duke
parents:
diff changeset
535 if (isBigEndian) {
a61af66fc99e Initial load
duke
parents:
diff changeset
536 return (((long) otherHalf) << 32) | (((long) oneHalf) & 0x00000000FFFFFFFFL);
a61af66fc99e Initial load
duke
parents:
diff changeset
537 } else{
a61af66fc99e Initial load
duke
parents:
diff changeset
538 return (((long) oneHalf) << 32) | (((long) otherHalf) & 0x00000000FFFFFFFFL);
a61af66fc99e Initial load
duke
parents:
diff changeset
539 }
a61af66fc99e Initial load
duke
parents:
diff changeset
540 }
a61af66fc99e Initial load
duke
parents:
diff changeset
541
a61af66fc99e Initial load
duke
parents:
diff changeset
542 /** Indicates whether Thread-Local Allocation Buffers are used */
a61af66fc99e Initial load
duke
parents:
diff changeset
543 public boolean getUseTLAB() {
a61af66fc99e Initial load
duke
parents:
diff changeset
544 return useTLAB;
a61af66fc99e Initial load
duke
parents:
diff changeset
545 }
a61af66fc99e Initial load
duke
parents:
diff changeset
546
a61af66fc99e Initial load
duke
parents:
diff changeset
547 public TypeDataBase getTypeDataBase() {
a61af66fc99e Initial load
duke
parents:
diff changeset
548 return db;
a61af66fc99e Initial load
duke
parents:
diff changeset
549 }
a61af66fc99e Initial load
duke
parents:
diff changeset
550
a61af66fc99e Initial load
duke
parents:
diff changeset
551 public Universe getUniverse() {
a61af66fc99e Initial load
duke
parents:
diff changeset
552 if (universe == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
553 universe = new Universe();
a61af66fc99e Initial load
duke
parents:
diff changeset
554 }
a61af66fc99e Initial load
duke
parents:
diff changeset
555 return universe;
a61af66fc99e Initial load
duke
parents:
diff changeset
556 }
a61af66fc99e Initial load
duke
parents:
diff changeset
557
a61af66fc99e Initial load
duke
parents:
diff changeset
558 public ObjectHeap getObjectHeap() {
a61af66fc99e Initial load
duke
parents:
diff changeset
559 if (heap == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
560 heap = new ObjectHeap(db);
a61af66fc99e Initial load
duke
parents:
diff changeset
561 }
a61af66fc99e Initial load
duke
parents:
diff changeset
562 return heap;
a61af66fc99e Initial load
duke
parents:
diff changeset
563 }
a61af66fc99e Initial load
duke
parents:
diff changeset
564
a61af66fc99e Initial load
duke
parents:
diff changeset
565 public SymbolTable getSymbolTable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
566 if (symbols == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
567 symbols = SymbolTable.getTheTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
568 }
a61af66fc99e Initial load
duke
parents:
diff changeset
569 return symbols;
a61af66fc99e Initial load
duke
parents:
diff changeset
570 }
a61af66fc99e Initial load
duke
parents:
diff changeset
571
a61af66fc99e Initial load
duke
parents:
diff changeset
572 public StringTable getStringTable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
573 if (strings == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
574 strings = StringTable.getTheTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
575 }
a61af66fc99e Initial load
duke
parents:
diff changeset
576 return strings;
a61af66fc99e Initial load
duke
parents:
diff changeset
577 }
a61af66fc99e Initial load
duke
parents:
diff changeset
578
a61af66fc99e Initial load
duke
parents:
diff changeset
579 public SystemDictionary getSystemDictionary() {
a61af66fc99e Initial load
duke
parents:
diff changeset
580 if (dict == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
581 dict = new SystemDictionary();
a61af66fc99e Initial load
duke
parents:
diff changeset
582 }
a61af66fc99e Initial load
duke
parents:
diff changeset
583 return dict;
a61af66fc99e Initial load
duke
parents:
diff changeset
584 }
a61af66fc99e Initial load
duke
parents:
diff changeset
585
a61af66fc99e Initial load
duke
parents:
diff changeset
586 public Threads getThreads() {
a61af66fc99e Initial load
duke
parents:
diff changeset
587 if (threads == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
588 threads = new Threads();
a61af66fc99e Initial load
duke
parents:
diff changeset
589 }
a61af66fc99e Initial load
duke
parents:
diff changeset
590 return threads;
a61af66fc99e Initial load
duke
parents:
diff changeset
591 }
a61af66fc99e Initial load
duke
parents:
diff changeset
592
a61af66fc99e Initial load
duke
parents:
diff changeset
593 public ObjectSynchronizer getObjectSynchronizer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
594 if (synchronizer == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
595 synchronizer = new ObjectSynchronizer();
a61af66fc99e Initial load
duke
parents:
diff changeset
596 }
a61af66fc99e Initial load
duke
parents:
diff changeset
597 return synchronizer;
a61af66fc99e Initial load
duke
parents:
diff changeset
598 }
a61af66fc99e Initial load
duke
parents:
diff changeset
599
a61af66fc99e Initial load
duke
parents:
diff changeset
600 public JNIHandles getJNIHandles() {
a61af66fc99e Initial load
duke
parents:
diff changeset
601 if (handles == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
602 handles = new JNIHandles();
a61af66fc99e Initial load
duke
parents:
diff changeset
603 }
a61af66fc99e Initial load
duke
parents:
diff changeset
604 return handles;
a61af66fc99e Initial load
duke
parents:
diff changeset
605 }
a61af66fc99e Initial load
duke
parents:
diff changeset
606
a61af66fc99e Initial load
duke
parents:
diff changeset
607 public Interpreter getInterpreter() {
a61af66fc99e Initial load
duke
parents:
diff changeset
608 if (interpreter == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
609 interpreter = new Interpreter();
a61af66fc99e Initial load
duke
parents:
diff changeset
610 }
a61af66fc99e Initial load
duke
parents:
diff changeset
611 return interpreter;
a61af66fc99e Initial load
duke
parents:
diff changeset
612 }
a61af66fc99e Initial load
duke
parents:
diff changeset
613
a61af66fc99e Initial load
duke
parents:
diff changeset
614 public StubRoutines getStubRoutines() {
a61af66fc99e Initial load
duke
parents:
diff changeset
615 if (stubRoutines == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
616 stubRoutines = new StubRoutines();
a61af66fc99e Initial load
duke
parents:
diff changeset
617 }
a61af66fc99e Initial load
duke
parents:
diff changeset
618 return stubRoutines;
a61af66fc99e Initial load
duke
parents:
diff changeset
619 }
a61af66fc99e Initial load
duke
parents:
diff changeset
620
a61af66fc99e Initial load
duke
parents:
diff changeset
621 public VMRegImpl getVMRegImplInfo() {
a61af66fc99e Initial load
duke
parents:
diff changeset
622 if (vmregImpl == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
623 vmregImpl = new VMRegImpl();
a61af66fc99e Initial load
duke
parents:
diff changeset
624 }
a61af66fc99e Initial load
duke
parents:
diff changeset
625 return vmregImpl;
a61af66fc99e Initial load
duke
parents:
diff changeset
626 }
a61af66fc99e Initial load
duke
parents:
diff changeset
627
a61af66fc99e Initial load
duke
parents:
diff changeset
628 public Bytes getBytes() {
a61af66fc99e Initial load
duke
parents:
diff changeset
629 if (bytes == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
630 bytes = new Bytes(debugger.getMachineDescription());
a61af66fc99e Initial load
duke
parents:
diff changeset
631 }
a61af66fc99e Initial load
duke
parents:
diff changeset
632 return bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
633 }
a61af66fc99e Initial load
duke
parents:
diff changeset
634
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 196
diff changeset
635 /** Returns true if this is a isBigEndian, false otherwise */
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 196
diff changeset
636 public boolean isBigEndian() {
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 196
diff changeset
637 return isBigEndian;
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 196
diff changeset
638 }
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 196
diff changeset
639
0
a61af66fc99e Initial load
duke
parents:
diff changeset
640 /** Returns true if this is a "core" build, false if either C1 or C2
a61af66fc99e Initial load
duke
parents:
diff changeset
641 is present */
a61af66fc99e Initial load
duke
parents:
diff changeset
642 public boolean isCore() {
a61af66fc99e Initial load
duke
parents:
diff changeset
643 return (!(usingClientCompiler || usingServerCompiler));
a61af66fc99e Initial load
duke
parents:
diff changeset
644 }
a61af66fc99e Initial load
duke
parents:
diff changeset
645
a61af66fc99e Initial load
duke
parents:
diff changeset
646 /** Returns true if this is a C1 build, false otherwise */
a61af66fc99e Initial load
duke
parents:
diff changeset
647 public boolean isClientCompiler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
648 return usingClientCompiler;
a61af66fc99e Initial load
duke
parents:
diff changeset
649 }
a61af66fc99e Initial load
duke
parents:
diff changeset
650
a61af66fc99e Initial load
duke
parents:
diff changeset
651 /** Returns true if this is a C2 build, false otherwise */
a61af66fc99e Initial load
duke
parents:
diff changeset
652 public boolean isServerCompiler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
653 return usingServerCompiler;
a61af66fc99e Initial load
duke
parents:
diff changeset
654 }
a61af66fc99e Initial load
duke
parents:
diff changeset
655
a61af66fc99e Initial load
duke
parents:
diff changeset
656 /** Returns true if C2 derived pointer table should be used, false otherwise */
a61af66fc99e Initial load
duke
parents:
diff changeset
657 public boolean useDerivedPointerTable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
658 return !disableDerivedPrinterTableCheck;
a61af66fc99e Initial load
duke
parents:
diff changeset
659 }
a61af66fc99e Initial load
duke
parents:
diff changeset
660
a61af66fc99e Initial load
duke
parents:
diff changeset
661 /** Returns the code cache; should not be used if is core build */
a61af66fc99e Initial load
duke
parents:
diff changeset
662 public CodeCache getCodeCache() {
a61af66fc99e Initial load
duke
parents:
diff changeset
663 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
664 Assert.that(!isCore(), "noncore builds only");
a61af66fc99e Initial load
duke
parents:
diff changeset
665 }
a61af66fc99e Initial load
duke
parents:
diff changeset
666 if (codeCache == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
667 codeCache = new CodeCache();
a61af66fc99e Initial load
duke
parents:
diff changeset
668 }
a61af66fc99e Initial load
duke
parents:
diff changeset
669 return codeCache;
a61af66fc99e Initial load
duke
parents:
diff changeset
670 }
a61af66fc99e Initial load
duke
parents:
diff changeset
671
a61af66fc99e Initial load
duke
parents:
diff changeset
672 /** Should only be called for C1 builds */
a61af66fc99e Initial load
duke
parents:
diff changeset
673 public Runtime1 getRuntime1() {
a61af66fc99e Initial load
duke
parents:
diff changeset
674 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
675 Assert.that(isClientCompiler(), "C1 builds only");
a61af66fc99e Initial load
duke
parents:
diff changeset
676 }
a61af66fc99e Initial load
duke
parents:
diff changeset
677 if (runtime1 == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
678 runtime1 = new Runtime1();
a61af66fc99e Initial load
duke
parents:
diff changeset
679 }
a61af66fc99e Initial load
duke
parents:
diff changeset
680 return runtime1;
a61af66fc99e Initial load
duke
parents:
diff changeset
681 }
a61af66fc99e Initial load
duke
parents:
diff changeset
682
a61af66fc99e Initial load
duke
parents:
diff changeset
683 /** Test to see whether we're in debugging mode (NOTE: this really
a61af66fc99e Initial load
duke
parents:
diff changeset
684 should not be tested by this code; currently only used in
a61af66fc99e Initial load
duke
parents:
diff changeset
685 StackFrameStream) */
a61af66fc99e Initial load
duke
parents:
diff changeset
686 public boolean isDebugging() {
a61af66fc99e Initial load
duke
parents:
diff changeset
687 return (debugger != null);
a61af66fc99e Initial load
duke
parents:
diff changeset
688 }
a61af66fc99e Initial load
duke
parents:
diff changeset
689
a61af66fc99e Initial load
duke
parents:
diff changeset
690 /** This is only used by the debugging (i.e., non-runtime) system */
a61af66fc99e Initial load
duke
parents:
diff changeset
691 public JVMDebugger getDebugger() {
a61af66fc99e Initial load
duke
parents:
diff changeset
692 if (debugger == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
693 throw new RuntimeException("Attempt to use debugger in runtime system");
a61af66fc99e Initial load
duke
parents:
diff changeset
694 }
a61af66fc99e Initial load
duke
parents:
diff changeset
695 return debugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
696 }
a61af66fc99e Initial load
duke
parents:
diff changeset
697
a61af66fc99e Initial load
duke
parents:
diff changeset
698 /** Indicates whether a given program counter is in Java code. This
a61af66fc99e Initial load
duke
parents:
diff changeset
699 includes but is not spanned by the interpreter and code cache.
a61af66fc99e Initial load
duke
parents:
diff changeset
700 Only used in the debugging system, for implementing
a61af66fc99e Initial load
duke
parents:
diff changeset
701 JavaThread.currentFrameGuess() on x86. */
a61af66fc99e Initial load
duke
parents:
diff changeset
702 public boolean isJavaPCDbg(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
703 // FIXME: this is not a complete enough set: must include areas
a61af66fc99e Initial load
duke
parents:
diff changeset
704 // like vtable stubs
a61af66fc99e Initial load
duke
parents:
diff changeset
705 return (getInterpreter().contains(addr) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
706 getCodeCache().contains(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
707 }
a61af66fc99e Initial load
duke
parents:
diff changeset
708
a61af66fc99e Initial load
duke
parents:
diff changeset
709 /** FIXME: figure out where to stick this */
a61af66fc99e Initial load
duke
parents:
diff changeset
710 public int getInvocationEntryBCI() {
a61af66fc99e Initial load
duke
parents:
diff changeset
711 return invocationEntryBCI;
a61af66fc99e Initial load
duke
parents:
diff changeset
712 }
a61af66fc99e Initial load
duke
parents:
diff changeset
713
a61af66fc99e Initial load
duke
parents:
diff changeset
714 /** FIXME: figure out where to stick this */
a61af66fc99e Initial load
duke
parents:
diff changeset
715 public int getInvalidOSREntryBCI() {
a61af66fc99e Initial load
duke
parents:
diff changeset
716 return invalidOSREntryBCI;
a61af66fc99e Initial load
duke
parents:
diff changeset
717 }
a61af66fc99e Initial load
duke
parents:
diff changeset
718
a61af66fc99e Initial load
duke
parents:
diff changeset
719 // FIXME: figure out where to stick this
a61af66fc99e Initial load
duke
parents:
diff changeset
720 public boolean wizardMode() {
a61af66fc99e Initial load
duke
parents:
diff changeset
721 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
722 }
a61af66fc99e Initial load
duke
parents:
diff changeset
723
a61af66fc99e Initial load
duke
parents:
diff changeset
724 public ReversePtrs getRevPtrs() {
a61af66fc99e Initial load
duke
parents:
diff changeset
725 return revPtrs;
a61af66fc99e Initial load
duke
parents:
diff changeset
726 }
a61af66fc99e Initial load
duke
parents:
diff changeset
727
a61af66fc99e Initial load
duke
parents:
diff changeset
728 public void setRevPtrs(ReversePtrs rp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
729 revPtrs = rp;
a61af66fc99e Initial load
duke
parents:
diff changeset
730 }
a61af66fc99e Initial load
duke
parents:
diff changeset
731
a61af66fc99e Initial load
duke
parents:
diff changeset
732 // returns null, if not available.
a61af66fc99e Initial load
duke
parents:
diff changeset
733 public String getVMRelease() {
a61af66fc99e Initial load
duke
parents:
diff changeset
734 return vmRelease;
a61af66fc99e Initial load
duke
parents:
diff changeset
735 }
a61af66fc99e Initial load
duke
parents:
diff changeset
736
a61af66fc99e Initial load
duke
parents:
diff changeset
737 // returns null, if not available.
a61af66fc99e Initial load
duke
parents:
diff changeset
738 public String getVMInternalInfo() {
a61af66fc99e Initial load
duke
parents:
diff changeset
739 return vmInternalInfo;
a61af66fc99e Initial load
duke
parents:
diff changeset
740 }
a61af66fc99e Initial load
duke
parents:
diff changeset
741
a61af66fc99e Initial load
duke
parents:
diff changeset
742 public boolean isSharingEnabled() {
a61af66fc99e Initial load
duke
parents:
diff changeset
743 if (sharingEnabled == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
744 Flag flag = getCommandLineFlag("UseSharedSpaces");
a61af66fc99e Initial load
duke
parents:
diff changeset
745 sharingEnabled = (flag == null)? Boolean.FALSE :
a61af66fc99e Initial load
duke
parents:
diff changeset
746 (flag.getBool()? Boolean.TRUE: Boolean.FALSE);
a61af66fc99e Initial load
duke
parents:
diff changeset
747 }
a61af66fc99e Initial load
duke
parents:
diff changeset
748 return sharingEnabled.booleanValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
749 }
a61af66fc99e Initial load
duke
parents:
diff changeset
750
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
751 public boolean isCompressedOopsEnabled() {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
752 if (compressedOopsEnabled == null) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
753 Flag flag = getCommandLineFlag("UseCompressedOops");
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
754 compressedOopsEnabled = (flag == null) ? Boolean.FALSE:
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
755 (flag.getBool()? Boolean.TRUE: Boolean.FALSE);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
756 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
757 return compressedOopsEnabled.booleanValue();
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
758 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
759
1571
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
760 public int getObjectAlignmentInBytes() {
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
761 if (objectAlignmentInBytes == 0) {
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
762 Flag flag = getCommandLineFlag("ObjectAlignmentInBytes");
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
763 objectAlignmentInBytes = (flag == null) ? 8 : (int)flag.getIntx();
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
764 }
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
765 return objectAlignmentInBytes;
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
766 }
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 844
diff changeset
767
0
a61af66fc99e Initial load
duke
parents:
diff changeset
768 // returns null, if not available.
a61af66fc99e Initial load
duke
parents:
diff changeset
769 public Flag[] getCommandLineFlags() {
a61af66fc99e Initial load
duke
parents:
diff changeset
770 if (commandLineFlags == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
771 readCommandLineFlags();
a61af66fc99e Initial load
duke
parents:
diff changeset
772 }
a61af66fc99e Initial load
duke
parents:
diff changeset
773
a61af66fc99e Initial load
duke
parents:
diff changeset
774 return commandLineFlags;
a61af66fc99e Initial load
duke
parents:
diff changeset
775 }
a61af66fc99e Initial load
duke
parents:
diff changeset
776
a61af66fc99e Initial load
duke
parents:
diff changeset
777 public Flag getCommandLineFlag(String name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
778 if (flagsMap == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
779 flagsMap = new HashMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
780 Flag[] flags = getCommandLineFlags();
a61af66fc99e Initial load
duke
parents:
diff changeset
781 for (int i = 0; i < flags.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
782 flagsMap.put(flags[i].getName(), flags[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
783 }
a61af66fc99e Initial load
duke
parents:
diff changeset
784 }
a61af66fc99e Initial load
duke
parents:
diff changeset
785 return (Flag) flagsMap.get(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
786 }
a61af66fc99e Initial load
duke
parents:
diff changeset
787
a61af66fc99e Initial load
duke
parents:
diff changeset
788 private void readCommandLineFlags() {
a61af66fc99e Initial load
duke
parents:
diff changeset
789 // get command line flags
a61af66fc99e Initial load
duke
parents:
diff changeset
790 TypeDataBase db = getTypeDataBase();
a61af66fc99e Initial load
duke
parents:
diff changeset
791 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
792 Type flagType = db.lookupType("Flag");
a61af66fc99e Initial load
duke
parents:
diff changeset
793 int numFlags = (int) flagType.getCIntegerField("numFlags").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
794 // NOTE: last flag contains null values.
a61af66fc99e Initial load
duke
parents:
diff changeset
795 commandLineFlags = new Flag[numFlags - 1];
a61af66fc99e Initial load
duke
parents:
diff changeset
796
a61af66fc99e Initial load
duke
parents:
diff changeset
797 Address flagAddr = flagType.getAddressField("flags").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
798
a61af66fc99e Initial load
duke
parents:
diff changeset
799 AddressField typeFld = flagType.getAddressField("type");
a61af66fc99e Initial load
duke
parents:
diff changeset
800 AddressField nameFld = flagType.getAddressField("name");
a61af66fc99e Initial load
duke
parents:
diff changeset
801 AddressField addrFld = flagType.getAddressField("addr");
a61af66fc99e Initial load
duke
parents:
diff changeset
802 AddressField kindFld = flagType.getAddressField("kind");
a61af66fc99e Initial load
duke
parents:
diff changeset
803
a61af66fc99e Initial load
duke
parents:
diff changeset
804 long flagSize = flagType.getSize(); // sizeof(Flag)
a61af66fc99e Initial load
duke
parents:
diff changeset
805
a61af66fc99e Initial load
duke
parents:
diff changeset
806 // NOTE: last flag contains null values.
a61af66fc99e Initial load
duke
parents:
diff changeset
807 for (int f = 0; f < numFlags - 1; f++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
808 String type = CStringUtilities.getString(typeFld.getValue(flagAddr));
a61af66fc99e Initial load
duke
parents:
diff changeset
809 String name = CStringUtilities.getString(nameFld.getValue(flagAddr));
a61af66fc99e Initial load
duke
parents:
diff changeset
810 Address addr = addrFld.getValue(flagAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
811 String kind = CStringUtilities.getString(kindFld.getValue(flagAddr));
a61af66fc99e Initial load
duke
parents:
diff changeset
812 commandLineFlags[f] = new Flag(type, name, addr, kind);
a61af66fc99e Initial load
duke
parents:
diff changeset
813 flagAddr = flagAddr.addOffsetTo(flagSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
814 }
a61af66fc99e Initial load
duke
parents:
diff changeset
815
a61af66fc99e Initial load
duke
parents:
diff changeset
816 // sort flags by name
a61af66fc99e Initial load
duke
parents:
diff changeset
817 Arrays.sort(commandLineFlags, new Comparator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
818 public int compare(Object o1, Object o2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
819 Flag f1 = (Flag) o1;
a61af66fc99e Initial load
duke
parents:
diff changeset
820 Flag f2 = (Flag) o2;
a61af66fc99e Initial load
duke
parents:
diff changeset
821 return f1.getName().compareTo(f2.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
822 }
a61af66fc99e Initial load
duke
parents:
diff changeset
823 });
a61af66fc99e Initial load
duke
parents:
diff changeset
824 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
825 // ignore. may be older version. command line flags not available.
a61af66fc99e Initial load
duke
parents:
diff changeset
826 }
a61af66fc99e Initial load
duke
parents:
diff changeset
827 }
a61af66fc99e Initial load
duke
parents:
diff changeset
828
a61af66fc99e Initial load
duke
parents:
diff changeset
829 public String getSystemProperty(String key) {
a61af66fc99e Initial load
duke
parents:
diff changeset
830 Properties props = getSystemProperties();
a61af66fc99e Initial load
duke
parents:
diff changeset
831 return (props != null)? props.getProperty(key) : null;
a61af66fc99e Initial load
duke
parents:
diff changeset
832 }
a61af66fc99e Initial load
duke
parents:
diff changeset
833
a61af66fc99e Initial load
duke
parents:
diff changeset
834 public Properties getSystemProperties() {
a61af66fc99e Initial load
duke
parents:
diff changeset
835 if (sysProps == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
836 readSystemProperties();
a61af66fc99e Initial load
duke
parents:
diff changeset
837 }
a61af66fc99e Initial load
duke
parents:
diff changeset
838 return sysProps;
a61af66fc99e Initial load
duke
parents:
diff changeset
839 }
a61af66fc99e Initial load
duke
parents:
diff changeset
840
a61af66fc99e Initial load
duke
parents:
diff changeset
841 private void readSystemProperties() {
2376
c7f3d0b4570f 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 2042
diff changeset
842 final InstanceKlass systemKls = getSystemDictionary().getSystemKlass();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
843 systemKls.iterate(new DefaultOopVisitor() {
a61af66fc99e Initial load
duke
parents:
diff changeset
844 ObjectReader objReader = new ObjectReader();
a61af66fc99e Initial load
duke
parents:
diff changeset
845 public void doOop(sun.jvm.hotspot.oops.OopField field, boolean isVMField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
846 if (field.getID().getName().equals("props")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
847 try {
2376
c7f3d0b4570f 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 2042
diff changeset
848 sysProps = (Properties) objReader.readObject(field.getValue(systemKls.getJavaMirror()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
849 } catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
850 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
851 e.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
852 }
a61af66fc99e Initial load
duke
parents:
diff changeset
853 }
a61af66fc99e Initial load
duke
parents:
diff changeset
854 }
a61af66fc99e Initial load
duke
parents:
diff changeset
855 }
a61af66fc99e Initial load
duke
parents:
diff changeset
856 }, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
857 }
a61af66fc99e Initial load
duke
parents:
diff changeset
858 }