Search in sources :

Example 1 with ExceptionHandler

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

the class HexCodeFileDisassemblerProvider method addExceptionHandlersComment.

private static void addExceptionHandlersComment(CompilationResult compResult, HexCodeFile hcf) {
    if (!compResult.getExceptionHandlers().isEmpty()) {
        String nl = HexCodeFile.NEW_LINE;
        StringBuilder buf = new StringBuilder("------ Exception Handlers ------").append(nl);
        for (ExceptionHandler e : compResult.getExceptionHandlers()) {
            buf.append("    ").append(e.pcOffset).append(" -> ").append(e.handlerPos).append(nl);
            hcf.addComment(e.pcOffset, "[exception -> " + e.handlerPos + "]");
            hcf.addComment(e.handlerPos, "[exception handler for " + e.pcOffset + "]");
        }
        hcf.addComment(0, buf.toString());
    }
}
Also used : ExceptionHandler(jdk.vm.ci.code.site.ExceptionHandler)

Example 2 with ExceptionHandler

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

the class CollectingObjectReferenceVisitor method addMethod.

public void addMethod(SharedMethod method, CompilationResult compilation, int compilationOffset) {
    int totalFrameSize = compilation.getTotalFrameSize();
    /* Mark the method start and register the frame size. */
    IPData startEntry = makeEntry(compilationOffset);
    startEntry.frameSizeEncoding = encodeFrameSize(totalFrameSize, true);
    /* Register the frame size for all entries that are starting points for the index. */
    long entryIP = CodeInfoDecoder.lookupEntryIP(CodeInfoDecoder.indexGranularity() + compilationOffset);
    while (entryIP <= CodeInfoDecoder.lookupEntryIP(compilation.getTargetCodeSize() + compilationOffset)) {
        IPData entry = makeEntry(entryIP);
        entry.frameSizeEncoding = encodeFrameSize(totalFrameSize, false);
        entryIP += CodeInfoDecoder.indexGranularity();
    }
    /* Make entries for all calls and deoptimization entry points of the method. */
    for (Infopoint infopoint : compilation.getInfopoints()) {
        final DebugInfo debugInfo = infopoint.debugInfo;
        if (debugInfo != null) {
            final int offset = getEntryOffset(infopoint);
            if (offset >= 0) {
                IPData entry = makeEntry(offset + compilationOffset);
                assert entry.referenceMap == null && entry.frameData == null;
                entry.referenceMap = (ReferenceMapEncoder.Input) debugInfo.getReferenceMap();
                entry.frameData = frameInfoEncoder.addDebugInfo(method, infopoint, totalFrameSize);
            }
        }
    }
    /* Make entries for all exception handlers. */
    for (ExceptionHandler handler : compilation.getExceptionHandlers()) {
        final IPData entry = makeEntry(handler.pcOffset + compilationOffset);
        assert entry.exceptionOffset == 0;
        entry.exceptionOffset = handler.handlerPos - handler.pcOffset;
    }
    ImageSingletons.lookup(Counters.class).methodCount.inc();
    ImageSingletons.lookup(Counters.class).codeSize.add(compilation.getTargetCodeSize());
}
Also used : ExceptionHandler(jdk.vm.ci.code.site.ExceptionHandler) ReferenceMapEncoder(com.oracle.svm.core.heap.ReferenceMapEncoder) Infopoint(jdk.vm.ci.code.site.Infopoint) DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint) DebugInfo(jdk.vm.ci.code.DebugInfo) Infopoint(jdk.vm.ci.code.site.Infopoint) DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint)

Example 3 with ExceptionHandler

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

the class CollectingObjectReferenceVisitor method verifyMethod.

protected void verifyMethod(CompilationResult compilation, int compilationOffset) {
    for (int relativeIP = 0; relativeIP < compilation.getTargetCodeSize(); relativeIP++) {
        int totalIP = relativeIP + compilationOffset;
        CodeInfoQueryResult codeInfo = new CodeInfoQueryResult();
        lookupCodeInfo(totalIP, codeInfo);
        assert codeInfo.getTotalFrameSize() == compilation.getTotalFrameSize();
        assert lookupTotalFrameSize(totalIP) == codeInfo.getTotalFrameSize();
        assert lookupExceptionOffset(totalIP) == codeInfo.getExceptionOffset();
        assert lookupReferenceMapIndex(totalIP) == codeInfo.getReferenceMapIndex();
        assert getReferenceMapEncoding() == codeInfo.getReferenceMapEncoding();
    }
    for (Infopoint infopoint : compilation.getInfopoints()) {
        if (infopoint.debugInfo != null) {
            int offset = CodeInfoEncoder.getEntryOffset(infopoint);
            if (offset >= 0) {
                assert offset < compilation.getTargetCodeSize();
                CodeInfoQueryResult codeInfo = new CodeInfoQueryResult();
                lookupCodeInfo(offset + compilationOffset, codeInfo);
                CollectingObjectReferenceVisitor visitor = new CollectingObjectReferenceVisitor();
                ReferenceMapDecoder.walkOffsetsFromPointer(WordFactory.zero(), codeInfo.getReferenceMapEncoding(), codeInfo.getReferenceMapIndex(), visitor);
                ReferenceMapEncoder.Input expected = (ReferenceMapEncoder.Input) infopoint.debugInfo.getReferenceMap();
                assert expected.equals(visitor.result);
                if (codeInfo.frameInfo != CodeInfoQueryResult.NO_FRAME_INFO) {
                    verifyFrame(compilation, infopoint.debugInfo.frame(), codeInfo.frameInfo, new BitSet());
                }
            }
        }
    }
    for (ExceptionHandler handler : compilation.getExceptionHandlers()) {
        int offset = handler.pcOffset;
        assert offset >= 0 && offset < compilation.getTargetCodeSize();
        long actual = lookupExceptionOffset(offset + compilationOffset);
        long expected = handler.handlerPos - handler.pcOffset;
        assert expected != 0;
        assert expected == actual;
    }
}
Also used : ExceptionHandler(jdk.vm.ci.code.site.ExceptionHandler) ReferenceMapEncoder(com.oracle.svm.core.heap.ReferenceMapEncoder) BitSet(java.util.BitSet) Infopoint(jdk.vm.ci.code.site.Infopoint) DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint) Infopoint(jdk.vm.ci.code.site.Infopoint) DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint)

Example 4 with ExceptionHandler

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

the class CompilationResult method recordExceptionHandler.

/**
 * Records an exception handler for this method.
 *
 * @param codePos the position in the code that is covered by the handler
 * @param handlerPos the position of the handler
 */
public void recordExceptionHandler(int codePos, int handlerPos) {
    checkOpen();
    assert validateExceptionHandlerAdd(codePos, handlerPos) : String.format("Duplicate exception handler for pc 0x%x handlerPos 0x%x", codePos, handlerPos);
    exceptionHandlers.add(new ExceptionHandler(codePos, handlerPos));
}
Also used : ExceptionHandler(jdk.vm.ci.code.site.ExceptionHandler)

Aggregations

ExceptionHandler (jdk.vm.ci.code.site.ExceptionHandler)4 DeoptEntryInfopoint (com.oracle.svm.core.deopt.DeoptEntryInfopoint)2 ReferenceMapEncoder (com.oracle.svm.core.heap.ReferenceMapEncoder)2 Infopoint (jdk.vm.ci.code.site.Infopoint)2 BitSet (java.util.BitSet)1 DebugInfo (jdk.vm.ci.code.DebugInfo)1