CN104375879B - Based on the binary translation method and device for performing tree depth - Google Patents

Based on the binary translation method and device for performing tree depth Download PDF

Info

Publication number
CN104375879B
CN104375879B CN201410688378.5A CN201410688378A CN104375879B CN 104375879 B CN104375879 B CN 104375879B CN 201410688378 A CN201410688378 A CN 201410688378A CN 104375879 B CN104375879 B CN 104375879B
Authority
CN
China
Prior art keywords
translation
tree depth
basic block
instruction
basic
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201410688378.5A
Other languages
Chinese (zh)
Other versions
CN104375879A (en
Inventor
康烁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Dijie Software Technology Co.,Ltd.
Original Assignee
康烁
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 康烁 filed Critical 康烁
Priority to CN201410688378.5A priority Critical patent/CN104375879B/en
Publication of CN104375879A publication Critical patent/CN104375879A/en
Application granted granted Critical
Publication of CN104375879B publication Critical patent/CN104375879B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a kind of based on the binary translation method and device that perform tree depth.This method be included in start construct superblock when, perform tree depth and be initialized as 0, and obtain default perform and set depth threshold, from the basic BOB(beginning of block) translation where default initial address, in translation, if the present instruction of the basic block of translation is direct jump instruction, the basic block that direct jump instruction enters is translated;If the present instruction of the basic block of translation be conditional jump instructions, Translation Condition jump instruction redirect after basic block and conditional jump instructions next basic block, and will perform and set depth and add 1;If the present instruction of the basic block of translation is function call instruction, function corresponding to function call instruction is then translated, and tree depth will be performed and add 1, when execution tree depth reaches execution tree depth threshold, translation terminates, and all basic blocks of translation form a superblock.By means of the invention it is possible to lift the performance for performing interpretive program.

Description

Based on the binary translation method and device for performing tree depth
Technical field
The present invention relates to field of computer technology, specifically, more particularly to based on the binary translation for performing tree depth Method and apparatus.
Background technology
Binary translation refers to a kind of binary program of source processor to be translated as on another target processor The method of machine language, so that the program being translated be able to can perform on target processor.In binary translation method, Multiple basic blocks are configured to a superblock, wherein, basic block refers to one section of instruction of only single entry and single outlet, super Block refers to the set of multiple basic blocks.
Existing method is with priority execution sequence, the multiple basic blocks performed on source processor composition One superblock, is then translated to this superblock.Therefore, existing interpretation method on source processor not holding Capable basic block translation is in superblock, and in target processor during configuration processor, execution efficiency is low.
The problem of performance of superblock after being translated for the execution two-stage system of target processor present in prior art is low, Effective solution method is not yet proposed at present.
The content of the invention
It is a kind of based on the binary translation method and device that perform tree depth it is a primary object of the present invention to provide, with solution Target processor certainly of the prior art performs the low problem of performance of the superblock after two-stage system translation.
According to one aspect of the present invention, there is provided a kind of based on the binary translation method for performing tree depth.
Included according to the binary translation method of the present invention:Step S0:Start to construct superblock, it is initial that tree depth will be performed 0 is turned to, and obtains default perform and sets depth threshold, from the basic BOB(beginning of block) translation where default initial address;Step S1: Translate the basic block got;Step S2:If the present instruction of the basic block of translation is direct jump instruction, obtains and directly jump Turn the basic block that instruction enters, and be back to step S1;Step S3:If the present instruction of the basic block of translation refers to for conditional jump Order, then obtain next basic block of the basic block after conditional jump instructions redirect and conditional jump instructions, and will perform tree Depth adds 1, is back to step S1;Step S4:If the present instruction of the basic block of translation is function call instruction, letter is obtained Function corresponding to number call instruction will perform tree depth and add 1 as basic block, be back to step S1, wherein, holding every time After row tree depth adds 1, judge whether current execution tree depth reaches execution tree depth threshold, held if performing tree depth and reaching Row tree depth threshold, then translation terminate, and all basic blocks of translation form a superblock.
Further, this method also includes:Step S5:After step S1 is performed, first instruction of basic block is stored Address.
Further, this method also includes:Step S6:While default execution tree depth threshold is obtained, obtain pre- If translation time threshold, and the timing when starting translation, wherein, performed each after tree depth adds 1, judge current meter When the translation time whether reach translation time threshold, if the translation time of present timing reaches translation time threshold, translate Terminate.
According to another aspect of the present invention, there is provided a kind of based on the binary translation device for performing tree depth.
Included according to the binary translation device of the present invention:Initialization module, for start construct superblock when, will perform Tree depth is initialized as 0, and obtains default perform and set depth threshold, is turned over from the basic BOB(beginning of block) where default initial address Translate;Translation module, for translating the basic block got;First acquisition module, for the present instruction for the basic block served as interpreter For direct jump instruction, the new basic block that direct jump instruction enters is obtained, and translated by translation module;Second obtains mould Block, the present instruction of the basic block for serving as interpreter is conditional jump instructions, obtains the basic block after conditional jump instructions redirect With next basic block of conditional jump instructions, translated by translation module, and tree depth will be performed and add 1;3rd obtains Module, the present instruction for the basic block served as interpreter is function call instruction, then obtains function conduct corresponding to function call instruction Basic block, translated by translation module, and tree depth will be performed and add 1;Judge module, for adding in each tree depth that performs After 1, judge whether current execution tree depth reaches execution tree depth threshold, if performing tree depth reaches execution tree depth threshold Value, then translation terminate, and all basic blocks of translation form a superblock.
Further, the device also includes:Memory module, after translating a basic block in translation module, storage The address of first instruction of the basic block.
Further, initialization module is additionally operable to while default execution tree depth threshold is obtained, obtain default Translate time threshold, and the timing when starting translation;Judge module is additionally operable to after each execution tree depth adds 1, is judged Whether the translation time of present timing reaches translation time threshold, if the translation time of present timing reaches translation time threshold, Then translation terminates.
By the present invention, when carrying out binary translation, translated from the basic BOB(beginning of block) where default initial address, During translation, if the present instruction of the basic block of translation is direct jump instruction, the basic block that direct jump instruction enters is translated; If the present instruction of the basic block of translation is conditional jump instructions, Translation Condition jump instruction redirect after basic block and condition Next basic block of jump instruction, and tree depth will be performed and add 1;If the present instruction of the basic block of translation is function call Instruction, then function corresponding to sweet potato function call instruction, and tree depth will be performed and add 1, tree is performed when execution tree depth reaches During depth threshold, translation terminates, and all basic blocks of translation form a superblock.Turned over by means of the invention it is possible to lift execution The performance of translator program.
Described above is only the general introduction of technical solution of the present invention, in order to better understand the technological means of the present invention, And can be practiced according to the content of specification, and in order to allow above and other objects of the present invention, feature and advantage can Become apparent, below especially exemplified by the embodiment of the present invention.
Brief description of the drawings
By reading the detailed description of hereafter preferred embodiment, it is various other the advantages of and benefit it is common for this area Technical staff will be clear understanding.Accompanying drawing is only used for showing the purpose of preferred embodiment, and is not considered as to the present invention Limitation.And in whole accompanying drawing, identical part is denoted by the same reference numerals.In the accompanying drawings:
Fig. 1 is the flow chart of binary translation method according to a first embodiment of the present invention;
Fig. 2 is the flow chart of binary translation method according to a second embodiment of the present invention;
Fig. 3 is the block diagram of binary translation device according to a second embodiment of the present invention.
Embodiment
The present invention will be further described with reference to the accompanying drawings and detailed description.It is pointed out that do not conflicting In the case of, the feature in embodiment and embodiment in the application can be mutually combined.
First embodiment
Fig. 1 is the flow chart of binary translation method according to a first embodiment of the present invention, as shown in figure 1, this method bag Include the steps:
Step S0:Start to construct superblock, tree depth will be performed and be initialized as 0, and obtain default perform and set depth threshold Value, from the basic BOB(beginning of block) translation where default initial address.
Step S1:Translate the basic block got.
Step S2:If the present instruction of the basic block of translation is direct jump instruction, obtains direct jump instruction and enter Basic block, and be back to step S1.
Step S3:If the present instruction of the basic block of translation is conditional jump instructions, obtains conditional jump instructions and redirect Basic block and next basic block of conditional jump instructions afterwards, and tree depth will be performed and add 1, it is back to step S1.
Step S4:If the present instruction of the basic block of translation is function call instruction, it is corresponding to obtain function call instruction Function as basic block, and by perform tree depth add 1, be back to step S1,
Wherein, after each execution tree depth adds 1, judge whether current execution tree depth reaches execution tree depth threshold Value, if performing tree depth reaches execution tree depth threshold, translation terminates, and all basic blocks of translation form a superblock.
The binary translation method based on execution tree depth provided using the embodiment, when constructing superblock, no matter Whether basic block is performed on source processor, as long as these basic blocks can be constructed same super on tree is performed Translated in block, the basic block for being possible to perform is placed in a superblock, so as to which the basic block of correlation is placed on one In individual superblock, it is possible to increase perform the performance of the superblock after translation.
Preferably, this method also includes:Step S6:While default execution tree depth threshold is obtained, obtain default Translation time threshold, and the timing when starting translation, wherein, performed each after tree depth adds 1, judge present timing The translation time whether reach translation time threshold, if the translation time of present timing reaches translation time threshold, translation knot Beam.
Using the preferred embodiment, using the translation time as one of structural environment of superblock, so as to be reached in the translation time It can terminate to translate when reaching threshold value to threshold value or execution tree depth, when the execution tree depth for avoiding specifying is translated when improper Between it is long.
Second embodiment
Fig. 2 is the flow chart of binary translation method according to a second embodiment of the present invention, in this embodiment, from one When the address of instruction proceeds by binary translation, function call instruction is encountered in current execution route or conditional jump refers to When making, instruction translation in current execution route and the execution route to be redirected while can be translated, thus, in the implementation In example, execution depth is also referred to as translated depth.Translation depth can flexibly be set according to specific application scenarios.Translate depth It is bigger, form that the basic block of superblock is also more, the basic block of composition is more to bring more code optimization effects, perform The performance of program also can be improved accordingly.But the more negative effect of basic block is that the translation time is elongated.It is complete in super block translation Into afterwards, the address of first instruction of each basic block included in superblock is saved.When target program starts When execution, the address of a basic block is often encountered, whether translated, if translation if can all search this basic block Cross, then jump in the superblock where translated basic block and perform.
Specifically, the flow for the method that the embodiment provides is as follows:
A, superblock is constructed since some initial address.
B, a translation depth is specified, when reaching this translation depth, superblock will stop translating, into step c;
C, the basic block where current address is translated, namely a basic block is translated from present instruction.
If d, present instruction is direct jump instruction, enter new basic block translation, into step c.
E, if conditional jump instructions, then depth adds one, and next basic block of Translation Condition instruction simultaneously and The object block redirected, into step g.
F, if function call instruction, then translated into the function, and translate depth and add one, into step g.
G, judge to translate whether depth reaches designated depth, if reached, translation terminates, and into step h, and completes The construction of superblock, if being not reaching to designated depth, into step c.
H, superblock construction terminates.
The binary translation method based on execution tree depth provided using the embodiment, is carried out code analysis, led in advance Cross default perform and set depth to construct superblock, superblock, the present invention are formed so as to which all basic blocks on tree will be performed It is the basic block for being possible to perform can be placed in a superblock, the basic block of correlation is so placed on one as far as possible In individual superblock, there is the raising of certain amplitude in the performance for performing the superblock after translating.
3rd embodiment
Fig. 3 is according to a third embodiment of the present invention based on the block diagram for performing the binary translation device for setting depth, such as Fig. 3 Shown, the translating equipment includes initialization module 10, translation module 20, the first acquisition module 30, the second acquisition module the 40, the 3rd Acquisition module 50 and judge module 60.
Wherein, initial in translation, the initialization translated by initialization module 10, specifically, initialization module 10 are opened When beginning to construct superblock, tree depth will be performed and be initialized as 0, and obtain default execution tree depth threshold, from default starting Basic BOB(beginning of block) translation where address.
First, translation module 20 turns over to the basic BOB(beginning of block) where some initial address in two-stage system program to be translated Translate, translate the basic block that each acquisition module is got one by one.
Each acquisition module is when obtaining basic block, the instruction that is based in the basic block currently translated, specific address, In translation process, the present instruction for the basic block served as interpreter is direct jump instruction, and the first acquisition module 30, which obtains, directly to be redirected The new basic block entered is instructed, the basic module got is translated by translation module 20;The basic block served as interpreter it is current Instruct and obtain basic block and conditional jump instructions after conditional jump instructions redirect for conditional jump instructions, the second acquisition module 40 Next basic block, the basic module got translated by translation module 10, and will be performed tree depth and added 1;When turning over The present instruction for the basic block translated is function call instruction, and the 3rd acquisition module obtains function conduct corresponding to function call instruction Basic block, the basic module got are translated by translation module 10, and will be performed tree depth and added 1.
After each execution tree depth adds 1, judge module 60 judges whether current execution tree depth reaches and performs tree Depth threshold, reach execution tree depth threshold if performing and setting depth, translation terminates, and all basic blocks of translation form one and surpassed Level block.
The binary translation device based on execution tree depth provided using the embodiment, when constructing superblock, no matter Whether basic block is performed on source processor, as long as these basic blocks can be constructed same super on tree is performed Translated in block, the basic block for being possible to perform is placed in a superblock, so as to which the basic block of correlation is placed on one In individual superblock, it is possible to increase perform the performance of the superblock after translation.
Preferably, the device also includes:Memory module, after translating a basic block in translation module, storage should The address of first instruction of basic block.
Using the preferred embodiment, the address of first instruction of each basic block is stored, so as to be turned in execution During the binary program translated, the address of a basic block is often encountered, whether can all search this basic block translated, if It is translated, then jump in the superblock where translated basic block and perform.
Preferably, initialization module is additionally operable to while default execution tree depth threshold is obtained, obtain default turns over Translate time threshold, and the timing when starting translation;Judge module is additionally operable to after each execution tree depth adds 1, judges to work as Whether the translation time of preceding timing reaches translation time threshold, if the translation time of present timing reaches translation time threshold, Translation terminates.
Using the preferred embodiment, using the translation time as one of structural environment of superblock, so as to be reached in the translation time It can terminate to translate when reaching threshold value to threshold value or execution tree depth, when the execution tree depth for avoiding specifying is translated when improper Between it is long.
From the description of various embodiments above, it can be seen that the embodiment of the present invention realizes following technique effect:Improve The performance of program after execution binary translation.
The foregoing is only a preferred embodiment of the present invention, but protection scope of the present invention be not limited thereto, Any people for being familiar with the technology disclosed herein technical scope in, the change or replacement that can readily occur in should all be covered Within protection scope of the present invention.Therefore, protection scope of the present invention should be defined by scope of the claims.

Claims (6)

  1. It is 1. a kind of based on the binary translation method for performing tree depth, it is characterised in that including:
    Step S0:Start to construct superblock, tree depth will be performed and be initialized as 0, and obtain default perform and set depth threshold, from Basic BOB(beginning of block) translation where default initial address;
    Step S1:Translate the basic block got;
    Step S2:If the present instruction of the basic block of translation is direct jump instruction, obtains the directly jump instruction and enter Basic block, and be back to step S1;
    Step S3:If the present instruction of the basic block of translation is conditional jump instructions, obtains the conditional jump instructions and redirect Basic block and next basic block of the conditional jump instructions afterwards, and tree depth will be performed and add 1, it is back to step S1;
    Step S4:If the present instruction of the basic block of translation is function call instruction, it is corresponding to obtain the function call instruction Function as basic block, and by perform tree depth add 1, be back to step S1,
    Wherein, after each execution tree depth adds 1, judge whether current execution tree depth reaches described and perform tree depth threshold Value, if the tree depth that performs reaches the execution tree depth threshold, translation terminates, and all basic blocks of translation form one Superblock, wherein, the basic block for forming superblock is included in being performed on source processor and was not performed.
  2. It is 2. according to claim 1 based on the binary translation method for performing tree depth, it is characterised in that also to include:
    Step S5:After step S1 is performed, the address of first instruction of the basic block is stored.
  3. It is 3. according to claim 1 or 2 based on the binary translation method for performing tree depth, it is characterised in that also to include:
    Step S6:While default execution tree depth threshold is obtained, default translation time threshold is obtained, and starting Timing during translation,
    Wherein, after each execution tree depth adds 1, judge whether the translation time of present timing reaches the translation time threshold Value, if the translation time of the present timing reaches the translation time threshold, translation terminates.
  4. It is 4. a kind of based on the binary translation device for performing tree depth, it is characterised in that including:
    Initialization module, during for starting to construct superblock, tree depth will be performed and be initialized as 0, and obtain and default perform tree Depth threshold, from the basic BOB(beginning of block) translation where default initial address;
    Translation module, for translating the basic block got;
    First acquisition module, the present instruction of the basic block for serving as interpreter is direct jump instruction, and acquisition is described directly to be redirected The new basic block entered is instructed, and is translated by the translation module;
    Second acquisition module, the present instruction of the basic block for serving as interpreter is conditional jump instructions, obtains the conditional jump Next basic block of basic block and the conditional jump instructions after redirecting is instructed, is translated by the translation module, and And tree depth will be performed and add 1;
    3rd acquisition module, the present instruction for the basic block served as interpreter is function call instruction, then obtains the function call and refer to Function corresponding to order is translated, and will perform tree depth and add 1 as basic block by the translation module;
    Judge module, after adding 1 in each execution tree depth, judge whether current execution tree depth reaches the execution Depth threshold is set, if the tree depth that performs reaches the execution tree depth threshold, translation terminates, all basic blocks of translation A superblock is formed, wherein, the basic block for forming superblock is included in being performed on source processor and was not performed 's.
  5. It is 5. according to claim 4 based on the binary translation device for performing tree depth, it is characterised in that also to include:
    Memory module, after translating a basic block in the translation module, store first instruction of the basic block Address.
  6. 6. the binary translation device based on execution tree depth according to claim 4 or 5, it is characterised in that
    The initialization module is additionally operable to while default execution tree depth threshold is obtained, obtain default translation time threshold Value, and the timing when starting translation;
    The judge module is additionally operable to after each execution tree depth adds 1, judges whether the translation time of present timing reaches The translation time threshold, if the translation time of the present timing reaches the translation time threshold, translation terminates.
CN201410688378.5A 2014-11-26 2014-11-26 Based on the binary translation method and device for performing tree depth Active CN104375879B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410688378.5A CN104375879B (en) 2014-11-26 2014-11-26 Based on the binary translation method and device for performing tree depth

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410688378.5A CN104375879B (en) 2014-11-26 2014-11-26 Based on the binary translation method and device for performing tree depth

Publications (2)

Publication Number Publication Date
CN104375879A CN104375879A (en) 2015-02-25
CN104375879B true CN104375879B (en) 2018-02-09

Family

ID=52554818

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410688378.5A Active CN104375879B (en) 2014-11-26 2014-11-26 Based on the binary translation method and device for performing tree depth

Country Status (1)

Country Link
CN (1) CN104375879B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109471668B (en) * 2018-11-20 2021-11-26 南方电网科学研究院有限责任公司 Cross-platform display card firmware translation execution method, device, equipment and readable medium
CN111090417B (en) * 2019-11-14 2023-11-28 杭州中恒电气股份有限公司 Binary file analysis method, binary file analysis device, binary file analysis equipment and binary file analysis medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1716202A (en) * 2004-06-30 2006-01-04 中国科学院计算技术研究所 Be association of activity and inertia incomplete disposal route of static information and device in the binary translation
CN1823322A (en) * 2003-07-15 2006-08-23 可递有限公司 Shared code caching method and apparatus for program code conversion
CN101387970A (en) * 2008-10-30 2009-03-18 上海交通大学 Method for generating super block utilizing partial information

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1823322A (en) * 2003-07-15 2006-08-23 可递有限公司 Shared code caching method and apparatus for program code conversion
CN1716202A (en) * 2004-06-30 2006-01-04 中国科学院计算技术研究所 Be association of activity and inertia incomplete disposal route of static information and device in the binary translation
CN101387970A (en) * 2008-10-30 2009-03-18 上海交通大学 Method for generating super block utilizing partial information

Also Published As

Publication number Publication date
CN104375879A (en) 2015-02-25

Similar Documents

Publication Publication Date Title
EP3211543A1 (en) Multi-round session interaction method and system, and computer device
RU2015121718A (en) METHOD AND DEVICE FOR PRESENTING A LIST OF ACCESS POINTS
CN105138335B (en) A kind of function call path extraction method and device based on controlling stream graph
CN106547520B (en) Code path analysis method and device
RU2016145668A (en) CONFIGURATION OF WORKING PROCESSES IN THE LEADING DEVICE WORKING IN THE SYSTEM OF MANAGEMENT OF TECHNOLOGICAL PROCESSES
CN105808609A (en) Discrimination method and equipment of point-of-information data redundancy
JP2018206261A (en) Word division estimation model learning device, word division device, method and program
CN104375879B (en) Based on the binary translation method and device for performing tree depth
CN103886023A (en) Storage and extraction method and system of Excel data tables
CN110516233A (en) Method, apparatus, terminal device and the storage medium of data processing
CN106843141A (en) Numerical control device
EA201990933A1 (en) EFFECTIVE DATA STRUCTURES FOR THE SUBMISSION OF BIOINFORMATICS INFORMATION
CN105468661A (en) Method and system for searching symbol information in ELF file
US9323889B2 (en) System and method for processing reference sequence for analyzing genome sequence
CN100573461C (en) In embedded system, analyze the method that storehouse uses
RU2013103695A (en) MANAGEMENT DEVICE, MANAGEMENT SYSTEM AND METHOD OF MANAGEMENT
CN106326258B (en) URL matching method and device
CN104376086B (en) Data processing method and device
CN104049949B (en) A kind of peephole optimization method towards BSWAP instruction
CN104572876A (en) Method and device for reading configuration file corresponding to software
RU2013119418A (en) METHOD AND DEVICE FOR DETERMINING AT LEAST ONE PROBABILITY OF EXITING AN AREA IDENTIFIED IN A DIGITAL CARD AS AN OPEN PLACE
CN106202017A (en) Fill in the method and device of list
CN104035765B (en) A kind of analysis method of embedded system context
CN106445603B (en) program processing method and device
CN106649364B (en) Table target column positioning method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20210122

Address after: Room 802, 8th floor, building 3, Science Park, shuimuwan District, Shaoxing City, Zhejiang Province, 312000

Patentee after: Zhejiang Dijie Software Technology Co.,Ltd.

Address before: No. 124, Fit3 District, Tsinghua University, Haidian District, Beijing 100084

Patentee before: Kang Shuo