Search in sources :

Example 1 with DeoptEntryInfopoint

use of com.oracle.svm.core.deopt.DeoptEntryInfopoint in project graal by oracle.

the class CompileQueue method verifyDeoptTarget.

private static boolean verifyDeoptTarget(HostedMethod method, CompilationResult result) {
    Map<Long, BytecodeFrame> encodedBciMap = new HashMap<>();
    /*
         * All deopt targets must have a graph.
         */
    assert method.compilationInfo.graph != null : "Deopt target must have a graph.";
    /*
         * No deopt targets can have a StackValueNode in the graph.
         */
    assert method.compilationInfo.graph.getNodes(StackValueNode.TYPE).isEmpty() : "No stack value nodes must be present in deopt target.";
    for (Infopoint infopoint : result.getInfopoints()) {
        if (infopoint.debugInfo != null) {
            DebugInfo debugInfo = infopoint.debugInfo;
            if (!debugInfo.hasFrame()) {
                continue;
            }
            BytecodeFrame topFrame = debugInfo.frame();
            BytecodeFrame rootFrame = topFrame;
            while (rootFrame.caller() != null) {
                rootFrame = rootFrame.caller();
            }
            assert rootFrame.getMethod().equals(method);
            boolean isDeoptEntry = method.compilationInfo.isDeoptEntry(rootFrame.getBCI(), rootFrame.duringCall, rootFrame.rethrowException);
            if (infopoint instanceof DeoptEntryInfopoint) {
                assert isDeoptEntry;
            } else if (rootFrame.duringCall && isDeoptEntry) {
                assert infopoint instanceof Call || isSingleSteppingInfopoint(infopoint);
            } else {
                continue;
            }
            long encodedBci = FrameInfoEncoder.encodeBci(rootFrame.getBCI(), rootFrame.duringCall, rootFrame.rethrowException);
            if (encodedBciMap.containsKey(encodedBci)) {
                assert encodedBciMap.get(encodedBci).equals(rootFrame) : "duplicate encoded bci " + encodedBci + " in deopt target " + method + " with different debug info:\n\n" + rootFrame + "\n\n" + encodedBciMap.get(encodedBci);
            }
            encodedBciMap.put(encodedBci, rootFrame);
        }
    }
    return true;
}
Also used : Call(jdk.vm.ci.code.site.Call) BytecodeFrame(jdk.vm.ci.code.BytecodeFrame) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint) Infopoint(jdk.vm.ci.code.site.Infopoint) DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint) DebugInfo(jdk.vm.ci.code.DebugInfo)

Example 2 with DeoptEntryInfopoint

use of com.oracle.svm.core.deopt.DeoptEntryInfopoint in project graal by oracle.

the class DeoptEntryOp method emitCode.

@Override
public void emitCode(CompilationResultBuilder crb) {
    CompilationResult compilation = crb.compilationResult;
    /* Search for the previous added info point. */
    List<Infopoint> infoPoints = compilation.getInfopoints();
    int size = infoPoints.size();
    for (int idx = size - 1; idx >= 0; idx--) {
        Infopoint infopoint = infoPoints.get(idx);
        int entryOffset = CodeInfoEncoder.getEntryOffset(infopoint);
        if (entryOffset >= 0) {
            if (entryOffset == crb.asm.position()) {
                crb.asm.ensureUniquePC();
                break;
            }
        }
    }
    /* Register this location as a deopt infopoint. */
    compilation.addInfopoint(new DeoptEntryInfopoint(crb.asm.position(), state.debugInfo()));
    /* Add NOP so that the next infopoint (e.g., an invoke) gets a unique PC. */
    crb.asm.ensureUniquePC();
}
Also used : DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint) Infopoint(jdk.vm.ci.code.site.Infopoint) CompilationResult(org.graalvm.compiler.code.CompilationResult) DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint) DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint) Infopoint(jdk.vm.ci.code.site.Infopoint)

Aggregations

DeoptEntryInfopoint (com.oracle.svm.core.deopt.DeoptEntryInfopoint)2 Infopoint (jdk.vm.ci.code.site.Infopoint)2 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 BytecodeFrame (jdk.vm.ci.code.BytecodeFrame)1 DebugInfo (jdk.vm.ci.code.DebugInfo)1 Call (jdk.vm.ci.code.site.Call)1 CompilationResult (org.graalvm.compiler.code.CompilationResult)1