CN114594981A - Method and device for solving generic compatibility problem during hot update - Google Patents

Method and device for solving generic compatibility problem during hot update Download PDF

Info

Publication number
CN114594981A
CN114594981A CN202210496327.7A CN202210496327A CN114594981A CN 114594981 A CN114594981 A CN 114594981A CN 202210496327 A CN202210496327 A CN 202210496327A CN 114594981 A CN114594981 A CN 114594981A
Authority
CN
China
Prior art keywords
function
generic
metadata information
interpreter
execute
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210496327.7A
Other languages
Chinese (zh)
Other versions
CN114594981B (en
Inventor
黄强
李建良
何雨泉
袁冠鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Yunyou Interactive Network Technology Co ltd
Online Tuyoo Beijing Technology Co ltd
Original Assignee
Beijing Yunyou Interactive Network Technology Co ltd
Online Tuyoo Beijing Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Yunyou Interactive Network Technology Co ltd, Online Tuyoo Beijing Technology Co ltd filed Critical Beijing Yunyou Interactive Network Technology Co ltd
Priority to CN202210496327.7A priority Critical patent/CN114594981B/en
Publication of CN114594981A publication Critical patent/CN114594981A/en
Application granted granted Critical
Publication of CN114594981B publication Critical patent/CN114594981B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/656Updates while running
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/76Adapting program code to run in a different environment; Porting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The method modifies a runtime which only supports AOT static compilation into a runtime which supports an AOT compiler and an interpreter by adding a C + + implementation interpreter to an IL2CPP tool; meanwhile, in order to solve the compatibility problem caused by using a high-level language characteristic functional, a program set comprising original function metadata information is simultaneously loaded into an IL2CPP runtime, and the phenomenon that the function metadata information is lost after a main program code is compiled into a machine code is overcome. When a new generic instance function in the hot update is executed, it is pointed to the execute function of the interpreter, and the MethodInfo structure of the original generic function is passed to the execute function of the interpreter by parameters, thereby completing the interpreted execution of the function.

Description

Method and device for solving generic compatibility problem during hot update
Technical Field
The present application relates to the field of computer technology, and more particularly, to a method, apparatus, computing device, and computer-readable storage medium for solving generic compatibility problems at hot update.
Background
In the mobile internet field, the function update or Bug repair of the APP is realized by using a hot update mode generally, the update can be realized when the APP is opened by a user, the whole APP does not need to be downloaded again, and therefore good user experience is realized. In the prior art, Lua and ILRuntime are generally used for realizing the function of hot update, but both the two ways have various defects, for example, ILRuntime is realized based on C #, but the use of ILRuntime is more limited at present, for example, when general programming is used, the class of hot update part inheriting main engineering needs to be reduced, and for each type used, corresponding adaptive code is needed at a framework layer, so that when hot update has newly introduced general instance functions, the hot update cannot be executed in runtime, and a great deal of compatibility problems exist.
Disclosure of Invention
In view of the above, the present application provides a method and an apparatus for solving the generic compatibility problem during hot update, so as to solve the technical defects existing in the prior art.
According to a first aspect of embodiments of the present application, there is provided a method for solving generic compatibility problems at hot update, comprising:
add an IL interpreter for the IL2CPP tool;
dynamically adding metadata information of the heat updating program set and the original function to the IL2CPP runtime;
when the generic instance function in the hot updating program set is executed, judging whether the generic instance function implementation exists in the operation process, if so, directly calling the compiled function code to complete function calling;
if the general example function does not exist, acquiring the metadata information of the general function corresponding to the general example function from the loaded original function metadata information; and directing the execution process of the generic instance function to an execute function of the IL interpreter, and transmitting metadata information of the generic function as a parameter to the execute function to perform interpretation and execution of the generic instance function.
According to a second aspect of the embodiments of the present application, there is provided a method for patching a generic function in a main program during hot update, including:
packaging a generic function list to be patched and metadata information of a patch function in a hot update program set;
dynamically loading the hot update assembly into an IL2CPP runtime;
and replacing the metadata information of the generic instance function in the runtime according to the generic function list and the metadata information of the patch function, so that the generic instance function jumps to an interpreter to execute when executing.
According to a third aspect of embodiments of the present application, there is provided an apparatus for solving a generic compatibility problem at a hot update, including:
IL2CPP runtime environment;
the IL interpreter is used for interpreting and executing the hot updated assembly code;
the dynamic loading module is used for dynamically loading the hot update program set and the metadata information of the original function into the IL2CPP runtime;
a judging module: the method comprises the steps of judging whether corresponding implementation of the generic instance function exists in the operation process when the generic instance function in the hot update program set is executed, and directly calling a compiled function code if the generic instance function exists; and if the metadata does not exist, acquiring metadata information of the generic function corresponding to the generic instance function from the loaded original function metadata.
A redirection module, configured to direct an execution process of the generic instance function to an execute function of the IL interpreter when no corresponding generic instance function is implemented in runtime;
and the execution module is used for transmitting the metadata information of the generic function as a parameter to the execute function to perform the explanation and execution of the generic instance function.
According to a fourth aspect of the embodiments of the present application, there is provided an apparatus for patching a generic function in a main program during hot update, including:
the system comprises an acquisition module, a hot update module and a hot update module, wherein the acquisition module is used for acquiring a generic function list needing patching and a hot update program set of metadata information of a patch function;
the dynamic loading module is used for dynamically loading the hot updating program set into the IL2CPP runtime;
and the execution module is used for replacing the metadata information of the generic instance function in the runtime according to the generic function list and the metadata information of the patch function, so that the generic instance function jumps to the interpreter to execute when executing.
According to a fifth aspect of embodiments herein, there is provided a computing device comprising a memory, a processor and computer instructions stored on the memory and executable on the processor, the processor implementing the steps of the method for resolving generic compatibility problems upon a hot update when executing the instructions.
According to a sixth aspect of embodiments herein, there is provided a computer readable storage medium storing computer instructions which, when executed by a processor, implement the steps of the method for solving generic compatibility problems at hot update.
The prior art can solve the partial hot update requirement through Lua or ILRuntime, but has the defects of development efficiency, cost and stability. According to the method and the device for solving the problem of generic compatibility during hot update, a C + + implementation interpreter is added to an IL2CPP tool of Unity, and AOT static compilation and local execution are used for codes which do not need to be updated; for code in the hot update program set, the execution is interpreted by the IL interpreter. Because other operation is not introduced, the compatibility problem caused by different operation in the prior art is solved.
Furthermore, in order to solve the compatibility problem caused by using a high-level language characteristic functional, the embodiment of the application loads the program set including the original function metadata information into the IL2CPP runtime at the same time, and overcomes the phenomenon that the function metadata information is lost after the main program code is compiled into the machine code.
The execution of the hot update instruction is realized through a function, in the embodiment of the application, through intercepting the loading process of the program set, the method pointer of the new generic instance function in the hot update program set points to the execute function of the interpreter, and then the MethodInfo structure body containing byte code information of the original generic function is transferred to the execute function of the interpreter through parameters, so that the interpretation and execution of the new generic instance function in the hot update program set are completed, the running seamless performance between the C + + function and the interpreter function of the AOT is ensured, and the compatibility problem of the generic function is solved.
By the method and the device in the embodiment of the application, various problems in hot update existing for a long time in the application based on Unity development in the game industry are solved, the development efficiency of the whole industry is improved, and the development cost is reduced.
Drawings
FIG. 1 is a block diagram of a computing device provided by an embodiment of the present application;
FIG. 2 is a flow chart illustrating a method for solving generic compatibility problems during hot update according to an embodiment of the present application;
FIG. 3 is a flowchart of a method for patching a generic function in a main program during hot update according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an apparatus for solving the generic compatibility problem during hot update according to an embodiment of the present application.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. This application is capable of implementation in many different ways than those herein set forth and of similar import by those skilled in the art without departing from the spirit of this application and is therefore not limited to the specific implementations disclosed below.
The terminology used in the one or more embodiments of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of the present application. As used in one or more embodiments of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used in one or more embodiments of the present application refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It will be understood that, although the terms first, second, etc. may be used herein in one or more embodiments of the present application to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first aspect may be termed a second aspect, and, similarly, a second aspect may be termed a first aspect, without departing from the scope of one or more embodiments of the present application. The word "if," as used herein, may be interpreted as "responsive to a determination," depending on the context.
In the present application, a method and apparatus, a computing device, and a computer-readable storage medium for solving generic compatibility problems at hot update are provided, which are described in detail in the following embodiments one by one.
FIG. 1 shows a block diagram of a computing device 100 according to an embodiment of the present application. The components of the computing device 100 include, but are not limited to, memory 110 and processor 120. The processor 120 is coupled to the memory 110 via a bus 130 and a database 150 is used to store data.
Computing device 100 also includes access device 140, access device 140 enabling computing device 100 to communicate via one or more networks 160. Examples of such networks include the Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the internet. Access device 140 may include one or more of any type of network interface (e.g., a Network Interface Card (NIC)) whether wired or wireless, such as an IEEE802.11 Wireless Local Area Network (WLAN) wireless interface, a worldwide interoperability for microwave access (Wi-MAX) interface, an ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a bluetooth interface, a Near Field Communication (NFC) interface, and so forth.
In one embodiment of the present application, the above-mentioned components of the computing device 100 and other components not shown in fig. 1 may also be connected to each other, for example, by a bus. It should be understood that the block diagram of the computing device architecture shown in FIG. 1 is for purposes of example only and is not limiting as to the scope of the present application. Those skilled in the art may add or replace other components as desired.
Computing device 100 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., tablet, personal digital assistant, laptop, notebook, netbook, etc.), a mobile phone (e.g., smartphone), a wearable computing device (e.g., smartwatch, smartglasses, etc.), or other type of mobile device, or a stationary computing device such as a desktop computer or PC. Computing device 100 may also be a mobile or stationary server.
In the prior art, various frameworks based on Lua such as Xlua or runtime ILRuntime based on C # are generally adopted to realize hot update of APP. The Lua-based solution, while capable of hot-update, also has a number of drawbacks.
In the prior art, an ILRuntime tool implemented based on C # is also proposed to implement a hot update scheme in the same language. ILRuntime provides a pure C # implementation for C # based platforms such as Unity, with fast, convenient and reliable IL runtime that enables hot-update of code in hardware environments that do not support JIT (e.g., iOS). Although ILRuntime overcomes some defects of Lua in a hot-update scenario, it also has many defects, such as when a high-level language characteristic is used, for example, when an ILRuntime and IL2CPP runtime environments are different, various operations such as adaptation and registration need to be performed manually, steps are complicated and error is prone, and more importantly, when a new generic instantiation function is introduced into a hot-update, for example, a new generic instantiation function cannot be executed due to lack of metadata information of an original generic function, resulting in occurrence of a large number of compatibility problems.
In the prior application CN 202210078151.3 of the applicant, a hot-update method and device for Unity platform are proposed, in which a new hot-update architecture is realized by performing custom modification on an IL2CPP tool and adding a custom interpreter to the IL2CPP tool, so as to fundamentally solve various problems in the prior art and greatly improve the cross-platform development efficiency of Unity. However, even if the hot update program set and the main program are loaded into the same runtime, the general-purpose use problem cannot be completely solved, for example:
a generic function void Show < T > (T x) is declared in the main program, and only int type instantiation is performed when AOT compiling of the main program is performed, such as Show < int > (int x), and a generic instance function of int type is formed. If a new instance function belonging to the generic function Show < T > (T x), such as Show < Vector3> (Vector3 x), is introduced in the hot update program; at this point, the runtime cannot execute the generic instance function instantiated with the Vector3 parameter, resulting in a hot update failure. The reason for the failure is that, when the main program is compiled, since the IL2CPP adopts AOT compilation, and after the main program code is compiled into the machine code, IL metadata information of all original functions including the generic function void Show < T > (T x) is lost, the generic instance function generated by the new parameter type cannot be run at runtime.
In view of the above, embodiments of the present application provide a method and apparatus for solving a generic compatibility problem at the time of hot update, so as to solve the problem.
Description the processor 120 of fig. 1 may perform the steps of the method for resolving generic compatibility problems at hot update shown in fig. 2. A flowchart implementing a method for resolving generic compatibility issues at hot update is shown in fig. 2, including steps 202 through 208.
Step 202: an IL interpreter is added for the IL2CPP tool.
In the step, an IL interpreter is added to the IL2CPP tool, so that the tool has the functions of an AOT compiler, a runtime environment and the IL interpreter, and has the compiling and hot updating bases of a plurality of different platforms. The code which does not need to be updated is statically compiled into a C + + code by using AOT (automatic instruction set), and then is compiled into a local executable program by a target platform; for code in the hot update program set, the execution is interpreted by the IL interpreter.
In the existing ILRuntime tool, an interpreter is completed by using C #, machine codes are executed statement by statement through Opcode, and the efficiency is low. In the embodiment of the application, an efficient interpreter is realized again by using a C + + language, and common compiler optimization techniques including but not limited to instruction set conversion, instruction optimization and the like are introduced, so that the memory and running performance are improved.
In the embodiment of the application, the operation of pure AOT is changed into the operation of AOT + interpreter from the improvement of the CLR operation environment of IL2CPP, so that the problem of hot update is fundamentally solved, the seamless performance in operation is ensured, and the problem of compatibility caused by different operations in the prior art is solved.
Step 204: dynamically adding metadata information of the heat updating program set and the original function to the IL2CPP runtime;
the IL2CPP compiling tool adopts AOT compiling, i.e. static compiling or pre-run compiling, which requires accessing all program sets and completing compiling during compiling, and does not support dynamic loading of other program sets. However, to implement a hot update, the assembly of programs in the hot update code must be dynamically loaded into runtime. Therefore, in this embodiment, the metadata management module in the IL2CPP runtime is modified to dynamically heat the updated dynamic library of the assembly.
In a specific embodiment, the updated assembly is heated to the run-time assembly list by the system.selection.assembly.load method. Wherein the engineering of hot updates is implemented using C # as well as the main application developed based on the Unity engine.
In the original IL2CPP operation, all program set metadata information including class name, attribute name, character string and other information are recorded in a global-metadata file, but the file only contains static metadata information included in compiling, and only a read-only global list is directly accessed for obtaining when the metadata is queried. Therefore, in this state, even if the hot-updated assembly is dynamically loaded into runtime, the hot-updated assembly data cannot be obtained from the read-only global list, and thus the hot update cannot be performed.
However, in the runtime library of IL2CPP, in order to save memory, when a metadata type in a program set is acquired, a field referencing the metadata type does not directly point to a memory pointer of one metadata, but a program set index of type int32_ t is used as an index for specifying a fixed array of the metadata of the type. Based on the above, the improvement of the metadata management module in the runtime can be realized, so that the dynamic loading of the hot updated program set is realized.
Further, when the hot-update Assembly is loaded at runtime, based on the same working principle as that of IL2CPP runtime, an index of int32_ t type is allocated to Assembly and encoded, for example, such that the upper 4 bits of the index are not 0. Since the range of positive integers supported by the int32_ t type is 1-2,147,483,647, and the total amount of the type field of the metadata in the program set is almost impossible to reach the maximum number of the range, that is, the high-order bit of the int32_ t type is not used in almost all cases, the high-order n-order bit of the int32_ t type can be used as a distinguishing bit to distinguish the hot update program set from the non-hot update program set, wherein the value of n is selected by a person skilled in the art according to actual situations. For example, when the high-order 4 bits of index are not 0 when executing the hot-update instruction, the metadata of the hot-update program set is not acquired from the global program set list, but is acquired from the dynamically loaded program set, that is, the dynamic metadata information is managed by the dynamically loaded hot-update program set, so that the dynamic program set loading management function under IL2CPP is realized.
Specifically, a GetFieldDefinitionFromIndex function in a runtime library of the IL2CPP is obtained, and the function is used for obtaining a field of metadata of the target program set. In this function is inserted an italic code,
static const Il2CppFieldDefinition* GetFieldDefinitionFromIndex(const Il2CppImage* image, FieldIndex index)
{
if (huatuo:: IsInterImage (image))
{
return huatuo::metadata::CliMetadata::GetFieldDefinitionFromEncodeIn dex(index);
}
…// other IL2CPP codes
}
In the function GetFieldDefinitionFromIndex, the upper 4 bits of the index of the image are judged through IsInterImage (image), so that whether the currently returned metadata in the hot update program set or the metadata in the non-hot update program set is determined, and further definition information of a metadata field is obtained from a corresponding position, and a foundation is laid for execution of hot update.
Furthermore, in order to solve the problem that the original metadata information of all functions is lost after the main program code is compiled into the machine code, the metadata information of the original function is independently loaded to the runtime, and the metadata information of the original function comprises the metadata information of all functions in the main program.
In one possible implementation, a program set of a main program is loaded to obtain metadata information, wherein the program set is a program set which is not compiled by AOT;
in another possible embodiment, a dedicated set of metadata information descriptors is loaded to obtain metadata information;
in another possible implementation, the program set containing the original function metadata information is published in a package together with the compiled main program or the program set containing the original function metadata information is published in a package together with the hot update program set.
Those skilled in the art should understand that the above-mentioned manner of obtaining the function metadata information is not exhaustive, and any manner capable of obtaining the original function metadata is included in the present embodiment.
In the step, the hot-updated program set is dynamically loaded to the IL2CPP runtime, the runtime type is dynamically expanded, and further, the index of the metadata field in the program set is encoded, so that the acquisition of metadata of different program sets is distinguished, and the preparation of hot update is realized. In this way, the hot update program set and the main program are loaded into the same runtime, and the incompatibility problem of the type system is eliminated. Furthermore, in order to solve the compatibility problem of the functional, a program set including original function metadata information is loaded to the IL2CPP runtime, and the phenomenon that the function metadata information is lost after a main program code is compiled into a machine code is overcome.
Step 206: when the generic instance function in the hot update program set is executed, judging whether a corresponding generic instance function implementation exists in the operation process, and if so, directly calling the compiled function code; and if the metadata does not exist, acquiring metadata information of the generic function corresponding to the generic instance function from the loaded original function metadata.
In one possible implementation, when a generic instance function exists in the hot update program set, for example, the generic instance function Show < Vector3> (Vector3 x) exists in the hot update program set, and its instantiation parameter is Vector3 type, the generic function corresponding to the generic instance function is the generic function void Show < T > (T x) declared in the main program, which is compiled into machine code through AOT when it is issued. When a generic instance function of the hot update program set is executed, firstly, inquiring metadata information of all functions in IL2CPP runtime, if description information of a function Show < Vector3> (Vector3 x) exists in a Methodinfo structure in the metadata information, indicating that the generic instance function is realized in compiled machine code, and directly calling; if the method info structure does not have the description information of the function Show < Vector3> (Vector3 x), the metadata information of the generic function void Show < T > (T x) corresponding to the generic instance function is obtained from the original function metadata information loaded in step 204. Since the original function metadata information contains metadata information of all functions of the main program, it necessarily includes the above information.
In another possible embodiment, the generic instance functions in the hot update procedure set can be not only instance functions of normal generic functions, but also member functions in a compiled generic class.
Step 208: the execution process of the generic instance function is directed to the execute function of the IL interpreter.
After the metadata information of the generic instance function in the hot update program set is obtained, the function needs to be further improved by combining with an interpreter in order to be able to execute the function.
In an IL2CPP runtime environment conforming to the CLR specification, various metadata information is loaded into a corresponding type structure in a memory, where the structure of function information in runtime is:
typedef struct MethodInfo
{
Il2CppMethodPointer methodPointer;
InvokerMethod invoker_method;
const char* name;
Il2CppClass *klass;
const Il2CppType *return_type;
const ParameterInfo* parameters;
union
{
const Il2CppRGCTXData* rgctx_data; /* is_inflated is true and is_generic is false, i.e. a generic instance method */
Il2CppMetadataMethodDefinitionHandle methodMetadataHandle;
};
} MethodInfo;
the methodPointer field points to the actual address of the function, and further points the methodPointer in the generic instance function MethodInfo structure to the execute function of the IL interpreter.
Step 210: and transferring the metadata information of the generic function as a parameter to an execute function to perform the interpretation and execution of the generic instance function.
In a specific embodiment, since the methodPointer in the metadata MethodInfo structure of the generic instance function points to the execute function of the interpreter, the execution task from the hot update suite generic instance function is handed over to the interpreter in runtime.
Further, when the interpreter interprets the hot updated program set line by line and executes the execute function corresponding to the generic instance function, the pointer methoddinfo of the metadata information of the generic function acquired in step 206 is transferred to the execute function as a parameter, thereby acquiring the field methodMetadataHandle in the methoddinfo structure.
From the definition of the structure of MethodInfo in IL2CPP, it can be seen that the variable methodMethataHandle is actually an Il2CppMethodDefinition data type whose structure is:
typedef struct Il2CppMethodDefinition
{
StringIndex nameIndex;
TypeDefinitionIndex declaringType;
TypeIndex returnType;
ParameterIndex parameterStart;
GenericContainerIndex genericContainerIndex;
uint32_t token;
uint16_t flags;
uint16_t iflags;
uint16_t slot;
uint16_t parameterCount;
} Il2CppMethodDefinition;。
in the data structure definition, a token field of the agent 32_ t type is included, byte code information of the function can be obtained through the token field, and by using the byte code information, the function of the interpreter can interpret and execute the generic instance function in the hot update program set.
In this step, when executing the interpreter execute function pointed by the generic instance function in the hot update program set, the MethodInfo structure including the generic function bytecode information is passed to the interpreter execute function via the parameter, and the interpreter execute function completes the execution of the generic instance function according to the bytecode information.
In another possible embodiment, the generic instance functions in the hot update program set can be not only instance functions of ordinary generic functions, but also member functions in a compiled generic class.
In another embodiment, based on the above method for solving the generic compatibility problem during hot update, a method for patching a generic function in a main program is implemented, as shown in fig. 3, and includes:
step 302: packaging a generic function list to be patched and metadata information of a patch function in a hot update program set;
step 304: dynamically loading the hot update assembly into the IL2CPP runtime;
step 306: and replacing a metadata information Methodinfo structure of the generic instance function in the runtime according to the generic function list and the metadata information of the patch function, so that when the generic instance function executes, the generic instance function jumps to an interpreter for execution.
Further, in the runtime, a corresponding generic instance function is obtained according to a function in the generic function list, and then a metadata information Methodinfo structure of the generic instance function is obtained, and a methodPointer in the metadata information structure points to an execute function of the interpreter. For example, according to the Show < T > (T x) in the generic function list, an instance function Show < int > (int x) that needs to be patched in runtime is obtained, and the methodpoint of the Show < int > (int x) points to the execute function of the interpreter.
Further, when the jump execution of the interpreter is carried out, the metadata information of the patch function is taken as a parameter to be transmitted to the execute function of the interpreter. For example, when the execute function parses the Show < int > (int x), the metadata information of the patch function Show < T > (T x) is passed to the execute function of the interpreter, thereby completing the patching work.
In the above embodiment, the structure of IL2CPP is improved, and a runtime that only supports AOT static compilation is transformed into a runtime that supports AOT + interpreter, thereby implementing the foundation of a cross-platform efficient hot-update scheme; furthermore, by encoding the metadata index, a dynamic library of a hot-update program set is dynamically loaded, the metadata type during running is expanded, and the unification of the type during running and the type system in the hot-update program set is realized; for the code using the generic dynamic mechanism, loading independent original function metadata information, in the calling process of the generic function, intercepting the loading process of the program set, pointing the generic instance function of the hot updating program set to the interpreter, and transferring the corresponding metadata information to the interpreter to execute the function, thereby not only avoiding the compatibility problem, but also realizing the patching work of the generic function compiled into machine code in the main program by using the method.
Corresponding to the above method embodiments, the present application further provides an embodiment of an apparatus for solving the generic compatibility problem at the time of hot update, and fig. 4 shows a schematic structural diagram of an apparatus for solving the generic compatibility problem at the time of hot update according to an embodiment of the present application. As shown in fig. 4, the apparatus includes:
IL2CPP runtime environment;
the IL interpreter is used for interpreting and executing the hot updated assembly code;
the dynamic loading module is used for dynamically loading the hot update program set and the metadata information of the original function into the IL2CPP runtime;
a judgment module: the method comprises the steps of judging whether corresponding implementation of the generic instance function exists in the operation process when the generic instance function in the hot update program set is executed, and directly calling a compiled function code if the generic instance function exists; and if the metadata does not exist, acquiring the metadata information of the generic function corresponding to the generic instance function from the loaded original function metadata.
A redirection module, configured to direct an execution process of the generic instance function to an execute function of the IL interpreter when no corresponding generic instance function is implemented in runtime;
and the execution module is used for transmitting the metadata information of the generic function as a parameter to the execute function to perform the explanation and execution of the generic instance function.
The above is an exemplary scheme of the present embodiment for solving the generic compatibility problem during hot update. It should be noted that, the technical solution of the apparatus for solving the generic compatibility problem at the time of the hot update belongs to the same concept as the technical solution of the method for solving the generic compatibility problem at the time of the hot update, and details of the technical solution of the apparatus for solving the generic compatibility problem at the time of the hot update, which are not described in detail, can be referred to the above description of the technical solution of the method for solving the generic compatibility problem at the time of the hot update.
There is also provided in an embodiment of the present application a computing device comprising a memory, a processor, and computer instructions stored on the memory and executable on the processor, the processor implementing the steps of the method for resolving generic compatibility problems upon a hot update when executing the instructions.
The above is an illustrative scheme of a computing device of the present embodiment. It should be noted that the technical solution of the computing device and the technical solution of the above method for solving the generic compatibility problem at the time of the hot update belong to the same concept, and details that are not described in detail in the technical solution of the computing device can be referred to the above description of the technical solution of the method for solving the generic compatibility problem at the time of the hot update.
An embodiment of the present application also provides a computer readable storage medium storing computer instructions which, when executed by a processor, implement the steps of the method for resolving generic compatibility problems upon a hot update as previously described.
The above is an illustrative scheme of a computer-readable storage medium of the present embodiment. It should be noted that the technical solution of the storage medium is the same as the technical solution of the above method for solving the generic compatibility problem at the time of the hot update, and details of the technical solution of the storage medium, which are not described in detail, can be referred to the above description of the technical solution of the method for solving the generic compatibility problem at the time of the hot update.
The foregoing description of specific embodiments of the present application has been presented. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The computer instructions comprise computer program code which may be in the form of source code, object code, an executable file or some intermediate form, or the like. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
It should be noted that, for the sake of simplicity, the above-mentioned method embodiments are described as a series of acts or combinations, but those skilled in the art should understand that the present application is not limited by the described order of acts, as some steps may be performed in other orders or simultaneously according to the present application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to the related descriptions of other embodiments.
The preferred embodiments of the present application disclosed above are intended only to aid in the explanation of the application. Alternative embodiments are not exhaustive and do not limit the invention to the precise embodiments described. Obviously, many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the application and its practical applications, to thereby enable others skilled in the art to best understand and utilize the application. The application is limited only by the claims and their full scope and equivalents.

Claims (12)

1. A method for resolving generic compatibility issues upon hot updates, comprising:
adding an IL interpreter to the IL2CPP tool;
dynamically adding metadata information of the heat updating program set and the original function to the IL2CPP runtime;
when the generic instance function in the hot updating program set is executed, judging whether the implementation of the generic instance function exists in the operation process, if so, directly calling the compiled function code to complete function calling;
if the generic example function does not exist, acquiring metadata information of the generic function corresponding to the generic example function from the loaded original function metadata information; directing an execution process of the generic instance function to an execute function of the IL interpreter; and transferring the metadata information of the generic function as a parameter to the execute function to perform the interpretation and execution of the generic instance function.
2. The method of claim 1, wherein directing execution of the generic instance function to an execute function of the IL interpreter comprises:
pointing the methodPointer in the MethodInfo structure of the generic instance function to the execute function of the IL interpreter.
3. The method of claim 2, wherein passing metadata information of the generic function as a parameter to the execute function for interpreted execution of the generic instance function further comprises:
transmitting a MethodInfo structure pointer of the generic function as a parameter to an execute function of an IL interpreter;
and acquiring bytecode information of the generic function according to the description information in the MethodInfo structure, and finishing the interpretation and execution of the generic instance function by the execute function according to the bytecode information.
4. The method of claim 1, wherein said generic instance functions further comprise member functions in a generic class.
5. The method of claim 1, wherein the hot update assembly comprises a dynamic library DLL that conforms to the CLI specification.
6. A method for patching a generic function in a main program during hot update, comprising:
packaging a generic function list to be patched and metadata information of a patch function in a hot update program set;
dynamically loading the hot update assembly into an IL2CPP runtime;
and replacing the metadata information of the generic instance function in the runtime according to the generic function list and the metadata information of the patch function, so that the generic instance function jumps to an interpreter to execute when executing.
7. The method of claim 6, wherein replacing metadata information of the generic instance function in runtime according to the generic function list and metadata information of the patch function comprises:
acquiring a metadata information Methodinfo structure of a function in the generic function list in runtime, and pointing a methodPointer in the Methodinfo structure to an execute function of an interpreter.
8. The method of claim 7, wherein causing jumping into an interpreter to execute when the generic instance function executes comprises:
and when the interpreter jumps to execute, the metadata information of the patch function is taken as a parameter and is transmitted to an execute function of the interpreter for executing the interpretation.
9. An apparatus for resolving generic compatibility issues upon hot updates, comprising:
IL2CPP runtime environment;
the IL interpreter is used for interpreting and executing the hot updated assembly code;
the dynamic loading module is used for dynamically loading the hot update program set and the metadata information of the original function into the IL2CPP runtime;
a judging module: the method comprises the steps of judging whether the realization of the generic instance function exists in the running process when the generic instance function in the hot updating program set is executed, and directly calling a compiled function code if the generic instance function exists; if the function type does not exist, acquiring metadata information of the generic function corresponding to the generic instance function from the loaded original function metadata;
a redirection module, configured to direct an execution process of the generic instance function to an execute function of the IL interpreter when the generic instance function implementation does not exist in runtime;
and the execution module is used for transmitting the metadata information of the generic function as a parameter to the execute function to perform the explanation and execution of the generic instance function.
10. An apparatus for patching a generic function in a main program during a hot update, comprising:
the system comprises an acquisition module, a hot update module and a hot update module, wherein the acquisition module is used for acquiring a generic function list needing patching and a hot update program set of metadata information of a patch function;
the dynamic loading module is used for dynamically loading the hot updating program set into the IL2CPP runtime;
and the execution module is used for replacing the metadata information of the generic instance function in the runtime according to the generic function list and the metadata information of the patch function, so that the generic instance function jumps to the interpreter to execute when executing.
11. A computing device comprising a memory, a processor, and computer instructions stored on the memory and executable on the processor, wherein the processor implements the steps of the method of any one of claims 1-8 when executing the instructions.
12. A computer-readable storage medium storing computer instructions, which when executed by a processor, perform the steps of the method of any one of claims 1 to 8.
CN202210496327.7A 2022-05-09 2022-05-09 Method and device for solving generic compatibility problem during hot update Active CN114594981B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210496327.7A CN114594981B (en) 2022-05-09 2022-05-09 Method and device for solving generic compatibility problem during hot update

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210496327.7A CN114594981B (en) 2022-05-09 2022-05-09 Method and device for solving generic compatibility problem during hot update

Publications (2)

Publication Number Publication Date
CN114594981A true CN114594981A (en) 2022-06-07
CN114594981B CN114594981B (en) 2022-08-09

Family

ID=81812132

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210496327.7A Active CN114594981B (en) 2022-05-09 2022-05-09 Method and device for solving generic compatibility problem during hot update

Country Status (1)

Country Link
CN (1) CN114594981B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050055681A1 (en) * 2003-09-08 2005-03-10 Makarand Gadre Compiling source code using generic classes
CN103984582A (en) * 2014-06-04 2014-08-13 网易(杭州)网络有限公司 Method and device for hot updating
CN108415719A (en) * 2018-03-29 2018-08-17 网易(杭州)网络有限公司 The hot update method of code and device, storage medium, processor and terminal
CN114115964A (en) * 2022-01-24 2022-03-01 在线途游(北京)科技有限公司 Hot updating method and device for Unity, computing equipment and computer-readable storage medium
CN114443052A (en) * 2022-01-24 2022-05-06 在线途游(北京)科技有限公司 Dynamic specialization method and device during IL instruction operation

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050055681A1 (en) * 2003-09-08 2005-03-10 Makarand Gadre Compiling source code using generic classes
CN103984582A (en) * 2014-06-04 2014-08-13 网易(杭州)网络有限公司 Method and device for hot updating
CN108415719A (en) * 2018-03-29 2018-08-17 网易(杭州)网络有限公司 The hot update method of code and device, storage medium, processor and terminal
CN114115964A (en) * 2022-01-24 2022-03-01 在线途游(北京)科技有限公司 Hot updating method and device for Unity, computing equipment and computer-readable storage medium
CN114443052A (en) * 2022-01-24 2022-05-06 在线途游(北京)科技有限公司 Dynamic specialization method and device during IL instruction operation

Also Published As

Publication number Publication date
CN114594981B (en) 2022-08-09

Similar Documents

Publication Publication Date Title
US10795660B1 (en) Live code updates
CN111770113A (en) Method for executing intelligent contract, block chain node and node equipment
CN108920133B (en) Cross-language programming method and device, electronic equipment and storage medium
US20050108690A1 (en) System and method of generating applications for mobile devices
CN101697131B (en) Method and device for dynamically loading relocatable file
CN111061638B (en) iOS system debugging method, device and server
CN114115964B (en) Hot updating method and device for Unity, computing equipment and computer-readable storage medium
US8997066B2 (en) Emulating pointers
CN109739508B (en) Source code compiling method, device, system and storage medium
CN111770116B (en) Method for executing intelligent contract, block chain node and storage medium
CN101937356B (en) Method for compiling WebKit browser and device thereof
CN111770205B (en) Method, block chain node, system and storage medium for executing intelligent contract
CN111815310B (en) Method for executing intelligent contract, block chain node and storage medium
CN111770204B (en) Method for executing intelligent contract, block chain node and storage medium
CN111768184A (en) Method for executing intelligent contract and block link point
US20100058305A1 (en) Automatic Generation of Language Bindings for Libraries Using Data from Compiler Generated Debug Information
CN113220326B (en) Intelligent contract upgrading method and block chain system
CN111770202B (en) Method for executing intelligent contract, block chain node and storage medium
US11188361B1 (en) Cross-architecture software distribution using a virtual instruction set architecture
CN114594981B (en) Method and device for solving generic compatibility problem during hot update
CN114443052A (en) Dynamic specialization method and device during IL instruction operation
CN113220327B (en) Intelligent contract upgrading method and block chain system
CN115048184A (en) Method and device for optimizing execution of interpreter instruction
CN116594622A (en) Python program compiling method and system based on type deduction and data flow analysis
CN115658140A (en) SDK packaging method, device, terminal and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant