CN100359471C - Library function calling processing method in binary translation system - Google Patents

Library function calling processing method in binary translation system Download PDF

Info

Publication number
CN100359471C
CN100359471C CNB2004100810202A CN200410081020A CN100359471C CN 100359471 C CN100359471 C CN 100359471C CN B2004100810202 A CNB2004100810202 A CN B2004100810202A CN 200410081020 A CN200410081020 A CN 200410081020A CN 100359471 C CN100359471 C CN 100359471C
Authority
CN
China
Prior art keywords
agreement
original system
target machine
register
library function
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
CNB2004100810202A
Other languages
Chinese (zh)
Other versions
CN1755631A (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.)
Institute of Computing Technology of CAS
Original Assignee
Institute of Computing Technology of CAS
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 Institute of Computing Technology of CAS filed Critical Institute of Computing Technology of CAS
Priority to CNB2004100810202A priority Critical patent/CN100359471C/en
Publication of CN1755631A publication Critical patent/CN1755631A/en
Application granted granted Critical
Publication of CN100359471C publication Critical patent/CN100359471C/en
Anticipated expiration legal-status Critical
Active legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The present invention discloses a method for calling and processing library functions in binary translation, which comprises: a memory of a target computer is used for simulating registers and stacks in an original system; a local agreement of the target computer is applied to parameter transfer, return value processing and the sequential processing of each basic block of a binary program in the original system. The present invention utilizes the local agreement of the target computer to transfer parameters and process return values instead of simulating a call agreement of an original computer and enables the frequent operation to the memory to be omitted in the procedure that the parameters are pushed into the registers and the stacks simulated in the original system, and the parameters are then taken out from the registers and the stacks to be put in parameter transfer registers or stacks of the target computer. The present invention has the advantages of raised program execution efficiency, improved system translation efficiency and enhanced system performance.

Description

Library function call disposal route in the binary translation
Technical field
The present invention relates to the binary translation method of computer realm, relate in particular to the library function call disposal route in the binary translation.
Background technology
Compiling is the gordian technique in computing machine self field, and binary translation then is an important research direction of compiling.Just developed first commercial binary translation system Bergh et al as far back as Hewlett-Packard Corporation in 1987.Next, many companies and research institution have also launched the research of this respect in succession, and wherein the most representative have HP, IBM, Digital, an AT﹠amp; T, APPLE, Transmeta, Australian Queensland university, technology university, Austria Vienna etc., at present, the software center that Intel is built up in China has also added these ranks.
Binary translation is becoming a research focus that solves the software transplanting problem at present.As everyone knows,, then can lose the support of existing software, influence its promotion and application if its instruction-level architecture (ISA) of processor newly developed is not compatible forward.This just forces the deviser to use valuable chip space to come compatible old processor, has so both increased the complexity and the power consumption of new processor, influences the raising of its dominant frequency, has hindered the development of processor again.The binary translation technology is that new and old processor has been erected a bridge block, and existing software transplanting is carried out to processor newly developed, makes new processor break away from compatible forward constraint.
The binary translation technology to the development that promotes homemade processor also highly significant.Closely during the last ten years, the information industry of China is able to develop rapidly, and progressively moves to maturity.Along with the accumulation of knowledge and experience, industry elite begin the technological challenge of core the most in computer realm.With " Godson ", " starlight ", " Noah's ark ", " Chinese core ", " martial prowess ", " ten thousand is logical ", " the many will of Beijing University " etc. is that the homemade general or embedded microprocessor of representative continues to bring out, and has broken the situation of Chinese nothing " core ".But because the restriction of Intel various patents on the X86 series microprocessor makes domestic many microprocessor Design persons have to adopt and the incompatible ISA of X86 series microprocessor.As everyone knows, X86 series machine has had extremely abundant application software as current mainstream model.The incompatible application software of homemade microprocessor that causes of ISA is compared some scarcity that seems with x86 microprocessor, influenced the paces of its promotion and application to a certain extent.Therefore carry out the research of binary translation, can enrich the application software of homemade processor equally, provide support for these national industries enlarge market.
Realizing with X86 being in the process of binary translation of former machine, one comparatively stubborn problem be to handle the X86 program to system library function calls problem.How to handle the performance that the library function call problem is directly connected to binary translation system, when library function call is handled well, just can improve the speed that former binary program moves on target machine, otherwise, the speed that former binary program moves then influenced on target machine.
The function parameter transmission of MIPS/Linux system is that the form that adopts storehouse and register to combine is carried out.The MIPS agreement has three kinds of parameter transfer modes: 032, N32 and N64.For 32 MIPS, 032 modes that adopt, we only analyze 032 mode more at present.
MIPS provides 4 integer register ($4-$7) and 4 floating type register ($f12-$f15) being used to transmit parameter, each register is 32, these 8 registers and storehouse combine and carry out the parameter transmission.032 mode parameter is transmitted more complicated, and floating number and integer data are distinguished.Its rule is as follows:
At first, according to the size of parameter requisite space, Caller distributes corresponding space for it in storehouse.In a minute timing, if the required gross space of parameter less than 16 bytes, then distributes 16 bytes for parameter in storehouse.That is to say no matter how many parameters needs the space, will distribute 16 bytes for it at least in storehouse.MIPS agreement, being used in the storehouse passes preceding 16 bytes of ginseng as reservation, and they are actually transmits by register.
The parameter load mode of these 16 bytes is such: at first Caller checks each parameter of function successively, if this parameter is a floating type, then uses floating type register transfer parameter successively.If run into an argument of type integer, then bring into use integer register transfer parameter.And, then do not re-use floating type register transfer parameter in case used the integer register.
In addition, 032 stipulates that also if used flating point register, then the integer register is vacated corresponding position.
The regulation of the rreturn value of 032 pair of function is more complicated also, and its rreturn value transmission is also undertaken by storehouse and rreturn value register.If rreturn value is a simple data type, undertaken by the rreturn value register.If rreturn value is a structure type, then carry out as the case may be.MIPS is provided with two registers and is used for the result and returns, if the structure that rreturn value is made up of two territories, and register transfer can then still be passed through with a register-stored in each territory; If this structure surpasses the storage restriction of return register, then transmit by storehouse.
In the prior art, in general, parameter that the simplest implementation method is exactly simulation X86 on target machine and rreturn value transmission agreement.Concrete is exactly the storehouse of simulating X86 on target machine with internal memory, when running into the system library function call, target machine still is pressed into parameter in the simulation storehouse according to the agreement of X86, call the system library function of packing then: from the simulation storehouse, take out parameter, put in corresponding biography ginseng register and the storehouse according to the target machine agreement, the system library function of invocation target machine local then, pass the agreement taking-up rreturn value of rreturn value at last according to target machine, put in corresponding simulation register or the internal memory according to the agreement of X86.
This method by the simulation parameter of X86 and rreturn value transmission agreement on target machine can be handled the problem of X86 program to the system library function call exactly, but its maximum defective is exactly an efficiency.By implementation method in front as can be seen, owing to need the storehouse of simulation X86, when carrying out the system library function call, parameter need be pressed in the simulation storehouse, again parameter is taken out in the biography ginseng register and storehouse of putting into target machine afterwards, influence executing efficiency.
Summary of the invention
Technical matters to be solved by this invention provides the library function call disposal route in a kind of binary translation, overcomes the inefficient defective of library function call processing translation execution in the prior art, improves translation execution efficient, and then improves system performance.
In order to solve the problems of the technologies described above, the invention provides the library function call disposal route in a kind of binary translation, may further comprise the steps:
A) in target machine with the register and the storehouse of internal memory simulation original system;
B) agreement of application target machine local passes ginseng and rreturn value processing, successively each fundamental block in the original system binary program is carried out following processing:
Is b1) differentiating the target of calling (CALL) instruction the system library function? if, carry out next step, if not, execution in step b7);
B2) according to the shape ginseng number and the size description of system library function, in this fundamental block, seek the instruction of pressing parameter forward;
Does b3) whether judgement search successful? if, carry out next step, if not, execution in step b7);
B4) corresponding local code Delete All behind the instruction push instruction translation of those pressure parameters that in this fundamental block, find, and form following local code: these parameters are passed the ginseng agreement according to target machine put in relevant register and the storehouse;
B5) call the local system built-in function;
B6) pass the rreturn value agreement according to target machine and take out rreturn value, put in the simulation register or internal memory of target machine simulation original system according to the original system agreement then;
B7) method that passes ginseng and rreturn value agreement according to general disposal route simulation original system is handled.
In such scheme, original system is the binary translation system of application layer.
In such scheme, original system is X86 (systems of Intel 32 bit architectures)/linux system and MIPS/Linux system.
In such scheme, step b4) in, original system simulation register ESP is the poor of original system simulation register ESP and the total size of all parameters.
As from the foregoing, the present invention passes ginseng by the agreement with target machine this locality and rreturn value is handled, rather than remove to simulate the calling convention of former machine, saved the simulation storehouse that parameter is pressed into the simulation original system, from storehouse, take out again then and put into the operation of frequently internally depositing in the process in target machine biography ginseng register or the storehouse, improve the efficient that program is carried out, and then improved system's translation efficiency, improved system performance.
Description of drawings
Fig. 1 is the register and the storehouse of simulating X86 in the prior art in the target machine with internal memory;
Fig. 2 is the process flow figure of library function call among the present invention.
Embodiment
Generally, the present invention be based upon following two in principle basic: the one, discern and promote the system library function call of original system binary program as much as possible; The 2nd, avoid the storehouse of simulation original system when handling library function call as much as possible, but arrange to handle library function call with the local function call of target machine, thereby to reach the purpose that improves executing efficiency.
Hereinafter will describe the present invention in conjunction with the accompanying drawings in detail.
Library function call disposal route in the binary translation may further comprise the steps:
Step 10, in target machine with the register and the storehouse of internal memory simulation original system.Is example with X86 system (systems of Intel 32 bit architectures) as original system, as shown in Figure 1, EAX, ECX, EDX, EBX, EBP, ESP, EDI, EDI are 8 general-purpose registers of X86 system.
Step 20, the agreement of application target machine local pass ginseng and rreturn value is handled, and successively each fundamental block in the original system binary program is handled.
In step 20, may further comprise the steps, as shown in Figure 2:
Step 200 differentiates whether the target of calling (CALL) instruction is the system library function, if, carry out next step, if not, execution in step 260;
Step 210 according to the shape ginseng number and the size description of system library function, is sought the instruction (push instruction) of pressing parameter forward in this fundamental block.
Whether step 220, judgement search successful, if, carry out next step, if not, execution in step 260;
Step 230 corresponding local code Delete All behind the instruction push instruction translation of those pressure parameters that find, and forms following local code: these parameters are passed the ginseng agreement according to target machine put in relevant register and the storehouse in this fundamental block.
In step 230, original system simulation register ESP=original system simulation register ESP one all parameters are size always.Wherein, described " original system simulation register ESP " is meant the internal storage location that is used for simulating original system register ESP in goal systems.
Step 240 is called the local system built-in function.
Step 250 passes the rreturn value agreement according to target machine and takes out rreturn value, puts in the simulation register or internal memory of target machine simulation original system according to the original system agreement then.
Step 260 is handled according to the method that general disposal route simulation original system passes ginseng and rreturn value agreement.
With certain X86 fundamental block is example:
push$10
push?8048032
call?printf
Simulate the code of translating after the method processing of former machine biography ginseng and rreturn value agreement with the general disposal route of most of binary translation system employing and be (totally 14 instructions):
addiu?t2,t2,-4?;push$10
li at,10
sw at,0(t2)
addiu?t2,t2,-4?;push?8048032
lui?t1,0x804
ori?t1,t1,0x8032
lw?at,0(t1)
sw?at,0(t2)
Lw at, 0 (t2); Below 4 instructions be from Simulation Stack, to take out parameter to put into
In the corresponding biography ginseng of the MIPS register
move?a0,at
lw?at,4(t2)
move?al,at
Li t9, printf; The built-in function printf of invocation target machine this locality
jal?t9
The code that adopts the inventive method to handle the back translation is (totally 7 instructions):
li?a0,10
lui?t1,0x804
ori?t1,t1,0x8032
lw?al,0(t1)
addiu?t2,t2,-8
Li t9, printf; The built-in function printf of invocation target machine this locality
jal?t9
Illustrate: the ESP of 1.MIPS general-purpose register t2 simulation X86 system.
2.at t1, t9 are the general-purpose registers of MIPS, are used for temporary register in the present invention.
3.a0 a1, a2, a3 are the biography ginseng registers of MIPS.
The present invention is applicable to the binary translation system (not cross operating system) of all application layers, comprises X86 (system of Intel32 bit architecture)/linux system and MIPS/Linux system.
Library function call disposal route in the binary translation provided by the present invention has following characteristics: the system library function call in original system (as the X86) binary program is discerned and promoted, agreement with target machine this locality passes ginseng and rreturn value processing, rather than remove to simulate the calling convention of former machine, can save like this parameter is pressed into simulation original system (as X86) simulation storehouse, from storehouse, take out again then and put into the operation of frequently internally depositing in the process in target machine biography ginseng register or the storehouse, improved the efficient that program is carried out.
It should be noted that at last: above embodiment is the unrestricted technical scheme of the present invention in order to explanation only, although the present invention is had been described in detail with reference to the foregoing description, those of ordinary skill in the art is to be understood that: still can make amendment or be equal to replacement the present invention, and not breaking away from any modification or partial replacement of the spirit and scope of the present invention, it all should be encompassed in the middle of the claim scope of the present invention.

Claims (2)

1, the library function call disposal route in a kind of binary translation may further comprise the steps:
A) in target machine with the register and the storehouse of internal memory simulation original system;
B) agreement of application target machine local passes ginseng and rreturn value processing, successively each fundamental block in the original system binary program is carried out following processing:
Is b1) target of differentiation call instruction the system library function? if, carry out next step, if not, execution in step b7);
B2) according to the shape ginseng number and the size description of system library function, in this fundamental block, seek the instruction of pressing parameter forward;
Does b3) whether judgement search successful? if, carry out next step, if not, execution in step b7);
B4) corresponding local code Delete All behind the instruction translation of those pressure parameters that in this fundamental block, find, and form following local code: these parameters are passed the ginseng agreement according to target machine put in relevant register and the storehouse;
B5) call the local system built-in function;
B6) pass the rreturn value agreement according to target machine and take out rreturn value, put in the simulation register or internal memory of target machine simulation original system according to the original system agreement then;
B7) method that passes ginseng and rreturn value agreement according to general disposal route simulation original system is handled.
2, the library function call disposal route in a kind of binary translation as claimed in claim 1 is characterized in that, original system is the binary translation system of application layer.
CNB2004100810202A 2004-09-30 2004-09-30 Library function calling processing method in binary translation system Active CN100359471C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2004100810202A CN100359471C (en) 2004-09-30 2004-09-30 Library function calling processing method in binary translation system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2004100810202A CN100359471C (en) 2004-09-30 2004-09-30 Library function calling processing method in binary translation system

Publications (2)

Publication Number Publication Date
CN1755631A CN1755631A (en) 2006-04-05
CN100359471C true CN100359471C (en) 2008-01-02

Family

ID=36688897

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2004100810202A Active CN100359471C (en) 2004-09-30 2004-09-30 Library function calling processing method in binary translation system

Country Status (1)

Country Link
CN (1) CN100359471C (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101488096B (en) * 2009-02-19 2011-03-30 上海交通大学 Method for constructing super block by utilizing subdivision information of access edge relationship
CN101546271B (en) * 2009-04-30 2012-01-04 上海交通大学 Register allocation method for super block in dynamic binary translation system.
CN102364442B (en) * 2011-06-24 2014-06-25 浙大网新科技股份有限公司 Method for transplanting Wine from x86 to advanced risc machine (ARM) platform
CN103186414A (en) * 2011-12-27 2013-07-03 联想(北京)有限公司 Program execution method, program manager and virtual machine

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5313614A (en) * 1988-12-06 1994-05-17 At&T Bell Laboratories Method and apparatus for direct conversion of programs in object code form between different hardware architecture computer systems
US5414848A (en) * 1993-04-01 1995-05-09 Intel Corporation Method and apparatus for sharing a common routine stored in a single virtual machine with other virtual machines operating in a preemptive muli-tasking computer system
WO1999057635A1 (en) * 1998-05-04 1999-11-11 Sun Microsystems, Inc. Encoding machine-specific optimizations in generic byte code by using local variables as pseudo-registers
US20030167458A1 (en) * 1998-01-02 2003-09-04 Vatsa Santhanam Programmatic access to the widest mode floating-point arithmetic supported by a processor
US6725451B1 (en) * 1997-12-17 2004-04-20 Siemens Aktiengesellschaft Method for converting a system call

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5313614A (en) * 1988-12-06 1994-05-17 At&T Bell Laboratories Method and apparatus for direct conversion of programs in object code form between different hardware architecture computer systems
US5414848A (en) * 1993-04-01 1995-05-09 Intel Corporation Method and apparatus for sharing a common routine stored in a single virtual machine with other virtual machines operating in a preemptive muli-tasking computer system
US6725451B1 (en) * 1997-12-17 2004-04-20 Siemens Aktiengesellschaft Method for converting a system call
US20030167458A1 (en) * 1998-01-02 2003-09-04 Vatsa Santhanam Programmatic access to the widest mode floating-point arithmetic supported by a processor
WO1999057635A1 (en) * 1998-05-04 1999-11-11 Sun Microsystems, Inc. Encoding machine-specific optimizations in generic byte code by using local variables as pseudo-registers

Also Published As

Publication number Publication date
CN1755631A (en) 2006-04-05

Similar Documents

Publication Publication Date Title
CN100462922C (en) Binary translation method using intermediate command set
CN100397347C (en) System and method for CPI scheduling on SMT processors
CN103150146B (en) Based on ASIP and its implementation of scalable processors framework
CN100549943C (en) Multithreaded microprocessor with the optimization thread scheduler that is used to promote the streamline service efficiency
CN101299192B (en) Non-aligning access and storage processing method
CN111512298A (en) Apparatus, method and system for conditional queuing in configurable spatial accelerators
CN104040491A (en) A microprocessor accelerated code optimizer
CN104040492A (en) Microprocessor accelerated code optimizer and dependency reordering method
CN104040490A (en) An accelerated code optimizer for a multiengine microprocessor
CN101221541B (en) Programmable communication controller for SOC and its programming model
CN101535951A (en) Methods and apparatus for recognizing a subroutine call
CN101375228A (en) Microprocessor having a power-saving instruction cache way predictor and instruction replacement scheme
WO2007002408A3 (en) Computer processor pipeline with shadow registers for context switching, and method
CN101147125A (en) Fractional-word writable architected register for direct accumulation of misaligned data
US7392489B1 (en) Methods and apparatus for implementing application specific processors
CN1216327C (en) 32-bit embedded microprocessor adopting double instruction set
CN1313957C (en) Hardware-assisted disign verification system using a packet-based protocol logic synthesized for efficient data loading and unloading
CN105550443A (en) SystemC based unified stainer array TLM model with accurate cycle
CN103559017A (en) Character string matching method and system based on graphic processing unit (GPU) heterogeneous computing platform
CN113703832A (en) Method, device and medium for executing immediate data transfer instruction
CN100451951C (en) 5+3 levels pipeline structure and method in RISC CPU
CN100359471C (en) Library function calling processing method in binary translation system
EP1532554A2 (en) Method and apparatus for translating to a hardware description language from an architecture description language
CN1650258A (en) Automatic task distribution in scalable processors
CN1648873A (en) Method for realizing break point debugging function

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant