A function calling method, apparatus, device and storage medium
By querying the target function using IL and AOT function loaders, the problem of Flutter's lack of dynamic support is solved, IL function calls are implemented, and Flutter's dynamic capabilities and execution efficiency are improved.
Patent Information
- Application Number
- CN202210247764.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-14
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2042-03-14
AI Technical Summary
Flutter does not support dynamics and cannot execute remotely deployed code. IL function calls are the foundation for implementing IL-based interpreters, and there is an urgent need to solve how to implement IL function calls to enrich Flutter's dynamic capabilities.
This paper provides a function call method that uses an IL function loader and an AOT function loader to query and determine the IL or AOT function corresponding to the function call input parameters, and returns the target function to realize the IL function call. It supports IL-based interpreters.
It implements Flutter's dynamic capabilities, improves the efficiency of IL function calls, and supports remote code execution.
Smart Images

Figure CN116795455B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data processing, and in particular to a function calling method, apparatus, device, and storage medium. Background Technology
[0002] Flutter is Google's cross-platform mobile UI framework that enables the rapid creation of high-quality native user interfaces on iOS and Android.
[0003] However, for security and performance reasons, Flutter does not support dynamics. Intermediate Language (IL) function calls are the foundation for implementing an IL-based interpreter and can further enrich Flutter's dynamic implementation. Therefore, how to implement IL function calls is a technical problem that urgently needs to be solved. Summary of the Invention
[0004] To address the aforementioned technical problems, embodiments of this disclosure provide a function call method, apparatus, device, and storage medium.
[0005] In a first aspect, embodiments of this disclosure provide a function call method, the method comprising:
[0006] When an intermediate language (IL) function call instruction is received, the function call input parameters carried in the IL function call instruction are obtained;
[0007] Call the IL function loader to check if there exists an IL function corresponding to the function call input parameters;
[0008] If it is determined that there exists an IL function corresponding to the function call input parameters, then the IL function is determined as the target function;
[0009] For IL function call instructions, return the target function.
[0010] In one optional implementation, the IL function loader is invoked to query whether an IL function corresponding to the function call input parameters exists, including:
[0011] The IL function loader is invoked to check if the IL function corresponding to the function call input parameters exists in the cache;
[0012] If it is determined that the IL function corresponding to the function call input parameter does not exist in the cache, the IL function loader searches for the corresponding IL function in the IL function lookup table. The IL function lookup table includes the correspondence between static IL functions and their address indices, as well as the correspondence between instance IL functions and their name indices.
[0013] In one optional implementation, before returning to the target function for an IL function call instruction, the following steps are further included:
[0014] If it is determined that there is no IL function corresponding to the function call input parameter, then the AOT function loader is invoked to check if there is an AOT function corresponding to the function call input parameter.
[0015] If it is determined that there exists an AOT function corresponding to the function call input parameters, then the target function is determined based on the AOT function, and the steps of executing the IL function call instruction and returning to the target function are continued.
[0016] In one optional implementation, the pre-compiled AOT function loader is invoked to query whether an AOT function corresponding to the function call input parameters exists, including:
[0017] Call the AOT function loader to check if the AOT function corresponding to the function call input parameters exists in the cache;
[0018] If it is determined that the AOT function corresponding to the function call input parameters does not exist in the cache, the AOT function loader will search for the corresponding AOT function in the AOT function lookup table. The AOT function lookup table includes the correspondence between AOT static functions and address indexes, as well as the correspondence between AOT instance functions and name indexes.
[0019] In one optional implementation, if it is determined that there exists an AOT function corresponding to the function call input parameters, then the target function is determined based on the AOT function, including:
[0020] If it is determined that there exists an AOT function corresponding to the function call input parameters, then obtain the proxy function corresponding to the AOT function; wherein, the proxy function is obtained by processing the AOT function based on a preset first data structure;
[0021] The proxy function corresponding to the AOT function is determined as the target function.
[0022] In one optional implementation, the method further includes:
[0023] When a function call instruction for an instrumented function is received, determine whether the function call instruction comes from an AOT function;
[0024] If it is determined that the function call instruction comes from an AOT function, the function call instruction is intercepted, and the IL function corresponding to the instrumented function is returned for the function call instruction; wherein, the IL function corresponding to the instrumented function is based on a preset second data structure that carries the running parameters of the instrumented function.
[0025] In one optional implementation, the data structure of the target function includes a function base class, an IL function class, and an AOT function class. Both the IL function class and the AOT function class inherit from the function base class, and the target function is an object described by the IL function class or an object described by the AOT function class.
[0026] Secondly, this disclosure also provides a function calling device, the device comprising:
[0027] The acquisition module is used to acquire the function call input parameters carried in the IL function call instruction when an intermediate language (IL) function call instruction is received.
[0028] The query module is used to call the IL function loader to check if there is an IL function corresponding to the function call input parameters;
[0029] The first determining module is used to determine the IL function as the target function if it is determined that there is an IL function corresponding to the function call input parameters;
[0030] The first return module is used to return the target function in response to IL function call instructions.
[0031] Thirdly, this disclosure provides a computer-readable storage medium storing instructions that, when executed on a terminal device, cause the terminal device to implement the above-described method.
[0032] Fourthly, this disclosure provides an apparatus comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the method described above.
[0033] Fifthly, this disclosure provides a computer program product comprising a computer program / instruction that, when executed by a processor, implements the method described above.
[0034] The technical solution provided in this disclosure has at least the following advantages compared with the prior art:
[0035] In the function call method provided in this embodiment, when an intermediate language (IL) function call instruction is received, the function call input parameters carried in the IL function call instruction are obtained, the IL function loader is invoked, and it is checked whether there is an IL function corresponding to the function call input parameters. If it is determined that there is an IL function corresponding to the function call input parameters, the IL function is determined as the target function. For the IL function call instruction, the target function is returned, and the IL function call is completed based on the IL function loader. This provides a foundation for realizing an IL-based interpreter and executor, thereby further realizing Flutter's dynamic capabilities. Attached Figure Description
[0036] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0037] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0038] Figure 1 A flowchart of a function call method provided in this embodiment of the disclosure;
[0039] Figure 2 An example diagram illustrating an IL function lookup representation provided in this disclosure embodiment;
[0040] Figure 3 This is a schematic diagram of an objective function data structure provided in an embodiment of the present disclosure;
[0041] Figure 4 A flowchart of another function call method provided in this disclosure embodiment;
[0042] Figure 5 This is an example diagram illustrating an AOT function lookup representation provided in an embodiment of this disclosure;
[0043] Figure 6 A schematic diagram illustrating the execution process of a function call method provided in this embodiment of the disclosure;
[0044] Figure 7 This is a schematic diagram of the structure of a function call device provided in an embodiment of the present disclosure;
[0045] Figure 8 This is a schematic diagram of the structure of a function call device provided in an embodiment of this disclosure. Detailed Implementation
[0046] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.
[0047] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.
[0048] Flutter is Google's cross-platform mobile UI (User Interface) framework that enables the rapid creation of high-quality native user interfaces on iOS and Android. Currently, Flutter is being used by an increasing number of developers and organizations.
[0049] However, for security and performance reasons, Flutter does not support dynamic capabilities, meaning it cannot execute remotely delivered code. IL (Intermediate Language) function calls are the foundation for implementing IL-based interpreters and can further enrich Flutter's dynamic implementation.
[0050] Therefore, in order to ensure that Flutter has dynamic capabilities, how to implement the calling of IL functions is a technical problem that urgently needs to be solved.
[0051] To this end, this disclosure provides a function call method. When an intermediate language (IL) function call instruction is received, the function call input parameters carried in the IL function call instruction are obtained, the IL function loader is called, and it is checked whether there is an IL function corresponding to the function call input parameters. If it is determined that there is an IL function corresponding to the function call input parameters, the IL function is determined as the target function, and the target function is returned for the IL function call instruction.
[0052] Based on this, the present disclosure provides a function call method, referencing Figure 1 Here is a flowchart of a function call method provided in this disclosure, the method including:
[0053] S101: When an intermediate language (IL) function call instruction is received, obtain the function call input parameters carried in the IL function call instruction.
[0054] Among them, IL function call instructions are used to implement function calls initiated by IL functions to other functions. Specifically, IL function calls include the following calling methods:
[0055] StaticCall: Static call, the address of the called function (i.e., the target function) is determined at compile time;
[0056] InstanceCall: Dynamic invocation, the address of the called function (i.e., the target function) needs to be determined by the specific class at runtime;
[0057] ClosureCall: Closure call. A closure is an executable code block in Dart syntax. When a closure is executed, it needs to be called through this instruction.
[0058] NativeCall: Local call. This instruction is required when calling native (such as C, C++, or Objective-C) code implemented in Dart.
[0059] In this embodiment of the disclosure, when an intermediate language (IL) function call instruction is received, the function call input parameters carried in the IL function call instruction are obtained according to the IL function call instruction. For example, when the IL function call instruction is StaticCall, the address of the function call input parameter addr carried in the IL function call instruction is obtained, and the corresponding target function is found according to the address.
[0060] S102: Call the IL function loader to check if there is an IL function corresponding to the function call input parameters.
[0061] The IL function loader is used to query whether a corresponding IL function exists based on the function call input parameters, and then loads the IL function.
[0062] In this embodiment of the disclosure, when an intermediate language (IL) function call instruction is received, the function call input parameters carried in the IL function call instruction are obtained, and the IL function loader is invoked to query the cache for an IL function corresponding to the function call input parameters. If an IL function corresponding to the function call input parameters exists in the cache, then that IL function is used as the target function. The cache stores functions that have been called recently, and the IL function loader can prioritize querying the cache for an IL function corresponding to the function call input parameters to improve the calling efficiency of IL functions. If no IL function corresponding to the function call parameters exists in the cache, then the IL function lookup table is searched for an IL function corresponding to the function call input parameters. The IL function lookup table includes the correspondence between static IL functions and address indices, and the correspondence between instance IL functions and name indices.
[0063] Specifically, an IL function lookup table is pre-built based on the IL functions in the IL file. The IL file includes multiple CFGs (Control Flow Graphs), each corresponding to an IL function and used to store data from that function. IL functions include static IL functions and instance IL functions. Since the addresses of static IL functions are determined at compile time, an index can be built based on these addresses to generate a mapping between static IL functions and their address indices. The addresses of instance IL functions cannot be determined at compile time and need to be determined based on the runtime object instance. Therefore, an index needs to be built using names such as package name, class name, and function name to generate a mapping between instance IL functions and their name indices. For a better understanding of the IL function lookup table, refer to [link to relevant documentation]. Figure 2This is an example diagram of an IL function lookup provided in an embodiment of this disclosure.
[0064] like Figure 2 As shown, IL function 1 is a static IL function, and the mapping relationship between IL function 1 and address 0x239a87c1 can be established through a globally unique address. IL function 2 is an instance function, and its address cannot be determined. The mapping relationship between IL function 1 and address 0x239a87c1 can be established through the name LibraryA.ClassA.funcA.
[0065] S103: If it is determined that there exists an IL function corresponding to the function call input parameters, then the IL function is determined as the target function.
[0066] In this embodiment of the disclosure, after receiving the intermediate language (IL) function call instruction, the function call input parameters carried in the IL function call instruction are obtained, and a query is performed in the cache. If the IL function corresponding to the function call input parameters exists in the cache, the found IL function is determined as the target function; if the IL function corresponding to the function call input parameters is not found in the cache, the search continues in the IL function lookup table, and the found IL function is determined as the target function.
[0067] S104: Returns the target function in response to an IL function call instruction.
[0068] In this embodiment of the disclosure, after obtaining the target function, the target function is returned in response to the received IL function call instruction, thus completing the function call of the IL function call instruction.
[0069] In one optional implementation, the data structure of the target function may include a function base class, an IL function class, and an AOT (Ahead-of-Time) function class. Both the IL function class and the AOT function class inherit from the function base class. The target function is either an object described by the IL function class or an object described by the AOT function class, specifically as follows: Figure 3 The diagram shown is a schematic of an objective function data structure provided in an embodiment of this disclosure.
[0070] The function base class is an abstract description of all functions, containing basic information such as function name, package name, class name, and external capabilities such as stack frame binding, initiating a call, and stack frame unbinding. The IL function class describes IL functions, i.e., functions defined in IL. In addition to the basic information contained in the function base class, it also includes code blocks, parameter descriptions, function addresses, etc. The parameter descriptions include information such as the number of type variables, positional variables, and named variables. The AOT function class describes AOT functions, i.e., functions not defined in IL. In addition to the basic information contained in the function base class, it also includes AOT function objects and unboxing parameters.
[0071] This disclosure provides a function call method. When an intermediate language (IL) function call instruction is received, the function call input parameters carried in the IL function call instruction are obtained. The IL function loader is invoked to check whether an IL function corresponding to the function call input parameters exists. If an IL function corresponding to the function call input parameters exists, the IL function is determined as the target function. For the IL function call instruction, the target function is returned. The IL function call is completed based on the IL function loader, providing a foundation for implementing an IL-based interpreter and executor, thereby further realizing Flutter's dynamic capabilities.
[0072] Based on this, the present disclosure also provides a function call method, referencing Figure 4 Here is a flowchart of another function call method provided in this disclosure, the method including:
[0073] S401: When an intermediate language (IL) function call instruction is received, obtain the function call input parameters carried in the IL function call instruction.
[0074] S402: Call the IL function loader to check if there is an IL function corresponding to the function call input parameters.
[0075] It should be noted that steps 401-402 are the same as steps 101-102 above. For details, please refer to the description of steps 101-102, which will not be elaborated here.
[0076] S403: If it is determined that there is no IL function corresponding to the function call input parameter, then the AOT function loader is invoked to check if there is an AOT function corresponding to the function call input parameter.
[0077] In this embodiment, if no IL function corresponding to the function call input parameter exists in either the cache or the IL function lookup table, the AOT function loader is invoked to query the cache for an AOT function corresponding to the function call input parameter. If an AOT function corresponding to the function call input parameter exists in the cache, it is used as the target function. The cache stores functions that have been called recently, and the AOT function loader can prioritize querying the cache for an AOT function corresponding to the function call input parameter to improve the calling efficiency of the AOT function. If no AOT function corresponding to the function call parameter exists in the cache, the AOT function lookup table is searched for. The AOT function lookup table includes the correspondence between AOT static functions and address indices, and the correspondence between AOT instance functions and name indices. If an AOT function corresponding to the function call input parameter is found in the AOT function lookup table, the proxy function corresponding to the AOT function is obtained and used as the target function.
[0078] The proxy function is obtained by processing the AOT function based on a preset first data structure, which can be a data structure supported by a stack-based virtual machine. Specifically, the proxy function wraps the AOT function, transforming it into a form that can be called by an IL function. Specifically, if a query is performed based on the function call input parameters and an AOT function corresponding to those parameters is found, an intermediate conversion is needed to transform the AOT function into a form that can be called by an IL function. This wrapping converts the IL function call input parameters into a format acceptable to the AOT function, and then the actual call to the AOT function is initiated using `Function.apply()` provided by the Dart standard library.
[0079] In addition, for a better understanding of the AOT function lookup table, please refer to the following for details. Figure 5 This is an example diagram illustrating an AOT function lookup provided in an embodiment of this disclosure.
[0080] like Figure 5 As shown, AOT function 1 is an IL static function, and the mapping relationship between AOT function 1 and address 0x8ef41183 can be established through a globally unique address. AOT function 2 is a static function, and its address cannot be determined. The mapping relationship between AOT function 2 and its name LibraryA.ClassB.funcE can be established.
[0081] In one optional implementation, the AOT function lookup table and the IL function lookup table can form a function lookup table, which is used to query the corresponding target function based on the function call input parameters.
[0082] S404: If it is determined that there exists an AOT function corresponding to the function call input parameters, then the target function is determined based on the AOT function;
[0083] In this embodiment of the disclosure, after receiving the intermediate language (IL) function call instruction, the function call input parameters carried in the IL function call instruction are obtained. If it is determined that there is no IL function corresponding to the function call input parameters, the AOT function loader is called to query whether there is an AOT function corresponding to the function call input parameters. If there is an AOT function corresponding to the function call input parameters, the AOT function is determined as the target function.
[0084] S405: Returns the target function in response to an IL function call instruction.
[0085] In this embodiment of the disclosure, after obtaining the AOT function corresponding to the function call input parameters, the target function is returned for the IL function call instruction, thus completing the function call of the IL function call instruction.
[0086] This disclosure provides a function call method. When an intermediate language (IL) function call instruction is received, the function call input parameters carried in the IL function call instruction are obtained. An IL function loader is invoked to check if an IL function corresponding to the function call input parameters exists. If it is determined that no IL function exists, an ahead-compiled AOT function loader is invoked to check if an AOT function exists. If an AOT function exists, a target function is determined based on the AOT function, and the target function is returned for the IL function call instruction. This disclosure uses a hierarchical approach to search for the target function based on the function call input parameters carried in the IL function call instruction, thereby realizing IL function calls and further enabling Flutter dynamics.
[0087] In some embodiments of this disclosure, when a function call instruction for an instrumented function is received, it is first determined whether the function call instruction comes from an AOT function. If it is determined that the function call instruction comes from an AOT function, the function call instruction is intercepted, and the IL function corresponding to the instrumented function is returned for the function call instruction. The IL function corresponding to the instrumented function carries the running parameters of the instrumented function based on a preset second data structure.
[0088] Since AOT functions cannot be aware of IL functions, if an AOT function has the ability to call an IL function, an interception operation needs to be performed at the point of the AOT function call to replace the execution logic of the AOT function with the execution logic of the IL function. This interception of AOT functions is called instrumentation. The instrumentation position can be determined in advance based on functional requirements, and the instrumentation is then completed.
[0089] Taking the `initState()` method of `State` as an example of "instrumentation," `State.initState()` is a function that is called by system AOT functions. When an IL function contains the `State.initState()` method, it means that the function needs to be interpreted and executed. Specifically, when a function call instruction for the `State.initState()` function is received, it is first determined whether the caller comes from a system AOT function. If so, the call is intercepted, and the IL function corresponding to the `State.initState()` function is returned for the function call instruction. If it is determined that the caller does not come from a system AOT function, the `initState()` function of the parent class of `State` is called directly.
[0090] To facilitate a further understanding of the function call method provided in this disclosure, a schematic diagram of the execution process of a function call method is provided in this disclosure embodiment. (Refer to...) Figure 6 .
[0091] This disclosure presents a utility class IL function loader that stores all IL functions and supports function lookup via function call input parameters. Additionally, this disclosure presents a utility class AOT function loader that stores all AOT functions and supports function lookup via function call input parameters.
[0092] Specifically, when an intermediate language (IL) function call instruction is received, the function call input parameters carried in the IL function call instruction are obtained, the IL function loader is called, and the existence of an IL function corresponding to the function call input parameters is checked. If it exists, the corresponding IL function is determined as the target function and returned according to the IL function call instruction. If it does not exist, the AOT function loader is called to determine the corresponding AOT function as the target function and returned according to the IL function call instruction. In order to better understand the embodiments of this disclosure, they will be specifically described in the following two parts.
[0093] 1. Finding the target function in IL functions
[0094] When a function call input parameter is received, the IL function loader is invoked. First, a search is performed in the cache. If the IL function corresponding to the function call input parameter exists in the cache, then that IL function is used as the target function and returned. If the IL function corresponding to the function call input parameter does not exist in the cache, then the search continues in the IL function lookup table. The IL function lookup table is constructed based on the control flow graph. If the IL function corresponding to the function call input parameter exists in the IL function lookup table, then that IL function is used as the target function and returned. If it does not exist, the next level of search is performed.
[0095] 2. Find the target function in the AOT function.
[0096] Upon receiving a function call input parameter, the IL function loader is invoked. If it is determined that no IL function corresponding to the function call input parameter exists, the AOT function loader is invoked to check if an AOT function corresponding to the function call input parameter exists. Specifically, the cache is first checked for an AOT function corresponding to the function call input parameter. If an AOT function corresponding to the function call input parameter exists in the cache, it is used as the target function and returned. If no AOT function corresponding to the function call input parameter exists in the cache, the AOT function loader continues searching in the AOT function lookup table. If an AOT function corresponding to the function call input parameter exists in the AOT function lookup table, the corresponding proxy function is obtained, and the proxy function is used as the target function and returned. If no AOT function corresponding to the function call input parameter exists in the AOT function lookup table, an exception is returned.
[0097] Corresponding to the above method embodiments, this disclosure also provides a function call device, referencing Figure 7 This is a schematic diagram of a function call device structure provided in an embodiment of the present disclosure. Specifically, the device includes:
[0098] The acquisition module 701 is used to acquire the function call input parameters carried in the intermediate language (IL) function call instruction when an intermediate language (IL) function call instruction is received;
[0099] Query module 702 is used to call the IL function loader to query whether there is an IL function corresponding to the function call input parameters;
[0100] The first determining module 703 is used to determine the IL function as the target function if it is determined that there is an IL function corresponding to the function call input parameters;
[0101] The first return module 704 is used to return the target function in response to IL function call instructions.
[0102] Accordingly, the query module 702 includes:
[0103] The first query submodule is used to call the IL function loader to check in the cache whether there is an IL function corresponding to the function call input parameters;
[0104] The second query submodule is used to query the IL function lookup table for the IL function corresponding to the function call input parameters if it is determined that there is no IL function in the cache. The IL function lookup table includes the correspondence between static IL functions and address indexes, and the correspondence between instance IL functions and name indexes.
[0105] Optionally, the device further includes:
[0106] The second determination module is used to call the AOT function loader to check if there is an AOT function corresponding to the function call input parameter if it is determined that there is no IL function.
[0107] The third determination module is used to determine the target function based on the AOT function if it is determined that there is an AOT function corresponding to the function call input parameters, and then continue to execute the step of the IL function call instruction and return to the target function.
[0108] Accordingly, the second determining module includes:
[0109] The third query submodule is used to call the AOT function loader to check in the cache whether there is an AOT function corresponding to the function call input parameters;
[0110] The fourth query submodule is used to query the AOT function corresponding to the function call input parameter in the AOT function lookup table if it is determined that there is no AOT function in the cache. The AOT function lookup table includes the correspondence between AOT static functions and address indexes, as well as the correspondence between AOT instance functions and name indexes.
[0111] Accordingly, the third determining module includes:
[0112] The first acquisition submodule is used to acquire the proxy function corresponding to the AOT function if it is determined that there is an AOT function corresponding to the function call input parameter; wherein, the proxy function is obtained by processing the AOT function based on a preset first data structure;
[0113] The first determination submodule is used to determine the proxy function corresponding to the AOT function as the target function.
[0114] Optionally, the device further includes:
[0115] The fourth determination module is used to determine whether the function call instruction comes from an AOT function when a function call instruction for an instrumented function is received.
[0116] The second return module is used to intercept the function call instruction if it is determined that the function call instruction comes from the AOT function, and return the IL function corresponding to the instrumented function for the function call instruction; wherein, the IL function corresponding to the instrumented function is based on a preset second data structure that carries the running parameters of the instrumented function.
[0117] In the function calling device provided in this embodiment, an intermediate language (IL) function calling instruction is received, the function calling input parameters carried in the IL function calling instruction are obtained, the IL function loader is invoked, and it is checked whether there is an IL function corresponding to the function calling input parameters. If it is determined that there is an IL function corresponding to the function calling input parameters, the IL function is determined as the target function. For the IL function calling instruction, the target function is returned, and the IL function call is completed based on the IL function loader. This provides a foundation for realizing an IL-based interpreter and executor, thereby further realizing the dynamic capabilities of Flutter.
[0118] In addition to the methods and apparatus described above, this disclosure also provides a function call medium, in which instructions are stored in a computer-readable storage medium, which, when executed on a terminal device, cause the terminal device to implement the function call method described in this disclosure.
[0119] This disclosure also provides a computer program product, which includes a computer program / instruction that, when executed by a processor, implements the function call method described in this disclosure.
[0120] In addition, this disclosure also provides a function call device, see [link to relevant documentation]. Figure 8 As shown, it may include:
[0121] The device includes a processor 801, a memory 802, an input device 803, and an output device 804. The function call device can have one or more processors 801. Figure 8 Taking a processor as an example. In some embodiments of this disclosure, the processor 801, memory 802, input device 803, and output device 804 can be connected via a bus or other means, wherein, Figure 8 Taking the example of a connection between China and Israel via a bus.
[0122] The memory 802 can be used to store software programs and modules. The processor 801 executes various functional applications and data processing of the function call device by running the software programs and modules stored in the memory 802. The memory 802 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function, etc. In addition, the memory 802 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. The input device 803 can be used to receive input digital or character information, and to generate signal inputs related to user settings and function control of the function call device.
[0123] Specifically in this embodiment, the processor 801 loads the executable files corresponding to the processes of one or more applications into the memory 802 according to the following instructions, and the processor 801 runs the applications stored in the memory 802, thereby realizing the various functions of the above-mentioned function call device.
[0124] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0125] The above description is merely a specific embodiment of this disclosure, enabling those skilled in the art to understand or implement it. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not to be limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A function call method, characterized in that, The method includes: When an intermediate language (IL) function call instruction is received, the function call input parameters carried in the IL function call instruction are obtained; Call the IL function loader to check if there exists an IL function corresponding to the input parameters of the function call; If it is determined that there exists an IL function corresponding to the input parameters of the function call, then that IL function is determined as the target function; If it is determined that there is no IL function corresponding to the function call input parameter, then the AOT function loader is invoked to check whether there is an AOT function corresponding to the function call input parameter; If it is determined that there exists an AOT function corresponding to the function call input parameters, then the proxy function corresponding to the AOT function is obtained; wherein, the proxy function is obtained by processing the AOT function based on a preset first data structure, and the proxy function is used to transform the AOT function into a form that can be called by the IL function; The proxy function corresponding to the AOT function is determined as the target function; In response to the IL function call instruction, the target function is returned.
2. The method according to claim 1, characterized in that, The process of calling the IL function loader to check if an IL function corresponding to the function call input parameters exists includes: Invoke the IL function loader to check if the IL function corresponding to the function call input parameters exists in the cache; If it is determined that the IL function corresponding to the function call input parameter does not exist in the cache, the IL function loader searches for the IL function corresponding to the function call input parameter in the IL function lookup table; wherein, the IL function lookup table includes the correspondence between IL static functions and address indexes and the correspondence between IL instance functions and name indexes.
3. The method according to claim 1, characterized in that, The process of calling the pre-compiled AOT function loader to check if an AOT function corresponding to the function call input parameters exists includes: Invoke the AOT function loader to check in the cache whether the AOT function corresponding to the function call input parameters exists; If it is determined that the AOT function corresponding to the function call input parameter does not exist in the cache, the AOT function loader queries the AOT function lookup table for the AOT function corresponding to the function call input parameter; wherein, the AOT function lookup table includes the correspondence between AOT static functions and address indexes and the correspondence between AOT instance functions and name indexes.
4. The method according to claim 1, characterized in that, The method further includes: When a function call instruction for an instrumented function is received, determine whether the function call instruction comes from an AOT function; If it is determined that the function call instruction comes from an AOT function, the function call instruction is intercepted, and the IL function corresponding to the instrumented function is returned for the function call instruction; wherein, the IL function corresponding to the instrumented function carries the running parameters of the instrumented function based on a preset second data structure.
5. The method according to claim 1, characterized in that, The data structure of the target function includes a function base class, an IL function class, and an AOT function class. Both the IL function class and the AOT function class inherit from the function base class. The target function is an object described by the IL function class or an object described by the AOT function class.
6. A function call apparatus, the apparatus comprising: The acquisition module is used to acquire the function call input parameters carried in the intermediate language (IL) function call instruction when an intermediate language (IL) function call instruction is received. The query module is used to call the IL function loader to query whether the IL function corresponding to the function call input parameter exists. The first determining module is used to determine the IL function as the target function if it is determined that there exists an IL function corresponding to the function call input parameters; The second determining module is used to call the AOT function loader to query whether there is an AOT function corresponding to the function call input parameter if it is determined that there is no IL function. The first acquisition submodule is used to acquire a proxy function corresponding to the AOT function if it is determined that there is an AOT function corresponding to the function call input parameter; wherein, the proxy function is obtained by processing the AOT function based on a preset first data structure, and the proxy function is used to convert the AOT function into a form that can be called by the IL function; The first determining submodule is used to determine the proxy function corresponding to the AOT function as the target function; The first return module is used to return the target function in response to the IL function call instruction.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on a terminal device, cause the terminal device to perform the method as described in any one of claims 1-5.
8. A function call device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the method as described in any one of claims 1-5.
9. A computer program product, characterized in that, The computer program product includes a computer program / instruction that, when executed by a processor, implements the method as described in any one of claims 1-5.
