use of com.oracle.truffle.espresso.classfile.constantpool.PoolConstant in project graal by oracle.
the class ConstantPool method toString.
// endregion unresolved constants
@Override
public String toString() {
Formatter buf = new Formatter();
for (int i = 0; i < length(); i++) {
PoolConstant c = at(i);
buf.format("#%d = %-15s // %s%n", i, c.tag(), c.toString(this));
}
return buf.toString();
}
use of com.oracle.truffle.espresso.classfile.constantpool.PoolConstant in project graal by oracle.
the class ConstantPoolImpl method patchForHiddenClass.
@Override
ConstantPool patchForHiddenClass(int thisKlassIndex, Symbol<?> newName) {
int newNamePos = constants.length;
Utf8Constant newNameConstant = new Utf8Constant(newName);
PoolConstant[] newEntries = Arrays.copyOf(constants, constants.length + 1);
newEntries[newNamePos] = newNameConstant;
newEntries[thisKlassIndex] = ClassConstant.create(newNamePos);
int rawLengthIncrease = 2 + /* u2 length */
newName.length();
return new ConstantPoolImpl(newEntries, majorVersion, minorVersion, totalPoolBytes + rawLengthIncrease);
}
use of com.oracle.truffle.espresso.classfile.constantpool.PoolConstant in project graal by oracle.
the class MethodVerifier method getMethodRefConstant.
private MethodRefConstant getMethodRefConstant(int bci) {
PoolConstant pc = poolAt(code.readCPI(bci));
verifyGuarantee(pc instanceof MethodRefConstant, "Invalid CP constant for a MethodRef: " + pc.getClass().getName());
pc.validate(pool);
return (MethodRefConstant) pc;
}
use of com.oracle.truffle.espresso.classfile.constantpool.PoolConstant in project graal by oracle.
the class MethodVerifier method verifyInvokeDynamic.
private void verifyInvokeDynamic(int bci, OperandStack stack) {
// Check padding
verifyGuarantee(code.readByte(bci + 2) == 0 && code.readByte(bci + 3) == 0, "bytes 3 and 4 after invokedynamic must be 0.");
PoolConstant pc = poolAt(code.readCPI(bci));
// Check CP validity
verifyGuarantee(pc.tag() == ConstantPool.Tag.INVOKEDYNAMIC, "Invalid CP constant for INVOKEDYNAMIC: " + pc.toString());
pc.validate(pool);
InvokeDynamicConstant idc = (InvokeDynamicConstant) pc;
Symbol<Name> name = idc.getName(pool);
// Check invokedynamic does not call initializers
verifyGuarantee(!isInstanceInit(name) && !isClassInit(name), "Invalid bootstrap method name: " + name);
// Check and pop arguments
Operand[] parsedSig = getOperandSig(idc.getSignature(pool));
assert parsedSig.length > 0 : "Empty descriptor for method";
for (int i = parsedSig.length - 2; i >= 0; i--) {
stack.pop(parsedSig[i]);
}
// push result
Operand returnKind = parsedSig[parsedSig.length - 1];
if (returnKind != Void) {
stack.push(returnKind);
}
}
use of com.oracle.truffle.espresso.classfile.constantpool.PoolConstant in project graal by oracle.
the class ClassRedefinition method isSame.
private static boolean isSame(BytecodeStream oldCode, ConstantPool oldPool, BytecodeStream newCode, ConstantPool newPool) {
int bci;
int nextBCI = 0;
while (nextBCI < oldCode.endBCI()) {
bci = nextBCI;
int opcode = oldCode.currentBC(bci);
nextBCI = oldCode.nextBCI(bci);
if (opcode == Bytecodes.LDC || opcode == Bytecodes.LDC2_W || opcode == Bytecodes.LDC_W || opcode == Bytecodes.NEW || opcode == Bytecodes.INVOKEDYNAMIC || opcode == Bytecodes.GETFIELD || opcode == Bytecodes.GETSTATIC || opcode == Bytecodes.PUTFIELD || opcode == Bytecodes.PUTSTATIC || Bytecodes.isInvoke(opcode)) {
int oldCPI = oldCode.readCPI(bci);
PoolConstant oldConstant = oldPool.at(oldCPI);
int newCPI = newCode.readCPI(bci);
PoolConstant newConstant = newPool.at(newCPI);
if (!oldConstant.toString(oldPool).equals(newConstant.toString(newPool))) {
return false;
}
}
}
return true;
}
Aggregations