Mercurial > hg > graal-compiler
diff agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeLoadConstant.java @ 3838:6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
Reviewed-by: kvn, twisti, jrose
author | never |
---|---|
date | Thu, 21 Jul 2011 08:38:25 -0700 |
parents | 1d1603768966 |
children | 2090c623107e |
line wrap: on
line diff
--- a/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeLoadConstant.java Wed Jul 20 18:04:17 2011 -0700 +++ b/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeLoadConstant.java Thu Jul 21 08:38:25 2011 -0700 @@ -28,29 +28,25 @@ import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.utilities.*; -public class BytecodeLoadConstant extends BytecodeWithCPIndex { +public class BytecodeLoadConstant extends Bytecode { BytecodeLoadConstant(Method method, int bci) { super(method, bci); } public boolean hasCacheIndex() { // normal ldc uses CP index, but fast_aldc uses swapped CP cache index - return javaCode() != code(); + return code() >= Bytecodes.number_of_java_codes; } - public int index() { - int i = javaCode() == Bytecodes._ldc ? - (int) (0xFF & javaByteAt(1)) - : (int) (0xFFFF & javaShortAt(1)); - if (hasCacheIndex()) { - return (0xFFFF & VM.getVM().getBytes().swapShort((short) i)); - } else { - return i; - } + int rawIndex() { + if (javaCode() == Bytecodes._ldc) + return getIndexU1(); + else + return getIndexU2(code(), false); } public int poolIndex() { - int i = index(); + int i = rawIndex(); if (hasCacheIndex()) { ConstantPoolCache cpCache = method().getConstants().getCache(); return cpCache.getEntryAt(i).getConstantPoolIndex(); @@ -61,12 +57,18 @@ public int cacheIndex() { if (hasCacheIndex()) { - return index(); + return rawIndex(); } else { return -1; // no cache index } } + public BasicType resultType() { + int index = poolIndex(); + ConstantTag tag = method().getConstants().getTagAt(index); + return tag.basicType(); + } + private Oop getCachedConstant() { int i = cacheIndex(); if (i >= 0) { @@ -88,7 +90,7 @@ jcode == Bytecodes._ldc2_w; if (! codeOk) return false; - ConstantTag ctag = method().getConstants().getTagAt(index()); + ConstantTag ctag = method().getConstants().getTagAt(rawIndex()); if (jcode == Bytecodes._ldc2_w) { // has to be double or long return (ctag.isDouble() || ctag.isLong()) ? true: false; @@ -107,7 +109,7 @@ return false; } - ConstantTag ctag = method().getConstants().getTagAt(index()); + ConstantTag ctag = method().getConstants().getTagAt(poolIndex()); return ctag.isKlass() || ctag.isUnresolvedKlass(); } @@ -120,7 +122,7 @@ // We just look at the object at the corresponding index and // decide based on the oop type. ConstantPool cpool = method().getConstants(); - int cpIndex = index(); + int cpIndex = poolIndex(); ConstantPool.CPSlot oop = cpool.getSlotAt(cpIndex); if (oop.isOop()) { return (Klass) oop.getOop();