Search in sources :

Example 1 with ExceptionHandler

use of jdk.vm.ci.meta.ExceptionHandler in project graal by oracle.

the class BciBlockMapping method handleExceptions.

private ExceptionDispatchBlock handleExceptions(BciBlock[] blockMap, int bci) {
    ExceptionDispatchBlock lastHandler = null;
    for (int i = exceptionHandlers.length - 1; i >= 0; i--) {
        ExceptionHandler h = exceptionHandlers[i];
        if (h.getStartBCI() <= bci && bci < h.getEndBCI()) {
            if (h.isCatchAll()) {
                // Discard all information about succeeding exception handlers, since they can
                // never be reached.
                lastHandler = null;
            }
            // We do not reuse exception dispatch blocks, because nested exception handlers
            // might have problems reasoning about the correct frame state.
            ExceptionDispatchBlock curHandler = new ExceptionDispatchBlock();
            blocksNotYetAssignedId++;
            curHandler.startBci = -1;
            curHandler.endBci = -1;
            curHandler.deoptBci = bci;
            curHandler.handler = h;
            curHandler.addSuccessor(blockMap[h.getHandlerBCI()]);
            if (lastHandler != null) {
                curHandler.addSuccessor(lastHandler);
            }
            lastHandler = curHandler;
        }
    }
    return lastHandler;
}
Also used : ExceptionHandler(jdk.vm.ci.meta.ExceptionHandler)

Example 2 with ExceptionHandler

use of jdk.vm.ci.meta.ExceptionHandler in project graal by oracle.

the class BciBlockMapping method makeExceptionEntries.

private void makeExceptionEntries(BciBlock[] blockMap) {
    // start basic blocks at all exception handler blocks and mark them as exception entries
    for (ExceptionHandler h : this.exceptionHandlers) {
        BciBlock xhandler = makeBlock(blockMap, h.getHandlerBCI());
        xhandler.isExceptionEntry = true;
    }
}
Also used : ExceptionHandler(jdk.vm.ci.meta.ExceptionHandler)

Example 3 with ExceptionHandler

use of jdk.vm.ci.meta.ExceptionHandler in project graal by oracle.

the class ClassfileBytecode method getExceptionHandlers.

@Override
public ExceptionHandler[] getExceptionHandlers() {
    if (exceptionTableBytes == null) {
        return new ExceptionHandler[0];
    }
    final int exceptionTableLength = exceptionTableBytes.length / EXCEPTION_HANDLER_TABLE_SIZE_IN_BYTES;
    ExceptionHandler[] handlers = new ExceptionHandler[exceptionTableLength];
    DataInputStream stream = new DataInputStream(new ByteArrayInputStream(exceptionTableBytes));
    for (int i = 0; i < exceptionTableLength; i++) {
        try {
            final int startPc = stream.readUnsignedShort();
            final int endPc = stream.readUnsignedShort();
            final int handlerPc = stream.readUnsignedShort();
            int catchTypeIndex = stream.readUnsignedShort();
            JavaType catchType;
            if (catchTypeIndex == 0) {
                catchType = null;
            } else {
                // opcode is not used
                final int opcode = -1;
                catchType = constantPool.lookupType(catchTypeIndex, opcode);
                // Check for Throwable which catches everything.
                if (catchType.toJavaName().equals("java.lang.Throwable")) {
                    catchTypeIndex = 0;
                    catchType = null;
                }
            }
            handlers[i] = new ExceptionHandler(startPc, endPc, handlerPc, catchTypeIndex, catchType);
        } catch (IOException e) {
            throw new GraalError(e);
        }
    }
    return handlers;
}
Also used : ExceptionHandler(jdk.vm.ci.meta.ExceptionHandler) JavaType(jdk.vm.ci.meta.JavaType) GraalError(org.graalvm.compiler.debug.GraalError) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream)

Example 4 with ExceptionHandler

use of jdk.vm.ci.meta.ExceptionHandler 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

ExceptionHandler (jdk.vm.ci.meta.ExceptionHandler)4 WrappedConstantPool (com.oracle.graal.pointsto.infrastructure.WrappedConstantPool)1 WrappedSignature (com.oracle.graal.pointsto.infrastructure.WrappedSignature)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 IOException (java.io.IOException)1 ConstantPool (jdk.vm.ci.meta.ConstantPool)1 JavaType (jdk.vm.ci.meta.JavaType)1 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)1 Signature (jdk.vm.ci.meta.Signature)1 GraalError (org.graalvm.compiler.debug.GraalError)1 CFunction (org.graalvm.nativeimage.c.function.CFunction)1