动态二进制翻译是一种即时编译技术,能在运行时将一种指令集体系结构的二进制代码实时翻译成可在另一种指令集体系结构下运行的代码。针对TCG(Tiny Code Generator)动态二进制翻译技术,首先对其基本原理进行研究,分析它的分层机制和翻译过程;然后对翻译块查询与缓存策略、TCG上下文维护,以及中间表示的分类和属性特点进行研究,并给出目标代码的生成步骤和及其常用的两种优化方式。这两种优化方式均在翻译阶段进行,具有实际的优化价值。
Dynamic binary translation is a just-in-time compilation technique. It can timely translate the running binary code of one in-struction set system into the code running in another instruction set system. Aiming at the TCG dynamic binary translation technique, we first study its rationale, analyse its hierarchical mechanism and translation process, and then study the strategy of translation block query and cache, the maintenance of TCG context, and the classification and attribute feature of intermediate representation. Besides, we provide the steps of generating the TCG target code and two common optimising methods. These two optimising means all work in translation stage, and have practical optimisation value.