Search in sources :

Example 6 with ConstantPool

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();
}
Also used : ConstantPool(jdk.vm.ci.meta.ConstantPool) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 7 with ConstantPool

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));
    }
}
Also used : ExceptionHandler(jdk.vm.ci.meta.ExceptionHandler) ConstantPool(jdk.vm.ci.meta.ConstantPool) WrappedConstantPool(com.oracle.graal.pointsto.infrastructure.WrappedConstantPool) WrappedSignature(com.oracle.graal.pointsto.infrastructure.WrappedSignature) Signature(jdk.vm.ci.meta.Signature) CFunction(org.graalvm.nativeimage.c.function.CFunction) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Aggregations

ConstantPool (jdk.vm.ci.meta.ConstantPool)7 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)5 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)3 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)3 WrappedConstantPool (com.oracle.graal.pointsto.infrastructure.WrappedConstantPool)1 WrappedSignature (com.oracle.graal.pointsto.infrastructure.WrappedSignature)1 AnalysisMetaAccess (com.oracle.graal.pointsto.meta.AnalysisMetaAccess)1 AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)1 AnalysisType (com.oracle.graal.pointsto.meta.AnalysisType)1 BeforeAnalysisAccessImpl (com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl)1 NativeLibraries (com.oracle.svm.hosted.c.NativeLibraries)1 JNIFieldAccessorMethod (com.oracle.svm.jni.hosted.JNIFieldAccessorMethod)1 JNIPrimitiveArrayOperationMethod (com.oracle.svm.jni.hosted.JNIPrimitiveArrayOperationMethod)1 Operation (com.oracle.svm.jni.hosted.JNIPrimitiveArrayOperationMethod.Operation)1 File (java.io.File)1 Method (java.lang.reflect.Method)1 URLClassLoader (java.net.URLClassLoader)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1