Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,42 +80,6 @@ protected short getConstantPoolIndexFromRefMap(int rawcode, int bci) {
return (short)cpool.objectToCPIndex(refIndex);
}

protected short getConstantPoolIndex(int rawcode, int bci) {
// get ConstantPool index from ConstantPoolCacheIndex at given bci
String fmt = Bytecodes.format(rawcode);
int cpCacheIndex;
switch (fmt.length()) {
case 2: cpCacheIndex = method.getBytecodeByteArg(bci); break;
case 3: cpCacheIndex = method.getBytecodeShortArg(bci); break;
case 5:
if (fmt.contains("__"))
cpCacheIndex = method.getBytecodeShortArg(bci);
else
cpCacheIndex = method.getBytecodeIntArg(bci);
break;
default: throw new IllegalArgumentException();
}

if (cpCache == null) {
return (short) cpCacheIndex;
} else if (fmt.contains("JJJJ")) {
// Invokedynamic require special handling
cpCacheIndex = ~cpCacheIndex;
cpCacheIndex = bytes.swapInt(cpCacheIndex);
short cpIndex = (short) cpCache.getIndyEntryAt(cpCacheIndex).getConstantPoolIndex();
Assert.that(cpool.getTagAt(cpIndex).isInvokeDynamic(), "CP Entry should be InvokeDynamic");
return cpIndex;
} else if (fmt.contains("JJ")) {
// change byte-ordering and go via cache
return (short) cpCache.getEntryAt((int) (0xFFFF & bytes.swapShort((short)cpCacheIndex))).getConstantPoolIndex();
} else if (fmt.contains("j")) {
// go via cache
return (short) cpCache.getEntryAt((int) (0xFF & cpCacheIndex)).getConstantPoolIndex();
} else {
return (short) cpCacheIndex;
}
}

private static void writeShort(byte[] buf, int index, short value) {
buf[index] = (byte) ((value >> 8) & 0x00FF);
buf[index + 1] = (byte) (value & 0x00FF);
Expand Down Expand Up @@ -152,22 +116,29 @@ public void rewrite() {
case Bytecodes._getstatic:
case Bytecodes._putstatic:
case Bytecodes._getfield:
case Bytecodes._putfield:
case Bytecodes._putfield: {
int fieldIndex = method.getNativeShortArg(bci + 1);
cpoolIndex = (short) cpCache.getFieldEntryAt(fieldIndex).getConstantPoolIndex();
writeShort(code, bci + 1, cpoolIndex);
break;
}
case Bytecodes._invokevirtual:
case Bytecodes._invokespecial:
case Bytecodes._invokestatic:
case Bytecodes._invokeinterface: {
cpoolIndex = getConstantPoolIndex(hotspotcode, bci + 1);
int cpci = method.getNativeShortArg(bci + 1);
cpoolIndex = (short) cpCache.getEntryAt(cpci).getConstantPoolIndex();
writeShort(code, bci + 1, cpoolIndex);
break;
}

case Bytecodes._invokedynamic:
cpoolIndex = getConstantPoolIndex(hotspotcode, bci + 1);
case Bytecodes._invokedynamic: {
int cpci = method.getNativeIntArg(bci + 1);
cpoolIndex = (short) cpCache.getIndyEntryAt(~cpci).getConstantPoolIndex();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really suppose to be ~cpci and not just cpci?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right. See

pool_index = mh->constants()->resolved_indy_entry_at(mh->constants()->decode_invokedynamic_index(cpci))->constant_pool_index();
and
static int decode_invokedynamic_index(int i) { assert(is_invokedynamic_index(i), ""); return ~i; }

I tend to use JvmtiClassFileReconstituter as the reference for the code involved in dumping the classfile, and that makes things easier to follow and implement.

writeShort(code, bci + 1, cpoolIndex);
writeShort(code, bci + 3, (short)0); // clear out trailing bytes
break;

}
case Bytecodes._ldc_w:
if (hotspotcode != bytecode) {
// fast_aldc_w puts constant in reference map
Expand Down
1 change: 0 additions & 1 deletion test/hotspot/jtreg/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ serviceability/sa/ClhsdbPmap.java#core 8267433 macosx-x64
serviceability/sa/ClhsdbPstack.java#core 8267433 macosx-x64
serviceability/sa/TestJmapCore.java 8267433 macosx-x64
serviceability/sa/TestJmapCoreMetaspace.java 8267433 macosx-x64
serviceability/sa/ClhsdbDumpclass.java 8316342 generic-all

serviceability/attach/ConcAttachTest.java 8290043 linux-all
serviceability/jvmti/RedefineClasses/RedefineLeakThrowable.java 8316658 generic-all
Expand Down