use of jdk.vm.ci.meta.ConstantPool in project graal by oracle.
the class BytecodeDisassembler method disassemble.
/**
* Disassembles {@code code} in a {@code javap}-like format.
*/
public String disassemble(Bytecode code, int startBci, int endBci) {
if (code.getCode() == null) {
return null;
}
ResolvedJavaMethod method = code.getMethod();
ConstantPool cp = code.getConstantPool();
BytecodeStream stream = new BytecodeStream(code.getCode());
StringBuilder buf = new StringBuilder();
int opcode = stream.currentBC();
try {
while (opcode != Bytecodes.END) {
int bci = stream.currentBCI();
if (bci >= startBci && bci <= endBci) {
String mnemonic = Bytecodes.nameOf(opcode);
buf.append(String.format("%4d: %-14s", bci, mnemonic));
if (stream.nextBCI() > bci + 1) {
decodeOperand(buf, stream, cp, method, bci, opcode);
}
if (newLine) {
buf.append(String.format("%n"));
}
}
stream.next();
opcode = stream.currentBC();
}
} catch (Throwable e) {
throw new RuntimeException(String.format("Error disassembling %s%nPartial disassembly:%n%s", method.format("%H.%n(%p)"), buf.toString()), e);
}
return buf.toString();
}
use of jdk.vm.ci.meta.ConstantPool in project graal by oracle.
the class UniverseBuilder method makeMethod.
private void makeMethod(AnalysisMethod aMethod) {
HostedType holder;
holder = makeType(aMethod.getDeclaringClass());
Signature signature = makeSignature(aMethod.getSignature(), holder);
ConstantPool constantPool = makeConstantPool(aMethod.getConstantPool(), holder);
ExceptionHandler[] aHandlers = aMethod.getExceptionHandlers();
ExceptionHandler[] sHandlers = new ExceptionHandler[aHandlers.length];
for (int i = 0; i < aHandlers.length; i++) {
ExceptionHandler h = aHandlers[i];
ResolvedJavaType catchType = makeType((AnalysisType) h.getCatchType());
sHandlers[i] = new ExceptionHandler(h.getStartBCI(), h.getEndBCI(), h.getHandlerBCI(), h.catchTypeCPI(), catchType);
}
HostedMethod sMethod = new HostedMethod(hUniverse, aMethod, holder, signature, constantPool, sHandlers);
assert !hUniverse.methods.containsKey(aMethod);
hUniverse.methods.put(aMethod, sMethod);
if (aMethod.getAnnotation(CFunction.class) != null) {
if (!aMethod.isNative()) {
unsupportedFeatures.addMessage(aMethod.format("%H.%n(%p)"), aMethod, "Method annotated with @" + CFunction.class.getSimpleName() + " must be declared native");
}
} else if (aMethod.isNative() && !aMethod.isIntrinsicMethod() && aMethod.isImplementationInvoked() && !NativeImageOptions.ReportUnsupportedElementsAtRuntime.getValue()) {
unsupportedFeatures.addMessage(aMethod.format("%H.%n(%p)"), aMethod, AnnotationSubstitutionProcessor.deleteErrorMessage(aMethod, DeletedMethod.NATIVE_MESSAGE, true));
}
}
Aggregations