• 中国计算机学会会刊
  • 中国科技核心期刊
  • 中文核心期刊

计算机工程与科学

• 高性能计算 • 上一篇    下一篇

基于TCG技术的二进制翻译条件转移指令优化研究

张家豪,单征,岳峰,傅立国,王军,李明亮   

  1. (数学工程与先进计算国家重点实验室,河南 郑州 450001)
  • 收稿日期:2019-01-15 修回日期:2019-04-01 出版日期:2019-08-25 发布日期:2019-08-25

Optimization of binary translation conditional
transfer instructions based on TCG technology

ZHANG Jia-hao,SHAN Zheng,YUE Feng,FU Li-guo,WANG Jun,LI Ming-liang   

  1. (State Key Laboratory of Mathematical Engineering and Advanced Computing,Zhengzhou 450001,China)
  • Received:2019-01-15 Revised:2019-04-01 Online:2019-08-25 Published:2019-08-25

摘要:

在二进制翻译中引入TCG中间表示技术可以实现多目标平台之间的程序移植,同时可以更加方便地引入新型平台,解决新平台对主流平台的兼容性问题。然而由于原有的中间表示在翻译过程中影响了代码的关联度,生成的后端代码中存在较多冗余指令,影响翻译程序的执行效率。分析了指令优化可行性,针对条件跳转指令进行优化,通过指令预处理对中间表示进行改进,实现中间表示到后端代码生成由一对多翻译模式到多对多翻译模式的转变,采用指令归约技术,针对条件跳转指令的2种模式CMP-JX型与TEST-JX型,分别设计相应的优化翻译算法,并在开源二进制平台QEMU上实现。基于NPB-3.3和SPEC CPU 2006测试集进行了测试,与以前的翻译模式进行对比,优化后的代码膨胀率平均减少了14.62%,翻译程序运行速度提升了17.23%,验证了该优化方法的有效性。

关键词: 二进制翻译, TCG中间表示, 条件跳转, 代码预处理, 指令归约

Abstract:

The application of TCG intermediate representation technology in binary translation can realize the migration of programs between multiple target platforms. In addition, it makes the introduction of new platforms more conveniently and ensure the compatibility between new platforms and mainstream platforms. However, due to a lack of consideration for the association of code in the translation process, the traditional intermediate representation generates back-end codes with many redundant instructions which affect the execution efficiency of the translation program. We firstly analyze the feasibility of instruction optimization and optimize conditional jump instructions. Secondly, we improve intermediate representation via instruction preprocessing, and implement the many-to-many translation model instead of one-to-many translation model to realize the transformation from intermediate representation to back-end code generation. We adopt the instruction reduction technique to design corresponding optimized translation algorithms for the two modes (CMP-JX and TEST-JX) of conditional jump instructions, and realize them on the open source binary platform QEMU. Experiments on the NPB-3.3 and SPEC CPU 2006 test sets show that the code expansion rate is reduced by an average of 14.62% and the running speed of translation programs is improved by 17.23% in comparison with the existing translation modes, which verifies the effectiveness of the proposed method.
 

Key words: binary translation, TCG intermediate representation, conditional jump instruction, code preprocessing, instruction optimization