An efficient inter-procedural escape analysis method for Golang programs based on value flow analysis
Through a method based on value flow analysis, combined with inverse topological sorting and reverse data flow analysis, the scale of escape analysis is reduced, and the problem of low escape analysis between the Golang program is solved, and more efficient escape variable capture and compilation optimization is achieved.
Patent Information
- Application Number
- CN202210476822.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-30
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2042-04-30
AI Technical Summary
At this stage, the inter-process escape analysis of Golang programs is inefficient, especially the escape analysis time affects the compilation time and lacks effective solutions.
Using a method based on value flow analysis, the Golang program is preprocessed, and the inter-process function call diagram and control flow diagram are created. Combined with inverse topology sorting and reverse data flow analysis technology, the scale of escape analysis is reduced, the analysis accuracy is improved, and the escape variable is calculated. The results are merged and the escape variables are directly calculated using functional programming characteristics.
It improves the escape analysis efficiency of Golang programs, shortens the analysis time, increases the number of captures of escape variables, and improves program execution efficiency and compilation optimization effect.
Smart Images

Figure CN114780105B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of program analysis, and in particular to an efficient inter-procedural escape analysis method for Golang programs based on value flow analysis. Background Art
[0002] With the continuous development and improvement of programming languages, the performance of program execution has begun to receive more and more attention. In order to improve the performance of programs, optimization techniques are often needed. Compilation optimization refers to the technology that improves the performance of the system or program through certain methods or strategies during the program compilation process. At present, many compilers of mainstream programming languages have compilation optimization functions. A program needs to be compiled to generate an executable file before it can run on the corresponding target machine. The compilation process includes compilation front-end, compilation back-end optimization and compilation back-end. Improving the speed of compilation optimization can greatly reduce the time of program compilation. Escape analysis technology is a technology and means of memory optimization, and it is also a kind of compiler optimization technology. Memory management is very important in software engineering. For example, cloud services run in containers with memory usage restrictions, and there is a risk that the memory cost exceeds the limit. Nowadays, more and more Internet companies are beginning to pay attention to memory management and optimization issues.
[0003] Escape analysis means that the compiler transfers the memory originally allocated on the heap to the stack by analyzing the scope of pointer variables. The access efficiency of stack memory is much higher than that of heap memory, and the memory on the stack will be automatically reclaimed when the method ends. Therefore, stack allocation can effectively improve the execution efficiency of the program. Since escape analysis requires global data flow analysis, it is very time-consuming, and the time of escape analysis will affect the entire compilation time. Therefore, how to find more escape variables in the shortest time and optimize the program to the greatest extent to improve the execution efficiency of the program is still a key point that needs to be studied at this stage.
[0004] Compiler optimization technology has always attracted much attention, and escape analysis technology has been continuously iterated in various versions. At present, escape analysis is enabled by default in the compilers of mainstream programming languages. For example, the JIT Compiler (Just In Time Compiler) in the Java virtual machine HotSopt VM performs escape analysis during runtime, and escape analysis is enabled by default in JDK1.8. Although the C / C++ compiler LLVM does not enable escape analysis by default, it also has an escape analysis pass in the many passes of LLVM backend optimization, and escape analysis can be manually enabled to optimize C / C++ code. Golang, the compiler of Go programs, directly relies on escape analysis technology to manage variable memory during compilation. However, the current escape analysis efficiency is still low, especially for inter-procedural escape analysis, for which there is no good solution. Therefore, this paper combines the idea of value flow graph to reduce the scale of intra-procedural escape analysis, uses data flow analysis to abstract the construction process of value flow graph, improves the accuracy of value flow analysis, and combines the idea of high-order functions in functional programming to abstract the analysis process of escape variables, reduce the time of escape analysis, improve the accuracy of inter-procedural escape analysis, and improve the execution efficiency of Golang programs, which is of great significance for the improvement of compilation optimization technology. Summary of the invention
[0005] The purpose of this section is to summarize some aspects of embodiments of the present invention and briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this section and the specification abstract and the invention title of this application to avoid blurring the purpose of this section, the specification abstract and the invention title, and such simplifications or omissions cannot be used to limit the scope of the present invention.
[0006] In view of the problems existing in the above-mentioned existing Golang program efficient inter-procedural escape analysis method based on value flow analysis, the present invention is proposed.
[0007] Therefore, the object of the present invention is to provide an efficient inter-procedural escape analysis method for Golang programs based on value flow analysis.
[0008] To solve the above technical problems, the present invention provides the following technical solutions: a Golang program efficient inter-procedural escape analysis method based on value flow analysis, comprising:
[0009] Preprocess the Golang program to obtain an intermediate code representation based on the static single assignment form, and create an inter-procedural function call graph and an intra-procedural control flow graph;
[0010] Perform reverse topological sorting on the function call graph, establish a sequence of functions to be analyzed, and determine whether the functions to be analyzed involve inter-procedural calls;
[0011] Calculate the escape variables of the objective function according to the different discriminations;
[0012] The escape variables of all functions in the program are analyzed based on the function call graph, and the ESC of all analyzed functions are merged to obtain the final set of escape variable values.
[0013] As a preferred solution of the efficient inter-procedural escape analysis method of Golang program based on value flow analysis described in the present invention, after determining that the function to be analyzed does not involve inter-procedural calls, variables related to the Golang language escape rules are collected.
[0014] As a preferred solution of the Golang program efficient inter-procedural escape analysis method based on value flow analysis described in the present invention, the program control flow graph is traversed using reverse data flow analysis technology to access a set of statements {s|s∈Sl, l=1,2,3,...} related only to a specified variable V(t), wherein s represents a program statement, l represents the line number corresponding to statement s, Sl represents the set of all program statements, t represents a related escape rule, V(t) represents a variable corresponding to escape rule t, and the analysis result of statement S(v) is passed in the traversal order.
[0015] As a preferred solution of the Golang program efficient inter-procedural escape analysis method based on value flow analysis described in the present invention, wherein: a data flow equation is constructed according to the definition of different statements S(v) in the Golang program, the constraint relationship of the statement S(v) is calculated according to the established data flow equation, and the target function is subjected to reverse data flow iterative analysis based on the data flow equation of different statements S(v) to obtain the Ppre of the target function, wherein Ppre represents the constraint set obtained by analyzing the previous statement, and in the initial state Use Ppre to calculate the escape variable of the objective function.
[0016] As a preferred solution of the Golang program efficient inter-procedural escape analysis method based on value flow analysis described in the present invention, based on the corresponding pointer variables that have been collected, let the variable be V(r), r represents the escape area corresponding to the target variable, collect all local variables and memory allocation information in the target function h(....), set the variables and the initial escape state of the memory to the non-escaped state.
[0017] As a preferred solution of the efficient inter-procedural escape analysis method of Golang programs based on value flow analysis described in the present invention, wherein: let F(x, y, r) be the constraint function of statement S(v), wherein x represents the variable related to V(t) in statement S(v), y represents the variable unrelated to V(t) in statement S(v), and r represents the analysis result of the previous statement S(v) received, and then the constraint relationship extraction equations corresponding to different statements S(v) are constructed.
[0018] As a preferred solution of the Golang program efficient inter-procedural escape analysis method based on value flow analysis described in the present invention, wherein: based on the constraint functions of various statements S(v), the target function h(...) is subjected to data flow iterative analysis using the reverse data flow iterative analysis technology, and the variable State is set to indicate whether the constraint set of the statement S(v) changes during the iterative analysis process, and the initial value of State is TRUE. If the constraint set of the statement S(v) does not change after one iteration analysis is completed, State = FALSE, and the iteration is stopped; if the constraint set of any S(v) changes during the iterative analysis process, State = TRUE, and when one iteration analysis is completed, State = FALSE, the iterative analysis is stopped, and it is said that the constraint set of each statement S(v) has reached a fixed value at this time;
[0019] If State = TRUE after one round of iterative analysis ends, the next round of iterative analysis will continue until State = FALSE, and then the iterative analysis will be stopped. Then, the final Ppre value obtained by the iterative calculation is used to establish a function to solve the constraint set Ppre of the statement S(v), and a function is established to calculate the escape variable of the objective function, and a judgment is made based on whether the objective function contains parameter type variables.
[0020] As a preferred solution of the efficient inter-procedural escape analysis method of Golang programs based on value flow analysis described in the present invention, after collecting variables related to the escape rules of the Golang language, the collection of related variables in the function call area is added, and Ppre at the function call point is marked, the escape analysis result of the called function is taken out, Ppre is substituted into the escape analysis result for calculation, and the escape variables in the calling function are captured.
[0021] Beneficial effects of the present invention:
[0022] 1. Escape analysis of Golang programs based on SSA code intermediate representation, which is highly scalable and convenient for subsequent code data flow analysis;
[0023] 2. Use value flow analysis technology to reduce the scale of escape analysis within the process, remove the analysis process of redundant code, and combine data flow iterative analysis technology to improve the accuracy of value flow analysis;
[0024] 3. Based on the results of the above value flow analysis, the characteristics of high-order functions in functional programming are utilized to directly calculate escape variables at the function call point, avoiding the construction of a huge inter-procedural relationship graph, which greatly improves the efficiency of inter-procedural escape analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. Among them:
[0026] Figure 1 It is a schematic diagram of the overall structure of the Golang program efficient inter-procedural escape analysis method based on value flow analysis of the present invention. DETAILED DESCRIPTION
[0027] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings.
[0028] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0029] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.
[0030] Secondly, the present invention is described in detail with reference to the schematic diagram. When describing the embodiments of the present invention in detail, for the sake of convenience, the cross-sectional diagrams showing the device structure will not be partially enlarged according to the general scale, and the schematic diagrams are only examples, which should not limit the scope of protection of the present invention. In addition, in actual production, the three-dimensional dimensions of length, width and depth should be included.
[0031] Example 1
[0032] Reference Figure 1 The present invention discloses an efficient inter-procedural escape analysis method for Golang programs based on value flow analysis, comprising the following steps:
[0033] First, based on the function call graph (Call Graph) of the Golang program to be analyzed, the function escape analysis is performed. This process is divided into intra-procedure escape analysis and inter-procedure escape analysis.
[0034] The above steps include: taking the Golang source file as input, preprocessing the Golang program, obtaining an intermediate code representation based on the SSA (Static Single Assignment) form, creating an inter-procedural function call graph (CallGraph) and an intra-procedural control flow graph (Control Flow Graph); performing a reverse topological sorting on the function call graph (Call Graph) to obtain a function sequence to be analyzed; if the function sequence to be analyzed is not empty, taking out a function from the function sequence to be analyzed for escape analysis, and determining whether the function to be analyzed involves an inter-procedural call.
[0035] When judging whether the function to be analyzed involves inter-procedural calls, different steps are entered, which are divided into: step (one) and step (two).
[0036] Step (a) When the function to be analyzed does not involve inter-procedural calls, the steps are as follows: first, variables related to the Golang language escape rules are collected, and in this step, pointer variables corresponding to the Return area (corresponding to the Return instruction statement), the Global area (corresponding to the Global keyword), the MakeSlice area (corresponding to the MakeSlice instruction statement), the MakeChan area (corresponding to the MakeChan instruction statement), and the MakeMap area (corresponding to the MakeMap instruction) in the above intermediate code representation are collected.
[0037] Then, based on the corresponding pointer variables that have been collected, set the variable to V(r), where r represents the escape area corresponding to the target variable. For example, the pointer variable searched through the Return instruction is represented as V(return); the pointer variable modified by the Global keyword is represented as V(global).
[0038] Then collect all local variables and memory allocation information in the target function h(....), set the variables and the initial escape state of the memory to the non-escaped state, (collecting memory allocation information refers to collecting information at the memory allocation statement). Memory allocation statements are mainly new type and make type statements, such as v=new(...) or v=make(...) (where v is a free variable), let Ml(t) represent memory information, t is the type of memory allocation statement, l is the line number corresponding to the memory allocation statement, if the statement is a new type statement, then Ml(t)=Ml(new), indicating the memory allocated by the new statement; if the statement is a make type statement, then Ml(t)=Ml(make), indicating the memory allocated by the make statement.
[0039] Then use the reverse data flow analysis technology to traverse the program control flow graph (Control Flow Graph), access the statement set {s|s∈Sl,l=1,2,3,...} related only to the specified variable V(t) (where s represents the program statement, l represents the line number corresponding to statement s, Sl represents the set of all program statements, t represents the relevant escape rule, and V(t) represents the variable corresponding to the escape rule t), and pass the analysis result of statement S(v) in the traversal order (assuming that S(v) represents the statement related only to the specified variable v); the data flow analysis mentioned in this step is a technology for collecting the collection information of possible values at different points in a computer program, and the reverse data flow analysis is to collect the information of values at different program points along the opposite direction of the normal execution path of the program.
[0040] Explain some related statements in this step: Assume statement l1: m = n, statement l2: q = t, statement l3: v = q, where m, n, q, t, v are all free pointer variables and variable q is the target variable to be analyzed, then statements l2 and l3 are called related statements, and statement l1 is called an irrelevant statement.
[0041] Then, according to the definition of different statements S(v) in the Golang program, the constraint relationship extraction equation is established, and the data flow iterative analysis is performed on the target function to obtain the final Ppre (the reverse data flow iterative analysis in this step is a data flow analysis framework, which continuously updates the data flow information of the program point during the iterative analysis process to obtain a more accurate analysis result). The specific process is: based on the constraint functions of the above-mentioned various statements S(v), the reverse data flow iterative analysis technology is used to perform data flow iterative analysis on the target function h(...), and the variable State is set to indicate whether the constraint set of the statement S(v) changes during the iterative analysis process. The initial value of State is TRUE. If the constraint set of the statement S(v) does not change after an iterative analysis, State = FALSE, and the iteration is stopped; if the constraint set of any S(v) changes during the iterative analysis process, State = TRUE. When State = FALSE after an iterative analysis is completed, the iterative analysis is stopped, and it is said that the constraint set of each statement S(v) has reached a fixed value. If State = TRUE after one round of iterative analysis ends, the next round of iterative analysis will continue until State = FALSE, and the iterative analysis will stop.
[0042] Finally, the final Ppre value is obtained through the above iterative calculation. Let the function Γ(z) solve the constraint set Ppre of the statement S(v), let Pesc=Γ(Ppre), and let the function Escape(fn,p) calculate the escape variable of the objective function, where fn is the objective function and p is the constraint set after the solution. Let the escape analysis result of the objective function be represented by ESCfn, then ESCv indicates that the escape analysis result obtained contains a specific value. Indicates that the escape analysis result obtained contains a specific function. If ESCv or If it does not exist, it is represented by Nil.
[0043] If fn does not contain parameter type variables, that is, ESCh=Escape(h(),Pesc), then calculate the set of all variables pointed to by v in Pesc. If Pesc={v→Mem(q)}, then ESC={q,Nil}; if Pesc={v→NewMem(v) / Make\Mem(v)}, then ESCv={new(T(v)) / make(T(v))}; if Pesc={v→Mem(q),v→Mem(z),v→NewMem(v),...},NewMem(v) / MakeMem(v),...}, then ESCv={(q,z,new(T(v)) / make(T(V)),...),Nil} (where the function T(var) is to take out the type of the corresponding variable var).
[0044] If fn contains parameter type variables, that is, Escape(h(a,b,c,...),Pesc), and a, b, c,... Pesc (indicates that Pesc does not contain any parameter variables), then the calculation result of ESCv is the same as (2-502).
[0045] If fn contains a parameter type variable, that is, Escape(h(a,b,c,...), Pesc), and Pesc contains one or more parameter type variables, assuming that the parameter variables contained in Pesc are a and b. If Pesc={v→a,v→b}, then
[0046] Since the final values of a, b, c, ... cannot be determined in the objective function, the final escape variable calculation result cannot be obtained. Therefore, the characteristics of high-order functions in functional programming are used here to return the escape analysis calculation result of the objective function h(a, b, c, ...) in the form of a function carrying parameters a and b, that is, the function (P(a),P(b)); if Ppre={v→Mem(a),v→Mem(b)}, then Where P(a) and P(b) represent the set of constraints associated with variables a and b.
[0047] The rule for solving the constraint set of statement S(v) using function Γ(z) described in the above steps is:
[0048]
[0049] Among them, α and β represent pointer type variables; δ and η can represent pointer type variables as well as Mem(v), NewMem(v), and MakeMem(v).
[0050] Step (2) If the function to be analyzed involves inter-procedural calls, the steps are as follows:
[0051] First, we still collect variables related to the Golang language escape rules and repeat the execution, add the collection of related variables in the function call area, and mark the Ppre at the function call point.
[0052] The specific process of this step is: assuming that function g(...) is the calling function of the above-analyzed function h(a,b,c,...), the escape analysis result of function g(...) is represented by ESCg, and then the variables related to the Golang language escape rules are still collected and repeated execution is performed, and the collection of parameter pointer variables corresponding to Call type instructions is added. If statement S(v) is a CallFunc type statement x=h(m,n,o,...), h(m,n,o,...) or go h(m,n,o,..), then mark the Ppre(v) value here and set it to Ppre__h(v). After executing the above-mentioned iterative analysis, the final Ppre__h(v) value is obtained; use function Γ(z) to solve Ppre__h(v), and set the result to Pesc_h.
[0053] Then take out the escape analysis results of the called function Substituting Ppre into Calculate inside and capture the escape variables in the calling function; the specific process of this step is: locate the CallFunc type statement in function G(...) again, take x=h(m,n,o,...) as an example, and extract the escape analysis result of function h(a,b,c,...), that is, the escape analysis result of function h In order to distinguish the following calculation from the general escape analysis result, let the function h be Part of Substitute Pesc_h(m) and Pesc_h(n) into In (P(a), P(b)), the escape variables of the function g(...) are calculated.
[0054] If g(...) takes no arguments, then If G(...) takes parameters, and The calculation process of (Pesc_h(m),Pesc_h(n)) contains parameter type variables, then
[0055] After the above-mentioned discrimination is performed, the escape variables of the objective function are calculated according to the different discriminations, and the escape variables are sorted.
[0056] Based on the function call graph, perform escape analysis on each function in the Golang program according to the above steps. Assume ESC($file_name) is the escape variable representation of the Golang program. According to the above description, ESC($file_name) = ESCh_v∪ESCg_v∪..., where $file_name represents the file name of the Golang program, ESCh_v and ESCg_v represent the ESCv part of ESCh and ESCg respectively, to realize the merging of ESC of all analyzed functions.
[0057] The present invention performs escape analysis of Golang programs based on the code intermediate representation of SSA;
[0058] In this embodiment, the traditional classical escape analysis method and the improved escape analysis method are compared (Table 1).
[0059] Traditional classical escape analysis method: escape analysis method based on connected graph.
[0060] Improved escape analysis method: An efficient escape analysis method based on value flow analysis.
[0061] Cost coefficient: The lower the coefficient, the higher the efficiency;
[0062]
[0063]
[0064] Table 1 Comparative analysis of escape analysis data
[0065] After comparative analysis, we can intuitively see that the improved escape analysis method has a shorter analysis time and captures more escape variables. The value flow analysis technology is used to reduce the scale of intra-procedural escape analysis, remove the analysis process of redundant code, and combine the data flow iteration analysis technology to improve the accuracy of value flow analysis; based on the results of the above value flow analysis, the characteristics of high-order functions in functional programming are used to directly calculate escape variables at the function call point, avoiding the construction of a huge inter-procedural relationship graph, which greatly improves the efficiency of inter-procedural escape analysis.
[0066] Importantly, it should be noted that the construction and arrangement of the present application shown in a plurality of different exemplary embodiments are only exemplary. Although only a few embodiments are described in detail in this disclosure, it should be readily understood by those who refer to this disclosure that many modifications are possible (e.g., the size, scale, structure, shape and proportion of various elements, and parameter values (e.g., temperature, pressure, etc.), installation arrangement, use of materials, color, directional changes, etc.) without substantially departing from the novel teachings and advantages of the subject matter described in the application. For example, the element shown as integrally formed can be composed of multiple parts or elements, the position of the element can be inverted or otherwise changed, and the nature or number or position of the discrete element can be changed or changed. Therefore, all such modifications are intended to be included in the scope of the present invention. The order or sequence of any process or method steps can be changed or reordered according to alternative embodiments. In the claims, any "device plus function" clause is intended to cover the structure of performing the function described herein, and is not only structurally equivalent but also equivalent structure. Without departing from the scope of the present invention, other replacements, modifications, changes and omissions can be made in the design, operating conditions and arrangement of the exemplary embodiments. Therefore, the invention is not limited to a specific embodiment, but extends to numerous modifications still falling within the scope of the appended claims.
[0067] Additionally, in order to provide a concise description of exemplary embodiments, all features of an actual embodiment (ie, those features that are not relevant to the best mode presently contemplated for carrying out the invention or those that are not relevant to implementing the invention) may not be described.
[0068] It will be appreciated that in the development of any actual implementation, as in any engineering or design project, numerous implementation-specific decisions may be made. Such a development effort may be complex and time-consuming, but will be a routine task of design, fabrication, and production for those of ordinary skill having the benefit of this disclosure without undue experimentation.
[0069] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. An efficient inter-procedural escape analysis method for Golang programs based on value flow analysis, characterized by: include, Preprocess the Golang program to obtain an intermediate code representation based on the static single assignment form, and create an inter-procedural function call graph and an intra-procedural control flow graph; Perform reverse topological sorting on the function call graph, establish a sequence of functions to be analyzed, and determine whether the functions to be analyzed involve inter-procedural calls; After determining that the function to be analyzed does not involve inter-procedural calls, collect variables related to the Golang language escape rules; Use the reverse data flow analysis technology to traverse the program control flow graph, access the statement set {s|s∈Sl, l =1,2,3,...} related only to the specified variable V(t), where s represents the program statement, l represents the line number corresponding to statement s, Sl represents the set of all program statements, t represents the relevant escape rule, V(t) represents the variable corresponding to the escape rule t, and pass the analysis result of statement S(v) in the traversal order; According to the definitions of different statements S(v) in the Golang program, a data flow equation is constructed. The constraint relationship of the statement S(v) is calculated based on the established data flow equation. Based on the data flow equations of different statements S(v), the target function is analyzed iteratively for reverse data flow to obtain the Ppre of the target function, where Ppre represents the constraint set obtained by analyzing the previous statement. In the initial state, Ppre(v) = ; Use Ppre to calculate the escape variable of the objective function; Let F(x, y, r) be the constraint function of statement S(v), where x represents the variable related to V(t) in statement S(v), y represents the variable unrelated to V(t) in statement S(v), and r represents the analysis result of the previous statement S(v) received. Then, the constraint relationship extraction equations corresponding to different statements S(v) are constructed; the escape variables of the objective function are calculated according to different discriminations; The escape variables of all functions in the program are analyzed based on the function call graph, and the ESC of all analyzed functions are merged to obtain the final set of escape variable values.
2. The Golang program efficient inter-procedural escape analysis method based on value flow analysis as claimed in claim 1, characterized in that: Based on the corresponding pointer variables that have been collected, let the variable be V(r), where r represents the escape area corresponding to the target variable, collect all local variables and memory allocation information in the target function h(....), and set the variables and the initial escape state of the memory to the non-escaped state.
3. The Golang program efficient inter-procedural escape analysis method based on value flow analysis as claimed in claim 2, characterized in that: Based on the constraint functions of various statements S(v), the reverse data flow iterative analysis technology is used to perform data flow iterative analysis on the target function h(...). The variable State is set to indicate whether the constraint set of the statement S(v) changes during the iterative analysis process. The initial value of State is TRUE. If the constraint set of the statement S(v) does not change after one iteration analysis, State = FALSE, and the iteration is stopped; if the constraint set of any S(v) changes during the iterative analysis process, State = TRUE. When one iteration analysis is completed, State = FALSE, and the iterative analysis is stopped, and it is said that the constraint set of each statement S(v) has reached a fixed value at this time; If State=TRUE after one round of iterative analysis ends, the next round of iterative analysis will continue until State=FALSE, and then the iterative analysis will be stopped. Then, the final Ppre value obtained by the iterative calculation is used to establish a function to solve the constraint set Ppre of the statement S(v), and a function is established to calculate the escape variable of the objective function, and a judgment is made based on whether the objective function contains parameter type variables.
4. The Golang program efficient inter-procedural escape analysis method based on value flow analysis as claimed in claim 3, characterized in that: After determining that the function to be analyzed involves inter-procedural calls, collect variables related to the Golang language escape rules, add the collection of relevant variables in the function call area, mark Ppre at the function call point, take out the escape analysis result of the called function, substitute Ppre into the escape analysis result for calculation, and capture the escape variables in the calling function.
Citation Information
Patent Citations
Method for analyzing memory security in C code by using data stream analysis algorithm
CN114153451A
Single-time multi-vulnerability code detection method and system
CN114282226A
