Method and apparatus for generating code for scheduling the execution of binary code

Saved in:
Bibliographic Details
Title: Method and apparatus for generating code for scheduling the execution of binary code
Patent Number: 7,673,293
Publication Date: March 02, 2010
Appl. No: 10/827527
Application Filed: April 20, 2004
Abstract: Dynamic binary translators enable binaries of a source platform to execute on a target platform without recompilation. This is achieved by runtime (on-the-fly) translation of source machine instructions into equivalent target machine instructions. Typically dynamic binary translators are used for migrating from an older platform to a newer one, implementing complex instruction set architectures, speeding up simulators and in profiling tools. In all these applications, the speed of translation is critical to ensure that the overheads incurred by the translator do not outweigh the advantages of dynamic translation. One such overhead is created by the analysis required when code is translated for execution in a parallel processing environment.
Inventors: Sanyal, Dibyapran (Uttar Pradesh, IN)
Assignees: Hewlett-Packard Development Company, L.P. (Houston, TX, US)
Claim: 1. A build and compilation process of a dynamic binary translator which operates between any processor or platform types and that translates a source code instruction into a target code instruction, wherein the source code differs from the target code, the process comprising: (a) creating a repository of magic numbers, wherein each magic number is a unique integer representing one and only one variant of a source instruction so that the collection of all the magic numbers represents the set of all valid instructions possible of a source instruction set to form a set of constants associating a unique string with a unique integer, wherein the swing shortly describes a variant of the instruction which the magic number is supposed to represent; (b) creating a repository of templates, wherein each template is a functionally equivalent sequence of target architecture instructions, for each source instruction, each template having temporary native registers for its operations and is compiled at the compile time of the binary dynamic translator as a function and whose name is derived from the corresponding magic number's associated swing so that the templates are available as a routine/function at run-time; (c) creating a table, indexed on magic numbers, containing the references to the corresponding templates so that at run-time the translator can pick up the appropriate template for a given instruction after ascertaining its magic number; (d) creating a repository of template filler routines in which each template filler routine has the knowledge of both the source and target instructions; causing the template filler routine of a given template to extract dynamic components of the source instruction and fill the extracted items in an in-memory template to replace corresponding place-holders; causing the translator to call the template filler routine for a given instruction at run-time so a template filler routine repository is linked to corresponding templates and magic numbers; (e) creating a repository of minimal decode/magic-number-routines; causing a minimal decode/magic-number-extractor routines repository to give a raw source instruction and return the magic number of that instruction; preparing the dynamic binary translator to operate between any processor or platform types by compiling steps (a)-(e) together.
Claim: 2. A method of operating a dynamic binary translator of claim 1 responsive to a source instruction Si in a source code so that the translator derives a target instruction in a target code that differs from the source code, the method comprising: using a repository of magic numbers, wherein each magic number is a unique integer representing one and only one variant of a source instruction so that the collection of all the magic numbers represents the set of all valid instructions possible of a source instruction set to form a set of constants associating a unique swing with a unique integer, wherein the string shortly describes a variant of the instruction which the magic number is supposed to represent and performing a plurality of steps including: (1) mapping Si to an appropriate minimal decode/magic-numbers-extractor routine to repository (MNEi); (2) call the MNEi with Si as a parameter; (3) causing MNEi to return the magic number mi; (4) mapping mi to template ti; (5) copying ti to a code generator buffer b; (6) mapping mi to a template filler routine (TFRi); (7) causing TFRi to extract dynamic compliments of Si and fill in the ti found at buffer b; (8) going to S(i+1) if the current block is not yet finished; (9) optimizing the sequence of instructions in buffer b for best tempera performance; and (10) emitting optimized code from buffer b to target code cache Ci.
Claim: 3. The build and compilation process according to claim 1 , wherein the dynamic binary translator maps the source code instructions to the target code instructions using the templates.
Claim: 4. The build and compilation process according to claim 1 , wherein the dynamic binary translator outputs the translated target code instruction for processing on a target processor using the templates and fill and analysis routines during compilation of the dynamic binary translator.
Claim: 5. A dynamic binary translator system which operates between any platform types for translating machine instruction in source code into equivalent target instructions of a code of a target platform, wherein the source code differs from the code of the target platform, said system comprising: a processor; and storage coupled to the processor, wherein the storage comprises: a dynamic binary translator arranged to be responsive to the precompiled template and for performing a build and compilation process of a dynamic binary translator which operates between any processor or platform types and that translates a source code instruction into a target code instruction, wherein the source code differs from the target code, the process comprising: (a) creating a repository of magic numbers, wherein each magic number is a unique integer representing one and only one variant of a source instruction so that the collection of all the magic numbers represents the set of all valid instructions possible of a source instruction set to form a set of constants associating a unique string with a unique integer, wherein the string shortly describes a variant of the instruction which the magic number is supposed to represent; (b) creating a repository of templates, wherein each template is a functionally equivalent sequence of target architecture instructions, for each source instruction, each template having temporary native registers for its operations and is compiled at the compile time of the binary dynamic translator as a function and whose name is derived from the corresponding magic number's associated string so that the templates are available as a routine/function at run-time; (c) creating a table, indexed on magic numbers, containing the references to the corresponding templates so that at run-time the translator can pick up the appropriate template for a given instruction after ascertaining its magic number; (d) creating a repository of template filler routines in which each template filler routine has the knowledge of both the source and target instructions; causing the template filler routine of a given template to extract dynamic components of the source instruction and fill the extracted items in an in-memory template to replace corresponding place-holders; causing the translator to call the template filler routine for a given instruction at run-time so a template filler routine repository is linked to corresponding templates and magic numbers; (e) creating a repository of minimal decode/magic-number-routines; causing a minimal decode/magic-number-extractor routines repository to give a raw source instruction and return the magic number of that instruction; preparing the dynamic binary translator to operate between any processor or platform types by compiling steps (a)-(e) together.
Claim: 6. The dynamic binary translator system according to claim 5 wherein the dynamic binary translator maps the source code instructions to the target code instructions using the templates.
Claim: 7. The dynamic binary translator system according to claim 5 wherein a fill and analysis routine generator arranged to be responsive to the templates for generating fill and analysis routines for identifying the fillable positions in the template by parsing the template and for generating code to extract and deposit fields from the machine instructions in source code into a precompiled template.
Claim: 8. The dynamic binary translator system according to claim 5 wherein the dynamic binary translator arranged to be responsive to the machine instructions and wherein the dynamic binary translator outputs the translated target code instruction for processing on a target processor using the templates and fill and analysis routines during compilation of the dynamic binary translator.
Claim: 9. A computer readable storage medium comprising a dynamic translator for performing a build and compilation process of the dynamic binary translator which operates between any processor or platform types and that translates a source code instruction into a target code instruction, having instructions that, when executed by a computer, cause the computer to perform a method comprising: (a) creating a repository of magic numbers, wherein each magic number is a unique integer representing one and only one variant of a source instruction so that the collection of all the magic numbers represents the set of all valid instructions possible of a source instruction set to form a set of constants associating a unique string with a unique integer, wherein the swing shortly describes a variant of the instruction which the magic number is supposed to represent; (b) creating a repository of templates, wherein each template is a functionally equivalent sequence of target architecture instructions, for each source instruction, each template having temporary native registers for its operations and is compiled at the compile time of the binary dynamic translator as a function and whose name is derived from the corresponding magic number's associated swing so that the templates are available as a routine/function at run-time; (c) creating a table, indexed on magic numbers, containing the references to the corresponding templates so that at run-time the translator can pick up the appropriate template for a given instruction after ascertaining its magic number; (d) creating a repository of template filler routines in which each template filler routine has the knowledge of both the source and target instructions; causing the template filler routine of a given template to extract dynamic components of the source instruction and fill the extracted items in an in-memory template to replace corresponding place-holders; causing the translator to call the template filler routine for a given instruction at run-time so a template filler routine repository is linked to corresponding templates and magic numbers; (e) creating a repository of minimal decode/magic-number-routines; causing a minimal decode/magic-number-extractor routines repository to give a raw source instruction and return the magic number of that instruction; preparing the dynamic binary translator to operate between any processor or platform types by compiling steps (a)-(e) together.
Claim: 10. The computer readable storage medium according to claim 9 wherein the dynamic binary translator maps the source code instructions to the target code instructions using the templates.
Claim: 11. The computer readable storage medium according to claim 9 wherein the dynamic binary translator outputs the translated target code instruction for processing on a target processor using the templates and fill and analysis routines during compilation of the dynamic binary translator.
Claim: 12. Apparatus which operates between any platform types for translating machine instructions in source code into equivalent target instructions of a code of a target platform, wherein the source code differs from the code of the target platform, said apparatus comprising: a processor; and storage means coupled to the processor, wherein the storage means comprises: a source of binary translation templates for mapping instructions in the source code into a set of instructions in the code of the target platform; a fill and analysis routine generator arranged to be responsive to the templates for generating fill and analysis routines for identifying fillable positions in a template by parsing the template and for generating code to extract and deposit fields from the instructions in source code into a precompiled template; and a dynamic binary translator performing the build and compilation process of claim 1 arranged to be responsive to the precompiled template.
Current U.S. Class: 717/136
Patent References Cited: 5202975 April 1993 Rasbold et al.
5894576 April 1999 Bharadwaj
6016396 January 2000 Mochizuki
6075937 June 2000 Scalzi et al.
6378066 April 2002 Lewis
6519768 February 2003 Hughes et al.
6772413 August 2004 Kuznetsov
2003/0088860 May 2003 Wang
WO 90/01738 February 1990
Other References: Altman et al., “Welcome to the Opportunities of Binary Translation,” IEEE Computer, Mar. 2000, pp. 40-45, vol. 33, No. 3. cited by other
Assistant Examiner: Yaary, Michael
Primary Examiner: Bullock, Jr., Lewis A
Accession Number: edspgr.07673293
Database: USPTO Patent Grants
Description
Abstract:Dynamic binary translators enable binaries of a source platform to execute on a target platform without recompilation. This is achieved by runtime (on-the-fly) translation of source machine instructions into equivalent target machine instructions. Typically dynamic binary translators are used for migrating from an older platform to a newer one, implementing complex instruction set architectures, speeding up simulators and in profiling tools. In all these applications, the speed of translation is critical to ensure that the overheads incurred by the translator do not outweigh the advantages of dynamic translation. One such overhead is created by the analysis required when code is translated for execution in a parallel processing environment.