Data processing method and device, electronic equipment and readable medium
By obtaining the function address parameters of heterogeneous functions and using binary translator to translate instructions, the problem of correctly executing customer architecture native functions in the virtual machine is solved, and cross-architecture compatibility and portability are improved.
Patent Information
- Application Number
- CN202510534950.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2025-08-12
AI Technical Summary
When running customer architecture programs in a virtual machine of the host architecture platform, how to correctly execute the native functions of the customer architecture, especially how to accurately obtain the function address under different registration methods to ensure the correct execution of the function.
By obtaining the function address parameters of heterogeneous functions when the target program is running, setting the registration method of the target heterogeneous functions according to the acquisition method indicated by the function address parameter, and using a binary translator to translate the instructions of the customer architecture into instructions of the host architecture to ensure that the target heterogeneous functions are correctly executed in the virtual machine.
It realizes accurate acquisition of function addresses under different registration methods, ensures the correct execution of target heterogeneous functions in the virtual machine, and improves cross-architecture compatibility and portability.
Smart Images

Figure CN120469742A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data processing method, device, electronic device and readable medium. Background Art
[0002] With the continuous development of computer technology, more and more instruction set architectures are available. Currently, client programs for a guest architecture are often run through a virtual machine on a host architecture platform. This allows programs compiled for one architecture to run on a hardware platform of another architecture, solving cross-platform compatibility issues between different architectures and improving cross-architecture portability.
[0003] In the prior art, client programs running on a host architecture platform sometimes call native functions in the client architecture's function library. Different native functions may be registered to the virtual machine in a variety of ways, which may cause execution exceptions. Therefore, how to correctly execute native functions has become a technical problem that needs to be solved urgently. Summary of the Invention
[0004] Embodiments of the present invention provide a data processing method, device, electronic device, and readable medium, which can solve the technical problem of how to correctly execute native functions.
[0005] In order to solve the above problems, an embodiment of the present invention discloses a data processing method, which includes:
[0006] When a target program is running in a virtual machine of a host platform, a function address parameter corresponding to a target heterogeneous function is obtained according to a heterogeneous function call request; a client architecture adapted by the target program is different from a host architecture of the host platform; the function address parameter is used to indicate a method for obtaining a function address of the target heterogeneous function and is set based on a registration method of the target heterogeneous function;
[0007] According to the acquisition method indicated by the function address parameter, the function address corresponding to the target heterogeneous function is acquired, and the target heterogeneous function is executed according to the function address.
[0008] In another aspect, an embodiment of the present invention discloses a data processing device, comprising:
[0009] A first acquisition module is configured to acquire, when a target program is running in a virtual machine of a host platform, a function address parameter corresponding to a target heterogeneous function according to a heterogeneous function call request; the client architecture adapted by the target program is different from the host architecture of the host platform; the function address parameter is used to indicate a method for acquiring a function address of the target heterogeneous function and is set based on a registration method of the target heterogeneous function;
[0010] The second acquisition module is used to acquire the function address corresponding to the target heterogeneous function according to the acquisition method indicated by the function address parameter, and execute the target heterogeneous function according to the function address.
[0011] On the other hand, an embodiment of the present invention discloses an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the aforementioned method.
[0012] An embodiment of the present invention further discloses a machine-readable medium having instructions stored thereon. When executed by one or more processors, the processors are enabled to execute the method described above.
[0013] The embodiments of the present invention include the following advantages: the data processing method provided by the embodiments of the present invention obtains the function address parameter corresponding to the target heterogeneous function according to the heterogeneous function call request when the target program is running in the virtual machine of the host platform; the client architecture adapted by the target program is different from the host architecture of the host platform; the function address parameter is used to indicate the method for obtaining the function address of the target heterogeneous function, and is set based on the registration method of the target heterogeneous function. According to the acquisition method indicated by the function address parameter, the function address corresponding to the target heterogeneous function is obtained, and the target heterogeneous function is executed according to the function address. By obtaining the function address parameter corresponding to the target heterogeneous function, the function address is obtained according to the acquisition method of the function address indicated by the function address parameter, and then the registration method of the target heterogeneous function is adapted to ensure that the function address is accurately obtained for different registration methods, so that the target heterogeneous function is correctly executed in the virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0015] Figure 1 This is a flowchart of a data processing method provided by an embodiment of the present invention;
[0016] Figure 2 This is a schematic diagram of a processing process provided by an embodiment of the present invention;
[0017] Figure 3 is a block diagram of a data processing device provided by an embodiment of the present invention;
[0018] Figure 4It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0019] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0020] Figure 1 This is a flow chart of the steps of a data processing method provided by an embodiment of the present invention. Figure 1 As shown, the data processing method may include the following steps:
[0021] Step 101: When a target program is running in a virtual machine on a host platform, a function address parameter corresponding to a target heterogeneous function is obtained according to a heterogeneous function call request. The client architecture adapted by the target program is different from the host architecture of the host platform; the function address parameter is used to indicate a method for obtaining the function address of the target heterogeneous function and is set based on a registration method of the target heterogeneous function.
[0022] Step 102: Obtain a function address corresponding to the target heterogeneous function according to the acquisition method indicated by the function address parameter, and execute the target heterogeneous function according to the function address.
[0023] In an embodiment of the present invention, the data processing method described above can be executed by a host platform. The architecture adapted by the host platform is called the host architecture. The host platform can run a virtual machine in which user programs of other architectures are run. The user program can be a Java program. The other architecture is the client architecture, and the user program of the other architecture currently running is the target program. For example, suppose a Java program of x86 architecture is run through a virtual machine on a LoongArch architecture platform. Then the LoongArch architecture is the host architecture, the x86 architecture is the client architecture, and the Java program of the x86 architecture is the target program.
[0024] The virtual machine can be a program adapted to the host architecture. The virtual machine is a program that can run on the host architecture and can simulate the instruction set and execution environment of the client architecture. In this way, the virtual machine can translate the instructions in the user program of the client architecture into the instructions of the host architecture through software simulation, thereby executing the instructions of the user program of the client architecture on the hardware of the host architecture. When it is necessary to run the target program, the host platform can start the virtual machine and then create a virtual machine process. The virtual machine process can use the user program as the target program and create a main thread for the target program. The main thread can be responsible for executing the main function (main) of the target program. The main thread can be called the target program thread. Among them, the virtual machine process can create a target program thread through a virtual machine thread. The virtual machine process also includes some other threads, for example, threads for garbage collection, compilation and other tasks. These threads together constitute the operating environment of the virtual machine.
[0025] In order to achieve the optimization requirements of specific hardware resources, reuse existing code libraries, or improve program performance, the target program sometimes calls native functions in the client architecture's function library. Among them, the client architecture's function library can also be called a cross-architecture function library or a cross-architecture shared library. Native functions refer to functions that are not implemented in pure Java code. For example, native functions can be functions implemented by native code (for example, C code or C++ code) in a Java program. For example, the native function called in the x86 architecture Java program is a C language library compiled into an x86 architecture binary file. The native functions in the client architecture's function library are heterogeneous functions. Correspondingly, the native functions in the host architecture's function library can be called same-architecture functions.
[0026] During the running process of the target program, if a call instruction for calling a heterogeneous function is executed, the target program will trigger a heterogeneous function call request for the native function. Accordingly, the native function called by the heterogeneous function call request is the target heterogeneous function. In response to the heterogeneous function call request, the function address parameter corresponding to the target heterogeneous function can be obtained to obtain the function address. Specifically, the embodiment of the present invention can be aimed at the cross-architecture function call scenario. When the native function called this time is a function in the cross-architecture function library, that is, when the native function called this time is a heterogeneous function, the subsequent process is executed to obtain the function address parameter corresponding to the target heterogeneous function.
[0027] The function address parameter may be a pre-agreed parameter whose specific value is related to the registration method of the native function. For example, the function address parameter may be represented as JNA_entry. Since the registration method for native functions is different under different registration methods, in an embodiment of the present invention, the function address parameter is set based on the registration method of the target heterogeneous function, and the function address of the target heterogeneous function is obtained based on the function address acquisition method indicated by the function address parameter, so that the address acquisition method is adapted to the registration method of the target heterogeneous function, thereby ensuring that the function address is accurately acquired for different registration methods.
[0028] Furthermore, because the guest architecture's function library is designed for the guest architecture, the functions in the guest architecture's function library are compiled into guest architecture binary files, while the virtual machine processes bytecodes. Therefore, the target heterogeneous function can be executed through a binary translator. Specifically, the instructions in the target heterogeneous function in the guest architecture's instruction format are translated into instructions in the host architecture's instruction format, and the translated instructions in the host architecture's instruction format are executed, thereby executing the target heterogeneous function on the host platform. The function address can also be referred to as the function execution address or the function entry address.
[0029] In summary, the data processing method provided by the embodiment of the present invention obtains the function address parameter corresponding to the target heterogeneous function according to the heterogeneous function call request when the target program is running in the virtual machine of the host platform; the client architecture adapted by the target program is different from the host architecture of the host platform; the function address parameter is used to indicate the method for obtaining the function address of the target heterogeneous function, and is set based on the registration method of the target heterogeneous function. According to the acquisition method indicated by the function address parameter, the function address corresponding to the target heterogeneous function is obtained, and the target heterogeneous function is executed according to the function address. By obtaining the function address parameter corresponding to the target heterogeneous function, the function address is obtained according to the acquisition method of the function address indicated by the function address parameter, and then the registration method of the target heterogeneous function is adapted to ensure that the function address is accurately obtained for different registration methods, so that the target heterogeneous function is correctly executed in the virtual machine.
[0030] Optionally, the embodiment of the present invention may further include the following steps:
[0031] Step S21: register any heterogeneous function defined in the target program.
[0032] Step S22: When the registration mode of the heterogeneous function is the first registration mode, the function address parameter corresponding to the heterogeneous function is set to a default value.
[0033] Step S23: When the registration mode of the heterogeneous function is the second registration mode, the function address parameter corresponding to the heterogeneous function is set to the function address of the springboard function corresponding to the heterogeneous function.
[0034] The trampoline function is generated based on the heterogeneous function during the registration process. The second registration method is to register the native function as a trampoline function. Exemplarily, the second registration method can be the JNA registration method or the JNR registration method. The first registration method is to directly register the native function without introducing a trampoline function. Exemplarily, the first registration method can be the JNI registration method. The native function defined in the target program refers to the native function declared in the target program code. The target program code may include code for declaring the native function. Registering the native function refers to binding the function name of the native function to the function implementation. The registration method of the native function can be pre-defined by the developer in the target program code. Exemplarily, for any native function defined in the target program, the target program code defines a code segment for indicating the registration of the native function. The code segment will specify the method for registering the native function and the library address of the function library to which the native function belongs. The native function in the embodiments of the present invention refers to the above-mentioned heterogeneous functions and functions of the same architecture. For example, taking the native function 1 defined in the target program as an example, it is assumed that the code segment for instructing to register the native function 1 is:
[0035] public class RegisterNativeFunction 1{
[0036] String library addr=. / example / native_library so
[0037] String libraryName="native_library";
[0038] String registrationType="JNI";
[0039] Then, it can be determined that the library address of native function 1 is . / examplelibrary.so, the library file name is "native_library", and the registration method defined for native function 1 is JNI registration. In this embodiment of the present invention, by defining the registration method for the native function, the host platform can accurately know the method used to register the native function.
[0040] JNI (Java Native Interface) is a standard interface for Java code to call native code (e.g., C / C++). Java programs can use JNI to load function libraries and call native functions within them. Native functions are typically declared using the "native" keyword. When registering using a first registration method, such as the JNI method, the function library to which the native function belongs can be loaded, and then the implementation code of the native function can be searched from the loaded function library. The address of the function library to which the native function belongs is pre-recorded in the code. A mapping relationship is then established between the declaration statement of the native function and the address (i.e., function address) of the native function's implementation code. For example, the function name and function address of the native function are recorded in the virtual machine, thereby completing the registration. Specifically, the virtual machine can create a method object for the native function and record the function name and function address of the native function in the method object of the native function. Exemplarily, the specific value of the function name parameter can be obtained from the native function's implementation code to obtain the function name of the native function. The function name of the native function is used as the input parameter of the search function, and the output parameter of the search function is obtained to obtain the function address of the native function. Next, the function name and function address of the native function are stored according to the structure of the Method object.
[0041] For example, function name represents the function name of the native function, function address represents the function address of the native function, and the structure includes:
[0042] typedef struct{
[0043] function name;
[0044] function address;
[0045] }
[0046] It should be noted that, after registration, the method objects of each native function can be recorded in the virtual machine, and the method objects of the native function can also record the library address of the function library to which the native function belongs. Furthermore, in response to a function call request, for the library file under the library address recorded in the method object of the function called by the function call request, if the characters representing the architecture in the file format of the library file represent the client architecture, it can be determined that the function call request is a heterogeneous function call request, and the function called this time is a heterogeneous function. Accordingly, the library address can be the address of the function library of the client architecture. When the characters representing the architecture in the file format of the library file represent the host architecture, the library address is determined to be the address of the function library of the host architecture, the function call request is determined to be a same-architecture function call request, and the function called this time is a same-architecture function.
[0047] Furthermore, JNA (Java Native Access) is an advanced Java library for simplifying the interaction between Java and native code. It provides a simple way for Java programs to call native functions without writing cumbersome JNI code. JNR (Java Native Runtime) is a technology for calling native code (for example, C / C++ library) in Java. In the second registration method, the registration of native functions is implemented through predefined Java interfaces. In the second registration method, the native function will be registered as the trampoline function corresponding to the native function. Accordingly, the function name of the native function is recorded in the virtual machine, and the function address of the trampoline function corresponding to the native function is also recorded. That is, in the second registration method, the address of the native function will actually be registered as the address of the trampoline function corresponding to the native function.
[0048] Specifically, the function library to which the native function belongs can be loaded first, and then the implementation code of the native function can be found from the loaded function library. In the case where the native function is a heterogeneous function, the function library to which the native function belongs can be loaded by calling a binary translator, and the implementation code of the native function can be found from the loaded function library. Exemplarily, the binary translator can be called to translate and execute the query program of the client architecture. By executing the query program, the function library to which the heterogeneous function belongs is loaded, and then the function address of the heterogeneous function is found from the loaded function library. The code at the function address of the heterogeneous function is the implementation code of the heterogeneous function. Then, based on the implementation code of the native function, a springboard function corresponding to the native function is generated. The function address of the springboard function corresponding to the native function is passed to the virtual machine through a preset binding function (e.g., RegisterNatives function). The preset binding function is called through an environment pointer (e.g., env). The springboard function is used to convert the format of the input parameters of the native function, and then pass the converted input parameters to the native function and call the actual native function. That is, the springboard function corresponding to the native function is a function that can indirectly call the native function. Exemplarily, the code for implementing format conversion can be encapsulated for the implementation code of the native function through the Foreign Function Interface Library (libffi), thereby obtaining the springboard function corresponding to the native function. Specifically, the springboard function corresponding to the native function includes a pointer variable pointing to the implementation code of the native function. When the pointer variable is executed, the implementation code of the native function will be searched and executed. Among them, libffi is a cross-platform library that provides an abstraction layer that simplifies calls from one language (such as Java) to another language (such as C).
[0049] For example, taking native function a as an example, assuming that the registration method of native function a is the first registration method, then the virtual machine obtains the function address of native function a: addr1; assuming that the registration method of native function a is the second registration method, then the virtual machine obtains the function address of the springboard function corresponding to native function a: addr2. Accordingly, when calling native function a, the function address parameter corresponding to native function a is set to JNA_entry=addr2. Accordingly, passing JNA_entry to the binary translator allows the binary translator to obtain the function address of the springboard function corresponding to native function 1: addr2, so that the binary translator can easily obtain the function address of the springboard function corresponding to native function 1 according to the function address parameter. Furthermore, the binary translator directly calls addr2 as the function address of the target heterogeneous function, that is, actually calls the springboard function corresponding to native function 1.
[0050] Accordingly, for a heterogeneous function, a function address parameter can be set for the heterogeneous function. When the registration method of the heterogeneous function is the first registration method, the function address parameter corresponding to the heterogeneous function is set to a default value. The default value can be pre-set by the developer. For example, the default value can be 0. That is, after the heterogeneous function is registered using the first registration method, the specific value of the JNA_entry of the heterogeneous function can be set to 0. When the registration method of the heterogeneous function is the second registration method, the function address parameter corresponding to the heterogeneous function is set to the function address of the springboard function corresponding to the heterogeneous function. That is, after the heterogeneous function is registered using the second registration method, the specific value of the JNA_entry of the heterogeneous function can be set to the function address of the springboard function corresponding to the heterogeneous function. In other words, in this embodiment of the present invention, the specific value of the JNA_entry of the heterogeneous function is set after the heterogeneous function is registered. Accordingly, when obtaining the function address parameter corresponding to the target heterogeneous function in step 102 above, the function address parameter previously set for the target heterogeneous function can be directly read.
[0051] In an embodiment of the present invention, any heterogeneous function defined in a target program is registered. After registration, for heterogeneous functions registered using the first registration method, the function address parameter corresponding to the heterogeneous function is set to a default value. For heterogeneous functions registered using the second registration method, the function address parameter corresponding to the heterogeneous function is set to the function address of the springboard function corresponding to the heterogeneous function. In this way, when a heterogeneous function is registered as a springboard function, the function address of the springboard function corresponding to the heterogeneous function can be easily obtained based on the function address parameter corresponding to the heterogeneous function, thereby facilitating subsequent function execution.
[0052] Optionally, the above step 102 may specifically include:
[0053] Step 1031: Pass the function address parameter to the binary translator.
[0054] Step 1032: Based on the function address acquisition method indicated by the function address parameter, the function address of the target heterogeneous function is acquired through the binary translator.
[0055] Step 1033: Execute the target heterogeneous function at the function address.
[0056] Among them, the binary translator can also be called a dynamic translator. Exemplarily, the binary translator can be QEMU. The virtual machine process can call a system call through a thread to create a new thread. For example, a new thread can be created through the Clone system call. The new thread can be responsible for running the binary translator. The new thread can be called a translator thread. In response to a heterogeneous function call request, when it is necessary to execute the target heterogeneous function, the thread that needs to execute the target heterogeneous function (i.e., the aforementioned target program thread) can send an execution request to the translator thread through the inter-thread communication mechanism. The execution request can also be called a translation request. The execution request can carry information that needs to be passed to the translator thread. For example, the execution request can carry the function address parameter corresponding to the target heterogeneous function, thereby realizing the transfer of the function address parameter corresponding to the target heterogeneous function to the binary translator. Among them, the translator thread can be in a running state and continuously wait for the execution request from the target program thread. After the target program thread sends the execution request, it can wait for the translator thread to return the execution result. It should be noted that it is also possible to create a process to run the target program to obtain the target program process, and to create a process to run the binary translator to obtain the translator process. Accordingly, the target program process can send an execution request to the translator process through an inter-process communication mechanism. In the embodiment of the present invention, based on the thread / inter-process communication mechanism, the execution request and the execution result can be transmitted, and the implementation cost is relatively low. Specifically, in the case of a relatively simple heterogeneous function, for example, when the heterogeneous function does not contain static variables and does not call functions in the virtual machine, the target program process and the translator process can be created by creating a process.
[0057] Furthermore, in response to the execution request, the translator thread obtains the function address of the target heterogeneous function based on the function address acquisition method indicated by the function address parameter, and finally executes the target heterogeneous function at the function address.
[0058] Specifically, the translator thread can translate the target heterogeneous function of the function address of the target heterogeneous function, and then execute the translated target heterogeneous function through the central processing unit (CPU) of the host platform. Since the CPU of the host architecture cannot directly run the binary file compiled for the client architecture, the binary translator can be used to obtain the function address of the target heterogeneous function based on the acquisition method indicated by the function address parameter, and translate the instructions in the instruction form of the client architecture in the target heterogeneous function into the instruction form of the host architecture, execute the translated instructions in the instruction form of the host architecture, and then realize the execution of the target heterogeneous function on the host platform. In this way, it can be ensured that the target heterogeneous function called this time can be executed correctly.
[0059] Optionally, the embodiment of the present invention may further include the following steps:
[0060] Step S31: Use the function name of the target heterogeneous function as the target function name, and pass the target function name and the function library address of the client architecture to the binary translator.
[0061] Accordingly, the step of obtaining the function address of the target heterogeneous function through the binary translator may specifically include:
[0062] Step 1032a: Obtain the function address based on the function library address and the target function name through a preset function processing program in the binary translator when the function address parameter is a default value.
[0063] Step 1032b: Otherwise, directly determine the specific value of the function address parameter as the function address.
[0064] Specifically, the target function name can be obtained by extracting the contents of the bitfield used to store the function name in the heterogeneous function call request. For example, the bitfield used to store the function name in the function call request can be determined based on the instruction format of the function call request. Assuming that the bitfield used to store the function name is bits 10 to 15, the target function name can be obtained by parsing the contents of bits 10 to 15. The client architecture's function library address refers to the library address of the function library to which the target heterogeneous function belongs. The client architecture's function library address can be pre-recorded by the virtual machine. For example, the virtual machine can record the library address of the function library to which the native function belongs in the native function's method object. For example, the specific value of String library addr in the native function's method object can be extracted to obtain the native function's library address. The native function's library address is then stored in the aforementioned typedef struct structure. The execution request sent to the translator thread can also carry the target function name and the client architecture's function library address. In this way, by sending the execution request to the translator thread, the target function name and the client architecture's function library address can be transmitted to the binary translator.
[0065] Furthermore, the binary translator can execute a pre-set preset function handler, which is adapted to the client architecture. By executing the preset function handler, the function address of the target heterogeneous function is determined, and the operation of the target heterogeneous function is executed based on the function address of the target heterogeneous function. The preset function handler can also be referred to as a heterogeneous function handler. The preset function handler is adapted to the client architecture, which means that the preset function handler is a binary file compiled into the client architecture. After receiving an execution request, the preset function handler in the translator thread can first check whether the function address parameter carried in the execution request is the default value. When executing the preset function handler, the binary translator can first dynamically translate the client architecture instructions in the preset function handler into host architecture instructions, that is, the binary translator is also used to translate the preset function handler. In this way, the client architecture preset function handler can be run on a host architecture platform. By executing the preset function handler, the operation of obtaining the function address based on the function address parameter is implemented.
[0066] When the function address parameter is the default value, the acquisition method indicated by the function address parameter is: acquisition based on the function library address and the target function name. When the function address parameter is not the default value, the acquisition method indicated by the function address parameter is: acquisition based on the specific value of the function address parameter. Specifically, when the function address parameter is the default value, that is, when JNA_entry = 0, it means that the current function call is a native method call under the JNI mechanism, that is, the target heterogeneous function called this time is registered using the JNI registration method. Accordingly, the preset function handler can be dynamically linked through the library loading function (for example, the dlopen function) and library search function (for example, the dlsym function) provided by the dynamic linker to search for the function address based on the library address and the target function name. Specifically, the function library address can be used as the input parameter of the dlopen function, and the dlopen function can be used to load the client architecture function library. The client architecture function library includes a symbol table, which records information such as the function name of each function included in the client architecture function library and its corresponding function entry address. Then, the target function name is used as the input parameter of the dlsym function. The dlsym function is used to search the symbol table for the function entry address corresponding to the function name that matches the target function name, and the function address of the target heterogeneous function is obtained. For example, assume that the target function name carried by the execution request is: native_funa, the function library address of the client architecture is: . / example1 / native_library.so, JNA_entry=0. You can input . / example1 / native_library.so into the dlopen function and execute the dlopen function. Then, the target function name native_funa is input as the input parameter into the dlsym function and the dlsym function is executed to extract the symbol table of the loaded function library and search for the function entry address corresponding to native_funa.
[0067] In this embodiment of the present invention, by passing the target function name and the client architecture's function library address to the binary translator, when the function address parameter is at a default value, the function address of the target heterogeneous function can be found based on the function library address and the target function name, thereby ensuring the accuracy of the found function address. It should be noted that in this embodiment of the present invention, step S31 can be performed again when the function address parameter is at a default value.
[0068] In practical application scenarios, Java programs typically call native functions through JNI or JNA. For heterogeneous functions, the architecture language of the function library where the heterogeneous function resides differs from the architecture language of the host platform. Accordingly, in embodiments of the present invention, for heterogeneous functions registered using the first registration method, the dynamic translator can obtain the function address of the heterogeneous function registered using the first registration method by calling the dlopen function and the dlsym function. However, for heterogeneous functions registered using the second registration method, since the heterogeneous function is actually registered as a corresponding springboard function, the function address of the springboard function corresponding to the heterogeneous function should be used when executing the heterogeneous function. However, by searching for the function address based on the function library address and the target function name, only the function address of the original heterogeneous function can be obtained. For example, taking native function a as an example, assuming that the function address of heterogeneous function a is addr1, when using the second registration method, the function address of the springboard function corresponding to heterogeneous function a is addr2. Since the function address of the springboard function corresponding to the heterogeneous function is generated based on the external function interface library, it is not directly exposed to the dynamic linker. The symbol table of the heterogeneous function library is generated during library compilation, recording the function address of the original heterogeneous function a: addr1. Using the library address and target function name to search for function addresses only retrieves the original heterogeneous function's function address: addr1, and cannot retrieve the function address of the springboard function corresponding to heterogeneous function a: addr2. Therefore, the aforementioned search method based on the library load function and library search function cannot retrieve the function address of the springboard function corresponding to the heterogeneous function, that is, it cannot obtain the function address of the heterogeneous function under the second registration method.
[0069] In an embodiment of the present invention, by setting a function address parameter, when the heterogeneous function is registered in the second registration mode, the function address of the springboard function corresponding to the heterogeneous function is passed to the binary translator through the function address parameter. When the heterogeneous function is registered in the first registration mode, the function address parameter is set to a default value, and by directly calling the binary translator, the binary translator obtains the function address of the heterogeneous function based on the library loading function and the library search function. In this way, while ensuring that the binary translator can obtain the function address of the heterogeneous function in the first registration mode, it is possible to overcome the problem that the binary translator cannot obtain the function address of the springboard function corresponding to the heterogeneous function, so that the binary translator can obtain the function address of the heterogeneous function in the first registration mode.
[0070] Accordingly, if the function address parameter is not the default value, that is, if JNA_entry = the function address of the springboard function corresponding to the target heterogeneous function, this indicates that the current function call is a native method call under the JNA mechanism, that is, the target heterogeneous function being called is registered using the JNA registration method. Accordingly, the preset function handler can directly determine the specific value of JNA_entry as the function address of the target heterogeneous function.
[0071] Because the functions in the client architecture's function library are in the client architecture's binary code form, in this embodiment of the present invention, a binary translator is called to execute a preset function handler adapted for the client architecture. The preset function handler is compiled into a client architecture binary file. This means that the architecture adapted by the preset function handler is the same as the architecture adapted by the client architecture's function library. This allows the preset function handler to be correctly loaded into the client architecture's function library via the library load and library search functions, thereby ensuring the correct execution of the target heterogeneous functions therein. Accordingly, when the binary translator is called to execute the preset function handler, the translator thread is equivalent to running in the client architecture environment.
[0072] Furthermore, the binary translator can adapt to the host architecture. The binary translator itself runs on the host hardware and can interact directly with the host hardware and operating system. Accordingly, when executing a target heterogeneous function, the binary translator can first dynamically translate the client instructions into host instructions. This allows the client user program to be run on the host platform while simultaneously executing functions in the client library, without having to recompile the client library into host code, thus saving operating costs.
[0073] Optionally, the embodiment of the present invention may further include the following steps:
[0074] Step S41: If the target heterogeneous function has input parameters, pass the input parameters to the binary translator.
[0075] Accordingly, the step of executing the target heterogeneous function at the function address may specifically include:
[0076] Step 1033a: Store the input parameters into a designated parameter storage location.
[0077] Step 1033b: Jump to the function address for execution, and during the execution process, read the input parameters in the parameter storage location for processing, and write the processing results into the return value register.
[0078] Step 1033c: After execution is completed, read the processing result of the target heterogeneous function from the return value register.
[0079] The processing result is the execution result of the target heterogeneous function. Specifically, if the function declaration of the target heterogeneous function defines input parameters, it can be determined that the target heterogeneous function has input parameters. For example, assuming the function declaration includes: int add(int a, int b), then the function includes two input parameters: a and b. Conversely, if the function declaration of the target heterogeneous function does not define input parameters, it can be determined that the target heterogeneous function does not have input parameters. Accordingly, if the target heterogeneous function has input parameters, the target program thread can write the input parameters of the target heterogeneous function to a designated stack or register according to the calling convention in accordance with the function declaration of the target heterogeneous function, thereby passing the input parameters to the called target heterogeneous function. The designated stack or register is a stack or register used to pass input parameters to the target heterogeneous function, and the designated stack or register can be pre-specified by the developer. Accordingly, the translator thread can read the input parameters of the target heterogeneous function from the designated stack or register.
[0080] The execution request sent to the translator thread may also carry the input parameters of the target heterogeneous function. That is, in this embodiment of the present invention, the execution request sent to the translator thread may carry the function address parameter corresponding to the target heterogeneous function, the target function name, the function library address of the client architecture, and the input parameters of the target heterogeneous function.
[0081] After obtaining the target heterogeneous function's function address, the pre-set function handler in the translator thread sequentially stores the input parameters from the execution request in the designated parameter storage locations. These designated parameter storage locations can be pre-set parameter registers and stacks, which can be pre-specified by the developer. Next, execution jumps to the target heterogeneous function's function address. During execution, the executed target heterogeneous function obtains the input parameters from the parameter storage locations and processes them according to the target heterogeneous function's processing logic.
[0082] For example, assuming that the processing logic of the target heterogeneous function is: calculate the sum of input parameter a and input parameter b, then the operation of the sum of input parameter a and input parameter b can be performed, and the calculated result (i.e., the processing result) can be written to the return value register. Of course, when the target heterogeneous function does not have input parameters, it can directly jump to the function address to execute, so as to implement the processing logic of the target heterogeneous function. Among them, when the springboard function corresponding to the target heterogeneous function is actually called, the code for implementing format conversion is first executed to convert the input parameters of the target heterogeneous function into the specified format, and then the implementation code of the native function is executed to implement the processing logic of the target heterogeneous function. Among them, the specified format is the parameter format defined in the code for implementing format conversion.
[0083] Furthermore, when the preset function handler calls the target function, it will store the return address in the return address register. The return address may be the address of the next instruction after the call instruction in the preset function handler. The return address register is a pre-agreed register, and the function body of the target heterogeneous function will include a return instruction. When the last return instruction is executed, the return address is read from the return address register and then returned to the return address. Therefore, when the function is executed to the end, the target heterogeneous function is executed and returns to the preset function handler. Furthermore, the preset function handler can read the value of the return value register to obtain the execution result of the target heterogeneous function. The return value register may be a register used to store the execution result of the heterogeneous function executed by the preset function handler, and the return value register may be pre-specified by the developer.
[0084] In an embodiment of the present invention, if the target heterogeneous function has input parameters, the input parameters of the target heterogeneous function are further transmitted to the binary translator. Accordingly, when the target heterogeneous function is executed, the input parameters are stored in a designated parameter storage location, and then execution is jumped to the function address. During execution, the target heterogeneous function can obtain the input parameters in the parameter storage location and process them, ensuring that the target heterogeneous function can be executed correctly.
[0085] Optionally, after the execution is completed, after the processing result of the target heterogeneous function is read from the return value register, the embodiment of the present invention may also include the following steps: step S51, returning the processing result of the target heterogeneous function to the target program. Specifically, the translator thread can send the read processing result of the target heterogeneous function to the target program thread, so as to realize returning the processing result of the target heterogeneous function to the target program. In this way, it is equivalent to the translator thread translating the instruction form instructions of the client architecture in the target heterogeneous function into instructions of the host architecture, simulating the execution of the called target heterogeneous function, and returning the actual execution result to the target program thread. Accordingly, after receiving the execution result of the target heterogeneous function, the target program thread uses it as the return value of the called target heterogeneous function, and then continues to execute subsequent operations.
[0086] In the embodiment of the present invention, the following steps may also be included:
[0087] Step S51: Using the predetermined preset function address as the function address of each heterogeneous function defined in the target program, and recording the address in the virtual machine.
[0088] Step S52: In response to the heterogeneous function call request, execute the preset transfer function at the preset function address to transfer the function address parameter to the binary translator.
[0089] The binary translator can be called through a preset transfer function, which can be a translator_helper function. Accordingly, when registering a native function, if the native function is a heterogeneous function, the function address of the preset transfer function can be used as the function address of the native function and recorded in the virtual machine of the host platform.
[0090] For example, for heterogeneous functions registered using the first registration method, the function address of the preset transfer function is used as the function address of the native function and recorded in the Method object corresponding to the native function. Accordingly, the binary translator can subsequently be called to query the actual function address of the heterogeneous function through the dlopen function and the dlsym function. Furthermore, for heterogeneous functions registered using the second registration method, the function address of the preset transfer function is used as the function address of the native function and recorded in the Method object corresponding to the native function. At the same time, the function address of the springboard function corresponding to the native function can also be recorded to be passed to the binary translator through the JNA_entry parameter. In an embodiment of the present invention, for any heterogeneous function defined in the target program, the preset function address is recorded as the function address of the heterogeneous function to the virtual machine. The preset function address is a pre-set fixed address. In this way, in response to a heterogeneous function call request, the preset transfer function at the preset function address can be executed, thereby conveniently implementing the operation of passing the function address parameter, the target function name, the function library address of the client architecture, and the input parameters to the binary translator. For example, assume that the preset function address is addr3, the target function name is: native_funa, the function library address of the client architecture is: . / examplel / native_library so, JNA_entry=0. The input parameters of the target function are parameter a and parameter b. Then, in response to the heterogeneous function call request, it can jump to addr3 to start execution, and then execute the translator_helper function. Furthermore, by executing the translator_helper function, it is achieved by passing to the binary translator: JNA_entry=0, native_funa, . / examplel / native_library so, parameter a and parameter b. It should be noted that if the function is a function of the same architecture, the function address of the function of the same architecture is recorded in the virtual machine. When calling the function of the same architecture later, you can directly jump to the recorded function address and execute the function of the same architecture directly.
[0091] When the function called by the target program thread is a heterogeneous function, the function address of the heterogeneous function has been set to the function address of the preset transfer function. This will cause the electronic device to actually execute the preset transfer function. By executing the preset transfer function, the above-mentioned operations of obtaining the function address parameter corresponding to the target heterogeneous function, reading the input parameters of the target heterogeneous function from the specified stack or register, obtaining the function library address of the client architecture to which the target heterogeneous function belongs from the method object corresponding to the target heterogeneous function, extracting the content of the bit field used to store the function name in the heterogeneous function call request as the target function name, and calling the binary translator to pass the function address parameter, the target function name, the function library address of the client architecture, and the input parameters to the binary translator are implemented, thereby executing the heterogeneous function through the binary translator. Exemplarily, the preset transfer function can be expressed as translator_helper(args, JNA_entry), where args represents the target function name, the function library address of the client architecture, and the input parameters. When the target heterogeneous function is registered in the first registration mode, the preset transfer function is translator_helper(args, JNA_entry=0); when the target heterogeneous function is registered in the second registration mode, the preset transfer function is translator_helper(args, JNA_entry=(addr*)trampoline_addr), where (addr*)trampoline_addr represents the function address of the trampoline function corresponding to the target heterogeneous function.
[0092] Specifically, the source code of the binary translator can be compiled into a library file in advance. The binary translator can then be run by calling the main function in the library file, thereby implementing the call of the binary translator. In this way, the coupling degree between the binary translator and the host environment can be reduced, making it easier to replace the binary translator in use. Furthermore, the preset transfer function can send an execution request to the binary translator via a preset information structure. The information structure can be represented as message_t, and the information structure corresponds to a pre-set shared memory space. The execution request can be written to the address (message_addr) of the shared memory space. The execution request can include a function address parameter, a target function name, a function library address of the client architecture, and input parameters. Since message_addr is an address in the host environment, the translator thread can directly access message_addr to obtain the execution request therein, thereby implementing the transfer of function address parameters, a target function name, a function library address of the client architecture, and input parameters to the translator thread. It should be noted that the above-mentioned translator thread can return the execution result of the target heterogeneous function to the target program thread through the information structure. For example, the execution result of the target heterogeneous function can be written to the shared memory space. When the target program thread detects that data is written to the shared memory space, it can read the written data and obtain the execution result of the target heterogeneous function.
[0093] Figure 2 This is a schematic diagram of a processing process provided by an embodiment of the present invention. Figure 2As shown, thread 1 represents a virtual machine thread. Thread 1 can create threads 2 and 3. Thread 2 represents the aforementioned translator thread, and thread 3 represents the aforementioned target program thread. When the target program executes a heterogeneous function call instruction in the host platform's virtual machine, thread 3 executes the instruction. It first obtains the function address parameter corresponding to the target heterogeneous function: JNA_entry, based on the heterogeneous function call request. It then initiates the translator_helper(args, JNA_entry) function and sends a translation request to the translator thread via message_t, passing the input parameters, library address, target function name, and JNA_entry to thread 2. Accordingly, the translator thread obtains the function address corresponding to the target heterogeneous function based on the acquisition method indicated by JNA_entry. Specifically, the translator thread executes a pre-configured heterogeneous function handler. If JNA_entry is 0, it uses acquisition method 1: obtaining the function address based on the library address and target function name using the dlopen and dlsym functions. If JNA_entry is not 0, the second acquisition method is used: JNA_entry is used as the function address. The target heterogeneous function is then executed based on this function address. Specifically, the input parameters are first set, that is, the input parameters are stored in the specified parameter storage location. Next, the function address is jumped to and the return value is obtained. Finally, the return value is returned to the target program thread via message_t.
[0094] In an embodiment of the present invention, since the passed parameters carry JNA_entry, when the target heterogeneous function is registered in JNA registration mode, the function address of the springboard function corresponding to the target heterogeneous function will be passed into JNA_entry, and then passed to the binary translator, so that the binary translator can correctly execute the springboard function corresponding to the target heterogeneous function, and thus complete the operation of executing the target heterogeneous function.
[0095] Reference Figure 3 , shows a block diagram of a data processing device provided by an embodiment of the present invention, such as Figure 3 As shown, the data processing device may specifically include:
[0096] A first acquisition module 201 is configured to acquire, when a target program is running in a virtual machine of a host platform, a function address parameter corresponding to a target heterogeneous function according to a heterogeneous function call request; the client architecture adapted by the target program is different from the host architecture of the host platform; the function address parameter is used to indicate a method for acquiring the function address of the target heterogeneous function and is set based on a registration method of the target heterogeneous function;
[0097] The second acquisition module 202 is configured to acquire a function address corresponding to the target heterogeneous function according to an acquisition method indicated by the function address parameter, and execute the target heterogeneous function according to the function address.
[0098] In summary, in the data processing device provided by the embodiment of the present invention, when the target program is running in the virtual machine of the host platform, the function address parameter corresponding to the target heterogeneous function is obtained according to the heterogeneous function call request; the client architecture adapted by the target program is different from the host architecture of the host platform; the function address parameter is used to indicate the method for obtaining the function address of the target heterogeneous function, and is set based on the registration method of the target heterogeneous function. According to the acquisition method indicated by the function address parameter, the function address corresponding to the target heterogeneous function is obtained, and the target heterogeneous function is executed according to the function address. By obtaining the function address parameter corresponding to the target heterogeneous function, the function address is obtained according to the acquisition method of the function address indicated by the function address parameter, and then the registration method of the target heterogeneous function is adapted to ensure that the function address is accurately obtained for different registration methods, so that the target heterogeneous function is correctly executed in the virtual machine.
[0099] Optionally, the device further comprises:
[0100] A registration module, used for registering any heterogeneous function defined in the target program;
[0101] A first setting module is used to set the function address parameter corresponding to the heterogeneous function to a default value when the registration mode of the heterogeneous function is the first registration mode;
[0102] The second setting module is used to set the function address parameter corresponding to the heterogeneous function to the function address of the springboard function corresponding to the heterogeneous function when the registration mode of the heterogeneous function is the second registration mode.
[0103] Optionally, the first acquisition module 201 is specifically configured to:
[0104] Passing the function address parameter to the binary translator;
[0105] Based on the function address acquisition method indicated by the function address parameter, acquiring the function address of the target heterogeneous function through the binary translator;
[0106] The target heterogeneous function at the function address is executed.
[0107] Optionally, the device further comprises:
[0108] A first transfer module, configured to use the function name of the target heterogeneous function as the target function name, and transfer the target function name and the function library address of the client architecture to the binary translator;
[0109] The first acquisition module 201 is further configured to:
[0110] Obtaining the function address based on the function library address and the target function name by a preset function processing program in the binary translator when the function address parameter is a default value;
[0111] Otherwise, the specific value of the function address parameter is directly determined as the function address.
[0112] Optionally, the device further comprises:
[0113] A second transfer module, configured to transfer input parameters to the binary translator if the target heterogeneous function has the input parameters;
[0114] The first acquisition module 202 is further configured to:
[0115] Storing the input parameters in a specified parameter storage location;
[0116] Jump to the function address for execution, and during the execution process, read the input parameters in the parameter storage location for processing, and write the processing results into the return value register;
[0117] After execution is completed, the processing result of the target heterogeneous function is read from the return value register.
[0118] Optionally, the device further comprises:
[0119] A return module is used to return the execution result of the target heterogeneous function to the target program.
[0120] Optionally, the device further comprises:
[0121] a third setting module, configured to use the predetermined preset function address as the function address of each heterogeneous function defined in the target program, and record the result in the virtual machine;
[0122] An execution module is used to execute a preset transfer function at the preset function address in response to the heterogeneous function call request, so as to transfer the function address parameter to the binary translator.
[0123] Reference Figure 4 Schematic diagram of the structure of the electronic device provided by the embodiment of the present invention. Figure 4 As shown, the electronic device includes: a processor, a memory, a communication interface and a communication bus.
[0124] The processor, the memory, and the communication interface communicate with each other via the communication bus; the memory is used to store at least one executable instruction, which enables the processor to execute the data processing method of the above embodiment. The executable instruction can form a program.
[0125] An embodiment of the present invention provides a machine-readable medium having instructions stored thereon. When executed by one or more processors, the processors are enabled to execute the data processing method of the aforementioned embodiment.
[0126] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0127] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, apparatus, or computer program products. Thus, embodiments of the present invention may take the form of a fully hardware embodiment, a fully software embodiment, or an embodiment combining software and hardware. Furthermore, embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0128] It should be noted that all actions of acquiring signals, information or data in this application are carried out in compliance with the relevant data protection laws and policies of the country where they are located and with the authorization given by the owner of the corresponding device.
[0129] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the process in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0130] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a predictable manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0131] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.
[0132] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0133] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are merely used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations.
[0134] Moreover, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or terminal device that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not preclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.
[0135] The data processing method, data processing device, electronic device and one or more readable media provided by the present invention are introduced in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there may be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A data processing method, characterized in that: The method comprises: When a target program is running in a virtual machine of a host platform, a function address parameter corresponding to a target heterogeneous function is obtained according to a heterogeneous function call request; a client architecture adapted by the target program is different from a host architecture of the host platform; the function address parameter is used to indicate a method for obtaining a function address of the target heterogeneous function and is set based on a registration method of the target heterogeneous function; According to the acquisition method indicated by the function address parameter, the function address corresponding to the target heterogeneous function is acquired, and the target heterogeneous function is executed according to the function address.
2. The method according to claim 1, characterized in that The method further comprises: Register any heterogeneous function defined in the target program; When the registration mode of the heterogeneous function is the first registration mode, setting the function address parameter corresponding to the heterogeneous function to a default value; In a case where the registration mode of the heterogeneous function is the second registration mode, the function address parameter corresponding to the heterogeneous function is set to the function address of the springboard function corresponding to the heterogeneous function.
3. The method according to claim 1 or 2, characterized in that The obtaining of a function address corresponding to the target heterogeneous function and executing the target heterogeneous function according to the function address includes: Passing the function address parameter to the binary translator; Based on the function address acquisition method indicated by the function address parameter, acquiring the function address of the target heterogeneous function through the binary translator; The target heterogeneous function at the function address is executed.
4. The method according to claim 3, characterized in that The method further comprises: using the function name of the target heterogeneous function as the target function name, and transmitting the target function name and the function library address of the client architecture to the binary translator; The obtaining the function address of the target heterogeneous function through the binary translator includes: Obtaining the function address based on the function library address and the target function name by a preset function processing program in the binary translator when the function address parameter is a default value; Otherwise, the specific value of the function address parameter is directly determined as the function address.
5. The method according to claim 3, characterized in that The method further comprises: If the target heterogeneous function has input parameters, passing the input parameters to the binary translator; The executing the target heterogeneous function at the function address includes: Storing the input parameters in a specified parameter storage location; Jump to the function address for execution, and during the execution process, read the input parameters in the parameter storage location for processing, and write the processing results into the return value register; After execution is completed, the processing result of the target heterogeneous function is read from the return value register.
6. The method according to claim 3, characterized in that The method further comprises: respectively taking the predetermined preset function address as the function address of each heterogeneous function defined in the target program and recording the address in the virtual machine; In response to the heterogeneous function call request, a preset transfer function at the preset function address is executed to transfer the function address parameter to the binary translator.
7. A data processing device, characterized in that: The device comprises: A first acquisition module is configured to acquire, when a target program is running in a virtual machine of a host platform, a function address parameter corresponding to a target heterogeneous function according to a heterogeneous function call request; the client architecture adapted by the target program is different from the host architecture of the host platform; the function address parameter is used to indicate a method for acquiring a function address of the target heterogeneous function and is set based on a registration method of the target heterogeneous function; The second acquisition module is used to acquire the function address corresponding to the target heterogeneous function according to the acquisition method indicated by the function address parameter, and execute the target heterogeneous function according to the function address.
8. The device according to claim 7, characterized in that The device further comprises: A registration module, used for registering any heterogeneous function defined in the target program; A first setting module is used to set the function address parameter corresponding to the heterogeneous function to a default value when the registration mode of the heterogeneous function is the first registration mode; The second setting module is used to set the function address parameter corresponding to the heterogeneous function to the function address of the springboard function corresponding to the heterogeneous function when the registration mode of the heterogeneous function is the second registration mode.
9. An electronic device, characterized in that: include: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store executable instructions, and the executable instructions enable the processor to execute the method according to any one of claims 1 to 6.
10. A machine-readable medium, characterized in that Instructions are stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 6.