Search in sources :

Example 1 with DefaultRefMapFormatter

use of jdk.vm.ci.code.CodeUtil.DefaultRefMapFormatter in project graal by oracle.

the class HexCodeFileDisassemblerProvider method disassemble.

private static String disassemble(CodeCacheProvider codeCache, CompilationResult compResult, InstalledCode installedCode) {
    TargetDescription target = codeCache.getTarget();
    RegisterConfig regConfig = codeCache.getRegisterConfig();
    byte[] code = installedCode == null ? Arrays.copyOf(compResult.getTargetCode(), compResult.getTargetCodeSize()) : installedCode.getCode();
    if (code == null) {
        // Method was deoptimized/invalidated
        return "";
    }
    long start = installedCode == null ? 0L : installedCode.getStart();
    HexCodeFile hcf = new HexCodeFile(code, start, target.arch.getName(), target.wordSize * 8);
    if (compResult != null) {
        HexCodeFile.addAnnotations(hcf, compResult.getAnnotations());
        addExceptionHandlersComment(compResult, hcf);
        Register fp = regConfig.getFrameRegister();
        RefMapFormatter slotFormatter = new DefaultRefMapFormatter(target.wordSize, fp, 0);
        for (Infopoint infopoint : compResult.getInfopoints()) {
            if (infopoint instanceof Call) {
                Call call = (Call) infopoint;
                if (call.debugInfo != null) {
                    hcf.addComment(call.pcOffset + call.size, CodeUtil.append(new StringBuilder(100), call.debugInfo, slotFormatter).toString());
                }
                addOperandComment(hcf, call.pcOffset, "{" + codeCache.getTargetName(call) + "}");
            } else {
                if (infopoint.debugInfo != null) {
                    hcf.addComment(infopoint.pcOffset, CodeUtil.append(new StringBuilder(100), infopoint.debugInfo, slotFormatter).toString());
                }
                addOperandComment(hcf, infopoint.pcOffset, "{infopoint: " + infopoint.reason + "}");
            }
        }
        for (DataPatch site : compResult.getDataPatches()) {
            hcf.addOperandComment(site.pcOffset, "{" + site.reference.toString() + "}");
        }
        for (Mark mark : compResult.getMarks()) {
            hcf.addComment(mark.pcOffset, codeCache.getMarkName(mark));
        }
    }
    String hcfEmbeddedString = hcf.toEmbeddedString();
    return HexCodeFileDisTool.tryDisassemble(hcfEmbeddedString);
}
Also used : DefaultRefMapFormatter(jdk.vm.ci.code.CodeUtil.DefaultRefMapFormatter) RefMapFormatter(jdk.vm.ci.code.CodeUtil.RefMapFormatter) RegisterConfig(jdk.vm.ci.code.RegisterConfig) Call(jdk.vm.ci.code.site.Call) TargetDescription(jdk.vm.ci.code.TargetDescription) Mark(jdk.vm.ci.code.site.Mark) Infopoint(jdk.vm.ci.code.site.Infopoint) DataPatch(jdk.vm.ci.code.site.DataPatch) Register(jdk.vm.ci.code.Register) DefaultRefMapFormatter(jdk.vm.ci.code.CodeUtil.DefaultRefMapFormatter)

Aggregations

DefaultRefMapFormatter (jdk.vm.ci.code.CodeUtil.DefaultRefMapFormatter)1 RefMapFormatter (jdk.vm.ci.code.CodeUtil.RefMapFormatter)1 Register (jdk.vm.ci.code.Register)1 RegisterConfig (jdk.vm.ci.code.RegisterConfig)1 TargetDescription (jdk.vm.ci.code.TargetDescription)1 Call (jdk.vm.ci.code.site.Call)1 DataPatch (jdk.vm.ci.code.site.DataPatch)1 Infopoint (jdk.vm.ci.code.site.Infopoint)1 Mark (jdk.vm.ci.code.site.Mark)1