CN115509645A - Function calling method and device - Google Patents

Function calling method and device Download PDF

Info

Publication number
CN115509645A
CN115509645A CN202211213521.6A CN202211213521A CN115509645A CN 115509645 A CN115509645 A CN 115509645A CN 202211213521 A CN202211213521 A CN 202211213521A CN 115509645 A CN115509645 A CN 115509645A
Authority
CN
China
Prior art keywords
target
instruction
function
prolog
stack space
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.)
Pending
Application number
CN202211213521.6A
Other languages
Chinese (zh)
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.)
Beijing Eswin Computing Technology Co Ltd
Original Assignee
Beijing Eswin Computing Technology Co 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 Beijing Eswin Computing Technology Co Ltd filed Critical Beijing Eswin Computing Technology Co Ltd
Priority to CN202211213521.6A priority Critical patent/CN115509645A/en
Publication of CN115509645A publication Critical patent/CN115509645A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • 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)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The application discloses a function calling method and device, and relates to the technical field of computers. The method of the present application comprises: acquiring a target executable binary code corresponding to a target application program; executing the target executable binary code; when a target function needs to be called, executing a target prolog instruction to open a target stack space according to the size parameter of the stack space to be opened, and sequentially storing the content stored in each target register into the target stack space according to a preset sequence corresponding to a plurality of target registers; calling a target function; and after the target function is called, executing a target tail sound instruction to restore the content corresponding to each target register stored in the target stack space into each target register according to the preset sequence corresponding to the target registers and the size parameter of the stack space to be opened, and restoring the stack pointer to a target position, wherein the target position is the position of the stack pointer before the target function is called.

Description

Function calling method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for function invocation.
Background
In the process that a CPU runs an executable binary code corresponding to an application program, when a certain function needs to be called, a plurality of function prolog instructions corresponding to the function are executed firstly to realize the purpose of opening up a stack space, and contents stored in a plurality of registers to be protected are stored in the stack space; then calling the function; after the function call is finished, executing a plurality of function tail sound instructions corresponding to the function to recover the content corresponding to each register stored in the stack space to each register, thereby ensuring the normal call of the function and the normal operation of the application program.
Since the application program needs to call the function frequently in the running process, the CPU needs to execute a large number of function prolog instructions and function tail instructions in the process of executing the executable binary code corresponding to the application program, however, executing a large number of function prolog instructions and function tail instructions may result in low efficiency of calling the function by the CPU, and thus performance of running the application program by the CPU may be reduced.
Disclosure of Invention
The embodiment of the application provides a function calling method and device, and mainly aims to improve the efficiency of calling a function by a CPU (central processing unit), so that the performance of running an application program by the CPU is improved.
In order to solve the above technical problem, an embodiment of the present application provides the following technical solutions:
in a first aspect, the present application provides a function call method, where the method is applied to a CPU, and the method includes:
acquiring a target executable binary code corresponding to a target application program, wherein the target executable binary code comprises a target function, a target prolog instruction corresponding to the target function and a target tail sound instruction, and the target prolog instruction and the target tail sound instruction both comprise a size parameter of a stack space to be opened up;
executing the target executable binary code;
when the target function needs to be called, executing the target prolog instruction to open a target stack space according to the size parameter of the stack space to be opened, and sequentially storing the content stored in each target register into the target stack space according to a preset sequence corresponding to a plurality of target registers;
calling the target function;
and after the target function is called, executing the target tail sound instruction to restore the content corresponding to each target register stored in the target stack space to each target register according to the preset sequence corresponding to the target registers and the size parameter of the stack space to be opened, and restoring a stack pointer to a target position, wherein the target position is the position of the stack pointer before the target function is called.
Optionally, before the obtaining of the target executable binary code corresponding to the target application program, the method further includes:
running a compiler;
inputting the source code corresponding to the target application program into the compiler so that the compiler compiles the source code corresponding to the target application program into an executable binary code, generating the target prolog instruction and the target tail sound instruction according to the size of the stack space to be opened after calculating the size of the stack space to be opened according to a preset algorithm, the capacity size corresponding to each target register and the data size corresponding to each local variable contained in the target function, and adding the target prolog instruction and the target tail sound instruction into the executable binary code to obtain the target executable binary code.
Optionally, the executing the target prolog instruction includes:
inputting the target prolog instruction into a decoding module so that the decoding module can decode the target prolog instruction to obtain a decoding result corresponding to the target prolog instruction;
and controlling a first special circuit to execute the operation corresponding to the target prolog instruction according to the decoding result corresponding to the target prolog instruction.
Optionally, the executing the target tail sound instruction includes:
inputting the target tail sound instruction into a decoding module so that the decoding module can decode the target tail sound instruction to obtain a decoding result corresponding to the target tail sound instruction;
and controlling a second special circuit to execute the operation corresponding to the target tail sound instruction according to the decoding result corresponding to the target tail sound instruction.
In a second aspect, the present application further provides a function calling apparatus, which is applied to a CPU, and includes:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a target executable binary code corresponding to a target application program, the target executable binary code comprises a target function, a target prolog instruction corresponding to the target function and a target tail sound instruction, and the target prolog instruction and the target tail sound instruction both comprise a size parameter of a stack space to be opened;
a first execution unit to execute the target executable binary code;
the second execution unit is used for executing the target prolog instruction when the target function needs to be called so as to open up a target stack space according to the size parameter of the stack space to be opened up, and sequentially storing the content stored in each target register into the target stack space according to a preset sequence corresponding to a plurality of target registers;
the calling unit is used for calling the target function;
and a third execution unit, configured to execute the target tail sound instruction after the target function is called, so as to restore, according to the preset sequence corresponding to the multiple target registers and the size parameter of the stack space to be created, the content corresponding to each target register stored in the target stack space into each target register, and restore a stack pointer to a target position, where the target position is a position where the stack pointer is located before the target function is called.
Optionally, the apparatus further comprises:
the running unit is used for running the compiler before the acquisition unit acquires the target executable binary code corresponding to the target application program;
and the input unit is used for inputting the source code corresponding to the target application program into the compiler so that the compiler compiles the source code corresponding to the target application program into an executable binary code, and after calculating the size of a stack space to be opened up according to a preset algorithm, the capacity size corresponding to each target register and the data size corresponding to each local variable contained in the target function, generating the target prolog instruction and the target tail sound instruction according to the size of the stack space to be opened up, and adding the target prolog instruction and the target tail sound instruction into the executable binary code to obtain the target executable binary code.
Optionally, the second execution unit is specifically configured to input the target prolog instruction into a decoding module, so that the decoding module performs decoding processing on the target prolog instruction to obtain a decoding result corresponding to the target prolog instruction, and controls the first special circuit to execute an operation corresponding to the target prolog instruction according to the decoding result corresponding to the target prolog instruction.
Optionally, the third execution unit is specifically configured to input the target tail sound instruction into a decoding module, so that the decoding module performs decoding processing on the target tail sound instruction to obtain a decoding result corresponding to the target tail sound instruction, and controls a second special circuit to execute an operation corresponding to the target tail sound instruction according to the decoding result corresponding to the target tail sound instruction.
In a third aspect, an embodiment of the present application provides a storage medium, where the storage medium includes a stored program, and when the program runs, a device in which the storage medium is located is controlled to execute the function call method according to the first aspect.
In a fourth aspect, an embodiment of the present application provides a function calling apparatus, which includes a storage medium; and one or more processors, the storage medium coupled with the processors, the processors configured to execute program instructions stored in the storage medium; the program instructions when executed perform the function call method of the first aspect.
By means of the technical scheme, the technical scheme provided by the application at least has the following advantages:
according to the method and the device for calling the function, the CPU executes the target prolog instruction and the target tail sound instruction corresponding to the target function, so that the CPU can be ensured to normally call the target function and normally run the target application program, the efficiency of calling the function by the CPU can be effectively improved, and the performance of running the target application program by the CPU can be effectively improved.
The foregoing description is only an overview of the technical solutions of the present application, and the present application can be implemented according to the content of the description in order to make the technical means of the present application more clearly understood, and the following detailed description of the present application is given in order to make the above and other objects, features, and advantages of the present application more clearly understandable.
Drawings
The above and other objects, features and advantages of exemplary embodiments of the present application will become readily apparent from the following detailed description read in conjunction with the accompanying drawings. Several embodiments of the present application are illustrated by way of example and not by way of limitation in the figures of the accompanying drawings and in which like reference numerals refer to similar or corresponding parts and in which:
fig. 1 is a flowchart illustrating a method for function call according to an embodiment of the present application;
fig. 2 is a block diagram illustrating a function calling apparatus according to an embodiment of the present application;
fig. 3 is a block diagram illustrating another function call apparatus according to an embodiment of the present disclosure.
Detailed Description
Exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
It is to be noted that, unless otherwise specified, technical or scientific terms used herein shall have the ordinary meaning as understood by those skilled in the art to which this application belongs.
When a user needs to run a certain application program on the terminal device in the process that the user uses the terminal device, a CPU in the terminal device needs to run a compiler first, compile a source code corresponding to the application program into an executable binary code through the compiler, and then execute the executable binary code corresponding to the application program, so as to implement running the application program.
When the source code corresponding to the application program includes a function to be called, in the process of compiling the source code corresponding to the application program into the executable binary code, the compiler needs to generate a plurality of function prolog instructions and a plurality of function mantissa instructions according to a plurality of registers to be protected by calling the function and a plurality of local variables included in the function, and add the plurality of generated function prolog instructions and the plurality of generated function mantissa instructions to the executable binary code corresponding to the application program.
An embodiment of the present application provides a function call method, as shown in fig. 1, where the method is applied to a CPU, and the method includes:
101. and acquiring a target executable binary code corresponding to the target application program.
In this embodiment of the present application, an execution subject in each step is a CPU in a target terminal device, where the target terminal device may be, but is not limited to: computers, smart phones, tablets, and the like.
The target application program may be any application program installed in the target terminal device, the target executable binary code corresponding to the target application program includes a target function, a target prolog instruction corresponding to the target function, and a target tail sound instruction, and the target function may be any function to be called included in the source code corresponding to the target application program, where the target prolog instruction and the target tail sound instruction are specifically generated by a compiler according to a size of a capacity corresponding to each target register and a size of a data amount corresponding to each local variable included in the target function, the target prolog instruction and the target tail sound instruction both include a size parameter of a stack space to be opened, the plurality of target registers are determined according to a function call convention corresponding to the CPU and are not determined according to the target function, when the function call convention corresponding to the CPU records various functions, contents stored in the CPU need to be protected, that is, when the plurality of target registers call various functions for the CPU, the registers need to protect the registers storing the contents.
It should be noted that the target function contained in the target executable binary code, the target prolog instruction corresponding to the target function, and the target tail sound instruction are all in binary format.
In this embodiment of the present application, when a user needs a target terminal device to run a target application, a CPU in the target terminal device needs to first obtain a target executable binary code corresponding to the target application.
102. The target executable binary code is executed.
In the embodiment of the application, after obtaining the target executable binary code corresponding to the target application program, the CPU may execute the target executable binary code corresponding to the target application program to implement running the target application program.
103. When the target function needs to be called, the target prolog instruction is executed.
The target prolog instruction corresponding to the target function has the functions of: (1) And opening up a target stack space according to the size parameter of the stack space to be opened up, which is contained in the target prolog instruction, for example, if the parameter value of the size parameter of the stack space to be opened up, which is contained in the target prolog instruction, is specifically 60bytes, executing the target prolog instruction can open up a target stack space (2) with the size of 60bytes, and sequentially store the contents stored in each target register into the target stack space according to the preset sequence corresponding to the target registers.
In the embodiment of the application, in the process that a target executable binary code corresponding to a target application program is executed by a CPU, when the target function needs to be called, the CPU needs to execute a target prolog instruction corresponding to the target function so as to open up a target stack space according to a size parameter of a stack space to be opened up contained in the target prolog instruction, and sequentially stores contents stored in each target register into the target stack space according to a preset sequence corresponding to a plurality of target registers, namely, the contents stored in the target registers with the preset sequence of 1 are stored into the target stack space, and then the contents stored in the target registers with the preset sequence of 2 are stored into the target stack space \8230, so that the CPU can normally call the target function.
It should be noted that, in the embodiment of the present application, how to set the preset sequence corresponding to the plurality of target registers is not specifically limited.
104. The target function is called.
In the embodiment of the application, after the target prolog instruction corresponding to the target function is executed, the CPU calls the target function.
105. And after the target function call is finished, executing the target tail sound instruction.
The target tail sound instruction corresponding to the target function has the functions of: (1) Restoring the content corresponding to each target register stored in the target stack space into each target register according to the preset sequence corresponding to the target registers and the size parameter of the stack space to be opened up (2) restoring the stack pointer to the target position; and the target position is the position of the stack pointer before the target function is called.
In the embodiment of the application, after the target function is called, the CPU needs to execute a target tail sound instruction corresponding to the target function, so as to restore the content corresponding to each target register stored in the target stack space to each target register according to the preset sequence corresponding to the plurality of target registers and the size parameter of the stack space to be opened up, that is, restore the content corresponding to the target register with the preset sequence of 1 stored in the target stack space to the target register with the preset sequence of 1, restore the content corresponding to the target register with the preset sequence of 2 stored in the target stack space to the target register with the preset sequence of 2, \ 8230, and restore the stack pointer to the target position, that is, restore the stack pointer to the position where the stack pointer is located before the target function is called, thereby ensuring that the CPU can normally execute the subsequent part in the target executable binary code, that is ensured that the CPU can normally run the target application program.
In the embodiment of the present application, when the CPU executes the target prolog instruction and the target tail sound instruction corresponding to the target function, it may be ensured that the CPU can normally call the target function and ensure that the CPU can normally operate the target application program, and therefore, the efficiency of calling the function by the CPU may be effectively improved, and the performance of the CPU in operating the target application program may be effectively improved.
Further, in this embodiment of the present application, the CPU needs to compile a source code corresponding to the target application into a target executable binary code in advance through the compiler, where a specific process of the CPU compiling the source code corresponding to the target application into the target executable binary code through the compiler is as follows: firstly, running a compiler; secondly, inputting a source code corresponding to a target application program into a compiler, after receiving the source code corresponding to the target application program, the compiler firstly compiles the source code corresponding to the target application program into an executable binary code, then calculates the size of a stack space to be opened up according to a preset algorithm, the capacity size corresponding to each target register and the data size corresponding to each local variable contained in the target function, generates a target prolog instruction and a target tail sound instruction corresponding to the target function according to the size of the stack space to be opened up, and finally adds the target prolog instruction and the target tail sound instruction into the executable binary code, thereby obtaining the target executable binary code; the preset algorithm may be, but is not limited to: a stack space calculation algorithm.
It should be noted that, in an actual application process, a programmer may set an optimized compilation option switch in a compiler in advance, after a CPU starts the compiler, the optimized compilation option switch in the compiler may be turned on or turned off by a preset instruction, when the optimized compilation option switch is turned on, in a process in which a source code corresponding to a target application program is compiled into a target executable binary code by the compiler, the compiler may generate a target prolog instruction and a target tail sound instruction corresponding to a function to be called in the above manner, add the target prolog instruction and the target tail sound instruction corresponding to the function to an executable binary code corresponding to the target application program, when the optimized compilation option switch is turned off, the compiler may generate a plurality of function prolog instructions and a plurality of function tail sound instructions corresponding to the function to be called by using an existing technology, and add the plurality of function prolog instructions and the plurality of function tail sound instructions corresponding to the executable binary code corresponding to the target application program, which is not specifically limited in this application embodiment.
It should be noted that, in the actual application process, a programmer may add a target function attribute to a function that needs to be called by the function calling method provided in the present application in the source code corresponding to the target application program in advance according to actual requirements; in the process of compiling a source code corresponding to a target application program into a target executable binary code by a compiler, when the compiler determines that a certain function includes a target function attribute, the compiler may generate a target prolog instruction and a target tail sound instruction corresponding to the function in the above manner, add the target prolog instruction and the target tail sound instruction corresponding to the function to the executable binary code corresponding to the target application program, and when the compiler determines that the certain function does not include the target function attribute, the compiler may generate a plurality of function prolog instructions and a plurality of function tail sound instructions corresponding to the function by using the prior art, and add the plurality of function prolog instructions and the plurality of function tail sound instructions corresponding to the function to the executable binary code corresponding to the target application program, which is not specifically limited in the embodiment of the present application.
Further, in the embodiment of the present application, the CPU includes a first dedicated circuit corresponding to the target prolog instruction and a second dedicated circuit corresponding to the target tail instruction. It should be noted that, in an actual application process, the first dedicated circuit corresponding to the target preamble command and the second dedicated circuit corresponding to the target tail sound command may be the same dedicated circuit or different dedicated circuits, which is not specifically limited in this embodiment of the present application.
Further, in this embodiment of the present application, a specific process of the CPU executing the target prolog instruction corresponding to the target function is as follows: firstly, inputting a target prolog instruction into a decoding module so that the decoding module can decode the target prolog instruction to obtain a decoding result corresponding to the target prolog instruction; and controlling the first special circuit to execute the operation corresponding to the target prolog instruction according to the decoding result corresponding to the target prolog instruction.
Further, in the embodiment of the present application, a specific process of executing, by the CPU, the target tail sound instruction corresponding to the target function is: firstly, inputting a target tail sound instruction into a decoding module so that the decoding module can decode the target tail sound instruction to obtain a decoding result corresponding to the target tail sound instruction; and then controlling a second special circuit to execute the operation corresponding to the target tail sound instruction according to the decoding result corresponding to the target tail sound instruction.
Further, as an implementation of the method shown in fig. 1, another embodiment of the present application further provides a function calling apparatus. The embodiment of the apparatus corresponds to the embodiment of the method, and for convenience of reading, details in the embodiment of the apparatus are not repeated one by one, but it should be clear that the apparatus in the embodiment can correspondingly implement all the contents in the embodiment of the method. The device is applied to improve the efficiency of calling a function by a CPU, so as to improve the performance of running an application program by the CPU, and specifically, as shown in fig. 2, the device includes:
the acquiring unit 21 is configured to acquire a target executable binary code corresponding to a target application program, where the target executable binary code includes a target function, a target prolog instruction corresponding to the target function, and a target wake instruction, and both the target prolog instruction and the target wake instruction include a size parameter of a stack space to be opened up;
a first execution unit 22 for executing the target executable binary code;
a second execution unit 23, configured to execute the target prolog instruction when the target function needs to be called, so as to open a target stack space according to the size parameter of the stack space to be opened, and sequentially store, according to a preset sequence corresponding to multiple target registers, contents stored in each target register into the target stack space;
a calling unit 24, configured to call the target function;
a third executing unit 25, configured to execute the target tail sound instruction after the target function is called, so as to restore, according to the preset sequence corresponding to the multiple target registers and the size parameter of the stack space to be created, the content corresponding to each target register stored in the target stack space into each target register, and restore a stack pointer to a target position, where the target position is a position where the stack pointer is located before the target function is called.
Further, as shown in fig. 3, the apparatus further includes:
an execution unit 26, configured to execute the compiler before the obtaining unit 21 obtains the target executable binary code corresponding to the target application program;
an input unit 27, configured to input a source code corresponding to the target application program into the compiler, so that the compiler compiles the source code corresponding to the target application program into an executable binary code, and after calculating a size of a stack space to be created according to a preset algorithm, a size of a capacity corresponding to each target register, and a size of a data amount corresponding to each local variable included in the target function, generate the target prolog instruction and the target tail sound instruction according to the size of the stack space to be created, and add the target prolog instruction and the target tail sound instruction to the executable binary code, so as to obtain the target executable binary code.
Further, as shown in fig. 3, the second execution unit 23 is specifically configured to input the target prolog instruction into the decoding module, so that the decoding module performs decoding processing on the target prolog instruction to obtain a decoding result corresponding to the target prolog instruction, and controls the first special circuit to execute an operation corresponding to the target prolog instruction according to the decoding result corresponding to the target prolog instruction.
Further, as shown in fig. 3, the third executing unit 25 is specifically configured to input the target tail sound instruction into a decoding module, so that the decoding module performs decoding processing on the target tail sound instruction to obtain a decoding result corresponding to the target tail sound instruction, and controls a second special circuit to execute an operation corresponding to the target tail sound instruction according to the decoding result corresponding to the target tail sound instruction.
In the embodiment of the application, a target prolog instruction and a target tail instruction corresponding to a target function are executed by a CPU, so that the CPU can be ensured to normally call the target function and normally run a target application program, the efficiency of calling the function by the CPU can be effectively improved, and the performance of running the target application program by the CPU can be effectively improved.
The embodiment of the application provides a storage medium, which comprises a stored program, wherein when the program runs, the device where the storage medium is located is controlled to execute the function calling method.
The storage medium may include volatile memory in a computer readable medium, random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
The embodiment of the application also provides a function calling device, which comprises a storage medium; and one or more processors, the storage medium coupled with the processors, the processors configured to execute program instructions stored in the storage medium; and when the program instruction runs, executing the function calling method.
The embodiment of the application provides equipment, the equipment comprises a processor, a memory and a program which is stored on the memory and can run on the processor, and the following steps are realized when the processor executes the program:
acquiring a target executable binary code corresponding to a target application program, wherein the target executable binary code comprises a target function, a target prolog instruction corresponding to the target function and a target tail sound instruction, and the target prolog instruction and the target tail sound instruction both comprise a size parameter of a stack space to be opened up;
executing the target executable binary code;
when the target function needs to be called, executing the target prolog instruction to open a target stack space according to the size parameter of the stack space to be opened, and sequentially storing the content stored in each target register into the target stack space according to a preset sequence corresponding to a plurality of target registers;
calling the target function;
and after the target function is called, executing the target tail sound instruction to restore the content corresponding to each target register stored in the target stack space to each target register according to the preset sequence corresponding to the target registers and the size parameter of the stack space to be opened, and restoring a stack pointer to a target position, wherein the target position is the position of the stack pointer before the target function is called.
Further, before the obtaining of the target executable binary code corresponding to the target application program, the method further includes:
running a compiler;
inputting a source code corresponding to the target application program into the compiler so that the compiler compiles the source code corresponding to the target application program into an executable binary code, generating a target prolog instruction and a target tail sound instruction according to the size of a stack space to be opened after calculating the size of the stack space to be opened according to a preset algorithm, the size of a capacity corresponding to each target register and the size of data quantity corresponding to each local variable contained in the target function, and adding the target prolog instruction and the target tail sound instruction into the executable binary code so as to obtain the target executable binary code.
Further, the executing the target prolog instruction comprises:
inputting the target prolog instruction into a decoding module so that the decoding module can decode the target prolog instruction to obtain a decoding result corresponding to the target prolog instruction;
and controlling a first special circuit to execute the operation corresponding to the target prolog instruction according to the decoding result corresponding to the target prolog instruction.
Further, the executing the target tail instruction includes:
inputting the target tail sound instruction into a decoding module so that the decoding module can decode the target tail sound instruction to obtain a decoding result corresponding to the target tail sound instruction;
and controlling a second special circuit to execute the operation corresponding to the target tail sound instruction according to the decoding result corresponding to the target tail sound instruction.
The present application further provides a computer program product adapted to perform program code for initializing the following method steps when executed on a data processing device: acquiring a target executable binary code corresponding to a target application program, wherein the target executable binary code comprises a target function, a target prolog instruction corresponding to the target function and a target tail sound instruction, and the target prolog instruction and the target tail sound instruction both comprise a size parameter of a stack space to be opened up; executing the target executable binary code; when the target function needs to be called, executing the target prolog instruction to open a target stack space according to the size parameter of the stack space to be opened, and sequentially storing the content stored in each target register into the target stack space according to a preset sequence corresponding to a plurality of target registers; calling the target function; and after the target function is called, executing the target tail sound instruction to restore the content corresponding to each target register stored in the target stack space into each target register according to the preset sequence corresponding to the target registers and the size parameter of the stack space to be opened, and restoring a stack pointer to a target position, wherein the target position is the position of the stack pointer before the target function is called.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Disks (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising a," "8230," "8230," or "comprising" does not exclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. A function call method applied to a CPU, the method comprising:
acquiring a target executable binary code corresponding to a target application program, wherein the target executable binary code comprises a target function, a target prolog instruction corresponding to the target function and a target tail sound instruction, and the target prolog instruction and the target tail sound instruction both comprise a size parameter of a stack space to be opened up;
executing the target executable binary code;
when the target function needs to be called, executing the target prolog instruction to open a target stack space according to the size parameter of the stack space to be opened, and sequentially storing the content stored in each target register into the target stack space according to a preset sequence corresponding to a plurality of target registers;
calling the target function;
and after the target function is called, executing the target tail sound instruction to restore the content corresponding to each target register stored in the target stack space to each target register according to the preset sequence corresponding to the target registers and the size parameter of the stack space to be opened, and restoring a stack pointer to a target position, wherein the target position is the position of the stack pointer before the target function is called.
2. The method of claim 1, wherein prior to said obtaining the target executable binary corresponding to the target application, the method further comprises:
running a compiler;
inputting a source code corresponding to the target application program into the compiler so that the compiler compiles the source code corresponding to the target application program into an executable binary code, generating a target prolog instruction and a target tail sound instruction according to the size of a stack space to be opened after calculating the size of the stack space to be opened according to a preset algorithm, the size of a capacity corresponding to each target register and the size of data quantity corresponding to each local variable contained in the target function, and adding the target prolog instruction and the target tail sound instruction into the executable binary code so as to obtain the target executable binary code.
3. The method of claim 1, wherein said executing the target prolog instruction comprises:
inputting the target prolog instruction into a decoding module so that the decoding module can decode the target prolog instruction to obtain a decoding result corresponding to the target prolog instruction;
and controlling a first special circuit to execute the operation corresponding to the target prolog instruction according to the decoding result corresponding to the target prolog instruction.
4. The method of claim 1, wherein the executing the target wake instruction comprises:
inputting the target tail sound instruction into a decoding module so that the decoding module can decode the target tail sound instruction to obtain a decoding result corresponding to the target tail sound instruction;
and controlling a second special circuit to execute the operation corresponding to the target tail sound instruction according to the decoding result corresponding to the target tail sound instruction.
5. A function calling apparatus, wherein the apparatus is applied to a CPU, the apparatus comprising:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a target executable binary code corresponding to a target application program, the target executable binary code comprises a target function, a target prolog instruction corresponding to the target function and a target tail sound instruction, and the target prolog instruction and the target tail sound instruction both comprise a size parameter of a stack space to be opened;
a first execution unit to execute the target executable binary code;
the second execution unit is used for executing the target prolog instruction when the target function needs to be called so as to open up a target stack space according to the size parameter of the stack space to be opened up, and sequentially storing the content stored in each target register into the target stack space according to a preset sequence corresponding to a plurality of target registers;
the calling unit is used for calling the target function;
and a third execution unit, configured to execute the target tail tone instruction after the target function is called, so as to restore, according to a preset sequence corresponding to the plurality of target registers and the size parameter of the stack space to be opened, contents corresponding to each target register stored in the target stack space to each target register, and restore a stack pointer to a target position, where the target position is a position where the stack pointer is located before the target function is called.
6. The apparatus of claim 5, further comprising:
the running unit is used for running the compiler before the acquisition unit acquires the target executable binary code corresponding to the target application program;
and the input unit is used for inputting the source code corresponding to the target application program into the compiler so that the compiler compiles the source code corresponding to the target application program into an executable binary code, and after calculating the size of a stack space to be opened up according to a preset algorithm, the capacity size corresponding to each target register and the data size corresponding to each local variable contained in the target function, generating the target prolog instruction and the target tail sound instruction according to the size of the stack space to be opened up, and adding the target prolog instruction and the target tail sound instruction into the executable binary code to obtain the target executable binary code.
7. The apparatus of claim 5,
the second execution unit is specifically configured to input the target prolog instruction into a decoding module, so that the decoding module performs decoding processing on the target prolog instruction to obtain a decoding result corresponding to the target prolog instruction, and controls a first special circuit to execute an operation corresponding to the target prolog instruction according to the decoding result corresponding to the target prolog instruction.
8. The apparatus of claim 5,
the third execution unit is specifically configured to input the target tail sound instruction into a decoding module, so that the decoding module performs decoding processing on the target tail sound instruction to obtain a decoding result corresponding to the target tail sound instruction, and controls a second special circuit to execute an operation corresponding to the target tail sound instruction according to the decoding result corresponding to the target tail sound instruction.
9. A storage medium comprising a stored program, wherein the program, when executed, controls a device on which the storage medium is located to execute the function call method according to any one of claims 1 to 4.
10. A function calling apparatus, comprising a storage medium; and one or more processors, the storage medium coupled with the processors, the processors configured to execute program instructions stored in the storage medium; the program instructions when executed perform the function call method of any of claims 1 to 4.
CN202211213521.6A 2022-09-30 2022-09-30 Function calling method and device Pending CN115509645A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211213521.6A CN115509645A (en) 2022-09-30 2022-09-30 Function calling method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211213521.6A CN115509645A (en) 2022-09-30 2022-09-30 Function calling method and device

Publications (1)

Publication Number Publication Date
CN115509645A true CN115509645A (en) 2022-12-23

Family

ID=84507912

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211213521.6A Pending CN115509645A (en) 2022-09-30 2022-09-30 Function calling method and device

Country Status (1)

Country Link
CN (1) CN115509645A (en)

Similar Documents

Publication Publication Date Title
CN107992307B (en) Function compiling method and device
CN109299587A (en) Algorithm protection method, device, equipment and storage medium based on go language
CN107045438B (en) Application top view processing method, device and component
CN111090433A (en) Data processing method, device and storage medium
CN110543338A (en) dynamic loading method and device for files
CN113468079B (en) Memory access method and device
CN110333867B (en) Multiparty secure computing data processing method, device and system
CN116185532A (en) Task execution system, method, storage medium and electronic equipment
CN111190692A (en) Monitoring method and system based on Roc processor and readable medium
CN111797390B (en) Program running method, program running device, electronic equipment and computer readable storage medium
CN115509645A (en) Function calling method and device
CN114880076B (en) Dynamic loading method and device for dynamic mapping file of user-mode virtual machine
CN115629795A (en) Configuration method and device of executable file and electronic equipment
CN107291439B (en) Target incremental data construction method and device
CN114428633A (en) Firmware upgrading method, device and equipment
CN107239270B (en) Code processing method and device
CN113590149A (en) Method and device for segmented loading and running of program
CN108958795B (en) BootLoader code reuse method and development board in embedded system
WO2019157891A1 (en) Application installation method and application installer generating method
CN112416444A (en) Board switching control method, device, equipment and medium
CN112286572A (en) Configuration method and device of business process
CN113138770B (en) Method and device for optimizing stack operation binary code based on symbolic execution
CN111240761A (en) Configuration file loading method and device
CN112540835B (en) Method and device for operating hybrid machine learning model and related equipment
CN110286909B (en) Statistical method and device for resource use data of Simulink model

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