Compiling method and device and computer readable storage medium

By using the grammatical tree during the compilation process to accurately determine the compilation unit, the problem of low resource utilization rate in existing technologies has been solved, and an efficient and real -time compilation process is achieved.

CN119376738AActive Publication Date: 2025-01-28ZHIXIE HUITONG (BEIJING) TECH CO LTD

Patent Information

Application Number
CN202411974948.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-01-28
Estimated Expiration
2044-12-30

AI Technical Summary

Technical Problem

In the prior art, the resource utilization rate during the compilation process is low, resulting in low compilation efficiency and difficult to meet the needs of high real-time.

Method used

By obtaining the grammar tree of the current source code, the syntax tree is traveled through the target node that determines the changes in the historical source code. The target compile unit is determined based on the target node, and precise compilation is performed to shrink the scope of compilation.

Benefits of technology

The more efficient resource use has been achieved, the compilation efficiency is improved, the compilation time is shortened, and the high -real -time needs are met.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119376738A_ABST
    Figure CN119376738A_ABST
Patent Text Reader

Abstract

The invention relates to a compiling method and device and a computer readable storage medium, and relates to the technical field of computers. The compiling method comprises the steps that a current syntax tree corresponding to a current source code is obtained, the current syntax tree comprises a sub-tree corresponding to each function unit in multiple function units of the current source code, each sub-tree comprises a father node and a sub-node, and the sub-nodes are determined based on context information of each function unit, the context information comprises parameter information of each functional unit and / or sub-operation in each functional unit; traversing the current syntax tree, and determining a target node, which is changed relative to a historical syntax tree corresponding to the historical source code, in the sub-tree from the father node and the sub-nodes; based on the target node, determining a target compiling unit in the plurality of function units; and compiling the current source code based on the target compiling unit to obtain a target code. According to the technical scheme, the resource utilization rate in the compiling process can be increased.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a compilation method, device and computer-readable storage medium. Background Art

[0002] In computer technology, compilation is the process in computer science of converting source code (such as a high-level programming language) into target code (such as machine code).

[0003] In the related art, regardless of whether the source code to be compiled is changed, the source code to be compiled is fully compiled, that is, the source code to be compiled is completely compiled from the beginning. Summary of the invention

[0004] The inventors of the present disclosure have discovered that the above-mentioned related technologies have the following problems: the utilization rate of resources during the compilation process is low.

[0005] In order to solve the above problems, the embodiments of the present disclosure provide the following solutions.

[0006] According to some embodiments of the present disclosure, a compilation method is provided, comprising: obtaining a current syntax tree corresponding to a current source code, the current syntax tree comprising a subtree corresponding to each of a plurality of functional units of the current source code, the subtree comprising a parent node and a child node, the child node being determined based on context information of each functional unit, the context information comprising parameter information of each functional unit and / or sub-operations within each functional unit; traversing the current syntax tree, determining from the parent node and the child node a target node in the subtree that has changed relative to a historical syntax tree corresponding to a historical source code; determining a target compilation unit among the plurality of functional units based on the target node; and compiling the current source code based on the target compilation unit to obtain a target code.

[0007] In some embodiments, determining the target compilation unit among the multiple functional units based on the target node includes: in response to the target node being the parent node, determining the functional unit corresponding to the subtree where the target node is located as the target compilation unit; or in response to the target node being the child node, determining the target compilation unit according to context information of the target node and the functional units corresponding to the subtree where the target node is located.

[0008] In some embodiments, determining the target compilation unit based on the context information of the target node and the functional unit corresponding to the subtree where the target node is located includes: in response to the target node being a child node determined based on parameter information of the functional unit corresponding to the subtree where the target node is located, determining the functional unit corresponding to the subtree where the target node is located as the target compilation unit; or in response to the target node being a child node determined based on a sub-operation within the functional unit corresponding to the subtree where the target node is located, determining the sub-operation corresponding to the target node as the target compilation unit.

[0009] In some embodiments, the parameter information of each functional unit includes data dependencies of each functional unit, and the compiling the current source code based on the target compilation unit includes: in response to the target node being a child node determined based on the data dependencies of the functional units corresponding to the subtree where the target node is located, determining a specified functional unit among the multiple functional units, and there is a logical dependency between the specified functional unit and the functional unit corresponding to the subtree where the target node is located; judging whether there is a syntax error in the current source code based on the data dependencies of the specified functional unit and the data dependencies of the functional units corresponding to the subtree where the target node is located; and in response to judging that there is no syntax error in the current source code, compiling the current source code based on the target compilation unit.

[0010] In some embodiments, the parameter information includes at least one of input information, output information and scope information of each functional unit.

[0011] In some embodiments, traversing the current syntax tree and determining, from the parent node and the child node, a target node in the child tree that has changed relative to a historical syntax tree corresponding to a historical source code includes: traversing the current syntax tree and determining a current hash value of the parent node; comparing the current hash value of the parent node with a historical hash value of the parent node in the historical syntax tree; and determining the target node from the parent node and the child node based on a result of the comparison.

[0012] In some embodiments, determining the target node from the parent node and the child node based on the result of the comparison includes: in response to the result of the comparison being that the current hash value of the parent node is different from the historical hash value of the parent node in the historical syntax tree, determining the parent node as the target node; or in response to the result of the comparison being that the current hash value of the parent node is the same as the historical hash value of the parent node in the historical syntax tree, determining the target node from the child node.

[0013] In some embodiments, determining the target node from the child node includes: comparing the current hash value of the child node with the historical hash value of the child node in the historical syntax tree, the current hash value of the child node being determined by traversing the current syntax tree; in response to the result of the comparison being that the current hash value of the child node is different from the historical hash value of the child node in the historical syntax tree, determining the child node as the target node.

[0014] In some embodiments, compiling the current source code based on the target compilation unit to obtain the target code includes: determining a designated compilation unit among the multiple functional units that has a logical dependency with the target compilation unit; compiling the target compilation unit and the designated compilation unit to obtain a new compiled code; and obtaining the target code based on the new compiled code.

[0015] In some embodiments, the compiling method further includes: storing the new compiled code in a cache area.

[0016] In some embodiments, obtaining the target code based on the new compiled code includes: detecting in the cache area existing compiled codes corresponding to other functional units among the multiple functional units except the target compiled unit and the designated compiled unit; and in response to detecting the existing compiled codes corresponding to the other functional units in the cache area, integrating the detected existing compiled codes and the new compiled code to obtain the target code.

[0017] In some embodiments, obtaining the target code based on the new compiled code includes: detecting existing compiled codes corresponding to other functional units among the multiple functional units except the target compiled unit and the designated compiled unit in the cache area; in response to not detecting the existing compiled codes corresponding to the other functional units in the cache area, compiling the other functional units to obtain other new compiled codes; and integrating the other new compiled codes and the new compiled code to obtain the target code.

[0018] In some embodiments, the cache area includes a first area and a second area; storing the newly compiled code in the cache area includes: storing a first result of the newly compiled code in the first area, and storing a second result of the newly compiled code in the second area, wherein the second result is calculated based on the first result.

[0019] In some embodiments, obtaining the target code based on the new compiled code includes: detecting in the second region a second result of the existing compiled code corresponding to other functional units among the multiple functional units except the target compiled unit and the designated compiled unit; in response to detecting the second result of the existing compiled code in the second region, integrating the detected second result of the existing compiled code and the new compiled code to obtain the target code; in response to not detecting the second result of the existing compiled code in the second region, detecting a first result of the existing compiled code in the first region; in response to detecting the first result of the existing compiled code in the first region, compiling the other functional units based on the first result of the existing compiled code to obtain other new compiled codes, and integrating the other new compiled codes with the new compiled code to obtain the target code.

[0020] In some embodiments, at least one or more functional units among the plurality of functional units are predefined functional units in a predefined functional unit library.

[0021] According to other embodiments of the present disclosure, a compiling device is provided, including: a memory; and a processor coupled to the memory, wherein the processor is configured to execute the compiling method in any one of the above embodiments based on instructions stored in the memory device.

[0022] According to some further embodiments of the present disclosure, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the compiling method in any of the above embodiments is implemented.

[0023] According to some further embodiments of the present disclosure, a computer program product is provided, comprising instructions, which, when executed by a processor, enable the processor to execute the compiling method according to any one of the above embodiments.

[0024] In the above embodiment, based on the current syntax tree corresponding to the current code, the target node that has changed in the subtree of the current syntax tree relative to the historical syntax tree can be determined from the parent node and the child node. Based on the target node, the target compilation unit is determined from multiple functional units of the current source code, and the current source code is compiled based on the determined target compilation unit to obtain the target code. In this way, by determining the target node from the subtree to determine the target compilation unit, the area where the current source code has changed relative to the historical source code can be accurately located within each functional unit, achieving smaller granularity difference detection, which helps to accurately narrow the compilation scope, not only improving compilation efficiency, but also improving resource utilization. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The accompanying drawings, which constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0026] The present disclosure can be more clearly understood from the following detailed description with reference to the accompanying drawings.

[0027] Figure 1 A flowchart showing some embodiments of the compilation method of the present disclosure.

[0028] Figure 2 A structural diagram of the current syntax tree of some embodiments of the present disclosure is shown.

[0029] Figure 3 Show Figure 1 Flowchart of some embodiments of step 140 in FIG.

[0030] Figure 4 Show Figure 1 Flowcharts of some other embodiments of step 140 in FIG.

[0031] Figure 5 A block diagram showing some embodiments of the compiling device of the present disclosure.

[0032] Figure 6 Block diagrams showing other embodiments of the compiling device of the present disclosure.

[0033] Figure 7 A block diagram showing some further embodiments of the compiling device of the present disclosure. DETAILED DESCRIPTION

[0034] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values ​​set forth in these embodiments do not limit the scope of the present disclosure unless otherwise specifically stated.

[0035] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.

[0036] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.

[0037] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.

[0038] In all examples shown and discussed herein, any specific values ​​should be interpreted as merely exemplary and not as limiting. Therefore, other examples of the exemplary embodiments may have different values.

[0039] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.

[0040] As mentioned above, in the related art, even if the source code to be compiled contains a large number of unchanged parts, the source code to be compiled is processed by full compilation. In this way, a large amount of resources will be wasted in the compilation process to reprocess the unchanged code, resulting in a waste of CPU resources during the compilation process, and further resulting in low resource utilization.

[0041] Embedded devices are widely used in scenarios such as autonomous driving, smart home, and industrial automation. In addition, these application scenarios usually have high requirements for the real-time performance, update efficiency, and operation stability of the algorithm. However, the full compilation method has great limitations in these application scenarios of embedded devices.

[0042] For example, in the scenario of autonomous driving, the obstacle detection algorithm deployed on the embedded device needs to update part of the algorithm logic in real time according to the changes in the environment. However, even if the logic of only one functional unit changes, the full compilation method requires the entire algorithm file to be fully parsed and compiled from scratch, resulting in a positive correlation between the compilation time and the overall size of the code, resulting in low compilation efficiency and difficulty in meeting high real-time requirements.

[0043] For example, in industrial automation scenarios, control algorithms deployed on embedded devices need to be dynamically optimized based on sensor data. However, on the one hand, the full compilation method cannot accurately locate the modified parts of the algorithm, resulting in the inability to quickly verify the effect of the algorithm optimization, which leads to low efficiency of algorithm optimization; on the other hand, in the full compilation method, the algorithm can only be updated after the system is suspended, which not only causes the system to be unable to respond to algorithm changes in a timely manner, resulting in insufficient dynamic performance of the algorithm, but also because the system cannot run continuously, resulting in low system operation stability.

[0044] In view of this, the present disclosure proposes a compilation technology solution, which can accurately locate the changed part of the current source code based on the syntax tree corresponding to the current source code, and then compile the current source code based on the changed part, thereby accurately narrowing the compilation scope, which not only improves the compilation efficiency, but also reduces the CPU resource consumption and improves resource utilization.

[0045] It should be noted that the compilation technology proposed in the present disclosure is applicable to various application scenarios of embedded devices. That is, the compilation technology proposed in the present disclosure can be used to compile the source code of various algorithms deployed on embedded devices (such as collision detection algorithms in autonomous driving scenarios), thereby improving the real-time performance of the algorithm and the operating stability of the system while improving resource utilization.

[0046] Figure 1 A flowchart showing some embodiments of the compilation method of the present disclosure.

[0047] like Figure 1 As shown, in step 110, a current syntax tree corresponding to the current source code is obtained.

[0048] Here, the current syntax tree includes a subtree corresponding to each of the multiple functional units of the current source code. The subtree may include a parent node and a child node. The child node is determined based on the context information of each functional unit, and the context information of each functional unit may include parameter information of each functional unit and / or a sub-operation within each functional unit.

[0049] In other words, the current syntax tree may represent the syntax structure of the current source code. The subtree corresponding to each functional unit may represent the syntax structure of the functional unit. The child nodes of each functional unit may include child nodes determined based on parameter information of the functional unit and / or child nodes determined based on sub-operations within the functional unit.

[0050] In some embodiments, by performing syntax parsing on the current source code, a current syntax tree corresponding to the current source code may be generated.

[0051] For example, by parsing the current source code, the grammatical logical dependencies between multiple functional units of the current source code, the operation type (also known as the task type) of each functional unit, and the context information of each functional unit can be determined. The grammatical logical dependencies between multiple functional units can be determined based on the input-output relationship between the multiple functional units. The operation type of each functional unit can be determined based on the functions that each functional unit can implement.

[0052] The parent node in the subtree corresponding to each functional unit can be determined based on the operation type of each functional unit. The child node in the subtree corresponding to each functional unit can be determined based on the context information of each functional unit. The connection relationship between multiple subtrees corresponding to multiple functional units can be determined based on the logical dependencies between multiple functional units.

[0053] In step 120, the current syntax tree is traversed to determine, from the parent nodes and the child nodes, a target node in the subtree that has changed relative to the historical syntax tree corresponding to the historical source code.

[0054] For example, the historical source code may be a historical version of the current source code. The historical syntax tree may represent the syntax structure of the historical source code. For example, the historical source code may be a source code of a previous compilation. The historical syntax tree may be a syntax tree generated during a previous compilation process and corresponding to the source code of the previous compilation.

[0055] In some embodiments, the current syntax tree can be traversed to determine the current hash values ​​of the parent node and the child node, and the target node in the subtree where the historical syntax tree changes can be determined based on the current hash values ​​of the parent node and the child node. The method of determining the target node will be further described below in conjunction with some embodiments.

[0056] In step 130 , a target compilation unit among the plurality of functional units is determined based on the target node.

[0057] For example, the target compilation unit among the multiple functional units may be determined accordingly according to whether the target node is a parent node or a child node.

[0058] It should be understood that the target node may reflect the changes of the current source code relative to the historical source code. The target compilation unit may include the relevant code of the changes of the current source code relative to the historical source code.

[0059] In step 140, the current source code is compiled based on the target compilation unit to obtain the target code.

[0060] In some embodiments, the current source code may be compiled based on the target compilation unit and the specified compilation unit having a logical dependency with the target compilation unit to obtain the target code. For example, the target code may be an executable code that can be directly executed by a machine.

[0061] In some embodiments, the compiled target code can be directly loaded into the runtime environment without restarting or interrupting the system, thereby improving the stability of system operation.

[0062] In the above embodiment, based on the current syntax tree corresponding to the current code, a target node in a subtree of the current syntax tree that has changed relative to the historical syntax tree can be determined from the parent node and the child node. Based on the target node, a target compilation unit is determined from multiple functional units of the current source code, and the current source code is compiled based on the determined target compilation unit to obtain the target code.

[0063] In this way, since the current syntax tree includes a subtree corresponding to each functional unit, and the subtree corresponding to each functional unit includes child nodes determined based on the context information of each functional unit, the current syntax tree can not only reflect the substructure of each functional unit in the syntax structure of the current source code, but also reflect the parameter information of each functional unit and / or the sub-operations within each functional unit.

[0064] Therefore, by determining the target node from the subtree of the current syntax tree to determine the target compilation unit, the area where the current source code has changed relative to the historical source code can be accurately located within each functional unit. In this way, small-granularity difference detection is achieved, and the compilation scope is accurately narrowed, which not only improves compilation efficiency, but also improves resource utilization.

[0065] In order to better understand the compilation technology solution proposed in the present disclosure, the syntax tree in the present disclosure is first schematically described in conjunction with some embodiments.

[0066] In some embodiments, the parameter information of each functional unit includes at least one of the input information, output information and scope information of each functional unit. For example, the parameter information of each functional unit may include the input information, output information and scope information of each functional unit. The subnode of each functional unit may include an input subnode determined based on the input information of the functional unit, an output subnode determined based on the output information of the functional unit, and a scope subnode determined based on the scope information of the functional unit.

[0067] In some embodiments, the parameter information of each functional unit may include the data dependency of each functional unit. The subnode of each functional unit may include a data dependency subnode determined based on the data dependency of the functional unit. For example, the data dependency may include the data on which the corresponding functional unit depends for execution.

[0068] It should be noted that in the present disclosure, the logical dependency between functional units refers to the dependency relationship determined based on the input-output relationship between the functional units (i.e., the grammatical dependency). The data dependency in the parameter information of the functional unit refers to the dependency of the functional unit on specific data determined based on the execution logic of the functional unit (i.e., the dependency in terms of data flow).

[0069] For example, by embedding specific data that the execution function unit depends on into a related field (such as the dependent_on field), the data dependency of the function unit can be reflected, so that the grammatical error can be judged based on the data dependency of the function unit and the logical dependency between the function units. The relevant implementation of judging the grammatical error will be further described in conjunction with some embodiments below.

[0070] In some embodiments, the parameter information of each functional unit may also include other parameter information required to execute the functional unit. The sub-nodes of each functional unit may also include other sub-nodes determined based on other parameter information.

[0071] For example, each functional unit in the current source code may correspond to a subtree in the current syntax tree, the operation type of each functional unit may correspond to a parent node in the subtree, and different attributes of each functional unit may correspond to different child nodes in the subtree.

[0072] Assume that the current source code includes two functional units, SignalService and Project. Some related codes are shown below.

[0073] SignalService:id=spool_0,output=x_4,input=`signal_queue`(signals=`msg_time,110,111,112,113,114,115,116,117`, frequency=`20hz`).

[0074] Project:id=spool_1,output=x_3,input=x_4(selects=`msg_time,110,111,112,113,114,115,116,117`).

[0075] Among them, SignalService is used to process the signals in the signal queue at a certain processing frequency. Project is used to take the processed signal output by SignalService as input and perform signal selection operations according to certain conditions.

[0076] Each functional unit can include one or more attributes of task type, task identifier, input, output, data dependency and sub-operation. For example, the task type of SignalService is type = "SignalService", the task identifier is id="spool_0", the input is input="ignal_queue", the output is output="x_4", and the data dependency can be described as dependent_on="msg_time,110,111,112,113,114,115,116,117".

[0077] It is understandable that each functional unit may further include other attributes corresponding to other parameter information. For example, SignalService may further include a frequency attribute corresponding to a frequency parameter, and the frequency attribute may be described as frequency="20hz".

[0078] Figure 2 A structural diagram of the current syntax tree of some embodiments of the present disclosure is shown.

[0079] like Figure 2 As shown, in the subtree S corresponding to SignalService, the parent node SignalService is determined based on the operation type (such as task type type = "SignalService"); the scope child node scope is determined based on the scope information (such as task identifier id="spool_0"); the input child node input is determined based on the input information (such as input="signal_queue"); the output child node output is determined based on the output information (such as output="x_4"); the data dependency child node Dependency is determined based on the data on which the execution of SignalService depends (such as dependent_on="msg_time,110,111,112,113,114,115,116,117"). In addition, the subtree corresponding to SignalService can also include other child nodes (such as frequency) determined based on other parameter information (such as frequency="20hz").

[0080] In the subtree P corresponding to Project, the parent node Project is determined based on the operation type (such as task type type = "Project"); the scope child node scope is determined based on the scope information (such as task identifier id="spool_1"); the input child node input is determined based on the input information (such as input=" x_4"); the output child node output is determined based on the output information (such as output=" x_3"); the data dependency child node Dependency is determined based on the data that the execution of Project depends on (such as dependent_on="msg_time,110,111,112,113,114,115,116,117"). Here, since Project also contains sub-operations selects, the subtree P corresponding to Project can also include operation child nodes selects determined based on sub-operations.

[0081] Since the input of Project is the output of SignalService, there is a logical dependency between Project and SignalService in terms of syntax. Therefore, based on this logical dependency, the subtree P corresponding to Project and the subtree S corresponding to SignalService can be connected. For example, Figure 2As shown, the subtree P corresponding to Project and the subtree S corresponding to SignalService can be connected through the parent node.

[0082] It can be seen that the syntax tree in the present disclosure can not only reflect the logical dependencies between functional units in terms of syntax, but also reflect the parameter information (such as input information, output information, scope information and data dependency) and sub-operation information of the functional unit itself.

[0083] In other words, the syntax tree in the present disclosure can combine the context information of each functional unit with the syntax structure between multiple functional units, so that the syntax tree can not only describe the static structure of the code, but also reflect the dynamic behavior of the program. Based on the syntax tree in the present disclosure, multi-dimensional difference detection can be achieved, thereby achieving accurate positioning of code changes, thereby supporting efficient incremental compilation.

[0084] In some embodiments, at least one or more of the multiple function units of the current source code may be predefined function units in a predefined function unit library. The predefined function unit library is also called an operator library, and the predefined function unit is also called an operator.

[0085] For example, one or more predefined functional units for implementing various functions (such as mathematical operations, logic control, data processing, etc.) may be predefined in a predefined functional unit library.

[0086] For example, the input, output, and execution logic of each operator in the operator library can be predefined. Taking the signal processing operator as an example, the input of the signal processing operator can be predefined as a signal queue, the output as a processed signal, and the execution logic as processing the signal in the signal queue at a certain processing frequency to output the processed signal.

[0087] In some embodiments, the current source code may be parsed according to a predefined functional unit library (ie, an operator library) to generate a current syntax tree corresponding to the current source code.

[0088] For example, through syntax parsing, the mapping relationship between each predefined functional unit (i.e., each operator) in the predefined functional unit library and the node of the current syntax tree can be determined. For example, SignalService is a signal processing operator (Signal Processing Operator), and based on the various properties of the operator, the operator is mapped to the parent node and child node in the subtree corresponding to SignalService. For another example, Project is a data processing operator (Data Processing Operator), and based on the various properties of the operator, the operator is mapped to the parent node and child node in the subtree corresponding to Project.

[0089] The operator library divides the algorithm functions into independent operator units, so that each code modification can only trigger the recompilation of the relevant operators that have changed. In this way, the system can efficiently perform incremental compilation and ensure that the update is completed in a shorter time. For example, when an operator is changed, the incremental compilation pipeline can regenerate the new compiled code of the operator and connect it to the existing runtime environment to achieve seamless code loading and dynamic update of the algorithm.

[0090] Next, the manner of compiling the syntax tree based on the present disclosure is further described in conjunction with some embodiments.

[0091] First, the relevant implementation of step 120 is schematically described in conjunction with some embodiments.

[0092] In some embodiments, the current syntax tree is traversed, and the field contents corresponding to each node in the current syntax tree can be compared one by one to determine the target node. For example, the Dependency node in the subtree corresponding to Project is compared. The field content corresponding to the node in the historical syntax tree is "msg_time, 110, 111, 112, 113, 114, 115, 116, 117", and the field content corresponding to the node in the current syntax tree is "msg_time, 110, 111, 112, 113, 114, 115, 116". Through the change of the field content, it can be determined that the node has changed, so that the node can be marked as the target node.

[0093] In some embodiments, the current hash value of the parent node can be determined by traversing the current syntax tree. The current hash value of the parent node is compared with the historical hash value of the parent node in the historical syntax tree, and then based on the comparison result, the target node in the subtree of the current syntax tree that has changed relative to the historical syntax tree is determined from the parent node and the child node.

[0094] As mentioned above, the historical syntax tree is a syntax tree corresponding to the historical source code. For example, the historical source code can be a historical version of the current source code. The current hash value of the parent node is compared with the historical hash value of the parent node in the historical syntax tree, that is, the current hash value of the parent node in the current syntax tree is compared with the historical hash value of the parent node in a certain historical syntax tree.

[0095] For example, the historical source code may be the source code of the previous compilation. The historical syntax tree may be the syntax tree generated during the previous compilation. The current hash value of the parent node is compared with the historical hash value in the syntax tree generated by the parent node during the previous compilation, and the target node in the subtree of the current syntax tree that has changed relative to the syntax tree generated during the previous compilation is determined based on the comparison result. Here, the target node reflects the changes in the current source code relative to the source code of the previous compilation.

[0096] Taking the SignalService functional unit described above as an example, the hash value of the parent node in the subtree corresponding to SignalService can at least be obtained by hashing the operation type of the SignalService functional unit. For example, the hash value of the parent node in the subtree corresponding to SignalService can be obtained by concatenating the various attributes of the SignalService functional unit (such as task type, task identifier, input, output, data dependency, etc.) into a string and then performing hash processing using a hash algorithm (such as the MD5 algorithm).

[0097] In the above embodiment, the target node can be determined from the parent node and the child node by comparing the hash value of the parent node, which has low computational complexity and low memory occupancy, thereby helping to further improve resource utilization.

[0098] In some embodiments, in response to the comparison result that the current hash value of the parent node is different from the historical hash value of the parent node in the historical syntax tree, the parent node can be determined as the target node. For example, the current hash value of the parent node is different from the historical hash value of the parent node in the historical syntax tree, which at least indicates that the operation type of the functional unit corresponding to the subtree where the parent node is located has changed.

[0099] In this case, it is not necessary to waste resources to further detect the child nodes in the subtree where the parent node is located, so that the waste of resources can be further reduced, thereby further improving the utilization rate of resources.

[0100] In some embodiments, in response to the comparison result that the current hash value of the parent node is the same as the historical hash value of the parent node in the historical syntax tree, the target node can be determined from the child node. For example, the current hash value of the parent node is the same as the historical hash value of the parent node in the historical syntax tree, which can indicate that the operation type of the functional unit corresponding to the child tree where the parent node is located has not changed. In this case, the child nodes in the child tree where the parent node is located can be further detected to determine the target node from the child nodes.

[0101] Thus, even if the parent node in the subtree has not changed, the target node can still be determined from the child node that can reflect the context information of the corresponding functional unit, so as to accurately narrow the scope of subsequent compilation, thereby further improving the compilation efficiency and the utilization of resources.

[0102] In some embodiments, the current hash value of the child node is compared with the historical hash value of the child node in the historical syntax tree, wherein the current hash value of the child node is determined by traversing the current syntax tree.

[0103] Still taking the SignalService functional unit described above as an example, the hash value of the child node in the subtree corresponding to SignalService can be obtained by concatenating the field contents corresponding to the child node into a string and then performing hash processing using a hash algorithm (such as the MD5 algorithm).

[0104] For example, when the current hash value of the parent node in the subtree is the same as the historical hash value, the subtree can be further traversed to determine the current hash value of the child node in the subtree. For example, the number of child nodes can be multiple. By traversing the current syntax tree, the current hash value of each child node in the subtree can be determined.

[0105] In response to the comparison result that the current hash value of the child node is different from the historical hash value of the child node in the historical syntax tree, the child node is determined as the target node.

[0106] It is understandable that, when there are multiple child nodes, for each child node, the current hash value of the child node can be compared with the historical hash value of the child node. And the child node with a different current hash value and historical hash value is determined as the target node. In other words, one or more child nodes can be determined as the target node.

[0107] For example, we can start from a parent node as the root node and recursively detect each subtree. If the parent node of the subtree has not changed, we recursively detect each child node of the subtree until the most fine-grained child node is detected, so that all the changed child nodes are detected.

[0108] In the above embodiment, by comparing the hash values ​​of the child nodes, the target node reflecting the changes of the current source code relative to the historical source code can be comprehensively and accurately determined, thereby achieving finer-grained difference detection, which helps to more accurately narrow the scope of subsequent compilation.

[0109] In some embodiments, after each code change, the corresponding syntax tree can be regenerated, and the hash value of each node in the syntax tree can be calculated. Then, the hash value of each node of the current syntax tree is compared with the hash value of each node of the historical syntax tree, and the node whose hash value has changed is determined as the target node.

[0110] Next, the relevant implementation of step 130 is schematically described in combination with some embodiments.

[0111] In some embodiments, in response to the target node being a parent node, a functional unit corresponding to a subtree where the target node is located may be determined as a target compilation unit.

[0112] For example, the parent node in the subtree may correspond to the operation type of the functional unit corresponding to the subtree. The target node being the parent node may at least indicate that the operation type of the functional unit corresponding to the subtree where the target node is located has changed. In this case, the functional unit corresponding to the subtree where the target node is located is determined as the target compilation unit, so that the functional unit corresponding to the subtree where the target node is located is recompiled during the compilation of the current source code.

[0113] For example, assuming that the SignalService functional unit is replaced by the Filter functional unit in the current source code (i.e., the operation type is changed from SignalService to Filter), in response to the target node being the parent node in the subtree corresponding to Filter, it can be determined that the functional units corresponding to the subtree where the target node is located have changed as a whole. Thus, the Filter functional unit is determined as the target compilation unit, so that the entire Filter functional unit can be recompiled during the compilation of the current source code.

[0114] In the above embodiment, once the target node that has changed is a parent node, the functional unit corresponding to the subtree where the target node is located is determined as the target compilation unit, so that the compilation of the current source code is performed based on the functional unit corresponding to the subtree where the target node is located. In this way, the reliability of the compilation is ensured on the basis of accurately narrowing the compilation scope.

[0115] In some embodiments, in response to the target node being a child node, the target compilation unit may be determined according to context information of the target node and a functional unit corresponding to a subtree where the target node is located.

[0116] Since the child nodes in the subtree corresponding to each functional unit are determined based on the context information of each functional unit, in response to the target node being a child node, the target compilation unit may be determined in combination with the target node and the context information corresponding to the target node.

[0117] As mentioned above, the context information of each functional unit includes parameter information of each functional unit and / or sub-operations within each functional unit. In other words, the sub-nodes of each functional unit may include sub-nodes determined based on the parameter information of the functional unit and / or sub-nodes determined based on sub-operations within the functional unit.

[0118] Based on this, in some embodiments, in response to the target node being a child node determined based on parameter information of a functional unit corresponding to a subtree where the target node is located, the functional unit corresponding to the subtree where the target node is located may be determined as a target compilation unit.

[0119] In other words, when the target node is a child node and the target node is a child node determined based on parameter information of a functional unit corresponding to the subtree where the target node is located, the functional unit corresponding to the subtree where the target node is located is determined as the target compilation unit.

[0120] For example, assuming that the input information of the SignalService functional unit in the current source code has changed, in response to the target node being an input child node determined based on the input information in the subtree corresponding to SignalService, it can be determined that the functional unit corresponding to the subtree where the target node is located will change as a whole due to the change in the input. Thus, the SignalService functional unit is determined as the target compilation unit, so that the entire SignalService functional unit can be recompiled during the compilation of the current source code.

[0121] In some embodiments, in response to the target node being a child node determined based on a child operation in a functional unit corresponding to a subtree where the target node is located, the child operation corresponding to the target node may be determined as a target compilation unit.

[0122] In other words, when the target node is a child node and the target node is a child node determined based on a sub-operation in a functional unit corresponding to the subtree in which the target node is located, the sub-operation corresponding to the target node is determined as a target compilation unit.

[0123] For example, assuming that the sub-operation selects of the Project functional unit in the current source code is replaced by collection, in response to the target node being the operation sub-node determined based on the sub-operation collection in the sub-tree corresponding to Project, it can be determined that the sub-operation in the functional unit corresponding to the sub-tree where the target node is located has changed. Therefore, the changed sub-operation collection can be determined as the target compilation unit, so that the sub-operation collection can be recompiled during the compilation of the current source code.

[0124] For another example, assuming that the selection condition of the sub-operation selects of the Project functional unit in the current source code has changed, in response to the target node being the operation sub-node determined based on the sub-operation selects in the sub-tree corresponding to the Project, it can be determined that the sub-operation in the functional unit corresponding to the sub-tree where the target node is located has changed. Thus, the changed sub-operation selects can be determined as the target compilation unit, so that the sub-operation selects can be recompiled during the compilation of the current source code.

[0125] It is understandable that a functional unit may include one or more independent sub-operations. By accurately determining the changed sub-operations as target compilation units, the sub-operations can be extracted as independent compilation units, thereby further narrowing the compilation scope of subsequent compilation and further improving resource utilization.

[0126] Next, the relevant implementation of step 140 is schematically described in combination with some embodiments.

[0127] As mentioned above, in some embodiments, the parameter information of each functional unit may include the data dependency of the functional unit.

[0128] For example, in response to the target node being a child node determined based on the data dependencies of the functional units corresponding to the subtree where the target node is located, a judgment can be made as to whether there are syntax errors in the current source code based on the data dependencies of the functional units corresponding to the subtree where the target node is located, and the current source code can be compiled based on the result of the judgment.

[0129] Combine the following Figure 3 This is further explained. Figure 3 Show Figure 1 Flowchart of some embodiments of step 140 in FIG.

[0130] like Figure 3 As shown, in step 310, in response to the target node being a child node determined based on data dependencies of the functional unit corresponding to the subtree where the target node is located, a designated functional unit among the multiple functional units is determined.

[0131] Here, there is a logical dependency between the specified functional unit and the functional unit corresponding to the subtree where the target node is located.

[0132] For example, see Figure 2 The functional unit corresponding to the subtree where the target node is located is the Project functional unit, and the designated functional unit that has a logical dependency on the Project functional unit is the SignalService functional unit.

[0133] In step 320, it is determined whether there is a syntax error in the current source code based on the data dependency of the specified functional unit and the data dependency of the functional unit corresponding to the subtree where the target node is located.

[0134] In some embodiments, the data flow direction between the two functional units can be determined based on the data dependency of the specified functional unit and the data dependency of the functional unit corresponding to the subtree where the target node is located. Based on whether the data flow direction between the two functional units is consistent with the logical dependency between the two functional units, it can be determined whether there is a syntax error in the current source code.

[0135] For example, see Figure 2 According to the logical dependency between the Project functional unit and the SignalService functional unit, the output of SignalService is the input of Project, so the data flow between the two functional units is from SignalService to Project. That is, the data that the execution of Project depends on should be a subset of the data that the execution of SignalService depends on.

[0136] Take the case where the functional unit corresponding to the subtree where the target node is located is the Project functional unit. In response to the changed target node being the data dependent child node Dependency in the subtree P corresponding to Project, it can be determined whether the data flow between the two functional units is consistent with the logical dependency between the two functional units based on whether the data that the execution of Project depends on is a subset of the data that the execution of SignalService depends on.

[0137] For example, in the current source code, suppose the data that the execution of Project depends on changes from "msg_time,110,111,112,113,114,115,116,117" to "msg_time,110,111,112,113,114,115,116,117,118", resulting in the data dependency child node Dependency in the subtree P corresponding to Project changing due to the newly added dependency data "118". However, the data that the execution of SignalService depends on is still "msg_time,110,111,112,113,114,115,116,117", that is, the data dependency child node Dependency in the subtree S corresponding to SignalService has not changed.

[0138] Since the data "118" is newly added to the data that the Project depends on, but this newly added data does not belong to the data that the SignalService depends on, the data that the Project depends on is no longer a subset of the data that the SignalService depends on. Therefore, it can be determined that the data flow between the two functional units, Project and SignalService, does not match the logical dependency between the two functional units, and thus it can be determined that there is a syntax error in the current source code.

[0139] For another example, in the current source code, suppose the data that the execution of Project depends on changes from "msg_time,110,111,112,113,114,115,116,117" to "msg_time,110,111,112,113,114,115,116", which causes the data dependent child node Dependency in the subtree P corresponding to Project to change due to the reduced dependent data "117". However, the data that the execution of SignalService depends on is still "msg_time,110,111,112,113,114,115,116,117".

[0140] In this case, even if the data "117" is reduced in the data that the Project depends on, since the reduced data that the Project depends on is still a subset of the data that the SignalService depends on, it can be determined that the data flow between the two functional units, Project and SignalService, is consistent with the logical dependency between the two functional units, and thus it can be determined that there is no syntax error in the current source code.

[0141] In step 330 , in response to determining that the current source code does not have a syntax error, the current source code is compiled based on the target compilation unit.

[0142] In some embodiments, in response to determining that the current source code has a syntax error, the current source code is not compiled. For example, the current source code may be modified to resolve the syntax error, and then the modified current source code is compiled.

[0143] In the above embodiment, during the compilation process, it is also possible to check whether the current source code has syntax errors based on the logic dependencies between the functional units and the data dependencies of the functional units, so as to compile the current source code if no syntax errors exist.

[0144] In this way, the syntax check of the current source code can be realized by double checking the logical dependency of the functional unit in terms of syntax and the data dependency in terms of data flow. Compared with the syntax check based only on the logical dependency of the functional unit in terms of syntax, the accuracy of the syntax check is improved on the basis of accurately narrowing the compilation scope, thereby further improving the reliability of the compilation.

[0145] The following further describes the method of compiling the current source code based on the target compilation unit in combination with some embodiments.

[0146] Figure 4 Show Figure 1 Flowcharts of some other embodiments of step 140 in FIG.

[0147] In step 410 , a designated compilation unit among a plurality of functional units that has a logical dependency with a target compilation unit is determined.

[0148] In some embodiments, the designated compilation unit may be determined from a plurality of functional units according to an input-output relationship of the target compilation unit.

[0149] In some embodiments, the target compilation unit is a functional unit corresponding to the subtree where the target node is located, and the designated compilation unit may include another functional unit that has a direct or indirect logical dependency on the functional unit corresponding to the subtree where the target node is located. For example, the designated compilation unit may include other functional units that directly or indirectly depend on the functional unit corresponding to the subtree where the target node is located.

[0150] For example, see Figure 2 In the example shown, it is assumed that the target compilation unit is SignalService. Since the output of SignalService affects the input of Project, that is, the Project logic depends on SignalService, Project can be determined as the specified compilation unit.

[0151] In some embodiments, the target compilation unit is a sub-operation in the functional unit corresponding to the subtree where the target node is located, and the specified compilation unit may include another sub-operation that has a logical dependency with the sub-operation corresponding to the target node. For example, the specified compilation unit may include other operations that directly or indirectly depend on the sub-operation corresponding to the target node. For example, the specified compilation unit may include other operations that have a function call relationship with the sub-operation corresponding to the target node.

[0152] For example, see Figure 2 In the example shown, it is assumed that Project includes the sub-operation selects and the sub-operation filter ( Figure 2 (not shown), and the output of selects will affect the input of filter. Taking selects as the target compilation unit as an example, since the filter logic depends on selects, filter can be determined as the specified compilation unit.

[0153] It is understandable that the target compilation unit may include the relevant code of the current source code that has changed relative to the historical source code. The designated compilation unit may include another part of the code that is directly or indirectly affected by the relevant code that has changed.

[0154] That is to say, the present disclosure can further detect whether the changed code causes changes across functional units or across sub-operations (such as across functions) by embedding a syntax tree with context information of each functional unit, thereby achieving accurate determination of the compilation scope.

[0155] In step 420 , compilation is performed on the target compilation unit and the designated compilation unit to obtain new compiled code.

[0156] In some embodiments, compilation may not be performed on other functional units among the plurality of functional units except for the target compilation unit and the designated compilation unit.

[0157] In step 430, a target code is obtained based on the new compiled code.

[0158] In some embodiments, existing compilation codes corresponding to other functional units except the target compilation unit and the designated compilation unit among the multiple functional units may be obtained, and then the new compilation code and the existing compilation code may be integrated to obtain the target code.

[0159] In the above embodiment, in the process of compiling the current source code based on the target compilation unit, not only the target compilation unit is compiled, but also the specified compilation unit directly or indirectly affected by the target compilation unit is compiled. In this way, on the basis of accurately narrowing the compilation scope, the potential impact of code changes on the overall algorithm logic corresponding to the current source code is reduced, thereby further improving the reliability of compilation.

[0160] In other words, this method can not only identify the related codes that have changed in the current source code, but also deeply analyze the potential impact of these changed related codes on the overall algorithm logic corresponding to the current source code, thereby achieving accurate marking of the compilation scope and ensuring the reliability of compilation.

[0161] The following is a schematic illustration of the implementation of step 430 in conjunction with some embodiments.

[0162] In some embodiments, the newly compiled code may be stored in a cache area, so that it can be easily reused later.

[0163] In some embodiments, the target code and the corresponding syntax tree may be stored in a cache area after each compilation is completed.

[0164] In some embodiments, existing compiled codes corresponding to other functional units other than the target compiled unit and the specified compiled unit in the multiple functional units can be detected in the cache area, and the target code can be obtained according to the detection result and the new compiled code. In this way, during the compilation process, it is possible to preferentially query whether there is existing compiled code that can be reused in the cache area, so as to reduce repeated compilation and reduce resource consumption.

[0165] In some embodiments, in response to detecting existing compiled codes corresponding to other functional units in the cache area, the detected existing compiled codes and the new compiled codes are integrated to obtain target codes.

[0166] For example, in response to detecting existing compiled codes corresponding to other functional units in the cache area, compilation can be performed on the target compiled unit and the specified compiled unit, while compilation is not performed on other functional units. The detected existing compiled codes and the compiled new compiled codes are then integrated to obtain the target code.

[0167] In some embodiments, in response to not detecting existing compiled codes corresponding to other functional units in the cache area, other functional units may be compiled to obtain other new compiled codes, and then the other new compiled codes and the new compiled code are integrated to obtain the target code.

[0168] For example, in response to not detecting existing compiled codes corresponding to other functional units in the cache area, the target compiled unit, the specified compiled unit, and other functional units may all be compiled, and then other newly compiled codes and the newly compiled code obtained by the compilation are integrated to obtain the target code.

[0169] In the above embodiment, in the process of compiling the current source code based on the target compilation unit, for other functional units that are not affected by the target compilation unit, the corresponding existing compilation code can be detected in the cache, and in response to the detection of the corresponding existing compilation code, the existing compilation code is directly reused, thereby eliminating the need for repeated compilation.

[0170] In this way, on the basis of accurately narrowing the compilation scope, the existing compiled code can be quickly reused and the compilation of some functional units can be skipped, thereby further improving the compilation efficiency and reducing resource consumption.

[0171] In some embodiments, the cache area may include a first area and a second area.

[0172] For example, a first result of the newly compiled code may be stored in the first area, and a second result of the newly compiled code may be stored in the second area, wherein the second result is calculated based on the first result. For example, the second result may be a final result obtained after compiling the target compilation unit and the specified compilation unit, and the first result may be an intermediate result obtained after compiling the target compilation unit and the specified compilation unit.

[0173] In this way, hierarchical storage of compilation results can be achieved, so that reusable compilation results can be quickly found later, which helps to improve compilation efficiency.

[0174] In some embodiments, second results of existing compiled codes corresponding to other functional units among the plurality of functional units except the target compilation unit and the designated compilation unit may be detected in the second region.

[0175] In response to detecting a second result of the existing compiled code in the second region, the detected second result of the existing compiled code and the new compiled code are integrated to obtain the target code.

[0176] In response to not detecting the second result of the existing compiled code in the second region, detecting the first result of the existing compiled code in the first region.

[0177] For example, the second result of the existing compiled code may be the final result obtained after compiling other functional units, and the first result of the existing compiled code may be the intermediate result obtained after compiling other functional units. It should be understood that the second result of the existing compiled code is calculated based on the first result of the existing compiled code.

[0178] In the above embodiment, once the second result of the existing compiled code is detected in the second region, the detected second result of the existing compiled code and the new compiled code can be integrated to obtain the target code. In this way, the second result of the existing compiled code can be directly reused without repeating the compilation process of obtaining the second result, thereby improving compilation efficiency and reducing resource consumption.

[0179] In some embodiments, in response to detecting a first result of an existing compiled code in the first region, other functional units are compiled based on the first result of the existing compiled code to obtain other new compiled code, and the other new compiled code and the new compiled code are integrated to obtain the target code.

[0180] In the above embodiment, even if the second result of the existing compiled code is not detected in the second area, further detection can be performed in the first area to determine whether there is a compilation result that can be reused. Once the first result of the existing compiled code is detected in the first area, other functional units can be compiled based on the first result of the existing compiled code, that is, the first result of the existing compiled code can be directly reused. In this way, there is no need to repeat the compilation process of obtaining the first result, which improves compilation efficiency and reduces resource consumption.

[0181] In some embodiments, in response to the first result that no existing compiled code is detected in the first region, other functional units are compiled to obtain other new compiled codes, and the other new compiled codes and the new compiled code are integrated to obtain the target code. That is, other functional units are recompiled only when there is no existing compiled code that can be reused, thereby improving resource utilization.

[0182] It should be understood that the cache area including the first area and the second area is only an example. In fact, the cache area may include multiple areas for storing data of different granularities. For example, the cache area may include an area for storing data of the smallest granularity (e.g., source data required to execute each functional unit), an area for storing data of intermediate granularity (e.g., intermediate results calculated based on the source data), and an area for storing data of the largest granularity (e.g., final results calculated based on the intermediate results).

[0183] This hierarchical storage mechanism can increase data access speed, thereby helping to improve compilation efficiency.

[0184] In some embodiments, the compiled target code can be loaded into the runtime environment, thereby achieving real-time deployment of the target code. For example, the compiled target code can be seamlessly loaded into the runtime environment through dynamic linking technology, so that the code update takes effect immediately.

[0185] In addition, by deploying the updated code in real time, it is possible to ensure that the system can be updated without interruption. In other words, there is no need to restart or shut down the system during the entire compilation process, which can ensure the seamless transition of the updated algorithm in the system, ensure the continuity of system operation, and thus improve the stability of system operation.

[0186] In the present disclosure, semantic-level difference detection can be achieved based on the current syntax tree, so that the compilation scope can be accurately determined. The core idea of ​​the present disclosure is to deeply analyze the syntax structure of the current source code and the context information of each functional unit in the current source code based on the current syntax tree to identify the potential impact of the current source code on the overall algorithm logic relative to the code change. Thus, independent compilation units with smaller granularity can be extracted from multiple functional units, which not only reduces the consumption of CPU resources, but also achieves efficient compilation.

[0187] The compilation technology solution proposed in this disclosure breaks through the limitations of the full compilation method and successfully realizes the incremental and real-time characteristics of compilation. The incremental characteristics can significantly reduce the scope of compilation, making the compilation time positively correlated with the scale of code changes, effectively improving the compilation efficiency. The real-time characteristics enable the system to quickly respond to code changes and complete algorithm updates under high real-time requirements, thereby ensuring the continuity of system (such as embedded systems) operation and improving the system's ability to quickly adapt to algorithm changes.

[0188] In other words, these features can ensure the efficient operation and dynamic update capabilities of various algorithms in embedded application scenarios.

[0189] Figure 5 A block diagram showing some embodiments of the compiling device of the present disclosure.

[0190] like Figure 5 As shown, the compiling device 500 includes an acquiring module 501 , a determining module 502 and a compiling module 503 .

[0191] The acquisition module 501 can be configured to acquire a current syntax tree corresponding to the current source code. The current syntax tree includes a subtree corresponding to each functional unit in a plurality of functional units of the current source code. The subtree includes a parent node and a child node, and the child node is determined based on the context information of each functional unit. The context information of each functional unit includes parameter information of each functional unit and / or a sub-operation within each functional unit.

[0192] The determination module 502 may be configured to traverse the current syntax tree, determine a target node in the subtree that has changed relative to the historical syntax tree corresponding to the historical source code from the parent node and the child node, and determine a target compilation unit among the multiple functional units based on the target node.

[0193] The compiling module 503 may be configured to compile the current source code based on the target compiling unit to obtain the target code.

[0194] In some embodiments, the compiling device 500 may further include other modules that execute other operations in the above embodiments.

[0195] Figure 6 Block diagrams showing other embodiments of the compiling device of the present disclosure.

[0196] like Figure 6 As shown, the compiling device 600 of this embodiment includes: a memory 601 and a processor 602 coupled to the memory 601 , and the processor 602 is configured to execute the compiling method in any one of the embodiments of the present disclosure based on the instructions stored in the memory 601 .

[0197] The memory 601 may include, for example, a system memory, a fixed non-volatile storage medium, etc. The system memory may store, for example, an operating system, an application program, a boot loader, a database, and other programs.

[0198] Figure 7 A block diagram showing some further embodiments of the compiling device of the present disclosure.

[0199] like Figure 7 As shown, the compiling device 700 of this embodiment includes: a memory 701 and a processor 702 coupled to the memory 701 , and the processor 702 is configured to execute the compiling method in any one of the aforementioned embodiments based on the instructions stored in the memory 701 .

[0200] The memory 701 may include, for example, a system memory, a fixed non-volatile storage medium, etc. The system memory may store, for example, an operating system, an application program, a boot loader, and other programs.

[0201] The compiling device 700 may further include an input / output interface 703, a network interface 704, a storage interface 705, etc. These interfaces 703, 704, 705, the memory 701, and the processor 702 may be connected, for example, via a bus 706. The input / output interface 703 provides a connection interface for input / output devices such as a display, a mouse, a keyboard, a touch screen, a microphone, and a speaker. The network interface 704 provides a connection interface for various networked devices. The storage interface 705 provides a connection interface for external storage devices such as an SD card and a USB flash drive.

[0202] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable non-transient storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0203] So far, the compilation technical solution according to the present disclosure has been described in detail. In order to avoid obscuring the concept of the present disclosure, some details known in the art are not described. Based on the above description, those skilled in the art can fully understand how to implement the technical solution disclosed here.

[0204] The method and system of the present disclosure may be implemented in many ways. For example, the method and system of the present disclosure may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present disclosure are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present disclosure may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present disclosure. Therefore, the present disclosure also covers a recording medium storing a program for executing the method according to the present disclosure.

[0205] Although some specific embodiments of the present disclosure have been described in detail by way of example, it should be understood by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present disclosure. It should be understood by those skilled in the art that the above embodiments may be modified without departing from the scope and spirit of the present disclosure.

Claims

1. A compilation method, comprising: Acquire a current syntax tree corresponding to a current source code, wherein the current syntax tree includes a subtree corresponding to each of a plurality of function units of the current source code, wherein the subtree includes a parent node and a child node, wherein the child node is determined based on context information of each function unit, wherein the context information includes parameter information of each function unit and / or a sub-operation within each function unit; Traversing the current syntax tree, determining, from the parent node and the child node, a target node in the child tree that has changed relative to a historical syntax tree corresponding to the historical source code; Based on the target node, determining a target compilation unit among the plurality of functional units; The current source code is compiled based on the target compilation unit to obtain a target code.

2. The compiling method according to claim 1, wherein: The determining, based on the target node, a target compilation unit among the plurality of functional units comprises: In response to the target node being the parent node, determining a functional unit corresponding to the subtree where the target node is located as the target compilation unit; or In response to the target node being the child node, the target compilation unit is determined according to context information of the target node and a functional unit corresponding to a subtree where the target node is located.

3. The compiling method according to claim 2, wherein: The determining the target compilation unit according to the context information of the target node and the functional unit corresponding to the subtree where the target node is located comprises: In response to the target node being a child node determined based on parameter information of a functional unit corresponding to a subtree where the target node is located, determining a functional unit corresponding to the subtree where the target node is located as the target compilation unit; or In response to the target node being a child node determined based on a sub-operation in a functional unit corresponding to a subtree where the target node is located, the sub-operation corresponding to the target node is determined as the target compilation unit.

4. The compiling method according to claim 1, wherein: The parameter information of each functional unit includes the data dependency of each functional unit. The compiling the current source code based on the target compilation unit comprises: In response to the target node being a child node determined based on data dependency of a functional unit corresponding to a subtree where the target node is located, determining a designated functional unit among the plurality of functional units, wherein there is a logical dependency between the designated functional unit and a functional unit corresponding to the subtree where the target node is located; Determining whether the current source code has a syntax error according to the data dependency of the specified functional unit and the data dependency of the functional unit corresponding to the subtree where the target node is located; In response to determining that the current source code does not have a syntax error, compiling the current source code based on the target compiling unit.

5. The compiling method according to any one of claims 1 to 4, wherein: The parameter information includes at least one of input information, output information and scope information of each functional unit.

6. The compiling method according to any one of claims 1 to 4, wherein: The traversing the current syntax tree and determining, from the parent node and the child node, a target node in the child tree that has changed relative to a historical syntax tree corresponding to the historical source code comprises: Traversing the current syntax tree to determine the current hash value of the parent node; Compare the current hash value of the parent node with the historical hash value of the parent node in the historical syntax tree; According to the comparison result, the target node is determined from the parent node and the child nodes.

7. The compiling method according to claim 6, wherein: Determining the target node from the parent node and the child node according to the comparison result includes: In response to the comparison result being that the current hash value of the parent node is different from the historical hash value of the parent node in the historical syntax tree, determining the parent node as the target node; or In response to the comparison result that the current hash value of the parent node is the same as the historical hash value of the parent node in the historical syntax tree, the target node is determined from the child nodes.

8. The compiling method according to claim 7, wherein: The determining the target node from the child nodes comprises: Compare the current hash value of the child node with the historical hash value of the child node in the historical syntax tree, the current hash value of the child node being determined by traversing the current syntax tree; In response to the result of comparing the current hash value of the child node with the historical hash value of the child node in the historical syntax tree being different, the child node is determined to be the target node.

9. The compiling method according to any one of claims 1 to 4, wherein: The compiling the current source code based on the target compilation unit to obtain the target code includes: Determine a specified compilation unit among the plurality of functional units that has a logical dependency on the target compilation unit; Compiling the target compilation unit and the designated compilation unit to obtain a new compiled code; The target code is obtained based on the new compiled code.

10. The compiling method according to claim 9, further comprising: The new compiled code is stored in a cache area.

11. The compiling method according to claim 10, wherein: The obtaining of the target code based on the new compiled code comprises: Detecting in the cache area existing compiled codes corresponding to other functional units among the plurality of functional units except the target compilation unit and the designated compilation unit; and In response to detecting existing compiled codes corresponding to the other functional units in the cache area, the detected existing compiled codes and the new compiled codes are integrated to obtain the target code.

12. The compiling method according to claim 10, wherein: The obtaining of the target code based on the new compiled code comprises: Detecting in the cache area existing compiled codes corresponding to other functional units among the plurality of functional units except the target compilation unit and the designated compilation unit; In response to not detecting the existing compiled code corresponding to the other functional unit in the cache area, compiling the other functional unit to obtain other new compiled code; and The other newly compiled codes and the newly compiled code are integrated to obtain the target code.

13. The compiling method according to claim 10, wherein: The cache area includes a first area and a second area; The storing the new compiled code in the cache area comprises: A first result of the newly compiled code is stored in the first area, and a second result of the newly compiled code is stored in the second area, where the second result is calculated based on the first result.

14. The compiling method according to claim 13, wherein: The obtaining of the target code based on the new compiled code comprises: detecting in the second region a second result of existing compiled codes corresponding to other functional units among the plurality of functional units except the target compilation unit and the designated compilation unit; In response to detecting a second result of the existing compiled code in the second region, integrating the detected second result of the existing compiled code and the new compiled code to obtain the target code; In response to not detecting the second result of the existing compiled code in the second area, detecting the first result of the existing compiled code in the first area; In response to detecting a first result of the existing compiled code in the first region, the other functional units are compiled based on the first result of the existing compiled code to obtain other new compiled codes, and the other new compiled codes and the new compiled code are integrated to obtain the target code.

15. The compiling method according to any one of claims 1 to 4, wherein: At least one or more functional units among the plurality of functional units are predefined functional units in a predefined functional unit library.

16. A compiling device, comprising: an acquisition module, configured to acquire a current syntax tree corresponding to a current source code, wherein the current syntax tree includes a subtree corresponding to each of a plurality of function units of the current source code, wherein the subtree includes a parent node and a child node, wherein the child node is determined based on context information of each function unit, wherein the context information includes parameter information of each function unit and / or a sub-operation within each function unit; a determination module configured to traverse the current syntax tree, determine, from the parent node and the child node, a target node in the child tree that has changed relative to a historical syntax tree corresponding to the historical source code, and determine, based on the target node, a target compilation unit among the plurality of functional units; The compiling module is configured to compile the current source code based on the target compiling unit to obtain the target code.

17. A compiling device, comprising: Memory; and A processor coupled to the memory, wherein the processor is configured to execute the compiling method according to any one of claims 1 to 15 based on instructions stored in the memory.

18. A computer-readable storage medium having computer instructions stored thereon, wherein when the instructions are executed by a processor, the compiling method according to any one of claims 1 to 15 is implemented.

19. A computer program product comprising instructions, which, when executed by a processor, cause the processor to perform the compilation method according to any one of claims 1 to 15.

Citation Information

Patent Citations

  • A program code similarity quick comparison method based on an abstract syntax tree,

    CN109445834A

  • Compilation processing method and device, equipment and storage medium

    CN112882718A

  • Code generation method and device based on syntax tree, electronic equipment and storage medium

    CN115016793A

  • Incremental compiling method and device based on source code detection

    CN115113876A

  • Code compiling detection method and automatic compiling platform

    CN118963772A

Cited By

  • Automatic incremental compiling method and system for Java development

    CN119396406A

  • IOS packaging method and system suitable for multiple accounts, multiple items and multiple results and storage medium

    CN121070379A