Mercurial > hg > truffle
diff agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java @ 2177:3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
Summary: move symbols from permgen into C heap and reference count them
Reviewed-by: never, acorn, jmasa, stefank
author | coleenp |
---|---|
date | Thu, 27 Jan 2011 16:11:27 -0800 |
parents | dad31fc330cd |
children | 1d1603768966 ed69575596ac |
line wrap: on
line diff
--- a/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java Thu Jan 27 13:42:28 2011 -0800 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java Thu Jan 27 16:11:27 2011 -0800 @@ -35,6 +35,38 @@ // as described in the class file public class ConstantPool extends Oop implements ClassConstants { + + public class CPSlot { + private Address ptr; + + CPSlot(Address ptr) { + this.ptr = ptr; + } + CPSlot(Symbol sym) { + this.ptr = sym.getAddress().orWithMask(1); + } + + public boolean isOop() { + return (ptr.minus(null) & 1) == 0; + } + public boolean isMetaData() { + return (ptr.minus(null) & 1) == 1; + } + + public Symbol getSymbol() { + if (isMetaData()) { + return Symbol.create(ptr.xorWithMask(1)); + } + throw new InternalError("not a symbol"); + } + public Oop getOop() { + if (isOop()) { + return VM.getVM().getObjectHeap().newOop(ptr.addOffsetToAsOopHandle(0)); + } + throw new InternalError("not an oop"); + } + } + // Used for debugging this code private static final boolean DEBUG = false; @@ -110,12 +142,17 @@ return new ConstantTag(getTags().getByteAt((int) index)); } - public Oop getObjAt(long index){ + public CPSlot getSlotAt(long index) { + return new CPSlot(getHandle().getAddressAt(indexOffset(index))); + } + + public Oop getObjAtRaw(long index){ return getHeap().newOop(getHandle().getOopHandleAt(indexOffset(index))); } public Symbol getSymbolAt(long index) { - return (Symbol) getObjAt(index); + CPSlot slot = getSlotAt(index); + return slot.getSymbol(); } public int getIntAt(long index){ @@ -187,7 +224,7 @@ // returns null, if not resolved. public Klass getKlassRefAt(int which) { if( ! getTagAt(which).isKlass()) return null; - return (Klass) getObjAt(which); + return (Klass) getObjAtRaw(which); } // returns null, if not resolved. @@ -477,7 +514,7 @@ case JVM_CONSTANT_Class: { dos.writeByte(cpConstType); // Klass already resolved. ConstantPool constains klassOop. - Klass refKls = (Klass) getObjAt(ci); + Klass refKls = (Klass) getObjAtRaw(ci); String klassName = refKls.getName().asString(); Short s = (Short) utf8ToIndex.get(klassName); dos.writeShort(s.shortValue()); @@ -498,7 +535,7 @@ case JVM_CONSTANT_String: { dos.writeByte(cpConstType); - String str = OopUtilities.stringOopToString(getObjAt(ci)); + String str = OopUtilities.stringOopToString(getObjAtRaw(ci)); Short s = (Short) utf8ToIndex.get(str); dos.writeShort(s.shortValue()); if (DEBUG) debugMessage("CP[" + ci + "] = string " + s);