< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.code/src/org/graalvm/compiler/code/HexCodeFileDisassemblerProvider.java

Print this page




  61         return "hcf";
  62     }
  63 
  64     @Override
  65     public String disassembleInstalledCode(CodeCacheProvider codeCache, CompilationResult compResult, InstalledCode installedCode) {
  66         assert installedCode != null;
  67         return installedCode.isValid() ? disassemble(codeCache, compResult, installedCode) : null;
  68     }
  69 
  70     private static String disassemble(CodeCacheProvider codeCache, CompilationResult compResult, InstalledCode installedCode) {
  71         TargetDescription target = codeCache.getTarget();
  72         RegisterConfig regConfig = codeCache.getRegisterConfig();
  73         byte[] code = installedCode == null ? Arrays.copyOf(compResult.getTargetCode(), compResult.getTargetCodeSize()) : installedCode.getCode();
  74         if (code == null) {
  75             // Method was deoptimized/invalidated
  76             return "";
  77         }
  78         long start = installedCode == null ? 0L : installedCode.getStart();
  79         HexCodeFile hcf = new HexCodeFile(code, start, target.arch.getName(), target.wordSize * 8);
  80         if (compResult != null) {
  81             HexCodeFile.addAnnotations(hcf, compResult.getAnnotations());
  82             addExceptionHandlersComment(compResult, hcf);
  83             Register fp = regConfig.getFrameRegister();
  84             RefMapFormatter slotFormatter = new DefaultRefMapFormatter(target.wordSize, fp, 0);
  85             for (Infopoint infopoint : compResult.getInfopoints()) {
  86                 if (infopoint instanceof Call) {
  87                     Call call = (Call) infopoint;
  88                     if (call.debugInfo != null) {
  89                         hcf.addComment(call.pcOffset + call.size, CodeUtil.append(new StringBuilder(100), call.debugInfo, slotFormatter).toString());
  90                     }
  91                     addOperandComment(hcf, call.pcOffset, "{" + codeCache.getTargetName(call) + "}");
  92                 } else {
  93                     if (infopoint.debugInfo != null) {
  94                         hcf.addComment(infopoint.pcOffset, CodeUtil.append(new StringBuilder(100), infopoint.debugInfo, slotFormatter).toString());
  95                     }
  96                     addOperandComment(hcf, infopoint.pcOffset, "{infopoint: " + infopoint.reason + "}");
  97                 }
  98             }
  99             for (DataPatch site : compResult.getDataPatches()) {
 100                 hcf.addOperandComment(site.pcOffset, "{" + site.reference.toString() + "}");
 101             }




  61         return "hcf";
  62     }
  63 
  64     @Override
  65     public String disassembleInstalledCode(CodeCacheProvider codeCache, CompilationResult compResult, InstalledCode installedCode) {
  66         assert installedCode != null;
  67         return installedCode.isValid() ? disassemble(codeCache, compResult, installedCode) : null;
  68     }
  69 
  70     private static String disassemble(CodeCacheProvider codeCache, CompilationResult compResult, InstalledCode installedCode) {
  71         TargetDescription target = codeCache.getTarget();
  72         RegisterConfig regConfig = codeCache.getRegisterConfig();
  73         byte[] code = installedCode == null ? Arrays.copyOf(compResult.getTargetCode(), compResult.getTargetCodeSize()) : installedCode.getCode();
  74         if (code == null) {
  75             // Method was deoptimized/invalidated
  76             return "";
  77         }
  78         long start = installedCode == null ? 0L : installedCode.getStart();
  79         HexCodeFile hcf = new HexCodeFile(code, start, target.arch.getName(), target.wordSize * 8);
  80         if (compResult != null) {
  81             HexCodeFile.addAnnotations(hcf, compResult.getCodeAnnotations());
  82             addExceptionHandlersComment(compResult, hcf);
  83             Register fp = regConfig.getFrameRegister();
  84             RefMapFormatter slotFormatter = new DefaultRefMapFormatter(target.wordSize, fp, 0);
  85             for (Infopoint infopoint : compResult.getInfopoints()) {
  86                 if (infopoint instanceof Call) {
  87                     Call call = (Call) infopoint;
  88                     if (call.debugInfo != null) {
  89                         hcf.addComment(call.pcOffset + call.size, CodeUtil.append(new StringBuilder(100), call.debugInfo, slotFormatter).toString());
  90                     }
  91                     addOperandComment(hcf, call.pcOffset, "{" + codeCache.getTargetName(call) + "}");
  92                 } else {
  93                     if (infopoint.debugInfo != null) {
  94                         hcf.addComment(infopoint.pcOffset, CodeUtil.append(new StringBuilder(100), infopoint.debugInfo, slotFormatter).toString());
  95                     }
  96                     addOperandComment(hcf, infopoint.pcOffset, "{infopoint: " + infopoint.reason + "}");
  97                 }
  98             }
  99             for (DataPatch site : compResult.getDataPatches()) {
 100                 hcf.addOperandComment(site.pcOffset, "{" + site.reference.toString() + "}");
 101             }


< prev index next >