Metadata processing method and device, electronic equipment and readable storage medium

By detecting and cropping the target metadata in the Unity IL2CPP virtual machine, the compiler's memory usage is reduced, and the problem of excessive memory of the IL2CPP virtual machine is solved, ensuring the normal operation of the game engine and compiler.

CN119149044APending Publication Date: 2024-12-17ZHUHAI KINGSOFT ONLINE GAME TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411181290.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-27
Publication Date
2024-12-17

AI Technical Summary

Technical Problem

Code bloat in Unity IL2CPP virtual machine causes excessive memory usage, resulting in insufficient device memory.

Method used

By obtaining the target metadata, detecting and processing based on the preset function list and the target metadata set, determining the metadata that meets the preset filtering conditions is trimmed, reducing the amount of data written to the metadata, thereby reducing the compiler's memory usage.

Benefits of technology

While ensuring the normal operation of the game engine and compiler, the amount of metadata written in the compiler is reduced and the memory usage is reduced, which solves the problem of excessive memory of the IL2CPP virtual machine.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119149044A_ABST
    Figure CN119149044A_ABST
Patent Text Reader

Abstract

The invention discloses a metadata processing method and device, electronic equipment and a readable storage medium, and relates to the technical field of metadata. The method comprises the following steps: firstly obtaining target data, then detecting target metadata based on a preset function list and a target metadata set, determining the target metadata meeting a preset filtering condition as filtered metadata, and determining the target metadata according with the preset filtering condition as metadata in a non-target metadata set according to the preset filtering condition, the target metadata is metadata of a function in a non-preset function list. A function in a preset function list is a first necessary function for supporting the operation of a game engine, a target metadata set is a data set constructed according to first metadata in a data collection stage, and the first metadata is metadata related to a second necessary function for supporting the operation of a compiler; therefore, the data volume of the metadata written in the compiler can be reduced under the condition that the editor and the game engine can normally run, so that the memory occupation of the compiler is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of metadata technology, and in particular to a metadata processing method, device, electronic device and readable storage medium. Background Art

[0002] IL2CPP (Intermediate Language to C++) is a script compiler in the Unity game engine. It is mainly responsible for converting game logic code written in C# or other scripting languages ​​supported by Unity into C++ code, and then compiling these C++ codes into machine code for the target platform. IL2CPP can also be regarded as a virtual machine. As the game functions increase, the amount of code in the Unity IL2CPP project is also growing, causing the code in the IL2CPP virtual machine to continue to expand, resulting in the IL2CPP virtual machine occupying more and more memory, resulting in insufficient device memory. Therefore, a method to reduce the memory usage in the IL2CPP virtual machine is urgently needed. Summary of the invention

[0003] The present application aims to solve at least one of the technical problems existing in the prior art. To this end, the present application proposes a metadata processing method, device, electronic device and readable storage medium, which can reduce the amount of metadata written in the compiler, thereby reducing the memory usage of the compiler.

[0004] According to the metadata processing method of the first aspect of the present application, the method is applied to a compiler of a game engine, and the method includes:

[0005] Get target metadata;

[0006] The target metadata is detected and processed based on a preset function list and a target metadata set; wherein the functions in the preset function list are first necessary functions to support the operation of the game engine, the target metadata set is a data set constructed according to the first metadata during the data collection phase, and the first metadata is metadata related to a second necessary function to support the operation of the compiler;

[0007] Determine the target metadata that meets the preset filtering condition as the filtering metadata, wherein the preset filtering condition is that the target metadata is not metadata in the target metadata set, and the target metadata is not metadata of a function in the preset function list;

[0008] The target metadata is clipped according to the filtering metadata to obtain the writing metadata.

[0009] According to the metadata processing method of the embodiment of the present application, at least the following beneficial effects are achieved: the metadata processing method of the embodiment of the present application is applied to the compiler of the game engine, firstly the target data is obtained, then the target metadata is detected and processed based on the preset function list and the target metadata set, and the target metadata that meets the preset filtering condition is determined as the filtering metadata, the preset filtering condition is that the target metadata is metadata in the non-target metadata set, and the target metadata is metadata of the function in the non-preset function list; the target metadata is clipped according to the filtering metadata to obtain the write metadata, thereby reducing the amount of data of the write metadata. And since the functions in the preset function list are the first necessary functions to support the operation of the game engine, the target metadata set is the data set constructed according to the first metadata in the data collection stage, and the first metadata is the metadata related to the second necessary function to support the operation of the compiler; therefore, even after the target metadata is clipped, the normal operation of the game engine and the compiler can be guaranteed, so as to reduce the amount of data of the metadata written in the compiler while ensuring the normal operation of the editor and the game engine, thereby reducing the memory usage of the compiler.

[0010] According to some embodiments of the present application, obtaining target metadata includes:

[0011] Get the dynamic link library file;

[0012] The target metadata is acquired based on the dynamic link library file.

[0013] According to some embodiments of the present application, the detecting and processing the target metadata based on the preset function list and the target metadata set includes:

[0014] Performing detection processing on the target metadata according to the metadata of the target metadata set;

[0015] In the case where it is detected that the target metadata is not metadata in the target metadata set, detecting and processing the target metadata according to the metadata of the function in the preset function list;

[0016] In the case where it is detected that the target metadata is metadata of a function other than the preset function list, it is determined that the target metadata meets the preset filtering condition.

[0017] According to some embodiments of the present application, the detecting and processing the target metadata according to the metadata of the function in the preset function list includes:

[0018] Determining a function signature of the target metadata;

[0019] The function signature of the target metadata is detected and processed according to the function signature of the function in the preset function list. When it is detected that the function signature of the target metadata does not match the function signature of the function in the preset function list, it is determined that the target metadata is not the metadata of the function in the preset function list.

[0020] According to some embodiments of the present application, the detecting and processing the target metadata according to the metadata of the function in the preset function list includes:

[0021] Performing detection processing on the target metadata according to the dependency relationship of the functions in the preset function list;

[0022] In a case where it is detected that the target metadata does not have a dependency relationship with a function in the preset function list, it is determined that the target metadata is metadata of a function that is not in the preset function list.

[0023] According to some embodiments of the present application, the target metadata set further includes second metadata, and a method for generating the second metadata includes:

[0024] Determining a marked reflective function that is pre-marked in the compiler;

[0025] The second metadata is determined according to the tag reflection function.

[0026] According to some embodiments of the present application, the second necessary function includes a runtime function of the compiler; and the obtaining the first metadata includes:

[0027] Determining the metadata index related to the runtime function through the specified function data index function of the compiler;

[0028] Based on the metadata index, metadata related to the runtime function is obtained.

[0029] According to some embodiments of the present application, the second necessary function includes a generic function of the compiler and a virtual function in a virtual table; and obtaining the first metadata includes:

[0030] determining context data for the compiler;

[0031] The metadata related to the generic function and the virtual function in the virtual table is obtained from the context data.

[0032] A second aspect of the present application provides a metadata processing device, which is applied to a compiler of a game engine, and the device includes:

[0033] An acquisition module, used to acquire target metadata;

[0034] a detection processing module, configured to detect and process the target metadata based on a preset function list and a target metadata set; wherein the functions in the preset function list are first necessary functions for supporting the operation of the game engine, the target metadata set is a data set constructed according to the first metadata during the data collection phase, and the first metadata is metadata related to a second necessary function for supporting the operation of the compiler;

[0035] a determination module, configured to determine the target metadata that meets a preset filtering condition as filtering metadata, wherein the preset filtering condition is that the target metadata is metadata that is not in the target metadata set, and the target metadata is metadata that is not a function in the preset function list;

[0036] The clipping processing module is used to clip the target metadata according to the filtering metadata to obtain the write metadata.

[0037] An embodiment of the third aspect of the present application provides an electronic device, the electronic device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the metadata processing method described in any embodiment of the first aspect of the present application when executing the computer program.

[0038] The fourth aspect of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the metadata processing method described in any embodiment of the first aspect of the present application.

[0039] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The present application is further described below with reference to the accompanying drawings and embodiments, wherein:

[0041] Figure 1 A schematic diagram of the processing process of the metadata processing method according to an embodiment of the present application;

[0042] Figure 2 A schematic diagram of the steps of the metadata processing method according to an embodiment of the present application;

[0043] Figure 3 A schematic diagram of the structure of a metadata processing device according to an embodiment of the present application;

[0044] Figure 4 A schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0045] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be understood as limiting the present application.

[0046] In the description of the present application, it should be understood that descriptions involving orientation, such as up, down, front, back, left, right, etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present application.

[0047] In the description of this application, "several" means more than one, "more" means more than two, "greater than", "less than", "exceed", etc. are understood to exclude the number itself, and "above", "below", "within", etc. are understood to include the number itself. If there is a description of "first" or "second", it is only used for the purpose of distinguishing technical features, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.

[0048] In the description of this application, unless otherwise clearly defined, terms such as setting, installing, connecting, etc. should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in this application based on the specific content of the technical solution.

[0049] In the description of the present application, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0050] First, the terms involved in this application are explained:

[0051] Compiler: A compiler is a software tool that converts source code written in a high-level programming language into machine code or other low-level form of code that a computer can execute. The main purpose of a compiler is to act as a bridge between the source code and the hardware, ensuring that the program can run on a specific computer architecture or virtual machine.

[0052] Unity Game Engine: Unity is a widely used cross-platform game development engine that allows developers to create 2D and 3D games, simulations, and other interactive content. The Unity engine is known for its powerful features, flexibility, and ease of use, and is suitable for projects of all sizes, from small independent developers to large game studios. Unity uses the IL2CPP editor to compile C# scripts into C++ code to improve performance and compatibility on certain platforms or devices.

[0053] Metadata: It is data that describes data, which provides information about the structure, characteristics, and meaning of the data. Metadata can have different forms and uses in different contexts. Especially in programming and software development, metadata plays an important role. In the compiler, metadata may be type information, such as the definition of user-defined types such as classes, structures, interfaces, enumerations, such as base classes, implemented interfaces, generic parameters, and other types of relationships. Metadata may also be member information, such as class members, including the definition of fields, properties, methods, constructors, indexers, etc. Metadata may also be parameter information, such as the parameter list of methods and constructors, including parameter types, names, default values, etc. Metadata may also be return types, such as the return type of a method, including basic types, custom types, or void. Metadata may also be attribute information, such as metadata declared using attributes, which can provide additional instructions or information to the compiler or runtime.

[0054] IL2CPP (Intermediate Language to C++) is a script compiler in the Unity game engine. It is mainly responsible for converting game logic code written in C# or other scripting languages ​​supported by Unity into C++ code, and then compiling these C++ codes into machine code for the target platform. The IL2CPP compiler is mainly triggered during the build phase of the Unity project to compile C# code into C++ code and finally generate a local executable file. The compiler automatically collects metadata when it runs and writes the metadata into the global-metadata.dat file, which is also called the global metadata file. This global metadata file will contain metadata that needs to be used, and will also contain more metadata that is not needed, resulting in a large amount of data in the global metadata file, which in turn causes the compiler to occupy a large amount of memory, resulting in insufficient memory on the device hosting Unity.

[0055] Based on this, the embodiments of the present application propose a metadata processing method, device, electronic device and readable storage medium, which can reduce the amount of metadata written in the compiler, thereby reducing the memory usage of the compiler.

[0056] Reference Figure 1 , Figure 1 A schematic diagram of the processing process of a metadata processing method provided in an embodiment of the present application. The specific processing process of the metadata processing method includes two stages, namely, a clipping stage and a collection stage. The stage in which the metadata needs to be filtered is the clipping stage, and the stage in which the metadata does not need to be filtered is the collection stage. The collection stage is performed first and then the clipping stage. In the collection stage, the compiler obtains the target metadata, and at the same time obtains the metadata related to the runtime function, generic function and virtual table of the compiler, and then obtains the target metadata set based on the metadata related to the runtime function, generic function and virtual table. And the collection stage directly writes all target metadata into the global-metadata.dat file to obtain the global-metadata.dat file. In the clipping stage, a preset filtering condition is first constructed through a preset function list and a target metadata set, and then the compiler obtains the target metadata, and filters the target metadata based on the preset filtering condition to obtain the filtered write metadata, and writes the write data into the global-metadata.dat file to obtain the global-metadata.dat file. Since the target metadata is filtered in the trimming phase, the data volume of the global-metadata.dat file obtained in the trimming phase is smaller than that of the global-metadata.dat file obtained in the collection phase, thereby reducing the memory usage of the compiler.

[0057] The first aspect of the present application provides a metadata processing method. Figure 2 , Figure 2 1 is a flowchart of a metadata processing method according to an embodiment of the present application. The metadata processing method according to an embodiment of the present application is applied to a compiler of a game engine, the game engine is a Unity game engine, and the compiler is an IL2CPP compiler. The steps of the metadata processing method include but are not limited to steps S210 to S240.

[0058] Step S210, obtaining target metadata;

[0059] It is worth noting that the target metadata is automatically obtained by the compiler at runtime. In the related art, the compiler automatically collects the target metadata, directly uses all the target metadata as the write metadata, and writes the write metadata into the global metadata file. In the present application, after obtaining the target metadata, the target metadata is trimmed to obtain the write metadata through subsequent steps S120 to S140.

[0060] Step S220, detecting and processing the target metadata based on the preset function list and the target metadata set; wherein the functions in the preset function list are first necessary functions to support the operation of the game engine, the target metadata set is a data set constructed according to the first metadata in the data collection phase, and the first metadata is metadata related to the second necessary function to support the operation of the compiler;

[0061] It is worth noting that the second necessary functions include metadata related to the compiler's runtime functions, generic functions, and functions in the virtual table; the first metadata includes metadata related to the compiler's runtime functions, metadata related to the compiler's generic functions, and metadata related to functions in the compiler's virtual table. The first metadata are all metadata that support the operation of the game engine.

[0062] It is worth noting that in IL2CPP compilation, runtime functions (RuntimeMethods) refer to C++ functions generated during the conversion process in IL2CPP compilation, which correspond to methods in C# code. They are designed to be executed in the runtime environment of Unity games to handle tasks such as game logic, UI interaction, and physical simulation. The C++ functions generated by IL2CPP are usually global functions rather than member functions of classes, which can simplify the logic of code conversion and make function calls more flexible. In the runtime environment of Unity games, runtime functions are called through the runtime library of IL2CPP. The runtime library provides the necessary support to simulate the runtime behavior of C# (such as garbage collection, type reflection, etc.) and ensure that C++ code can correctly execute the logic of C# code. The metadata related to the runtime function of the compiler refers to the metadata required for the runtime function to be executed.

[0063] It is worth noting that generic functions (GenericMethods) are a programming paradigm supported in C#, which allows you to define functions, classes, interfaces or methods without specifying specific data types, but only specifying them when they are used. In this way, the same function can be used for multiple different data types without having to write separate functions for each type. In IL2CPP, generic functions are converted to template functions or similar mechanisms in C++ to achieve similar functions. IL2CPP implements a generic sharing mechanism, which means that for certain types of generic functions, IL2CPP can generate a common code implementation and dynamically bind to these codes at runtime based on specific type parameters. This is very helpful for reducing the size of executable files and improving performance. When the IL2CPP compiler encounters a generic function, it generates the corresponding C++ code based on the type and constraints of the generic parameters. The metadata related to generic functions refers to the metadata required by the generic function when it is executed.

[0064] It is worth noting that the virtual table (VTable) is a mechanism used to implement polymorphic behavior in languages ​​compiled by IL2CPP (such as C++). It is an array of function pointers that contains pointers to all virtual functions in a class. A virtual table is a table stored in memory, and its structure is similar to an array, where each entry is a pointer to a virtual function. Each class (a class that contains virtual functions) has its own virtual function table. Derived classes inherit the virtual function table of the base class and add their own new virtual functions or override the virtual functions of the base class. Each object contains a pointer to the virtual function table of its class (usually called vptr), which is located at the beginning or end of the object's memory layout and is inserted by the compiler. Virtual table-related metadata refers to the metadata required to execute the virtual functions in the virtual table.

[0065] Step S230, determining the target metadata that meets the preset filtering condition as the filtering metadata, the preset filtering condition being that the target metadata is metadata in the non-target metadata set, and the target metadata is metadata of a function that is not in the preset function list;

[0066] It is worth noting that the functions in the preset function list are pre-set, and the functions in the preset function list are all necessary functions to support the operation of the compiler. For example, the preset function list includes all virtual functions, all constructors, all functions of the Unity module, all property set functions, all property get functions, and functions inherited from the MonoBehaviour class. The preset function list also includes functions marked with RuntimeInitializeOnLoadMethodAttribute, which are functions used for initialization when the Unity engine starts. The preset function list also includes functions whose names include "InternalArray__", which are necessary functions for system containers. The preset function list also includes functions named "Dispose", "Init", "PerformWaitCallback", "UnsafeQueueCustomWorkItem", and "CreateCulture", which are the first necessary functions of the Unity engine.

[0067] Step S240: cutting the target metadata according to the filtering metadata to obtain write metadata.

[0068] It is worth noting that the write metadata represents metadata written into the global metadata file. The clipping process is: after obtaining the filter metadata, the filter metadata is removed from the target metadata to obtain the write metadata, and then the write metadata is written into the global metadata file.

[0069] The metadata processing method of the embodiment of the present application, through the above steps S110 to S140, first obtains the target data, and then detects and processes the target metadata based on the preset function list and the target metadata set, and determines the target metadata that meets the preset filtering conditions as the filtering metadata, the preset filtering conditions are that the target metadata is metadata in the non-target metadata set, and the target metadata is metadata of the function in the non-preset function list; the target metadata is trimmed according to the filtering metadata to obtain the write metadata, thereby reducing the amount of data written to the metadata. And because the functions in the preset function list are the first necessary functions to support the operation of the game engine, the target metadata set is a data set constructed according to the first metadata in the data collection phase, and the first metadata is metadata related to the second necessary function to support the operation of the compiler; therefore, even after the target metadata is trimmed, the normal operation of the game engine and the compiler can be guaranteed, and the amount of data written to the metadata in the compiler is reduced while ensuring that the editor and the game engine can operate normally, thereby reducing the memory usage of the compiler.

[0070] In one embodiment, acquiring the target metadata includes: acquiring a dynamic link library file; and acquiring the target metadata based on the dynamic link library file.

[0071] It is worth noting that the dynamic link library file (Dynamic Link Library) is an executable file that allows programs to share code and other resources necessary to perform special tasks. After the compiler obtains the dynamic link library file, the IL2CPP compiler collects target metadata by loading and analyzing the DLL file. These target metadata are the metadata that will be written to the global metadata file. The compiler obtains the DLL file from the Unity game engine. In the Unity project, the C# source code is first compiled into intermediate language (IL) code and encapsulated in the DLL file. These DLL files (such as Assembly-CSharp.dll) contain the project's IL code and related metadata.

[0072] In one embodiment, Figure 1 A specific step flow of step S220 is: detecting and processing the target metadata according to the metadata of the target metadata set; when it is detected that the target metadata is not metadata in the target metadata set, detecting and processing the target metadata according to the metadata of the function in the preset function list; when it is detected that the target metadata is not metadata of the function in the preset function list, determining that the target metadata meets the preset filtering conditions.

[0073] It is worth noting that, in the case where it is detected that the target metadata is metadata in the target metadata set, it can be determined that the target metadata does not meet the preset filtering condition.

[0074] It is worth noting that, in the case where it is detected that the target metadata is metadata of a function in a preset function list, it can be determined that the target metadata does not meet the preset filtering condition.

[0075] It is worth noting that, when the embodiment of the present application detects and processes the target metadata, it first detects whether the target metadata is metadata in the target metadata set. If it is detected that the target metadata is metadata in the non-target metadata set, it detects whether the target metadata is metadata of a function in a preset function list. If it is detected that the target metadata is metadata of a function in a non-preset function list, it determines that the target metadata meets the preset filtering condition. In the embodiment of the present application, since it is more likely that the target metadata is metadata in the target metadata set, first detecting whether the target metadata is metadata in the target metadata set can reduce the number of judgments in the detection process, thereby improving detection efficiency.

[0076] In one embodiment, the target metadata is detected and processed according to the metadata of the function in the preset function list, which can be achieved through the following steps: determining the function signature of the target metadata; detecting and processing the function signature of the target metadata according to the function signature of the function in the preset function list, and when it is detected that the function signature of the target metadata does not match the function signature of the function in the preset function list, determining that the target metadata is metadata of a function not in the preset function list.

[0077] It is worth noting that it is detected whether the function signature of the target metadata matches the function signature of at least one function in the preset function list. If the function signature of the target metadata matches the function signature of at least one function in the preset function list, it is determined that the target metadata is the metadata of the function in the preset function list, and then it can be determined that the target metadata does not meet the preset filtering conditions.

[0078] It is worth noting that the function signature is a unique identifier of a function, which is used to call the function in the code. A series of information describing the characteristics of a function, which defines the name, return type, and parameter list of the function. In programming, the function signature is the key to distinguishing different functions. Even if two functions have the same name, they are considered different functions if their signatures are different. The function signature is used to determine the correctness of the function call at compile time to ensure that the parameters provided during the call match the signature of the function definition. The embodiment of the present application determines whether the target metadata is the metadata of a function in a preset function list by detecting whether the function signature of the target metadata matches the function signature of at least one function in the preset function list.

[0079] In one embodiment, the target metadata is detected and processed according to the metadata of the functions in the preset function list, which can be achieved through the following steps: the target metadata is detected and processed according to the dependency relationship of the functions in the preset function list; when it is detected that the target metadata does not have a dependency relationship with the functions in the preset function list, it is determined that the target metadata is not the metadata of the function in the preset function list.

[0080] It is worth noting that, when it is detected that the target metadata has a dependency relationship with at least one function in the preset function list, it can be determined that the target metadata is the metadata of the function in the preset function list, and further it can be determined that the target metadata does not meet the preset filtering condition.

[0081] It is worth noting that dependencies include direct dependencies, indirect dependencies, and type dependencies. When a component (such as function A) directly calls or uses another component (such as function B), there is a direct dependency between them. If function A calls function B, and function B calls function C, then function A has an indirect dependency on function C. A function may depend on a specific data type or class. For example, if function A uses an instance of class B as a parameter, then function A depends on class B. The embodiment of the present application can determine whether the target metadata is the metadata of a function in the preset function list by detecting whether the target metadata has a type dependency with at least one function in the preset function list.

[0082] In one embodiment, the target metadata set is constructed by the first metadata and the second metadata. Therefore, the target metadata set includes the first metadata and the second metadata. The second metadata is obtained by the following steps: determining a marking reflection function pre-marked in the compiler; and determining the second metadata according to the marking reflection function.

[0083] It is worth noting that the compiler may perform reflection calls during operation, and the reflection calls are performed through reflection functions. When the compiler automatically collects metadata, it cannot determine the specific reflection function used in the compilation process, so it will not collect the metadata used in the reflection call process. However, the developer knows the specific reflection function used in the compilation process, so the reflection function is marked in advance to obtain a marked reflection function. During the operation of the compiler, the marked reflection function pre-marked in the compiler is determined, and then the second metadata can be determined based on the marked reflection function to obtain the second metadata.

[0084] In one embodiment, C# has a component called Attribute, which can add some declarative information to a function. Developers can define an Attribute as a tag to mark the reflection function. Therefore, when a function is detected to include the Attribute, it can be determined that the function is a marked reflection function.

[0085] It should be noted that in C#, reflection calls obtain type information and method information through the Type class and the MethodInfo class. The Type class represents a type and can obtain information such as the type's name, properties, and methods; the MethodInfo class represents a method and can obtain information such as the method's name, parameters, and return value. At runtime, the program can use the reflection mechanism to obtain type information and method information and call methods.

[0086] In another embodiment, the developer cannot know some reflection functions, so the reflection functions cannot be marked in advance. For the reflection functions that the developer cannot know, the second metadata of the reflection function that the developer cannot know is obtained through the MethodInfo.Invoke function, the Type.GetMethod function and the class::GetMethodFromNameFlagsAndsig function. When the compiler makes a reflection call, it must execute the MethodInfo.Invoke function, the Type.GetMethod function and the class::GetMethodFromNameFlagsAndsig function. MethodInfo.Invoke and Type.GetMethod are both C# APIs for reflection calls. The class::GetMethodFromNameFlagsAndsig function is a function in the il2cpp virtual machine, which is used to obtain function information through the function name. Therefore, the second metadata of the reflection function that the developer cannot know can be obtained through the MethodInfo.Invoke function, the Type.GetMethod function and the class::GetMethodFromNameFlagsAndsig function.

[0087] In one embodiment, the step of obtaining the first metadata includes: determining a metadata index related to the runtime function through a specified function data index function of the compiler; and obtaining metadata related to the runtime function based on the metadata index.

[0088] It is worth noting that the specified function data index function refers to the GetEncodedMethodMetadataUsageIndex function in the IL2CPP compiler. The specified function data index function is used to obtain the metadata index metadataIndex referenced by the specified function. The metadata index metadataIndex related to the runtime function is obtained through the specified function data index function. Through the metadata index, metadata related to the runtime function can be obtained.

[0089] In another embodiment, the step of obtaining the first metadata includes: determining context data of the compiler; and obtaining metadata related to generic functions and virtual tables from the context data.

[0090] It is worth noting that the compiler uses context to save the collected detailed data, including metadata, from which metadata related to the virtual table vtable and metadata related to generic functions can be directly obtained. For example, based on the function signature of the generic function, the generic function is determined from the context, and then metadata related to the generic function is obtained. For example, based on the pointer of the virtual function in the virtual table, the virtual function is determined, and then metadata related to the virtual function is determined, thereby obtaining metadata related to the virtual table.

[0091] Reference Figure 3 The second aspect of the present application provides a metadata processing device, which is applied to a compiler of a game engine, and the device includes:

[0092] An acquisition module 310 is used to acquire target metadata;

[0093] The detection processing module 320 is used to detect and process the target metadata based on the preset function list and the target metadata set; wherein the functions in the preset function list are first necessary functions for supporting the operation of the game engine, the target metadata set is a data set constructed according to the first metadata in the data collection phase, and the first metadata is metadata related to the second necessary function for supporting the operation of the compiler; the second necessary function includes the runtime function of the compiler, the generic function, and the virtual function in the virtual table;

[0094] A determination module 330, configured to determine target metadata that meets a preset filtering condition as filtering metadata, wherein the preset filtering condition is that the target metadata is metadata in a non-target metadata set, and the target metadata is metadata of a function in a non-preset function list;

[0095] The clipping processing module 340 is used to clip the target metadata according to the filtering metadata to obtain write metadata.

[0096] The metadata processing device is used to execute the metadata processing method of the first embodiment of the present application. When executing the method, first obtain the target data, then detect and process the target metadata based on the preset function list and the target metadata set, and determine the target metadata that meets the preset filtering conditions as the filtering metadata, the preset filtering conditions are that the target metadata is metadata in the non-target metadata set, and the target metadata is metadata of the function in the non-preset function list; the target metadata is trimmed according to the filtering metadata to obtain the write metadata, so as to reduce the amount of data written to the metadata. And because the functions in the preset function list are the first necessary functions to support the operation of the game engine, the target metadata set is a data set constructed according to the first metadata in the data collection phase, and the first metadata is metadata related to the second necessary function to support the operation of the compiler; therefore, even after the target metadata is trimmed, the normal operation of the game engine and the compiler can be guaranteed, so as to reduce the amount of data written to the metadata in the compiler while ensuring that the editor and the game engine can operate normally, thereby reducing the memory usage of the compiler.

[0097] In one embodiment, the acquisition module includes a first acquisition submodule and a second acquisition submodule.

[0098] The first acquisition submodule is used to acquire a dynamic link library file;

[0099] The second acquisition submodule is used to acquire target metadata based on the dynamic link library file.

[0100] In one embodiment, the detection processing module 320 includes a first detection submodule, a second detection submodule and a first determination submodule.

[0101] The first detection submodule is used to detect and process the target metadata according to the metadata of the target metadata set;

[0102] The second detection submodule is used for detecting and processing the target metadata according to the metadata of the function in the preset function list when it is detected that the target metadata is metadata not in the target metadata set;

[0103] The first determining submodule is used to determine that the target metadata meets the preset filtering condition when it is detected that the target metadata is metadata of a function not in the preset function list.

[0104] In one embodiment, the second detection submodule includes a first determination subunit and a first detection subunit.

[0105] The first determination subunit is used to determine a function signature of target metadata;

[0106] The first detection sub-unit is used to detect and process the function signature of the target metadata according to the function signature of the function in the preset function list, and when it is detected that the function signature of the target metadata does not match the function signature of the function in the preset function list, it is determined that the target metadata is metadata of a function not in the preset function list.

[0107] In one embodiment, the second detection submodule includes a second determination subunit and a second detection subunit.

[0108] The second detection subunit is used to detect and process the target metadata according to the dependency relationship of the functions in the preset function list;

[0109] The second determining subunit is used for determining that the target metadata is metadata of a function not in the preset function list when it is detected that the target metadata has no dependency relationship with a function in the preset function list.

[0110] In one embodiment, the metadata processing device further includes a tag function determination module and a second metadata determination module. The target metadata set further includes second metadata.

[0111] The marking function determination module is used to determine the marking reflection function that is pre-marked in the compiler;

[0112] The second metadata determination module is used to determine the second metadata according to the marking reflection function.

[0113] In one embodiment, the metadata processing device further includes an index determination module and a first metadata acquisition module.

[0114] The index determination module is used to determine the metadata index related to the runtime function through the specified function data index function of the compiler;

[0115] The first metadata acquisition module is used to acquire metadata related to the runtime function based on the metadata index.

[0116] In one embodiment, the metadata processing device further includes a context data determination module.

[0117] The context data determination module is used to determine the context data of the compiler;

[0118] The first metadata acquisition module is also used to acquire metadata related to generic functions and virtual functions in virtual tables from context data.

[0119] The third aspect of the present application provides an electronic device. Figure 4 , Figure 4 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. The electronic device includes:

[0120] The processor 401 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;

[0121] The memory 402 may be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 402 may store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 402, and the processor 401 calls and executes the metadata processing method of the embodiment of this application;

[0122] Input / output interface 403, used to implement information input and output;

[0123] Communication interface 404, used to realize communication interaction between the device and other devices, which can be realized by wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);

[0124] Bus 405 , which transmits information between various components of the device (e.g., processor 401 , memory 402 , input / output interface 403 , and communication interface 404 );

[0125] The processor 401 , the memory 402 , the input / output interface 403 and the communication interface 404 are connected to each other in communication within the device via the bus 405 .

[0126] The fourth aspect of the present application is a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the metadata processing method of any one of the first aspect embodiments is implemented.

[0127] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0128] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0129] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0130] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0131] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0132] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0133] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the mapping relationship of the mapping objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next mapping objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0134] In the several embodiments provided in the present application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0135] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0136] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0137] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0138] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.

Claims

1. A metadata processing method, characterized in that: A compiler applied to a game engine, the method comprising: Get target metadata; The target metadata is detected and processed based on a preset function list and a target metadata set; wherein the functions in the preset function list are first necessary functions to support the operation of the game engine, the target metadata set is a data set constructed according to the first metadata during the data collection phase, and the first metadata is metadata related to a second necessary function to support the operation of the compiler; Determine the target metadata that meets the preset filtering condition as the filtering metadata, wherein the preset filtering condition is that the target metadata is not metadata in the target metadata set, and the target metadata is not metadata of a function in the preset function list; The target metadata is clipped according to the filtering metadata to obtain the writing metadata.

2. The metadata processing method according to claim 1, characterized in that: The obtaining of target metadata includes: Get the dynamic link library file; The target metadata is acquired based on the dynamic link library file.

3. The metadata processing method according to claim 1, characterized in that: The detecting and processing the target metadata based on the preset function list and the target metadata set includes: Performing detection processing on the target metadata according to the metadata of the target metadata set; In the case where it is detected that the target metadata is not metadata in the target metadata set, detecting and processing the target metadata according to the metadata of the function in the preset function list; In the case where it is detected that the target metadata is metadata of a function other than those in the preset function list, it is determined that the target metadata meets the preset filtering condition.

4. The metadata processing method according to claim 3, characterized in that: The detecting and processing the target metadata according to the metadata of the function in the preset function list includes: Determining a function signature of the target metadata; The function signature of the target metadata is detected and processed according to the function signature of the function in the preset function list. When it is detected that the function signature of the target metadata does not match the function signature of the function in the preset function list, it is determined that the target metadata is not the metadata of the function in the preset function list.

5. The metadata processing method according to claim 3, characterized in that: The detecting and processing the target metadata according to the metadata of the function in the preset function list includes: Performing detection processing on the target metadata according to the dependency relationship of the functions in the preset function list; In a case where it is detected that the target metadata does not have a dependency relationship with a function in the preset function list, it is determined that the target metadata is metadata of a function that is not in the preset function list.

6. The metadata processing method according to claim 1, characterized in that: The target metadata set further includes second metadata, and a method for generating the second metadata includes: Determining a marked reflective function that is pre-marked in the compiler; The second metadata is determined according to the tag reflection function.

7. The metadata processing method according to claim 1, characterized in that: The second necessary functions include runtime functions of the compiler; The obtaining of the first metadata includes: Determining a metadata index related to the runtime function through a specified function data index function of the compiler; Based on the metadata index, metadata related to the runtime function is obtained.

8. The metadata processing method according to claim 1, characterized in that: The second necessary function includes a generic function of the compiler and a virtual function in a virtual table; The obtaining of the first metadata includes: determining context data for the compiler; The metadata related to the generic function and the virtual function in the virtual table is obtained from the context data.

9. A metadata processing device, characterized in that: A compiler applied to a game engine, the device comprising: An acquisition module, used to acquire target metadata; a detection processing module, configured to detect and process the target metadata based on a preset function list and a target metadata set; wherein the functions in the preset function list are first necessary functions for supporting the operation of the game engine, the target metadata set is a data set constructed according to the first metadata during the data collection phase, and the first metadata is metadata related to a second necessary function for supporting the operation of the compiler; a determination module, configured to determine the target metadata that meets a preset filtering condition as filtering metadata, wherein the preset filtering condition is that the target metadata is metadata that is not in the target metadata set, and the target metadata is metadata that is not a function in the preset function list; The clipping processing module is used to clip the target metadata according to the filtering metadata to obtain the write metadata.

10. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the metadata processing method according to any one of claims 1 to 7 when executing the computer program.

11. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the metadata processing method according to any one of claims 1 to 7 is implemented.