CN108304191B - Function dynamic calling method and device - Google Patents

Function dynamic calling method and device Download PDF

Info

Publication number
CN108304191B
CN108304191B CN201610875839.9A CN201610875839A CN108304191B CN 108304191 B CN108304191 B CN 108304191B CN 201610875839 A CN201610875839 A CN 201610875839A CN 108304191 B CN108304191 B CN 108304191B
Authority
CN
China
Prior art keywords
function
execution
parameters
return value
calling
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
CN201610875839.9A
Other languages
Chinese (zh)
Other versions
CN108304191A (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.)
Loongson Technology Corp Ltd
Original Assignee
Loongson Technology Corp Ltd
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 Loongson Technology Corp Ltd filed Critical Loongson Technology Corp Ltd
Priority to CN201610875839.9A priority Critical patent/CN108304191B/en
Publication of CN108304191A publication Critical patent/CN108304191A/en
Application granted granted Critical
Publication of CN108304191B publication Critical patent/CN108304191B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Executing Machine-Instructions (AREA)

Abstract

The invention provides a method and a device for dynamically calling a function, wherein the method comprises the following steps: acquiring a packed message, wherein the packed message comprises an execution function, and the execution function comprises at least one parameter; storing the parameters according to a function calling appointed ABI mode; determining the address of the current execution position of the execution function; calling and executing a called function corresponding to the execution function, and determining a return value of the called function; and returning to the execution position of the execution function according to the address of the execution position to continue executing the program after the execution position of the execution function is executed, and saving a return value. The method can effectively complete the operation of executing the calling context of the function and complete the execution and calling of the function when the parameter in the function is determined when the compiled assembly language is executed.

Description

Function dynamic calling method and device
Technical Field
The present invention relates to computer processing technologies, and in particular, to a method and an apparatus for dynamically calling a function.
Background
In the programming process of a computer, it is generally necessary to compile a high-level language into an assembly language so that the computer executes the assembly language.
However, in the prior art, in the process of compiling a high-level language into an assembly language, there is a situation that parameters in a function of the assembly language cannot be determined at that time, and the number of parameters in the function needs to be determined when the compiled assembly language is executed; at this time, the prior art cannot execute the function whose number of parameters has not been determined, and cannot call the function corresponding to the function.
Disclosure of Invention
The invention provides a method and a device for dynamically calling functions, which are used for solving the problems that functions with the number of parameters not determined yet cannot be executed and the functions corresponding to the functions cannot be called in the prior art.
One aspect of the present invention provides a method for dynamically calling a function, including:
obtaining a packed message, wherein the packed message comprises an execution function, and the execution function comprises at least one parameter;
storing the at least one parameter according to a function call convention application program binary interface (ABI) mode;
determining an address at a current execution position of the execution function;
calling and executing a called function corresponding to the execution function, and determining a return value of the called function;
and returning to the execution position of the execution function according to the address of the execution position to continuously execute the program after the execution position of the execution function is executed, and saving the return value.
In the above method, the storing the at least one parameter according to the ABI mode of the function call convention includes:
if the number N of the parameters in the execution function is less than or equal to M, storing the N parameters into a first register;
if the number N of the parameters in the execution function is larger than M, storing M parameters in the N parameters into a first register, and sequentially storing N-M parameters into a first stack;
wherein N, M is a positive integer, and M < N.
In the method, the calling and executing the called function corresponding to the executing function includes:
determining the called function corresponding to the calling parameter according to the calling parameter in the execution function;
acquiring the address of the called function, and determining the position of the called function according to the address of the called function;
and calling and executing the called function.
In the method described above, the saving the return value includes:
determining the number of bytes of the return value;
if the number of bytes of the return value is less than or equal to the preset number of bytes, storing the return value into a second register;
and if the number of bytes of the return value is greater than the preset number of bytes, storing the return value into a second stack, and storing the address of the second stack into the second register.
Another aspect of the present invention provides a device for dynamically calling a function, including:
an obtaining module, configured to obtain a packed message, where the packed message includes an execution function, and the execution function includes at least one parameter;
the storage module is used for storing the at least one parameter according to a function calling convention application ABI mode;
a determining module, configured to determine an address at a current execution position of the execution function;
the calling module is used for calling and executing a called function corresponding to the executing function and determining a return value of the called function;
and the return module is used for returning to the execution position of the execution function according to the address of the execution position to continue executing the program after the execution position of the execution function, and storing the return value.
In the apparatus, the storage module includes:
the first storage submodule is used for storing the N parameters into a first register if the number N of the parameters in the execution function is less than or equal to M;
and the second storage submodule is used for storing M parameters in the N parameters into the first register and sequentially storing N-M parameters into the first stack if the number N of the parameters in the execution function is greater than M, wherein N, M is a positive integer, and M is less than N.
In the above apparatus, the invoking module is specifically configured to:
determining the called function corresponding to the calling parameter according to the calling parameter in the execution function;
acquiring the address of the called function, and determining the position of the called function according to the address of the called function;
and calling and executing the called function, and determining the return value of the called function.
In the apparatus as described above, the return module includes:
the return submodule is used for returning to the execution position of the execution function according to the address at the execution position;
the determining submodule is used for determining the number of bytes of the return value;
the first storage module is used for storing the return value into a second register if the number of bytes of the return value is less than or equal to the preset number of bytes;
and the second saving module is used for saving the return value into a second stack and saving the address of the second stack into the second register if the number of bytes of the return value is greater than the preset number of bytes.
The method comprises the steps of obtaining a packed message, wherein the packed message comprises an execution function, and the execution function comprises at least one parameter; storing the parameters according to a function calling appointed ABI mode; determining the address of the current execution position of the execution function; calling and executing a called function corresponding to the execution function, and determining a return value of the called function; and returning to the execution position of the execution function according to the address of the execution position to continue executing the program after the execution position of the execution function is executed, and saving a return value. When the parameters in the function of the assembly language cannot be determined in the compiling process, when the compiled assembly language is executed, the parameters in the determined execution function are stored in a function calling convention ABI mode, after the called function corresponding to the execution function is executed, the address of the current execution position of the execution function is jumped to, then the current program is continuously executed, and the return value determined by the called function is saved. Therefore, when the parameters in the function are determined when the compiled assembly language is executed, the operation of executing the calling context of the function can be effectively finished, and the execution and calling of the function can be finished.
Drawings
Fig. 1 is a flowchart of a method for dynamically calling a function according to an embodiment of the present invention;
fig. 2 is a flowchart of a method for dynamically calling a function according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of a dynamic function call device according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of a function dynamic call apparatus according to a fourth embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Fig. 1 is a flowchart of a method for dynamically invoking a function according to an embodiment of the present invention, as shown in fig. 1, the method according to the embodiment includes:
step 101, obtaining a packed message, wherein the packed message comprises an execution function, and the execution function comprises at least one parameter.
In this embodiment, specifically, when the compiled assembly language is executed, the number of parameters in each execution function is determined in real time. At this time, a packed message is firstly acquired, the packed message comprises an execution function, and then the current execution function is acquired; the execution function comprises at least one parameter, and N parameters in the execution function are obtained, wherein N is a positive integer. The type of the parameter in the execution function is not limited, and may be an int type, a float type, or a char type.
And 102, storing at least one parameter according to a function call convention application program binary interface ABI mode.
In this embodiment, specifically, a function call convention ABI manner may be adopted to process parameters in an execution function. The ABI mode of function calling convention can be adopted, and all parameters of the executed function are stored one by one.
And 103, determining the address of the current execution position of the execution function.
In this embodiment, specifically, at this time, it is necessary to first determine the address at the current execution position of the execution function, and perform a pre-storage.
And 104, calling and executing the called function corresponding to the execution function, and determining the return value of the called function.
In this embodiment, specifically, the executing function in step 101 has a called function corresponding thereto, and the called function corresponding to the executing function is called according to the requirement of the executing function; then the called function is executed, and after the called function is executed, a return value is generated.
And 105, returning to the execution position of the execution function according to the address at the execution position to continue executing the program after the execution position of the execution function, and saving a return value.
In this embodiment, specifically, since the address at the current execution position of the execution function is determined in step 103, the execution position of the execution function can be returned to according to the address at the current execution position of the execution function. At the same time, the return value of the called function generated in step 104 is saved.
The embodiment obtains a packed message, wherein the packed message comprises an execution function, and the execution function comprises at least one parameter; storing the parameters according to a function calling appointed ABI mode; determining the address of the current execution position of the execution function; calling and executing a called function corresponding to the execution function, and determining a return value of the called function; and returning to the execution position of the execution function according to the address of the execution position to continue executing the program after the execution position of the execution function is executed, and saving a return value. When the parameters in the function of the assembly language cannot be determined in the compiling process, when the compiled assembly language is executed, the parameters in the determined execution function are stored in a function calling convention ABI mode, after the called function corresponding to the execution function is executed, the address of the current execution position of the execution function is jumped to, then the current program is continuously executed, and the return value determined by the called function is saved. Therefore, when the parameters in the function are determined when the compiled assembly language is executed, the operation of executing the calling context of the function can be effectively finished, and the execution and calling of the function can be finished.
Fig. 2 is a flowchart of a method for dynamically invoking a function according to a second embodiment of the present invention, as shown in fig. 2, based on the first embodiment, step 102 includes:
step 1021, if the number N of the parameters in the execution function is less than or equal to M, the N parameters are stored in the first register.
In this embodiment, specifically, in step 101, the first platform sends a packet message to the second platform, where the packet message includes an execution function carrying at least one parameter. The second platform is an execution main body of the scheme, and after receiving the packed message, the second platform analyzes the execution parameters in the packed message and stores each parameter in the execution function according to a function calling convention interface ABI mode. The present embodiment is not limited to this execution scenario.
In the process that the second platform stores each parameter in the execution function, the execution function has N parameters, but according to the ABI convention of function call, only M parameters of the N parameters can be stored in the first register respectively, and it is known that M is smaller than N, and N, M is a positive integer. If the number N of the parameters in the execution function is determined to be less than or equal to M, all the N parameters can be directly stored in the first register.
And step 1022, if the number N of the parameters in the executed function is greater than M, storing M parameters of the N parameters into a first register, and sequentially storing N-M parameters into a first stack.
In this embodiment, specifically, if the number N of parameters in the execution function is greater than M, the second platform may store the first M parameters of the N parameters into the first register; the second platform can also select some M parameters from the N parameters and store the M parameters into the first register. And then the second platform sequentially stores the rest N-M parameters into the first stack according to the arrangement sequence of the parameters.
Regarding the ABI method for function call contract, each machine platform has its own set of ABI to contract the function call process, taking MIPS-N64 platform as an example, the related constraints are as follows: firstly, filling parameters in an execution function into a first register, and if the parameters exist, filling the parameters onto a stack; therefore, when the called function is called, 16 bytes of stack space need to be reserved for the called function to store the values of a0, a1, a2.. a7 for the called function, so that the parameter that the first register does not put needs to be put in the space above +16 bytes of the stack frame of the called function.
Regarding the ABI mode, the ABI mode can be the function calling mode of the MIPS-N64 platform, or the ABI mode can be the function calling mode of the MIPS-O32 platform, so that the N parameters are respectively stored in the first register and the first stack. For example, there are 9 functions in the execution function:
int a,double b,char c,float d,double e,long f,int g,char h,int i
the first 8 parameters a, b, c, d, e, f, g, h of the 9 parameters are required to be stored in the first registers a0, a1, a2.. a7, respectively, and then the 9 th parameter i which is not stored is stored on the first stack. At this time, a certain stack space is dynamically applied for the assembly code manually according to the number of the parameters, and the assembly code is as follows:
"and $17, $17,0 xfffffff 00\ r \ n"// $17 stores the number of input parameters
"addiu$17,$17,256\r\n"//stack size
"subu$29,$29,$17\r\n"
First, $17 is a register in which the number of input parameters of the C + + function is stored, and $29 is also a register which is a stack pointer register whose value points to the stack address. "and $17, $ 0xffffff00\ r \ n", this instruction is bit and operated on with the values of the registers 0 xfffffff 00 and $17, in order to make the value of the $17 register an integer multiple of 256. "addiu $17, $17,256\ r \ n", this instruction is to add 256 to the value of $17 register, and the value after the addition is used as the size of the stack space to be applied; "subbu $29, $29, $17\ r \ n", adjust the stack pointer position, namely apply for $17 size stack space. Therefore, the code can apply for a stack space of 256 integral multiples according to the number of input parameters. The parameter i may then be deposited on the corresponding first stack, thereby completing the parameter preparation for executing the function. The effect of the storage parameter of the first register and the effect of the storage parameter of the first stack can thus be obtained, as shown in tables 1 and 2:
TABLE 1 first register stores parameters
Register with a plurality of registers a0 a1 a2 a3 a4 a5 a6 a7
Parameter(s) a b c d e f g h
Table 2 first stack storage parameters
Figure BDA0001125351580000071
Step 104, specifically comprising:
step 1041, determining a called function corresponding to the calling parameter according to the calling parameter in the execution function.
In this embodiment, specifically, the second platform may determine, according to a call parameter in the current execution function, a called function corresponding to the call function.
Step 1042, obtaining the address of the called function, and determining the position of the called function according to the address of the called function.
In this embodiment, specifically, the second platform may receive an address of the called function passed by the upper layer of the program, so that the location of the called function may be determined according to the address of the called function.
And 1043, calling and executing the called function, and determining the return value of the called function.
In this embodiment, specifically, the second platform may call and execute the called function according to the position of the called function, and may further obtain a return value of the called function after the called function is executed.
Step 105 comprises:
and 1051, returning to the execution position of the execution function according to the address of the execution position to continue executing the program after the execution position of the execution function.
In this embodiment, specifically, the second platform may return to the execution location of the execution function according to the address at the execution location, so that the program after executing the execution location of the function may be continuously executed. For example, the execution of the execution function or the execution of the program may be completed by returning to the execution position of the execution function according to the indication of the stack frame pointer of the first stack.
Step 1052, determining the number of bytes of the return value.
In this embodiment, specifically, the second platform determines the number of bytes of the return value of the called function in step 104.
And 1053, if the number of bytes of the return value is less than or equal to the preset number of bytes, storing the return value in a second register.
In this embodiment, specifically, after determining the number of bytes of the return value in step 1052, the second platform will return to filling the second register or the second stack according to the ABI constraint.
Specifically, if the number of bytes of the return value is determined by the second platform to be less than or equal to the preset number of bytes, the return value can be returned to the second register v0, v 1; otherwise, step 1054 may be performed.
And 1054, if the number of bytes of the return value is larger than the preset number of bytes, storing the return value in the second stack, and storing the address of the second stack in the second register.
In this embodiment, specifically, if the second platform determines that the number of bytes of the return value is greater than the preset number of bytes, the second register stores the return value with a large number of bytes, so as to store the return value in the second stack, determine an address of the second stack, and then store the address of the second stack in the second register.
For example, there are two second registers v0, v1, one second stack, and the number of the predetermined bytes is 8. If the return value of the called function is 1 int type return value, the number of bytes of the 1 int type return value is 4, and does not exceed the preset number of bytes 8, so that the current return value can be saved in the second register v0, and the second register v1 can be left empty. If the return value of the called function is 2 int types, 2 int types are set as the return values of 1 structure type, so that the number of bytes of the return value of 1 structure type is 8, and the number of bytes does not exceed the preset number of bytes 8, and the current return value can be sequentially stored in the second register v0 and the second register v 1. If the return value of the called function is the return value of 1 structure type, the current return value of 1 structure type has a value of 2 int types, a value of 1 char type and a value of 1 float type, and the number of bytes of the current return value exceeds the preset number of bytes by 8, so that the current return value can be stored in the second stack; meanwhile, the address of the second stack is determined, if the number of bytes of the address of the second stack is within 4, the address of the second stack is stored in a second register v0, and the second register v1 can be empty; and if the number of bytes of the address of the second stack exceeds 4, saving the address of the second stack into a second register v0 and a second register v 1.
In the embodiment, when the number N of parameters in the execution function is less than or equal to M, the N parameters are stored in the first register; when the number N of parameters in the execution function is larger than M, storing M parameters in the N parameters to a first register, and storing N-M parameters to a first stack; when the compiled assembly language is executed, the number of the parameters in the execution function is stored in a register and a stack by adopting a function calling appointed ABI mode, and the processing of the parameters of the execution function is completed; and when the number of bytes of the return value is less than or equal to the preset number of bytes, the return value is stored in a second register, and when the number of bytes of the return value is greater than the preset number of bytes, the return value is stored in a second stack, and the address of the second stack is stored in the second register, so that the return value of the called function is stored in an ABI (abstract constraint) mode. Meanwhile, when the number of parameters in the function is determined when the compiled assembly language is executed, the operation of executing the calling context of the function can be effectively finished, and the execution and calling of the function can be finished.
Fig. 3 is a schematic structural diagram of a dynamic function call device according to a third embodiment of the present invention, and as shown in fig. 3, the dynamic function call device according to the third embodiment includes:
an obtaining module 31, configured to obtain a packet message, where the packet message includes an execution function, and the execution function includes at least one parameter;
the storage module 32 is configured to store at least one parameter according to a function call convention application ABI manner;
a determining module 33, configured to determine an address at a current execution position of the execution function;
a calling module 34, configured to call and execute a called function corresponding to the execution function, and determine a return value of the called function;
and the return module 35 is used for returning to the execution position of the execution function according to the address at the execution position to continue executing the program after the execution position of the execution function, and saving a return value.
The dynamic function calling device of this embodiment can execute the dynamic function calling method provided in the first embodiment of the present invention, and the implementation principles thereof are similar, and are not described herein again.
The embodiment obtains a packed message, wherein the packed message comprises an execution function, and the execution function comprises at least one parameter; storing the parameters according to a function calling appointed ABI mode; determining the address of the current execution position of the execution function; calling and executing a called function corresponding to the execution function, and determining a return value of the called function; and returning to the execution position of the execution function according to the address of the execution position to continue executing the program after the execution position of the execution function is executed, and saving a return value. When the parameters in the function of the assembly language cannot be determined in the compiling process, when the compiled assembly language is executed, the parameters in the determined execution function are stored in a function calling convention ABI mode, after the called function corresponding to the execution function is executed, the address of the current execution position of the execution function is jumped to, then the current program is continuously executed, and the return value determined by the called function is saved. Therefore, when the parameters in the function are determined when the compiled assembly language is executed, the operation of executing the calling context of the function can be effectively finished, and the execution and calling of the function can be finished.
Fig. 4 is a schematic structural diagram of a dynamic function call device according to a fourth embodiment of the present invention, and based on the third embodiment, as shown in fig. 4, the dynamic function call device according to the present embodiment, a storage module 32 includes:
the first storing submodule 321 is configured to store the N parameters in the first register if the number N of the parameters in the execution function is less than or equal to M;
and a second storing submodule 322, configured to store M parameters of the N parameters into the first register and sequentially store N-M parameters into the first stack if the number N of parameters in the execution function is greater than M, where N, M is a positive integer and M < N.
The invoking module 34 is specifically configured to:
determining a called function corresponding to a calling parameter according to the calling parameter in the execution function;
acquiring the address of the called function, and determining the position of the called function according to the address of the called function;
and calling and executing the called function, and determining the return value of the called function.
A return module 35 comprising:
a return submodule 351 for returning to the execution position of the execution function according to the address at the execution position;
a determination submodule 352 for determining the number of bytes of the return value;
the first saving module 353 is configured to, if the number of bytes of the return value is less than or equal to the preset number of bytes, save the return value to the second register;
the second saving module 354 is configured to, if the number of bytes of the return value is greater than the preset number of bytes, save the return value in the second stack, and save the address of the second stack in the second register.
The dynamic function calling device of this embodiment can execute the dynamic function calling methods provided in the second embodiment of the present invention and the foregoing embodiments, and the implementation principles thereof are similar, and are not described herein again.
In the embodiment, when the number N of parameters in the execution function is less than or equal to M, the N parameters are stored in the first register; when the number N of parameters in the execution function is larger than M, storing M parameters in the N parameters to a first register, and storing N-M parameters to a first stack; when the compiled assembly language is executed, the number of the parameters in the execution function is stored in a register and a stack by adopting a function calling appointed ABI mode, and the processing of the parameters of the execution function is completed; and when the number of bytes of the return value is less than or equal to the preset number of bytes, the return value is stored in a second register, and when the number of bytes of the return value is greater than the preset number of bytes, the return value is stored in a second stack, and the address of the second stack is stored in the second register, so that the return value of the called function is stored in an ABI (abstract constraint) mode. Meanwhile, when the number of parameters in the function is determined when the compiled assembly language is executed, the operation of executing the calling context of the function can be effectively finished, and the execution and calling of the function can be finished.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (8)

1. A method for dynamically calling a function, comprising:
acquiring a packed message when the compiled assembly language is executed; the packed message comprises an execution function, and the execution function comprises at least one parameter;
storing the at least one parameter according to a function call convention application program binary interface (ABI) mode;
determining an address at a current execution position of the execution function;
calling and executing a called function corresponding to the execution function, and determining a return value of the called function;
and returning to the execution position of the execution function according to the address of the execution position to continuously execute the program after the execution position of the execution function is executed, and saving the return value.
2. The method as claimed in claim 1, wherein said storing said at least one parameter according to a function call convention ABI scheme comprises:
if the number N of the parameters in the execution function is less than or equal to M, storing the N parameters into a first register;
if the number N of the parameters in the execution function is larger than M, storing M parameters in the N parameters into a first register, and sequentially storing N-M parameters into a first stack;
wherein N, M is a positive integer.
3. The method of claim 1, wherein said calling and executing a called function corresponding to said executing function comprises:
determining the called function corresponding to the calling parameter according to the calling parameter in the execution function;
acquiring the address of the called function, and determining the position of the called function according to the address of the called function;
and calling and executing the called function.
4. The method of any of claims 1-3, wherein saving the return value comprises:
determining the number of bytes of the return value;
if the number of bytes of the return value is less than or equal to the preset number of bytes, storing the return value into a second register;
and if the number of bytes of the return value is greater than the preset number of bytes, storing the return value into a second stack, and storing the address of the second stack into the second register.
5. A dynamic function calling apparatus, comprising:
the acquisition module is used for acquiring the packed message when the compiled assembly language is executed; the packed message comprises an execution function, and the execution function comprises at least one parameter;
the storage module is used for storing the at least one parameter according to a function calling convention application ABI mode;
a determining module, configured to determine an address at a current execution position of the execution function;
the calling module is used for calling and executing a called function corresponding to the executing function and determining a return value of the called function;
and the return module is used for returning to the execution position of the execution function according to the address of the execution position to continue executing the program after the execution position of the execution function, and storing the return value.
6. The apparatus of claim 5, wherein the storage module comprises:
the first storage submodule is used for storing the N parameters into a first register if the number N of the parameters in the execution function is less than or equal to M;
and the second storage submodule is used for storing M parameters in the N parameters into the first register and sequentially storing N-M parameters into the first stack if the number N of the parameters in the execution function is greater than M, wherein N, M is a positive integer.
7. The apparatus of claim 5, wherein the invoking module is specifically configured to:
determining the called function corresponding to the calling parameter according to the calling parameter in the execution function;
acquiring the address of the called function, and determining the position of the called function according to the address of the called function;
and calling and executing the called function, and determining the return value of the called function.
8. The apparatus of any of claims 5-7, wherein the return module comprises:
the return submodule is used for returning to the execution position of the execution function according to the address at the execution position;
the determining submodule is used for determining the number of bytes of the return value;
the first storage module is used for storing the return value into a second register if the number of bytes of the return value is less than or equal to the preset number of bytes;
and the second saving module is used for saving the return value into a second stack and saving the address of the second stack into the second register if the number of bytes of the return value is greater than the preset number of bytes.
CN201610875839.9A 2016-09-30 2016-09-30 Function dynamic calling method and device Active CN108304191B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610875839.9A CN108304191B (en) 2016-09-30 2016-09-30 Function dynamic calling method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610875839.9A CN108304191B (en) 2016-09-30 2016-09-30 Function dynamic calling method and device

Publications (2)

Publication Number Publication Date
CN108304191A CN108304191A (en) 2018-07-20
CN108304191B true CN108304191B (en) 2021-06-01

Family

ID=62871808

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610875839.9A Active CN108304191B (en) 2016-09-30 2016-09-30 Function dynamic calling method and device

Country Status (1)

Country Link
CN (1) CN108304191B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111610966A (en) * 2019-02-22 2020-09-01 龙芯中科技术有限公司 Program running method and device and computing equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1664779A (en) * 2003-06-26 2005-09-07 微软公司 Software development infrastructure
CN102222017A (en) * 2010-04-13 2011-10-19 英特尔公司 Methods and systems to implement non-ABI conforming features across unseen interfaces
CN104503819A (en) * 2015-01-05 2015-04-08 中国科学院计算技术研究所 Assembler for different operating systems (OSes) and assembly transplantation method
CN104572482A (en) * 2014-12-19 2015-04-29 北京华为数字技术有限公司 Process variable storage method and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB0215033D0 (en) * 2002-06-28 2002-08-07 Critical Blue Ltd Instruction set translation method
US9864518B2 (en) * 2014-11-10 2018-01-09 International Business Machines Corporation Assigning home memory addresses to function call parameters

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1664779A (en) * 2003-06-26 2005-09-07 微软公司 Software development infrastructure
CN102222017A (en) * 2010-04-13 2011-10-19 英特尔公司 Methods and systems to implement non-ABI conforming features across unseen interfaces
CN104572482A (en) * 2014-12-19 2015-04-29 北京华为数字技术有限公司 Process variable storage method and device
CN104503819A (en) * 2015-01-05 2015-04-08 中国科学院计算技术研究所 Assembler for different operating systems (OSes) and assembly transplantation method

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
"Function calls and the PowerPC 64-bit ABI";Jonathan Bartlett;《https://www.ibm.com/developerworks/library/l-powasm4/index.html》;20070228;第1-12页 *
"x86-64指令和ABI";Weizhenwei;《http://weizhenwei.github.io/blog/2014/12/25/x86-64zhi-ling-he-abi/》;20141225;第1-3页 *
"基于龙芯的Windows软件运行环境的设计与实现";苏煜 等;《江苏科技大学学报(自然科学版)》;20140815;第28卷(第4期);第387-391页 *

Also Published As

Publication number Publication date
CN108304191A (en) 2018-07-20

Similar Documents

Publication Publication Date Title
CN106598579B (en) Method and apparatus for integrating dynamic type programming language on blockchain
EP2966566A1 (en) Driver program loading method and embedded device
CN104866293B (en) A kind of method and device to Android application extensions for Microsoft Internet Explorer & Microsoft Office
US8464230B2 (en) Methods and systems to implement non-ABI conforming features across unseen interfaces
CN110704037A (en) Rule engine implementation method and device
CN107230135B (en) Order splitting processing method and device
CN108614696B (en) Application making method, static library generation method and device
JP2017504106A5 (en)
CN109359060B (en) Data extraction method, device, computing equipment and computer storage medium
CN110599341A (en) Transaction calling method and system
CN104965687A (en) Big data processing method and apparatus based on instruction set generation
CN108304191B (en) Function dynamic calling method and device
CN109800078B (en) Task processing method, task distribution terminal and task execution terminal
WO2017012351A1 (en) Parallel computing method and terminal
CN109343856A (en) The generation method and device of custom algorithm component
JPWO2013085025A1 (en) Minimum cut set evaluation system, minimum cut set calculation method and program
CN110689114B (en) Network node processing method and device, storage medium and electronic equipment
US20100042971A1 (en) System and method for calling an un-predetermined subroutine in a computer program
CN106681787A (en) Method and device for developing application
CN110032407B (en) Method and device for improving parallel performance of CPU (Central processing Unit) and electronic equipment
CN109976751B (en) Model operation method, related device and computer readable storage medium
CN109766515B (en) Matrix decomposition processing device and method
CN109002684B (en) Interval information analysis method
CN107817969B (en) Program generation method and device and computer system
CN111079390A (en) Method and device for determining selection state of check box list

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 100095 Building 2, Longxin Industrial Park, Zhongguancun environmental protection technology demonstration park, Haidian District, Beijing

Applicant after: Loongson Zhongke Technology Co.,Ltd.

Address before: 100095 Building 2, Longxin Industrial Park, Zhongguancun environmental protection technology demonstration park, Haidian District, Beijing

Applicant before: LOONGSON TECHNOLOGY Corp.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant