Compiling method and device, electronic equipment, storage medium and product

By deciding whether to inline function based on the calling frequency of the function during compilation, the problem of frequent inline functions resulting in the increase in the source code volume is solved, and the operation efficiency of the application is improved.

CN119396403APending Publication Date: 2025-02-07VIVO MOBILE COMM CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411410970.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-10
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

During the compilation process, frequent calls to inline functions lead to a growth in the source code volume, thereby reducing the operation efficiency of the application.

Method used

By obtaining the calling frequency of the function at compile time, only functions with calling frequency higher than or equal to a certain threshold are inlined, thereby reducing unnecessary inline operations and avoiding excessive growth of the source code volume.

Benefits of technology

It effectively reduces the number of times the application performs function inline, avoids a significant increase in the source code volume, and thus improves the operation efficiency of the application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396403A_ABST
    Figure CN119396403A_ABST
Patent Text Reader

Abstract

The invention discloses a compiling method and device, electronic equipment, a storage medium and a product, and belongs to the technical field of communication. The method comprises the steps that under the condition that a first source code of a first application is compiled, a first function identifier is obtained, and the first function identifier is used for indicating a first function in the first source code; under the condition that the first function identifier is matched with any one of the at least one second function identifier, performing function inline on the first source code and a function body corresponding to the first function to generate a second source code; wherein the second function identifier is used for indicating a function of which the calling frequency is greater than or equal to a first threshold value in the first application.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of communication technology, and specifically relates to a compilation method, device, electronic device, storage medium and product. Background Art

[0002] Currently, when an application is compiled, compilation optimization is performed to improve the startup and running speed of the application. Various optimization modules are called during compilation to optimize the source code, such as dead source code elimination, constant folding, inline optimization, etc. Inline optimization is to insert the source code of the inline function directly into the call point during the compilation process. When the program is running, it does not need to execute the function call step, but directly executes the source code of the inline function, thereby saving the function call overhead.

[0003] However, if the body of an inline function is large and is frequently called from multiple locations, the source code size will increase significantly, which may cause the application's operating efficiency to decrease. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a compilation method, device, electronic device, storage medium and product, which can improve the operating efficiency of an application.

[0005] In a first aspect, an embodiment of the present application provides a compilation method, the method comprising: when compiling a first source code of a first application, obtaining a first function identifier, the first function identifier being used to indicate a first function in the first source code; when the first function identifier matches any one of at least one second function identifier, inlining the first source code and a function body corresponding to the first function to generate a second source code; wherein the second function identifier is used to indicate a function in the first application whose calling frequency is greater than or equal to a first threshold.

[0006] In a second aspect, an embodiment of the present application provides a compilation device, which includes: an acquisition module and a processing module. The acquisition module is used to obtain a first function identifier when compiling a first source code of a first application, and the first function identifier is used to indicate a first function in the first source code. The processing module is used to inline the first source code and the function body corresponding to the first function to generate a second source code when the first function identifier obtained by the acquisition module matches any one of at least one second function identifier; wherein the second function identifier is used to indicate a function in the first application whose calling frequency is greater than or equal to a first threshold.

[0007] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.

[0008] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0009] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.

[0010] In a sixth aspect, an embodiment of the present application provides a computer program / program product, wherein the computer program / program product is stored in a storage medium, and the program / program product is executed by at least one processor to implement the method described in the first aspect.

[0011] In an embodiment of the present application, when compiling the first source code of the first application, a first function identifier is obtained, and the first function identifier is used to indicate the first function in the first source code; when the first function identifier matches any one of at least one second function identifier, the first source code and the function body corresponding to the first function are inlined to generate a second source code; wherein the second function identifier is used to indicate a function in the first application whose calling frequency is greater than or equal to the first threshold. In this scheme, when compiling the first source code of the first application, the electronic device performs function inlining on the first source code and the function body corresponding to the first function to generate the second source code only when it determines that the calling frequency of the first function in the first source code is greater than or equal to the first threshold, that is, when it determines that the first function is a frequently called function, thereby reducing the number of times the first application performs function inlining, and avoiding a substantial increase in the source code volume of the first application. Thereby improving the operating efficiency of the application. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Figure 1 This is one of the flowcharts of a compilation method provided in an embodiment of the present application;

[0013] Figure 2 This is a second flow chart of a compilation method provided in an embodiment of the present application;

[0014] Figure 3 This is a third flowchart of a compilation method provided in an embodiment of the present application;

[0015] Figure 4 This is a fourth flowchart of a compilation method provided in an embodiment of the present application;

[0016] Figure 5 This is a fifth flowchart of a compilation method provided in an embodiment of the present application;

[0017] Figure 6It is a structural diagram of a compiling device provided in an embodiment of the present application;

[0018] Figure 7 This is one of the hardware structure diagrams of an electronic device provided in an embodiment of the present application;

[0019] Figure 8 This is the second schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0020] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.

[0021] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way are interchangeable where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0022] The terms "at least one (item)", "at least one of" and the like in the specification and claims of the present application refer to any one, any two or a combination of more than two of the objects included therein. For example, at least one (item) of a, b, and c can be represented by: "a", "b", "c", "a and b", "a and c", "b and c" and "a, b and c", where a, b, and c can be single or multiple. Similarly, "at least two (items)" refers to two or more, and its meaning is similar to that of "at least one (item)".

[0023] The following is an explanation of some concepts and / or terms involved in the compilation method provided in the embodiments of the present application.

[0024] 1. Inline function: It is used to prompt the compiler to embed the function body directly into the calling point when the function is called, instead of through the conventional function calling mechanism.

[0025] 2. Inline functions are declared using the inline keyword. Usually, inline is used at the definition of a function, as shown below:

[0026] inline int add(int a,int b){

[0027] Return a+b;

[0028] }

[0029] In this example, the add function is declared as an inline function. When the add function is called in the source code, the compiler will try to insert the body of this function directly into the call site instead of performing a function call.

[0030] 3. Speed-profile compilation mode. When the application editing mode is speed-profile compilation mode, the application source code is compiled according to at least one frequently called function recorded in the profile file. The application source code is partially compiled.

[0031] 4. Speed ​​compilation mode. When the compilation mode of the application is speed compilation mode, the source code of the application is fully compiled, and there is no need to call functions when compiling the source code.

[0032] The compilation method provided in the embodiment of the present application is described in detail below through specific embodiments and application scenarios in conjunction with the accompanying drawings.

[0033] The compilation method in the embodiment of the present application can be applied to the scenario of source code compilation.

[0034] At present, when compiling frameworks and applications, Ahead-of-Time (AOT) compilation optimization and Just-In-Time (JIT) compilation optimization are performed to improve the startup and running speed of frameworks and applications. Various optimization modules are called during compilation to optimize the source code, such as dead source code elimination, constant folding, inline optimization, etc. In order to implement calls between source codes, the compiler needs to allocate an active area for each source code, save the caller for each parameter, create the callee's environment, transfer control to the callee, and finally pass parameters when returning. Inline optimization is to directly convert the called function to the call point, which can be used to reduce the overhead of function calls, facilitate escape analysis and delete repeated memory barrier (LoadStore) operations, and obtain more optimization opportunities to improve the execution efficiency of source code. However, through inlining, the inline optimization module will try to replace all called functions during the source code compilation process. However, if the function body of the called function is large and is frequently called in multiple locations, it will cause a significant increase in the source code volume and cause source code expansion. This may result in a decrease in the operating efficiency of the application.

[0035] In the compilation method, device, electronic device and storage medium provided in the embodiments of the present application, when compiling the first source code of the first application, the electronic device performs function inlining on the first source code and the function body corresponding to the first function to generate the second source code only when it is determined that the calling frequency of the first function in the first source code is greater than or equal to the first threshold, that is, when it is determined that the first function is a frequently called function, thereby reducing the number of times the first application performs function inlining and avoiding a substantial increase in the source code volume of the first application. This improves the operating efficiency of the application.

[0036] The execution subject of the compilation method provided in the embodiment of the present application may be a compilation device, and the compilation device may be an electronic device, or a functional module or entity in an electronic device. The technical solution provided in the embodiment of the present application is described below using an electronic device as an example.

[0037] The present application embodiment provides a compilation method. Figure 1 A flowchart of a compilation method provided by an embodiment of the present application is shown, and the method can be applied to electronic devices. Figure 1 As shown, the compilation method provided in the embodiment of the present application may include the following steps 201 and 202.

[0038] Step 201: When compiling a first source code of a first application, the electronic device obtains a first function identifier.

[0039] In an embodiment of the present application, the above-mentioned first function identifier is used to indicate the first function in the first source code.

[0040] In some embodiments of the present application, the first application may be any one of the following: a communication application, a payment application, a shopping application, a reading application, a video application, etc. The embodiments of the present application do not limit this.

[0041] In some embodiments of the present application, the first source code may be a source code corresponding to any source code segment in the application source code of the first application, and each source code segment corresponds to a function.

[0042] In some embodiments of the present application, the first function may be an inline function.

[0043] In some embodiments of the present application, the first function identifier may be a unique identifier of the first function, that is, the address of the function in the memory.

[0044] It should be noted that the source code in the embodiments of the present application can be understood as code, which is not limited in the embodiments of the present application.

[0045] Step 202: When the first function identifier matches any one of the at least one second function identifier, the electronic device inlines the first source code and the function body corresponding to the first function to generate a second source code.

[0046] In an embodiment of the present application, the second function identifier is used to indicate a function in the first application whose calling frequency is greater than or equal to a first threshold.

[0047] In some embodiments of the present application, the second function identifier may be a unique identifier of the function.

[0048] In some embodiments of the present application, the calling frequency of a function is greater than or equal to a first threshold, which can be understood as the function is often called.

[0049] In some embodiments of the present application, the electronic device may first determine whether the first function identifier matches any one of at least one second function identifier, and then, when the first function identifier matches any one of at least one second function identifier, the electronic device may inline the first source code and the function body corresponding to the first function to generate a second source code.

[0050] In some embodiments of the present application, the electronic device determines whether a first function identifier matches any one of at least one second function identifier, which can be understood as: the electronic device determines whether the calling frequency of the first function indicated by the first function identifier is greater than or equal to a first threshold, that is, determines whether the first function is frequently called.

[0051] In some embodiments of the present application, the electronic device may compare the first function identifier with at least one second function identifier to determine whether the first function identifier matches any one of the at least one second function identifier.

[0052] It can be understood that since the second function identifier is used to indicate a function in the first application whose calling frequency is greater than or equal to the first threshold, when the first function identifier matches any one of at least one second function identifier, the calling frequency of the first function indicated by the first function identifier is also greater than or equal to the first threshold, and therefore it can be determined that the first function is frequently called.

[0053] In some embodiments of the present application, Figure 1 ,like Figure 2 As shown, before the above step 201, the compilation method provided in the embodiment of the present application also includes the following step 301.

[0054] Step 301: The electronic device obtains a configuration file of a first application.

[0055] In an embodiment of the present application, the above configuration file includes at least one second function identifier.

[0056] In some embodiments of the present application, the above configuration file may be a profile file.

[0057] In some embodiments of the present application, the electronic device determining whether the first function identifier matches any one of the at least one second function identifier can also be understood as: the electronic device determining whether the first function identifier exists in the configuration file.

[0058] In some embodiments of the present application, the electronic device may record in the configuration file the functions in the first application whose calling frequency is greater than or equal to the first threshold.

[0059] In some embodiments of the present application, the function whose calling frequency indicated by the second function identifier is greater than or equal to the first threshold may be at least one of the following: a function called when the first application is started, and a function called when the first application is run.

[0060] In some embodiments of the present application, when the first application is started, the electronic device can record the function called when the first application is started, and then record the function identifier in a configuration file when the number of function calls is greater than or equal to a first threshold.

[0061] In some embodiments of the present application, when running a first application, the electronic device may record a function called when running the first application, and then record a function identifier in a configuration file when the number of function calls is greater than or equal to a first threshold.

[0062] In this way, since the electronic device can record the functions in the first application whose calling frequency is greater than or equal to the first threshold in the configuration file, it can determine whether the calling frequency of the first function is greater than or equal to the first threshold by comparing the first function identifier with at least one second function identifier in the configuration file, that is, determine whether the first function is a commonly used function, and then perform inline optimization if the first function is a commonly used function, thereby reducing the number of times the first application performs function inlining, avoiding a substantial increase in the source code volume of the first application, and thus improving the operating efficiency of the application.

[0063] In some embodiments of the present application, the electronic device may call TryInlineAndReplace to perform function inlining on the first source code and the function body corresponding to the first function to generate a second source code.

[0064] In some embodiments of the present application, the electronic device can find the function body of the first function through the first function identifier, so as to inline the first source code and the function body corresponding to the first function to generate the second source code.

[0065] In some embodiments of the present application, the electronic device performs function inlining on the first source code and the function body corresponding to the first function, which can be understood as the electronic device replacing the function body of the first function with the calling source code.

[0066] In some embodiments of the present application, when the first function identifier does not match at least one second function identifier, the electronic device does not perform function inlining.

[0067] It can be understood that since the second function identifier is used to indicate a function in the first application whose calling frequency is greater than or equal to the first threshold, when the first function identifier does not match at least one second function identifier, the calling frequency of the first function indicated by the first function identifier is lower, that is, the first function is not called frequently, and therefore the electronic device may not perform function inlining.

[0068] In some embodiments of the present application, Figure 3 As shown, it is a flowchart of an electronic device performing inline optimization on a first source code of a first application, including the following steps S1 to S5.

[0069] S1. When compiling a first source code of a first application, the electronic device obtains a unique identifier of a first function.

[0070] S2. Obtain a configuration file of the first application, and obtain a unique identifier of at least one function whose calling frequency is greater than or equal to a first threshold.

[0071] S3. The electronic device determines whether the unique identifier of the first function matches any one of the at least one unique identifier included in the configuration file.

[0072] If the unique identifier of the first function matches any one of the at least one unique identifier included in the configuration file, the electronic device executes step S4; if the unique identifier of the first function does not match any one of the at least one unique identifier included in the configuration file, the electronic device executes step S5;

[0073] S4. The electronic device inlines the first source code and the function body corresponding to the first function to generate a second source code.

[0074] S5. The electronic device determines that the inline optimization of the first function is completed.

[0075] It should be noted that for the relevant description of step S1 to step S5, reference can be made to the contents of the above embodiment, which will not be repeated here.

[0076] In some embodiments of the present application, the electronic device compiles the first source code of the first application including the following five examples:

[0077] Example 1: When the electronic device compiles the first source code of the first application, it first determines whether the first function is a static function or a directly called function (IsInvokeStaticOrDirect). When the first function is a static function or a directly called function, the electronic device can determine whether the calling frequency of the first function is greater than or equal to a first threshold. Then, when the calling frequency of the first function is greater than or equal to the first threshold, the electronic device can inline the first source code and the function body corresponding to the first function to generate a second source code.

[0078] In some embodiments of the present application, when the first function is a static function or a directly called function, the electronic device can directly obtain the first function identifier through the GetResolved method to determine whether the calling frequency of the first function is greater than or equal to the first threshold.

[0079] In this way, after determining that the first function is a static function or a directly called function, the electronic device adds a judgment on the heat value (i.e., the calling frequency) of the first function. If the heat value of the first function is not high, the function inlining operation is not performed. If the heat value of the first function is high, the function inlining operation is performed on it. Therefore, compared with the related art, the method of directly performing the function inlining operation on the first function after determining that the first function is a static function or a directly called function reduces the number of times the first application performs function inlining, avoids a substantial increase in the source code volume of the first application, and thus improves the operating efficiency of the application.

[0080] Example 2: When the first function is not a static function or a directly called function, the electronic device can determine whether the first function is a virtualized call, and then when the first function is a virtualized call, the electronic device can determine whether the calling frequency of the first function is greater than or equal to a first threshold, and then when the calling frequency of the first function is greater than or equal to the first threshold, the electronic device can inline the first source code and the function body corresponding to the first function to generate a second source code.

[0081] In some embodiments of the present application, when the first function is a virtualized call, the electronic device may obtain the first function identifier through Class Hierarchy Analysis (CHA) to determine whether the calling frequency of the first function is greater than or equal to a first threshold.

[0082] In some embodiments of the present application, the electronic device may call the function TryInlineFromCHA to obtain the first function identifier.

[0083] In some embodiments of the present application, the electronic device may call TryInlineAndReplace to inline the first source code and the function body corresponding to the first function.

[0084] In some embodiments of the present application, the electronic device may use AddCHAGuard to perform deoptimization judgment and processing.

[0085] In this way, after determining that the first function is a virtualization call, the electronic device adds a judgment on the heat value of the first function. If the heat value of the first function is not high, the function inline operation is not performed. If the heat value of the first function is high, the function inline operation is performed on it. Therefore, compared with the related technology, the method of directly performing a function inline operation on the first function after determining that the first function is a virtualization call reduces the number of times the first application performs function inlining, avoids a substantial increase in the source code volume of the first application, and thus improves the operating efficiency of the application.

[0086] Example three, when the first function is not a static function or a directly called function, and the first function is not a virtualized call, the electronic device can determine whether the first function exists in an inline cache area (InlineCache). When the first function exists in the inline cache area, the electronic device can determine whether the calling frequency of the first function is greater than or equal to a first threshold. Then, when the calling frequency of the first function is greater than or equal to the first threshold, the electronic device can inline the first source code and the function body corresponding to the first function to generate a second source code.

[0087] In some embodiments of the present application, when the first function exists in the inline cache area, the electronic device can determine whether the first function is monomorphic or polymorphic. When the first function is monomorphic, TryInlineMonomorphicCall is called to obtain the first function identifier; when the first function is polymorphic, TryInlinePolymorphicCallToSameTarget is called to obtain the first function identifier to determine whether the calling frequency of the first function is greater than or equal to the first threshold.

[0088] In some embodiments of the present application, the electronic device may call the function TryInlineFromInlineCache to obtain the first function identifier.

[0089] In some embodiments of the present application, when the first function is monomorphic (TryInlineMonomorphicCall), the electronic device can obtain class_index through FindClassIndexIn, and then obtain monomorphic_type through GetMonomorphicType(classes), and then obtain the function identifier of the actual called function through the Resolve method FromInlineCache(monomorphic_type, invoke_instruction, pointer_size).

[0090] In some embodiments of the present application, when the first function is polymorphic (TryInlinePolymorphicCall), the processing is divided into two cases. First, TryInlinePolymorphicCallToSameTarget is called to handle the situation of multiple invokes of the same method. Here, the actual real function and the function identifier of the real function being called are found by traversing various types, and then a judgment is made. The remaining processing of multiple invokes of different methods is also to traverse various corresponding types to find the actual real function and the function identifier of the real function being called.

[0091] In this way, after determining that the first function exists in the inline cache area, the electronic device adds a judgment on the heat value of the first function. If the heat value of the first function is not high, the function inline operation is not performed. If the heat value of the first function is high, the function inline operation is performed on it. Therefore, compared with the related art, the method of directly performing function inline operation on the first function after determining that the first function exists in the inline cache area reduces the number of times the first application performs function inlining, avoids a substantial increase in the source code volume of the first application, and thus improves the operating efficiency of the application.

[0092] In some embodiments of the present application, Figure 4 As shown, it is a flowchart of an electronic device performing inline optimization on a first source code of a first application, including the following steps S11 to S19:

[0093] S11. The electronic device determines whether the first function is a static function or a directly called function.

[0094] When the first function is a static function or a directly called function, execute steps S12 and S13; when the first function is not a static function or a directly called function, execute step S14;

[0095] S12: The electronic device directly obtains a first function identifier.

[0096] S13: The electronic device determines a calling frequency of the first function, and when the calling frequency of the first function is greater than or equal to a first threshold, the electronic device performs inline optimization.

[0097] S14: The electronic device determines whether the first function is a virtualization call.

[0098] When the first function is a virtualized call, execute steps S15 and S13; when the first function is not a virtualized call, execute step S16;

[0099] S15. The electronic device obtains a first function identifier through CHA.

[0100] S16. The electronic device determines whether the first function exists in the inline cache area.

[0101] When the first function exists in the InlineCache, step S17 is executed; when the first function does not exist in the InlineCache, the process ends;

[0102] S17. The electronic device determines whether the first function is monomorphic or polymorphic.

[0103] When the first function is monomorphic, steps S18 and S13 are executed; when the first function is polymorphic, steps S19 and S13 are executed;

[0104] S18. The electronic device calls TryInlineMonomorphicCall to obtain a first function identifier.

[0105] S19. The electronic device calls TryInlinePolymorphicCallToSameTarget to obtain a first function identifier.

[0106] It should be noted that for the relevant description of step S11 to step S19, reference can be made to the contents of the above embodiment, which will not be repeated here.

[0107] Example 4, in combination with Example 1, when the first function is a static function or a directly called function, and the calling frequency of the first function is greater than or equal to a first threshold, when the electronic device inlines the first source code and the function body corresponding to the first function, if the function inlining fails, the electronic device can determine whether the first function is a virtualization call. When the first function is a virtualization call, the electronic device can obtain the first function identifier through CHA, and then re-determine whether the calling frequency of the first function is greater than or equal to the first threshold. Then, when the calling frequency of the first function is greater than or equal to the first threshold, the first source code and the function body corresponding to the first function are inlined to generate a second source code.

[0108] It can be understood that the failure of the electronic device to execute function inlining indicates that it is wrong to directly obtain the first function identifier through the GetResolved method. Therefore, the electronic device can determine whether the first function is a virtualization call. When the first function is a virtualization call, the electronic device can obtain the first function identifier again through CHA to determine whether the calling frequency of the first function is greater than or equal to the first threshold. Then, when the calling frequency of the first function is greater than or equal to the first threshold, the first source code and the function body corresponding to the first function are inlined to generate a second source code.

[0109] Example 5, in combination with Example 4, when the first function is a static function or a directly called function, and the calling frequency of the first function is greater than or equal to the first threshold, the electronic device inlines the first source code and the function body corresponding to the first function, but the function inlining fails. Then, when the first function is a virtualized call and it is determined that the calling frequency of the first function is greater than or equal to the first threshold, the electronic device inlines the first source code and the function body corresponding to the first function, but the function inlining fails again, the electronic device can determine whether the first function exists in the inline cache area. When the first function exists in the inline cache area, the electronic device can determine whether the first function is monomorphic or polymorphic. When the first function is monomorphic, TryInlineMonomorphicCall is called to obtain the first function identifier again; when the first function is polymorphic, TryInlinePolymorphicCallToSameTarget is called to obtain the first function identifier again to determine whether the calling frequency of the first function is greater than or equal to the first threshold. Then, when the calling frequency of the first function is greater than or equal to the first threshold, the first source code and the function body corresponding to the first function are inlined to generate a second source code.

[0110] It can be understood that the failure of the electronic device to execute function inlining indicates that the first function identifier obtained through CHA is incorrect. Therefore, the electronic device can determine whether the first function exists in the inline cache area. When the first function exists in the inline cache area, the electronic device can re-obtain the first function identifier to re-determine whether the calling frequency of the first function is greater than or equal to the first threshold. Then, when the calling frequency of the first function is greater than or equal to the first threshold, the first source code and the function body corresponding to the first function are inlined to generate a second source code.

[0111] In this way, after the function inlining fails, the electronic device can re-obtain the first function identifier through other means and re-judge the heat value of the first function. If the heat value of the first function is not high, the function inlining operation is not performed. If the heat value of the first function is high, the function inlining operation is performed on it. Therefore, compared with the related technology, after the function inlining fails, the method of directly performing the function inlining operation on the first function after obtaining the first function identifier through other means reduces the number of times the first application performs function inlining, avoids a substantial increase in the source code volume of the first application, and thus improves the operating efficiency of the application.

[0112] In some embodiments of the present application, before the above-mentioned step 201, the electronic device may determine the compilation mode of the first application. When it is determined that the compilation mode of the first application is the speed-profile compilation mode, the electronic device starts to execute step 201, that is, starts to execute the inline optimization solution of the present application.

[0113] In some embodiments of the present application, the compilation mode of the first application may also be the compilation mode of the framework corresponding to the first application, which is not limited in the embodiments of the present application.

[0114] In some embodiments of the present application, when it is determined that the compilation mode of the first application is the speed compilation mode, the electronic device does not need to execute the inline optimization solution of the present application.

[0115] It can be understood that when the compilation mode of the first application is the speed compilation mode, the source code of the first application is fully compiled and does not need to call functions, so there is no need to execute the inline optimization solution of the present application.

[0116] In some embodiments of the present application, before determining the compilation mode of the first application, the electronic device may first set a mutex to synchronize access to certain data structures, and then determine the compilation mode of the first application.

[0117] In some embodiments of the present application, before the above step 201, the compiling method provided by the embodiment of the present application further includes the following step 401. In addition, the "electronic device inlines the first source code and the function body corresponding to the first function" in the above step 202 can be specifically implemented by the following step 202a.

[0118] Step 401: The electronic device determines a first value.

[0119] In an embodiment of the present application, the above-mentioned first value is the maximum number of function inline instructions corresponding to the first application.

[0120] In some embodiments of the present application, the above-mentioned maximum number of function inline instructions can also be understood as: the maximum number of function inline times, that is, the maximum number of times the electronic device can execute function inlining when compiling the source code of the first application.

[0121] In some embodiments of the present application, the above step 401 can be specifically implemented through the following step 401a.

[0122] Step 401a: The electronic device determines a first value according to the first information.

[0123] In an embodiment of the present application, the first information includes information for indicating at least one of the following: a computing capability of the electronic device, a usage frequency of the first application, and a number of at least one second function identifier.

[0124] In some embodiments of the present application, the electronic device may determine the computing capability of the electronic device based on the processor type of the electronic device.

[0125] In some embodiments of the present application, the processor type of the electronic device includes any of the following: high-end type, mid-end type, and low-end type.

[0126] It can be understood that the higher the level of the processor type of an electronic device, the stronger the computing power of the electronic device.

[0127] In some embodiments of the present application, the first information is used to indicate the computing capability of the electronic device and the usage frequency of the first application; the step 401a can be specifically implemented through the following step 401a1.

[0128] Step 401a1: The electronic device determines a first value according to the computing capability of the electronic device and the usage frequency of the first application.

[0129] In an embodiment of the present application, the computing capability of the electronic device and the usage frequency of the first application are positively correlated with the first value.

[0130] It can be understood that the stronger the computing power of the electronic device is, the larger the first value is; and the higher the frequency of use of the first application is, the larger the first value is.

[0131] In some embodiments of the present application, the electronic device may determine a first range corresponding to the computing power of the electronic device, and then when the usage frequency of the first application is greater than or equal to a second threshold, add the second value to the first adjustment value to obtain the above-mentioned first value.

[0132] Exemplarily, the computing capabilities of the electronic device are different, and the corresponding first ranges are also different. The stronger the computing capability of the electronic device is, the larger the upper limit value of the corresponding first range is.

[0133] Exemplarily, when the usage frequency of the first application is greater than or equal to the second threshold, the first application is a frequently used application.

[0134] Exemplarily, the second numerical value may be a median value of the first range.

[0135] Exemplarily, the first adjustment value may be a first preset value, and the first adjustment value is an adjustment value corresponding to the usage frequency of the first application.

[0136] For example: assuming that the first range corresponding to the computing power of the electronic device is (512, 1024), the median value of the first range is 768 (that is, the second value mentioned above), and the first adjustment value is 100; when the usage frequency of the first application is greater than the second threshold, the electronic device can determine that the first value is: 768+100=868.

[0137] In some embodiments of the present application, when the usage frequency of the first application is less than the second threshold, the electronic device may subtract the second value from the first adjustment value to obtain the above-mentioned first value.

[0138] In some embodiments of the present application, the first value is within a first range.

[0139] In some embodiments of the present application, when the value obtained after adding the first adjustment value to the second value exceeds the upper limit of the first range, the electronic device may use the upper limit of the first range as the first value.

[0140] In some embodiments of the present application, when the value obtained after subtracting the second value from the first adjustment value does not exceed the lower limit of the first range, the electronic device may use the lower limit of the first range as the first value.

[0141] In some embodiments of the present application, the first information is used to indicate the number of at least one second function identifier; the step 401a can be specifically implemented by the following step 401a2.

[0142] Step 401a2: The electronic device determines a first value according to the number of at least one second function identifier.

[0143] In an embodiment of the present application, the number of the at least one second function identifier is positively correlated with the first numerical value.

[0144] It can be understood that the greater the number of the at least one second function identifier, the greater the first value.

[0145] In some embodiments of the present application, after obtaining the number of the second function identifier, the electronic device can search the storage table, and then use the numerical value corresponding to the number stored in the storage table as the above-mentioned first numerical value.

[0146] In some embodiments of the present application, the electronic device may pre-set a corresponding relationship between the number of second function identifiers and the first numerical value, and store the corresponding relationship in a storage table.

[0147] In some embodiments of the present application, the first information is used to indicate: the computing capability of the electronic device, the usage frequency of the first application, and the number of at least one second function identifier. The step 401a can be specifically implemented by the following step 401a3.

[0148] Step 401a3: The electronic device determines a first value according to the computing capability of the electronic device, the usage frequency of the first application, and the number of at least one second function identifier.

[0149] In some embodiments of the present application, the electronic device may determine a first range corresponding to the computing power of the electronic device, and then when the usage frequency of the first application is greater than or equal to a second threshold, add the second value to the first adjustment value to obtain a third value, and then when the number of at least one second function identifier is greater than or equal to the third threshold, add the third value to the second adjustment value to obtain the above-mentioned first value.

[0150] In some embodiments of the present application, the second adjustment value may be a second preset value, and the second adjustment value is an adjustment value corresponding to the number of the second function identifier.

[0151] Exemplarily, the first preset value and the second preset value may be the same or different.

[0152] For example: assuming that the first range corresponding to the computing power of the electronic device is (512, 1024), the median value of the first range is 768 (i.e., the second value mentioned above), the first adjustment value is 100, and the second adjustment value is 50; when the usage frequency of the first application is greater than the second threshold, the electronic device can determine that the third value is: 768+100=868, and then when the number of at least one second function identifier is greater than the third threshold, the electronic device can determine that the first value is 868+50=918.

[0153] In some embodiments of the present application, when the usage frequency of the first application is less than a second threshold, the electronic device may subtract the second value from the first adjustment value to obtain a fourth value, and then when the number of at least one second function identifier is less than a third threshold, the electronic device may subtract the fourth value from the second adjustment value to obtain the above-mentioned first value.

[0154] In some embodiments of the present application, when the usage frequency of the first application is greater than or equal to a second threshold, the electronic device may add the second value to the first adjustment value to obtain a third value, and then when the number of at least one second function identifier is less than the third threshold, the electronic device may subtract the third value from the second adjustment value to obtain the above-mentioned first value.

[0155] In some embodiments of the present application, when the usage frequency of the first application is less than a second threshold, the electronic device may subtract the second value from the first adjustment value to obtain a fourth value, and then when the number of at least one second function identifier is greater than a third threshold, the electronic device may add the fourth value to the second adjustment value to obtain the above-mentioned first value.

[0156] In some embodiments of the present application, the first value is within a first range.

[0157] In some embodiments of the present application, when a first value calculated by an electronic device exceeds an upper limit value of a first range, the electronic device may use the upper limit value of the first range as the first value.

[0158] In some embodiments of the present application, when the first numerical value calculated by the electronic device does not exceed the lower limit of the first range, the electronic device may use the lower limit of the first range as the first numerical value.

[0159] It should be noted that in the embodiment of the present application, after determining the first range, it is only illustrated by first determining whether the usage frequency of the first application is greater than or equal to the second threshold, and then determining whether the number of at least one second function identifier is greater than or equal to the third threshold. After determining the first range, the electronic device may also first determine whether the number of at least one second function identifier is greater than or equal to the third threshold, and then determine whether the usage frequency of the first application is greater than or equal to the second threshold. The embodiment of the present application is not limited to this.

[0160] In some embodiments of the present application, Figure 5 As shown, it is a flowchart for an electronic device to determine the maximum number of function inline instructions corresponding to a first application, including the following steps S21 to S29.

[0161] S21. The electronic device determines a processor type of the electronic device.

[0162] S22. The electronic device determines a first range corresponding to the processor type.

[0163] S23, the electronic device determines whether the first application is a commonly used application;

[0164] When the electronic device determines that the first application is a commonly used application, steps S24 and S26 are executed; when the electronic device determines that the first application is not a commonly used application, steps S25 and S26 are executed;

[0165] S24, the electronic device increases the number of function inline instructions corresponding to the first application;

[0166] S25, the electronic device reduces the number of inline function instructions corresponding to the first application;

[0167] S26. The electronic device determines whether the number of at least one second function identifier is greater than a third threshold;

[0168] When the number of at least one second function identifier is greater than the third threshold, executing step S27, and when the number of at least one second function identifier is less than the third threshold, executing step S28;

[0169] S27, the electronic device increases the number of inline function instructions corresponding to the first application;

[0170] S28, the electronic device reduces the number of inline function instructions corresponding to the first application;

[0171] S29. The electronic device obtains a maximum number of function inline instructions corresponding to the first application.

[0172] It should be noted that for the relevant description of steps S21 to S29, reference can be made to the contents of the above embodiments, which will not be repeated here.

[0173] Step 202a: When the first instruction number is less than the first value, the electronic device inlines the first source code and the function body corresponding to the first function.

[0174] In an embodiment of the present application, the first number of instructions is: the number of instructions for inlining the source code of the first application and the function body corresponding to the function.

[0175] It can be understood that when the electronic device compiles the first source code of the first application, it can first determine whether the number of instructions for inlining the source code of the first application and the function body corresponding to the function exceeds the maximum number of function inlining instructions corresponding to the first application. If it does not exceed, the first source code and the function body corresponding to the first function are inlined; if it exceeds, the inline optimization is not performed.

[0176] In this way, since the electronic device can determine the maximum number of function inline instructions suitable for the application based on information such as the processor type, whether it is a commonly used application, and the number of functions with higher calling frequency in the configuration file, compared with the related art, the maximum number of function inline instructions corresponding to all applications is the same. When applications with larger volumes (for example, configuration files exceeding 200KB and application volumes exceeding 200MB) are compiled using the same maximum number of function inline instructions, the source code volume will increase significantly. The present application can determine the maximum number of function inline instructions suitable for the application, thereby avoiding a significant increase in the source code volume. At the same time, as the source code volume is reduced, the memory used when the application is running will also be reduced, thereby improving the running smoothness, reducing the application compilation power consumption, and improving the battery life.

[0177] The compilation method provided in the embodiment of the present application, when compiling the first source code of the first application, the electronic device performs function inlining on the first source code and the function body corresponding to the first function to generate the second source code only when it determines that the calling frequency of the first function in the first source code is greater than or equal to the first threshold, that is, when it determines that the first function is a frequently called function, thereby reducing the number of times the first application performs function inlining and avoiding a substantial increase in the source code volume of the first application. Thus, the running efficiency of the application is improved.

[0178] It should be noted that the compilation method provided in the embodiment of the present application can be executed by a compilation device. In the embodiment of the present application, the compilation device provided in the embodiment of the present application is described by taking the compilation method executed by the compilation device as an example.

[0179] It should be noted that the above-mentioned method embodiments, or various possible implementation methods in each method embodiment, can be executed separately, or, under the premise that there is no contradiction, can also be executed in combination with each other. The specific implementation can be determined according to actual usage requirements, and the embodiments of the present application do not limit this.

[0180] Figure 6 A possible structural diagram of a compiling device involved in an embodiment of the present application is shown. Figure 6 As shown, the compiling device 70 may include: an acquisition module 71 and a processing module 72 .

[0181] The acquisition module 71 is used to acquire a first function identifier when compiling a first source code of a first application, where the first function identifier is used to indicate a first function in the first source code.

[0182] The processing module 72 is used to inline the first source code and the function body corresponding to the first function to generate a second source code when the first function identifier obtained by the acquisition module 71 matches any one of at least one second function identifier; wherein the second function identifier is used to indicate a function in the first application whose calling frequency is greater than or equal to the first threshold.

[0183] The embodiment of the present application provides a compiling device, because when compiling the first source code of the first application, the electronic device performs function inlining on the first source code and the function body corresponding to the first function to generate the second source code only when it determines that the calling frequency of the first function in the first source code is greater than or equal to the first threshold, that is, when it determines that the first function is a frequently called function, thereby reducing the number of times the first application performs function inlining and avoiding a substantial increase in the source code volume of the first application. Thus, the running efficiency of the application is improved.

[0184] In one possible implementation, the acquisition module 71 is also used to inline the first source code and the function body corresponding to the first function when the first function identifier matches any one of at least one second function identifier in the processing module 72, and obtain a configuration file of the first application before generating the second source code, the configuration file including at least one second function identifier.

[0185] In a possible implementation, the compilation device 70 provided in the embodiment of the present application further includes: a determination module; the determination module is used to determine a first value before the acquisition module 71 acquires the first function identifier, the first value being the maximum number of function inline instructions corresponding to the first application. The processing module 72 is specifically used to inline the first source code and the function body corresponding to the first function when the first instruction number is less than the first value determined by the determination module 72; wherein the first instruction number is: the number of instructions for inlining the source code of the first application and the function body corresponding to the function.

[0186] In a possible implementation, the determination module is specifically used to determine a first value based on first information; wherein the first information includes information for indicating at least one of the following: computing power of the electronic device, frequency of use of the first application, and the number of at least one second function identifier.

[0187] In one possible implementation, the first information is used to indicate the computing power of the electronic device and the frequency of use of the first application; the determination module 72 is specifically used to determine the first value based on the computing power of the electronic device and the frequency of use of the first application; wherein the computing power of the electronic device and the frequency of use of the first application are positively correlated with the first value.

[0188] In one possible implementation, the first information is used to indicate the number of at least one second function identifier; the determination module 72 is specifically used to determine the first numerical value based on the number of at least one second function identifier; wherein the number of at least one second function identifier is positively correlated with the first numerical value.

[0189] The compiling device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (Augmented Reality, AR) / virtual reality (Virtual Reality, VR) device, a robot, a wearable device, a super mobile personal computer (Ultra-Mobile Personal Computer, UMPC), a netbook or a personal digital assistant (Personal Digital Assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (Personal Computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.

[0190] The compiling device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0191] The compilation device provided in the embodiment of the present application can implement each process implemented in the above method embodiment, and will not be described again here to avoid repetition.

[0192] Alternatively, if Figure 7 As shown, an embodiment of the present application also provides an electronic device 900, including a processor 901 and a memory 902, wherein the memory 902 stores programs or instructions that can be executed on the processor 901, and when the program or instructions are executed by the processor 901, the various steps of the above-mentioned method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, they are not described here.

[0193] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0194] Figure 8 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.

[0195] The electronic device 100 includes but is not limited to components such as a radio frequency unit 101, a network module 102, an audio output unit 103, an input unit 104, a sensor 105, a display unit 106, a user input unit 107, an interface unit 108, a memory 109, and a processor 110.

[0196] Those skilled in the art will appreciate that the electronic device 100 may also include a power source (such as a battery) for supplying power to various components, and the power source may be logically connected to the processor 110 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 8 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.

[0197] Among them, the processor 110 is used to obtain a first function identifier when compiling a first source code of a first application, and the first function identifier is used to indicate a first function in the first source code; and when the first function identifier matches any one of at least one second function identifier, the first source code and the function body corresponding to the first function are inlined to generate a second source code; wherein the second function identifier is used to indicate a function in the first application whose calling frequency is greater than or equal to a first threshold;.

[0198] The embodiment of the present application provides an electronic device, which generates a second source code by inlining the first source code and the function body corresponding to the first function when compiling the first source code of the first application, i.e., when determining that the calling frequency of the first function in the first source code is greater than or equal to the first threshold, i.e., determining that the first function is a frequently called function, thereby reducing the number of times the first application performs function inlining and avoiding a substantial increase in the source code volume of the first application. This improves the operating efficiency of the application.

[0199] In some embodiments of the present application, the processor 110 is further used to, when the first function identifier matches any one of at least one second function identifier, perform function inlining on the first source code and the function body corresponding to the first function, and before generating the second source code, obtain a configuration file of the first application, the configuration file including at least one second function identifier.

[0200] In some embodiments of the present application, the processor 110 is further used to determine a first value before obtaining the first function identifier, where the first value is a maximum number of function inline instructions corresponding to the first application.

[0201] The processor 110 is specifically used to inline the first source code and the function body corresponding to the first function when the first instruction number is less than the first value; wherein the first instruction number is: the number of instructions for inlining the source code of the first application and the function body corresponding to the function.

[0202] In some embodiments of the present application, the processor 110 is specifically used to determine a first numerical value based on first information; wherein the first information includes information for indicating at least one of the following: computing power of the electronic device, frequency of use of the first application, and the number of at least one second function identifier.

[0203] In some embodiments of the present application, the first information is used to indicate the computing power of the electronic device and the frequency of use of the first application; the processor 110 is specifically used to determine the first numerical value based on the computing power of the electronic device and the frequency of use of the first application; wherein the computing power of the electronic device and the frequency of use of the first application are positively correlated with the first numerical value.

[0204] In some embodiments of the present application, the first information is used to indicate the number of at least one second function identifier; the processor 110 is specifically used to determine the first numerical value based on the number of at least one second function identifier; wherein the number of at least one second function identifier is positively correlated with the first numerical value.

[0205] The electronic device provided in the embodiment of the present application can implement each process implemented in the above method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described here.

[0206] The beneficial effects of various implementations in this embodiment can be specifically referred to the beneficial effects of the corresponding implementations in the above method embodiment. To avoid repetition, they will not be described again here.

[0207] It should be understood that in the embodiment of the present application, the input unit 104 may include a graphics processor (Graphics Processing Unit, GPU) 1041 and a microphone 1042, and the graphics processor 1041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 106 may include a display panel 1061, and the display panel 1061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 107 includes a touch panel 1071 and at least one of other input devices 1072. The touch panel 1071 is also called a touch screen. The touch panel 1071 may include two parts: a touch detection device and a touch controller. Other input devices 1072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.

[0208] The memory 109 can be used to store software programs and various data. The memory 109 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 109 may include a volatile memory or a non-volatile memory, or the memory 109 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 109 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

[0209] The processor 110 may include one or more processing units; optionally, the processor 110 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 110.

[0210] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0211] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.

[0212] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0213] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0214] An embodiment of the present application provides a computer program / program product, which is stored in a storage medium. The program / program product is executed by at least one processor to implement the various processes of the above-mentioned method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described here.

[0215] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0216] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0217] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A compiling method, characterized in that: The method comprises: When compiling a first source code of a first application, obtaining a first function identifier, where the first function identifier is used to indicate a first function in the first source code; In a case where the first function identifier matches any one of at least one second function identifier, inlining the first source code and a function body corresponding to the first function to generate a second source code; The second function identifier is used to indicate a function in the first application whose calling frequency is greater than or equal to a first threshold.

2. The method according to claim 1, characterized in that When the first function identifier matches any one of the at least one second function identifier, inlining the first source code and the function body corresponding to the first function, before generating the second source code, the method further includes: A configuration file of the first application is obtained, where the configuration file includes at least one second function identifier.

3. The method according to claim 1, characterized in that Before obtaining the first function identifier, the method further includes: Determine a first value, where the first value is a maximum number of function inline instructions corresponding to the first application; The step of inlining the first source code and the function body corresponding to the first function includes: When the first instruction number is less than the first value, inlining the first source code and the function body corresponding to the first function; The first number of instructions is: the number of instructions for inlining the source code of the first application and the function body corresponding to the function.

4. The method according to claim 3, characterized in that The determining of the first value comprises: Determine the first value according to the first information; The first information includes information for indicating at least one of the following: the computing capability of the electronic device, the usage frequency of the first application, and the number of at least one second function identifier.

5. The method according to claim 4, characterized in that The first information is used to indicate the computing capability of the electronic device and the usage frequency of the first application; The determining the first value according to the first information includes: determining the first value according to the computing capability of the electronic device and the usage frequency of the first application; The computing capability of the electronic device and the usage frequency of the first application are positively correlated with the first value.

6. The method according to claim 4, characterized in that The first information is used to indicate the number of at least one second function identifier; The determining the first value according to the first information includes: determining the first value according to the number of at least one second function identifier; The number of the at least one second function identifier is positively correlated with the first value.

7. A compiling device, characterized in that: The device comprises: an acquisition module and a processing module; The acquisition module is used to acquire a first function identifier when compiling a first source code of a first application, where the first function identifier is used to indicate a first function in the first source code; The processing module is configured to, when the first function identifier obtained by the obtaining module matches any one of at least one second function identifier, perform function inlining on the first source code and a function body corresponding to the first function to generate a second source code; The second function identifier is used to indicate a function in the first application whose calling frequency is greater than or equal to a first threshold.

8. The device according to claim 7, characterized in that The device further includes: a determination module; the determination module is used to determine a first value before the acquisition module acquires the first function identifier, the first value being the maximum number of function inline instructions corresponding to the first application; The processing module is specifically configured to inline the first source code and the function body corresponding to the first function when the first instruction number is less than the first value determined by the determining module; The first number of instructions is: the number of instructions for inlining the source code of the first application and the function body corresponding to the function.

9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the compiling method according to any one of claims 1 to 6 are implemented.

10. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the compilation method according to any one of claims 1 to 6 are implemented.

11. A computer program product, characterized in that The computer program product is stored in a storage medium, and the program product is executed by at least one processor to implement the steps of the compilation method according to any one of claims 1 to 6.