Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java @ 1579:e9ff18c4ace7
Merge
author | jrose |
---|---|
date | Wed, 02 Jun 2010 22:45:42 -0700 |
parents | c18cbe5936b8 |
children | 136b78722a08 |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1385
diff
changeset
|
2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1385
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1385
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:
1385
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.oops; | |
26 | |
27 import java.io.*; | |
28 import java.util.*; | |
29 import sun.jvm.hotspot.debugger.*; | |
30 import sun.jvm.hotspot.runtime.*; | |
31 import sun.jvm.hotspot.types.*; | |
32 import sun.jvm.hotspot.utilities.*; | |
33 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
34 // A ConstantPool is an oop containing class constants |
0 | 35 // as described in the class file |
36 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
37 public class ConstantPool extends Oop implements ClassConstants { |
0 | 38 // Used for debugging this code |
39 private static final boolean DEBUG = false; | |
40 | |
41 protected void debugMessage(String message) { | |
42 System.out.println(message); | |
43 } | |
44 | |
45 static { | |
46 VM.registerVMInitializedObserver(new Observer() { | |
47 public void update(Observable o, Object data) { | |
48 initialize(VM.getVM().getTypeDataBase()); | |
49 } | |
50 }); | |
51 } | |
52 | |
53 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { | |
54 Type type = db.lookupType("constantPoolOopDesc"); | |
55 tags = new OopField(type.getOopField("_tags"), 0); | |
56 cache = new OopField(type.getOopField("_cache"), 0); | |
57 poolHolder = new OopField(type.getOopField("_pool_holder"), 0); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
58 length = new CIntField(type.getCIntegerField("_length"), 0); |
0 | 59 headerSize = type.getSize(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
60 elementSize = 0; |
0 | 61 } |
62 | |
63 ConstantPool(OopHandle handle, ObjectHeap heap) { | |
64 super(handle, heap); | |
65 } | |
66 | |
67 public boolean isConstantPool() { return true; } | |
68 | |
69 private static OopField tags; | |
70 private static OopField cache; | |
71 private static OopField poolHolder; | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
72 private static CIntField length; // number of elements in oop |
0 | 73 |
74 private static long headerSize; | |
75 private static long elementSize; | |
76 | |
77 public TypeArray getTags() { return (TypeArray) tags.getValue(this); } | |
78 public ConstantPoolCache getCache() { return (ConstantPoolCache) cache.getValue(this); } | |
79 public Klass getPoolHolder() { return (Klass) poolHolder.getValue(this); } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
80 public int getLength() { return (int)length.getValue(this); } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
81 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
82 private long getElementSize() { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
83 if (elementSize !=0 ) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
84 return elementSize; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
85 } else { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
86 elementSize = VM.getVM().getOopSize(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
87 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
88 return elementSize; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
89 } |
0 | 90 |
91 private long indexOffset(long index) { | |
92 if (Assert.ASSERTS_ENABLED) { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
93 Assert.that(index > 0 && index < getLength(), "invalid cp index " + index + " " + getLength()); |
0 | 94 } |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
95 return (index * getElementSize()) + headerSize; |
0 | 96 } |
97 | |
98 public ConstantTag getTagAt(long index) { | |
99 return new ConstantTag(getTags().getByteAt((int) index)); | |
100 } | |
101 | |
102 public Oop getObjAt(long index){ | |
103 return getHeap().newOop(getHandle().getOopHandleAt(indexOffset(index))); | |
104 } | |
105 | |
106 public Symbol getSymbolAt(long index) { | |
107 return (Symbol) getObjAt(index); | |
108 } | |
109 | |
110 public int getIntAt(long index){ | |
111 return getHandle().getJIntAt(indexOffset(index)); | |
112 } | |
113 | |
114 public float getFloatAt(long index){ | |
115 return getHandle().getJFloatAt(indexOffset(index)); | |
116 } | |
117 | |
118 public long getLongAt(long index) { | |
119 int oneHalf = getHandle().getJIntAt(indexOffset(index + 1)); | |
120 int otherHalf = getHandle().getJIntAt(indexOffset(index)); | |
121 // buildLongFromIntsPD accepts higher address value, lower address value | |
122 // in that order. | |
123 return VM.getVM().buildLongFromIntsPD(oneHalf, otherHalf); | |
124 } | |
125 | |
126 public double getDoubleAt(long index) { | |
127 return Double.longBitsToDouble(getLongAt(index)); | |
128 } | |
129 | |
130 public int getFieldOrMethodAt(int which) { | |
131 if (DEBUG) { | |
132 System.err.print("ConstantPool.getFieldOrMethodAt(" + which + "): new index = "); | |
133 } | |
134 int i = -1; | |
135 ConstantPoolCache cache = getCache(); | |
136 if (cache == null) { | |
137 i = which; | |
138 } else { | |
139 // change byte-ordering and go via cache | |
140 i = cache.getEntryAt(0xFFFF & VM.getVM().getBytes().swapShort((short) which)).getConstantPoolIndex(); | |
141 } | |
142 if (Assert.ASSERTS_ENABLED) { | |
143 Assert.that(getTagAt(i).isFieldOrMethod(), "Corrupted constant pool"); | |
144 } | |
145 if (DEBUG) { | |
146 System.err.println(i); | |
147 } | |
148 int res = getIntAt(i); | |
149 if (DEBUG) { | |
150 System.err.println("ConstantPool.getFieldOrMethodAt(" + i + "): result = " + res); | |
151 } | |
152 return res; | |
153 } | |
154 | |
155 public int getNameAndTypeAt(int which) { | |
156 if (Assert.ASSERTS_ENABLED) { | |
157 Assert.that(getTagAt(which).isNameAndType(), "Corrupted constant pool"); | |
158 } | |
159 int i = getIntAt(which); | |
160 if (DEBUG) { | |
161 System.err.println("ConstantPool.getNameAndTypeAt(" + which + "): result = " + i); | |
162 } | |
163 return i; | |
164 } | |
165 | |
166 public Symbol getNameRefAt(int which) { | |
167 int refIndex = getNameAndTypeAt(getNameAndTypeRefIndexAt(which)); | |
168 int nameIndex = extractLowShortFromInt(refIndex); | |
169 return getSymbolAt(nameIndex); | |
170 } | |
171 | |
172 public Symbol getSignatureRefAt(int which) { | |
173 int refIndex = getNameAndTypeAt(getNameAndTypeRefIndexAt(which)); | |
174 int sigIndex = extractHighShortFromInt(refIndex); | |
175 return getSymbolAt(sigIndex); | |
176 } | |
177 | |
178 // returns null, if not resolved. | |
179 public Klass getKlassRefAt(int which) { | |
180 if( ! getTagAt(which).isKlass()) return null; | |
181 return (Klass) getObjAt(which); | |
182 } | |
183 | |
184 // returns null, if not resolved. | |
185 public InstanceKlass getFieldOrMethodKlassRefAt(int which) { | |
186 int refIndex = getFieldOrMethodAt(which); | |
187 int klassIndex = extractLowShortFromInt(refIndex); | |
188 return (InstanceKlass) getKlassRefAt(klassIndex); | |
189 } | |
190 | |
191 // returns null, if not resolved. | |
192 public Method getMethodRefAt(int which) { | |
193 InstanceKlass klass = getFieldOrMethodKlassRefAt(which); | |
194 if (klass == null) return null; | |
195 Symbol name = getNameRefAt(which); | |
196 Symbol sig = getSignatureRefAt(which); | |
197 return klass.findMethod(name, sig); | |
198 } | |
199 | |
200 // returns null, if not resolved. | |
201 public Field getFieldRefAt(int which) { | |
202 InstanceKlass klass = getFieldOrMethodKlassRefAt(which); | |
203 if (klass == null) return null; | |
204 Symbol name = getNameRefAt(which); | |
205 Symbol sig = getSignatureRefAt(which); | |
206 return klass.findField(name, sig); | |
207 } | |
208 | |
209 public int getNameAndTypeRefIndexAt(int index) { | |
210 int refIndex = getFieldOrMethodAt(index); | |
211 if (DEBUG) { | |
212 System.err.println("ConstantPool.getNameAndTypeRefIndexAt(" + index + "): refIndex = " + refIndex); | |
213 } | |
214 int i = extractHighShortFromInt(refIndex); | |
215 if (DEBUG) { | |
216 System.err.println("ConstantPool.getNameAndTypeRefIndexAt(" + index + "): result = " + i); | |
217 } | |
218 return i; | |
219 } | |
220 | |
221 /** Lookup for entries consisting of (name_index, signature_index) */ | |
222 public int getNameRefIndexAt(int index) { | |
223 int refIndex = getNameAndTypeAt(index); | |
224 if (DEBUG) { | |
225 System.err.println("ConstantPool.getNameRefIndexAt(" + index + "): refIndex = " + refIndex); | |
226 } | |
227 int i = extractLowShortFromInt(refIndex); | |
228 if (DEBUG) { | |
229 System.err.println("ConstantPool.getNameRefIndexAt(" + index + "): result = " + i); | |
230 } | |
231 return i; | |
232 } | |
233 | |
234 /** Lookup for entries consisting of (name_index, signature_index) */ | |
235 public int getSignatureRefIndexAt(int index) { | |
236 int refIndex = getNameAndTypeAt(index); | |
237 if (DEBUG) { | |
238 System.err.println("ConstantPool.getSignatureRefIndexAt(" + index + "): refIndex = " + refIndex); | |
239 } | |
240 int i = extractHighShortFromInt(refIndex); | |
241 if (DEBUG) { | |
242 System.err.println("ConstantPool.getSignatureRefIndexAt(" + index + "): result = " + i); | |
243 } | |
244 return i; | |
245 } | |
246 | |
247 final private static String[] nameForTag = new String[] { | |
248 }; | |
249 | |
250 private String nameForTag(int tag) { | |
251 switch (tag) { | |
252 case JVM_CONSTANT_Utf8: return "JVM_CONSTANT_Utf8"; | |
253 case JVM_CONSTANT_Unicode: return "JVM_CONSTANT_Unicode"; | |
254 case JVM_CONSTANT_Integer: return "JVM_CONSTANT_Integer"; | |
255 case JVM_CONSTANT_Float: return "JVM_CONSTANT_Float"; | |
256 case JVM_CONSTANT_Long: return "JVM_CONSTANT_Long"; | |
257 case JVM_CONSTANT_Double: return "JVM_CONSTANT_Double"; | |
258 case JVM_CONSTANT_Class: return "JVM_CONSTANT_Class"; | |
259 case JVM_CONSTANT_String: return "JVM_CONSTANT_String"; | |
260 case JVM_CONSTANT_Fieldref: return "JVM_CONSTANT_Fieldref"; | |
261 case JVM_CONSTANT_Methodref: return "JVM_CONSTANT_Methodref"; | |
262 case JVM_CONSTANT_InterfaceMethodref: return "JVM_CONSTANT_InterfaceMethodref"; | |
263 case JVM_CONSTANT_NameAndType: return "JVM_CONSTANT_NameAndType"; | |
264 case JVM_CONSTANT_Invalid: return "JVM_CONSTANT_Invalid"; | |
265 case JVM_CONSTANT_UnresolvedClass: return "JVM_CONSTANT_UnresolvedClass"; | |
1385 | 266 case JVM_CONSTANT_UnresolvedClassInError: return "JVM_CONSTANT_UnresolvedClassInError"; |
0 | 267 case JVM_CONSTANT_ClassIndex: return "JVM_CONSTANT_ClassIndex"; |
268 case JVM_CONSTANT_UnresolvedString: return "JVM_CONSTANT_UnresolvedString"; | |
269 case JVM_CONSTANT_StringIndex: return "JVM_CONSTANT_StringIndex"; | |
270 } | |
1385 | 271 throw new InternalError("Unknown tag: " + tag); |
0 | 272 } |
273 | |
274 public void iterateFields(OopVisitor visitor, boolean doVMFields) { | |
275 super.iterateFields(visitor, doVMFields); | |
276 if (doVMFields) { | |
277 visitor.doOop(tags, true); | |
278 visitor.doOop(cache, true); | |
279 visitor.doOop(poolHolder, true); | |
280 | |
281 final int length = (int) getLength(); | |
282 // zero'th pool entry is always invalid. ignore it. | |
283 for (int index = 1; index < length; index++) { | |
284 int ctag = (int) getTags().getByteAt((int) index); | |
285 switch (ctag) { | |
286 case JVM_CONSTANT_ClassIndex: | |
287 case JVM_CONSTANT_StringIndex: | |
288 case JVM_CONSTANT_Integer: | |
289 visitor.doInt(new IntField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true), true); | |
290 break; | |
291 | |
292 case JVM_CONSTANT_Float: | |
293 visitor.doFloat(new FloatField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true), true); | |
294 break; | |
295 | |
296 case JVM_CONSTANT_Long: | |
297 visitor.doLong(new LongField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true), true); | |
298 // long entries occupy two slots | |
299 index++; | |
300 break; | |
301 | |
302 case JVM_CONSTANT_Double: | |
303 visitor.doDouble(new DoubleField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true), true); | |
304 // double entries occupy two slots | |
305 index++; | |
306 break; | |
307 | |
1385 | 308 case JVM_CONSTANT_UnresolvedClassInError: |
0 | 309 case JVM_CONSTANT_UnresolvedClass: |
310 case JVM_CONSTANT_Class: | |
311 case JVM_CONSTANT_UnresolvedString: | |
312 case JVM_CONSTANT_Utf8: | |
313 visitor.doOop(new OopField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true), true); | |
314 break; | |
315 | |
316 case JVM_CONSTANT_Fieldref: | |
317 case JVM_CONSTANT_Methodref: | |
318 case JVM_CONSTANT_InterfaceMethodref: | |
319 case JVM_CONSTANT_NameAndType: | |
320 visitor.doInt(new IntField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true), true); | |
321 break; | |
322 } | |
323 } | |
324 } | |
325 /* | |
326 int length = getLength(); | |
327 for (int index = 0; index < length; index++) { | |
328 long offset = baseOffset + (index + typeDataBase.getOopSize()); | |
329 visitor.doOop(new IndexableField(index, offset, false), getObjAt(index)); | |
330 } | |
331 */ | |
332 } | |
333 | |
334 public void writeBytes(OutputStream os) throws IOException { | |
335 // Map between any modified UTF-8 and it's constant pool index. | |
336 Map utf8ToIndex = new HashMap(); | |
337 DataOutputStream dos = new DataOutputStream(os); | |
338 TypeArray tags = getTags(); | |
339 int len = (int)getLength(); | |
340 int ci = 0; // constant pool index | |
341 | |
342 // collect all modified UTF-8 Strings from Constant Pool | |
343 | |
344 for (ci = 1; ci < len; ci++) { | |
345 byte cpConstType = tags.getByteAt(ci); | |
346 if(cpConstType == JVM_CONSTANT_Utf8) { | |
347 Symbol sym = getSymbolAt(ci); | |
348 utf8ToIndex.put(sym.asString(), new Short((short) ci)); | |
349 } | |
350 else if(cpConstType == JVM_CONSTANT_Long || | |
351 cpConstType == JVM_CONSTANT_Double) { | |
352 ci++; | |
353 } | |
354 } | |
355 | |
356 | |
357 for(ci = 1; ci < len; ci++) { | |
358 int cpConstType = (int)tags.getByteAt(ci); | |
359 // write cp_info | |
360 // write constant type | |
361 switch(cpConstType) { | |
362 case JVM_CONSTANT_Utf8: { | |
363 dos.writeByte(cpConstType); | |
364 Symbol sym = getSymbolAt(ci); | |
365 dos.writeShort((short)sym.getLength()); | |
366 dos.write(sym.asByteArray()); | |
367 if (DEBUG) debugMessage("CP[" + ci + "] = modified UTF-8 " + sym.asString()); | |
368 break; | |
369 } | |
370 | |
371 case JVM_CONSTANT_Unicode: | |
372 throw new IllegalArgumentException("Unicode constant!"); | |
373 | |
374 case JVM_CONSTANT_Integer: | |
375 dos.writeByte(cpConstType); | |
376 dos.writeInt(getIntAt(ci)); | |
377 if (DEBUG) debugMessage("CP[" + ci + "] = int " + getIntAt(ci)); | |
378 break; | |
379 | |
380 case JVM_CONSTANT_Float: | |
381 dos.writeByte(cpConstType); | |
382 dos.writeFloat(getFloatAt(ci)); | |
383 if (DEBUG) debugMessage("CP[" + ci + "] = float " + getFloatAt(ci)); | |
384 break; | |
385 | |
386 case JVM_CONSTANT_Long: { | |
387 dos.writeByte(cpConstType); | |
388 long l = getLongAt(ci); | |
389 // long entries occupy two pool entries | |
390 ci++; | |
391 dos.writeLong(l); | |
392 break; | |
393 } | |
394 | |
395 case JVM_CONSTANT_Double: | |
396 dos.writeByte(cpConstType); | |
397 dos.writeDouble(getDoubleAt(ci)); | |
398 // double entries occupy two pool entries | |
399 ci++; | |
400 break; | |
401 | |
402 case JVM_CONSTANT_Class: { | |
403 dos.writeByte(cpConstType); | |
404 // Klass already resolved. ConstantPool constains klassOop. | |
405 Klass refKls = (Klass) getObjAt(ci); | |
406 String klassName = refKls.getName().asString(); | |
407 Short s = (Short) utf8ToIndex.get(klassName); | |
408 dos.writeShort(s.shortValue()); | |
409 if (DEBUG) debugMessage("CP[" + ci + "] = class " + s); | |
410 break; | |
411 } | |
412 | |
413 // case JVM_CONSTANT_ClassIndex: | |
1385 | 414 case JVM_CONSTANT_UnresolvedClassInError: |
0 | 415 case JVM_CONSTANT_UnresolvedClass: { |
416 dos.writeByte(JVM_CONSTANT_Class); | |
417 String klassName = getSymbolAt(ci).asString(); | |
418 Short s = (Short) utf8ToIndex.get(klassName); | |
419 dos.writeShort(s.shortValue()); | |
420 if (DEBUG) debugMessage("CP[" + ci + "] = class " + s); | |
421 break; | |
422 } | |
423 | |
424 case JVM_CONSTANT_String: { | |
425 dos.writeByte(cpConstType); | |
426 String str = OopUtilities.stringOopToString(getObjAt(ci)); | |
427 Short s = (Short) utf8ToIndex.get(str); | |
428 dos.writeShort(s.shortValue()); | |
429 if (DEBUG) debugMessage("CP[" + ci + "] = string " + s); | |
430 break; | |
431 } | |
432 | |
433 // case JVM_CONSTANT_StringIndex: | |
434 case JVM_CONSTANT_UnresolvedString: { | |
435 dos.writeByte(JVM_CONSTANT_String); | |
436 String val = getSymbolAt(ci).asString(); | |
437 | |
438 Short s = (Short) utf8ToIndex.get(val); | |
439 dos.writeShort(s.shortValue()); | |
440 if (DEBUG) debugMessage("CP[" + ci + "] = string " + s); | |
441 break; | |
442 } | |
443 | |
444 // all external, internal method/field references | |
445 case JVM_CONSTANT_Fieldref: | |
446 case JVM_CONSTANT_Methodref: | |
447 case JVM_CONSTANT_InterfaceMethodref: { | |
448 dos.writeByte(cpConstType); | |
449 int value = getIntAt(ci); | |
450 short klassIndex = (short) extractLowShortFromInt(value); | |
451 short nameAndTypeIndex = (short) extractHighShortFromInt(value); | |
452 dos.writeShort(klassIndex); | |
453 dos.writeShort(nameAndTypeIndex); | |
454 if (DEBUG) debugMessage("CP[" + ci + "] = ref klass = " + | |
455 klassIndex + ", N&T = " + nameAndTypeIndex); | |
456 break; | |
457 } | |
458 | |
459 case JVM_CONSTANT_NameAndType: { | |
460 dos.writeByte(cpConstType); | |
461 int value = getIntAt(ci); | |
462 short nameIndex = (short) extractLowShortFromInt(value); | |
463 short signatureIndex = (short) extractHighShortFromInt(value); | |
464 dos.writeShort(nameIndex); | |
465 dos.writeShort(signatureIndex); | |
466 if (DEBUG) debugMessage("CP[" + ci + "] = N&T name = " + nameIndex | |
467 + ", type = " + signatureIndex); | |
468 break; | |
469 } | |
1385 | 470 default: |
471 throw new InternalError("unknown tag: " + cpConstType); | |
0 | 472 } // switch |
473 } | |
474 dos.flush(); | |
475 return; | |
476 } | |
477 | |
478 public void printValueOn(PrintStream tty) { | |
479 tty.print("ConstantPool for " + getPoolHolder().getName().asString()); | |
480 } | |
481 | |
482 public long getObjectSize() { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
483 return alignObjectSize(headerSize + (getLength() * getElementSize())); |
0 | 484 } |
485 | |
486 //---------------------------------------------------------------------- | |
487 // Internals only below this point | |
488 // | |
489 | |
490 private static int extractHighShortFromInt(int val) { | |
491 return (val >> 16) & 0xFFFF; | |
492 } | |
493 | |
494 private static int extractLowShortFromInt(int val) { | |
495 return val & 0xFFFF; | |
496 } | |
497 } |