Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPoolCache.java @ 113:ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
author | coleenp |
---|---|
date | Sun, 13 Apr 2008 17:43:42 -0400 |
parents | a61af66fc99e |
children | d1605aabd0a1 |
comparison
equal
deleted
inserted
replaced
110:a49a647afe9a | 113:ba764ed4b6f2 |
---|---|
29 import sun.jvm.hotspot.debugger.*; | 29 import sun.jvm.hotspot.debugger.*; |
30 import sun.jvm.hotspot.runtime.*; | 30 import sun.jvm.hotspot.runtime.*; |
31 import sun.jvm.hotspot.types.*; | 31 import sun.jvm.hotspot.types.*; |
32 import sun.jvm.hotspot.utilities.*; | 32 import sun.jvm.hotspot.utilities.*; |
33 | 33 |
34 // A ConstantPool is an array containing class constants | 34 // ConstantPoolCache : A constant pool cache (constantPoolCacheOopDesc). |
35 // as described in the class file | 35 // See cpCacheOop.hpp for details about this class. |
36 | 36 // |
37 public class ConstantPoolCache extends Array { | 37 public class ConstantPoolCache extends Oop { |
38 static { | 38 static { |
39 VM.registerVMInitializedObserver(new Observer() { | 39 VM.registerVMInitializedObserver(new Observer() { |
40 public void update(Observable o, Object data) { | 40 public void update(Observable o, Object data) { |
41 initialize(VM.getVM().getTypeDataBase()); | 41 initialize(VM.getVM().getTypeDataBase()); |
42 } | 42 } |
45 | 45 |
46 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { | 46 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { |
47 Type type = db.lookupType("constantPoolCacheOopDesc"); | 47 Type type = db.lookupType("constantPoolCacheOopDesc"); |
48 constants = new OopField(type.getOopField("_constant_pool"), 0); | 48 constants = new OopField(type.getOopField("_constant_pool"), 0); |
49 baseOffset = type.getSize(); | 49 baseOffset = type.getSize(); |
50 | |
51 Type elType = db.lookupType("ConstantPoolCacheEntry"); | 50 Type elType = db.lookupType("ConstantPoolCacheEntry"); |
52 elementSize = elType.getSize(); | 51 elementSize = elType.getSize(); |
52 length = new CIntField(type.getCIntegerField("_length"), 0); | |
53 } | 53 } |
54 | 54 |
55 ConstantPoolCache(OopHandle handle, ObjectHeap heap) { | 55 ConstantPoolCache(OopHandle handle, ObjectHeap heap) { |
56 super(handle, heap); | 56 super(handle, heap); |
57 } | 57 } |
60 | 60 |
61 private static OopField constants; | 61 private static OopField constants; |
62 | 62 |
63 private static long baseOffset; | 63 private static long baseOffset; |
64 private static long elementSize; | 64 private static long elementSize; |
65 private static CIntField length; | |
66 | |
65 | 67 |
66 public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); } | 68 public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); } |
67 | 69 |
68 public long getObjectSize() { | 70 public long getObjectSize() { |
69 return alignObjectSize(baseOffset + getLength() * elementSize); | 71 return alignObjectSize(baseOffset + getLength() * elementSize); |
85 | 87 |
86 public void printValueOn(PrintStream tty) { | 88 public void printValueOn(PrintStream tty) { |
87 tty.print("ConstantPoolCache for " + getConstants().getPoolHolder().getName().asString()); | 89 tty.print("ConstantPoolCache for " + getConstants().getPoolHolder().getName().asString()); |
88 } | 90 } |
89 | 91 |
92 public int getLength() { | |
93 return (int) length.getValue(this); | |
94 } | |
95 | |
90 public void iterateFields(OopVisitor visitor, boolean doVMFields) { | 96 public void iterateFields(OopVisitor visitor, boolean doVMFields) { |
91 super.iterateFields(visitor, doVMFields); | 97 super.iterateFields(visitor, doVMFields); |
92 if (doVMFields) { | 98 if (doVMFields) { |
93 visitor.doOop(constants, true); | 99 visitor.doOop(constants, true); |
94 for (int i = 0; i < getLength(); i++) { | 100 for (int i = 0; i < getLength(); i++) { |