SYSTEMS AND METHODS FOR INFORMATION FLOW ANALYSIS
Computer-implemented methods for analyzing computer programs written in semi-structured languages are disclosed. The method is based on unification of the two classic forms of program flow analysis, control flow and data flow analysis. As such, it is capable of substantially increased precision, which increases the effectiveness of applications such as automated parallelization and software testing. Certain implementations of the method are based on a process of converting source code to a decision graph and transforming that into one or more alpha graphs which support various applications in software development. The method is designed for a wide variety of digital processing platforms, including highly parallel machines. The method may also be adapted to the analysis of (semi-structured) flows in other contexts including water systems and electrical grids.
This application claims priority to U.S. Provisional Application No. 61/027,967, filed Feb. 12, 2008, and to U.S. Provisional Application No. 61/027,975, filed Feb. 12, 2008, which are hereby incorporated by reference in their entirety.
BACKGROUNDProgram analysis is a discipline which underlies many of the most essential specialties of computer science. These include automatic parallelization, software testing, software verification, software debugging, compiler optimization and program transformation.
The purpose of program analysis is to determine whether a computer program satisfies a set of specified properties either at compile time (static analysis) or during controlled execution (dynamic analysis). Program analysis is an automated method for doing so based on program structure.
In the existing literature, the terms “information flow” and “information flow analysis” have been used to refer to several earlier forms of program analysis that attempt to combine control flow and data flow analysis in some manner other than that disclosed in this patent application. Unless otherwise noted, as used herein these terms refer to the unification of control flow and data flow analysis as disclosed herein.
Although the applications of information flow analysis are myriad, the focus of this section will be on one important application in which the need for new methods of program analysis has been characterized as “critical”: automatic parallelization. Copeland, M. V., “A chip too far?,” Fortune, September 2008, pp. 43-44.
Methods for Program Analysis have not Kept Pace with the Rapid Improvements in Computer Hardware
The computer industry is undergoing a major transition due to fundamental advances in chip design. In particular, the advent of multi-core processors is leading to a spectrum of new computing platforms from high performance computing on desktops to cloud computing. The common denominator in these trends is parallel processing. In parallel processing, a single program is divided into several pieces, and the pieces are executed simultaneously (“in parallel”) on multiple processors. An automatic parallelizer is a software tool which separates the program into the individual pieces.
Most existing methods of program analysis were developed in an era in which processing consisted of a single program being executed on a single processor. These methods were not developed with parallelization as a goal, and software tools based on these methods are not sufficient to fully exploit the performance of the new multi-processor machines.
The main exception is in the area of supercomputers, where some program analysis methods for parallelization, such as dependence analysis, have been developed. See Allen, R., Kennedy, K., “Optimizing Compilers for Modern Architectures,” Academic Press, 2002.
These methods tend to be restricted in their capabilities due to the problem domain, which is mathematical computations. In particular, these methods focus on mathematical operations involving arrays within loops, which are not as common in commercial applications. Even in this limited problem domain, these program analysis methods do not typically provide full automation, and must be supplemented by the skills of highly trained specialists and the use of niche languages to obtain satisfactory results.
Manual parallelization and the employment of niche languages do not constitute a realistic solution for commercial applications. As high performance computing migrates to the business world and even the home, there is an acute need for software tools which can automatically parallelize software written in mainstream languages such as Java. These must be based on a foundation of new methods of precise program analysis.
SUMMARYThe present invention is generally directed to computer-implemented methods for analyzing computer programs written in semi-structured languages as well as generalized flow networks. More particularly the present invention is directed to a process, and to a system or machine using such a process, which satisfies the need for precise analysis of generalized flow networks that are representable as directed or semi-structured flows (including, for example, flows of data and control within computer programs, electricity within power grids, gas within gas systems, and water within water systems), in order to determine the independent and quasi-independent flows that may occur within the represented networks.
In an exemplary embodiment, the present invention implements a set of parallel, cooperative processes that accept a representation of the flow network to be analyzed and collectively use graph transformation to precisely identify the independent flows within the represented flow network. In this embodiment, the use of graph transformation in combination with a solid mathematical foundation enables accurate, deterministic, automated analysis with a high degree of precision.
In another exemplary embodiment, the central process (“alpha transform”) is preceded by one or more application-specific preprocessors that prepare and submit inputs to the central process, and succeeded by one or more application-specific postprocessors. The overall effect of the alpha transform is to convert each network model input (such as a decision graph) into one or more “alpha graph” outputs, each of which describes a set of independent flows discovered by analyzing the input using the method of the present invention.
In a further exemplary embodiment, each conceptual subprocess or process step of the central process is loosely coupled to the others, and may be multiply instantiated, any instance of which may be implemented as an application-specific hardware device (e.g., ASIC), a software process, or in any of various hybrid combinations, such that the various instantiations of processes or process steps may operate independently, asynchronously, and in parallel, thereby enabling both upward and downward scalability, and straightforward, platform-agnostic implementation on a wide variety of digital processing architectures.
In an additional exemplary embodiment oriented toward certain disciplines related to computer programming, the present invention enables precise analysis of an arbitrarily complex computer program (which is typically a complex flow network having both control and data flows that are not constrained by the laws of physics) in order to identify the independent and quasi-independent control and data flows occurring within its program units. In this embodiment, the use of graph transformation in combination with the new signal flow algebra further enables native support for semi-structured programming constructs (such as break, multiple returns in a single method, continue, and exceptions) that previously required “work-arounds” such as structuring preprocessors. Said embodiment enables an exemplary application where the identified control and data flows may be used for automated generation of the test cases needed for efficiently performing path testing. Said embodiment further enables another exemplary application where the identified control and data flows may be used for the automatic parallelization of software source codes in order to enable more efficient use of multicore processors, multi-way processor configurations, and computing clusters such as those typically found in supercomputers and cloud computing.
In another exemplary embodiment, a digital-processor-implemented method for analyzing computer programs written in semi-structured languages is provided, the method comprising: transforming source (or object) code of the program into decision graphs which represent the control flow structure of said program, with data flow elements attached to the graphs; transforming said decision graphs into one or more information flowgraphs which represent control flow and data flow in a unified manner, and which identify the independent and quasi-independent flows therein; and converting said information flowgraphs into the source (or object) code of the original programming language for use in automatic parallelization or efficient automated software testing approximating all-paths testing. Also provided herein is a digital-processor-implemented method for analyzing any directed-flow network that is representable as directed or semi-structured flows, the method comprising: transforming an application-specific representation of the directed-flow network into decision graphs which represent the control flow structure of said flow network, with data flow elements attached to the graphs; transforming said decision graphs into one or more information flowgraphs which represent the directed flows of said flow network in a unified manner, and which identify the independent and quasi-independent flows therein; and transforming said information flowgraphs into application-specific artifacts for identifying independent and quasi-independent flows occurring in said flow network. Also provided herein are a digital-processor-controlled apparatus comprising at least one digital processor and at least one machine-readable storage medium, the digital-processor-controlled apparatus being capable of performing the methods referred to above; and a computer-readable storage medium having instructions encoded thereon which, when executed by a computer, cause the computer to perform the methods referred to above.
These and other features, aspects, and advantages of the present invention will become better understood with regard to the following description, appended claims, and accompanying drawings where:
Summary
Intra-Method Graphs
Signal Flow Algebra
External Breaks
Partial Outcome
Generalized Search of the Decision Graph
Sign Examples
Compound Predicate
Loop Transform
Partition Transform
Star Transform
Kappa Transform
Delta Transform
Delta Star Transform
Kappa Cleanup Transform
Cleanup Transform
Path Testing
Automatic Parallelization
Program analysis refers to some means of analyzing a computer program (or similar system) based on its static structure (for software, at compile-time) or dynamic structure (for software, at run-time). The systems addressable by the present invention fall within the general class of systems that can be described by languages (most notably computer programming languages) that possess semi-structured control-flow. This class includes computer programs developed with those languages most widely employed in industrial practice (such as Java).
Flow Analysis
The identification of independent processes is a fundamental problem in program analysis, and therefore in the numerous essential specialties of computer science which programs analysis underlies. Informally speaking, process A and process B are independent if changing the ordering of the processes (for example, from “A before B” to “B before A”) does not change the behavior of the system. If process A supplies a necessary input for process B, then the two processes are not independent, and process A must precede process B to avoid incorrect system behavior. The constraint imposed by A's supplying a necessary input for B can be modeled by a flow from A to B. In this context, the flow is called a “necessary” flow because it represents a necessary ordering of A and B.
If process A can somehow control whether process B occurs, then there is control flow from A to B. If process A and process B both occur and A supplies data to B, then there is a data flow from A to B. These flows are often represented by graphs, in which A and B are nodes of the graph and flows are edges of the graph. A path is a series of edges in the graph. In an ideal representation for flow analysis, if there is a necessary flow from A to B, then there is a path in the graph from A to B. Conversely, in an ideal representation, if processes A and B are independent, then there is no path in the graph from A to B.
Traditional models used in program analysis have been typically based on analysis of either control flow or data flow but not both. The main limitation of analyzers based exclusively on control flow is that, in general, not all paths in the control flowgraph represent necessary flows. The main limitation of analyzers based exclusively on data flow is that the data flowgraph is not capable of representing all necessary flows. More recent systems for program analysis have attempted to combine the control flowgraph with the data flowgraph in some manner to overcome these limitations. These systems inherit at least some limitations of the traditional models, since their methods for combining the two forms of flow analysis, which have been empirically derived, do not represent a full unification.
Information Flow Analysis
The foundation for the advancements presented herein is the signal flow algebra, which is a mathematical system for describing necessary flows. Signal flow analysis was originally developed in the middle of the 20th century for analyzing analog electronic circuits. The signal flowgraph represented the equations governing voltages and current flow in these circuits.
By analogy, the information flowgraph presented herein represents the signal flow equations governing the control and data flow in computer programs and similar systems. The signal flow algebra disclosed herein, being non-associative, bears little resemblance to the signal flow algebra underlying circuit analysis, which is similar to the algebraic rules of arithmetic.
The information flowgraph is the central part of the flow analyzer disclosed in this patent. The information flowgraph is a single, unified representation of both control and data flow. The information flowgraph is closer to an ideal representation of flow than its predecessors because it has a sound mathematical basis. (Note that a static representation that consists exclusively of necessary flows is a theoretical impossibility for the general class of computer programs.)
The main features of the information flow analyzer are:
-
- a sound mathematical foundation
- an implementation based on graph transformation
- (see overview in this section under the heading, “Process”)
- versus the iterative algorithms typically used by other methods
- a physical model
- (see “the flow of state” in the section, “Intra-method Graphs”)
- native support for semi-structured constructs (break, multiple returns in a single method, continue, exceptions) versus the structuring
- preprocessor typically required for other methods
Applications
The implications of this theoretical and practical advancement is a program analyzer better suited for the challenges posed by contemporary trends, such as multicore processors, highly parallel supercomputers, and cloud computing. Although program analysis has many applications to software and computer controlled systems, two are highlighted in this patent application. The potential benefits of the information flow analyzer for transforming programs to run on multi-core processors and highly parallel systems are demonstrated in the section “Automatic Parallelization.” The application of the information flow analyzer to software testing is introduced in the section “Path Testing.” The central part of information flow analysis, the information flowgraph, is an inherently parallel representation of flow and is therefore ideally suited to these applications.
The effectiveness of any program analysis method for these applications depends directly upon its precision. As demonstrated in the section “Automatic Parallelization,” information flow analysis offers greater precision than traditional methods such as dependence analysis, because of its ability to distinguish necessary and unnecessary flows.
In general, as noted above there is a wide range of applications of information flow analysis. The present invention is capable of analyzing virtually any system of generalized flow models representable as directed or semi-structured flows (including, in addition to control and data flows in computer programs, flows of gas, power, and water in utility systems) in order to determine the independent flows that may occur in the represented system.
For example, if flow paths of an arbitrary system (such as a community water supply system) can be represented as a semi-structured flow (such as DDF, an intermediary language described elsewhere) that can be translated (e.g., via preprocessors or other means) into a format suitable for input into the central process of the present invention, then the present invention can precisely identify the independent flows of the subject system.
In the case of the example community water supply system having multiple sources of supply, multiple consumers, and numerous flow paths, knowing the system's independent flows would allow the determination of which consumers would be affected by a shock to the system such as pump failure or sabotage at a particular point. Conversely, given a set of affected consumers, knowing the system's independent flows would allow the determination of which upstream points could be responsible for a particular symptom. Furthermore, knowing the system's independent flows would enable maximally efficient testing of the system flows, as well as enable the optimization of energy used to meet the needs of various subsets of consumers (in this example, water need only flow along the shortest path from suitable supplies to the consumers who currently need it).
Overview of Process
In a preferred embodiment, each conceptual process and/or process step described herein is loosely coupled to the others, and may be multiply instantiated, any instance of which may be implemented as an application-specific hardware device (e.g., ASIC), a software process, or in any of various hybrid combinations, such that the various instantiations of processes and/or process steps may operate independently, asynchronously, and in parallel.
Since the inputs to the analysis to be performed may span from relatively simple to arbitrarily complex, and any number of such inputs may need to be analyzed at the same time, the process described herein scales downward as easily as upward, and is straightforward to implement on a wide variety of digital processing architectures. In particular, the process lends itself to hardware implementation and/or acceleration, yet is also well-suited for massively parallel supercomputing and cloud-computing architectures.
The central process in the information flow analyzer is called the “alpha transform,” as depicted in
The overall effect of the alpha transform is to convert each decision graph received as input to one or more alpha graph outputs, each of which describes a set of independent flows discovered by analyzing the input using the method of the present invention. Subsequently, the alpha graph outputs may be post-processed (e.g., by downstream “subscribers”) to achieve application-specific goals such as automatic test-case generation (approximating all-paths testing), automatic parallelization of software codes (such as for maximizing achievable throughput from multicore or massively parallel processors), and other uses.
As noted above, in a preferred embodiment the alpha transform is preceded by one or more preprocessors (collectively depicted by the single oval in
The operation of the aforementioned preprocessors will vary, depending on the system and flow model. For example, the use of various programming languages or object codes as inputs to be analyzed in a software system may call for diverse preprocessors. In some scenarios, a single preprocessor may directly convert the available representation (e.g., source language) of a system into the decision graph format needed as input by the alpha transform process, whereas other scenarios may call for a multiplicity of preprocessors.
In this summary, we assume a preferred embodiment having a standard preprocessing architecture where three loosely coupled preprocessors collectively implement the requisite preprocessing sequence conceptually encapsulated by the single oval in
In a preferred embodiment, the first preprocessor (sometimes referred to in the art as a “front-end”) converts the representation of the system to be analyzed (e.g., source code) to an optional intermediary language called DDF that may serve as a target language for a wide variety of front-end preprocessors. This front-end preprocessor may be implemented most straightforwardly as a parser using compiler-writing techniques well known in the art. Note that DDF is a human-readable form that may also be manually generated, such as for testing purposes.
In a preferred embodiment, the second preprocessor, which also may be implemented as a parser, converts the DDF output received from a front-end preprocessor (or, in some cases, manually generated DDF) to another intermediary form called a “decorated decision graph.”
In a preferred embodiment, the third preprocessor accepts decorated decision graphs and converts them to the decision graph format required as input to the alpha transform process depicted by the boxes in
In an alternate embodiment of preprocessors, the three conceptual preprocessors may occur singly or in any combination that provides a decision graph suitable for use by the alpha transform process.
The remainder of this section presents a synopsis of how the graph transformations in
1. As depicted in
2. As depicted in
3. As depicted in
4. As depicted in
5. As depicted in
Note: A mated pair of one-use alpha graphs consists of the delta graph and kappa graph produced from a mated pair of decision graphs. For every mated pair of one-use decision graphs input to the transforms “Delta” and “Kappa,” there is exactly one mated pair of one-use alpha graphs output, the parts of which are pushed, published, or otherwise made available as input to the downstream transform “KappaCleanUp,” as depicted in
6. As depicted in
7. As depicted in
8. As depicted in
9. As depicted in
10. As depicted in
As noted earlier, the alpha graph outputs may be post-processed (e.g., by downstream “subscribers” collectively represented by the oval in
The algorithm for information flow analysis is based on graph transformation. This section describes the two fundamental graphs that constitute the input and output of the algorithm operating at the intra-method level:
-
- decision graph
- alpha graph
The input of the algorithm is a decision graph. The decision graph is a hierarchical representation of control flow, annotated with the data elements described below. The decision graph is derived from source code in a semi-structured language, such as Java, or an intermediary representation of method structure. The intermediary representation is typically an annotated control flowgraph, which may be presented pictorially, or encoded as an XML file or DDF file. The latter is a decision data flow language file, and is employed in some of our examples.
The output of the algorithm is an information flowgraph at the intra-method level or simply alpha graph. The descriptor, “alpha,” denotes information flow at the intra-method level. If the method contains independent information flows, a single decision graph is transformed into multiple alpha graphs.
1.2 Data ElementsThe data elements are the memory access elements and intra-segment data flow elements, which are constructed from the memory access elements.
1.2.1 Memory Access ElementsA memory access element represents a memory read or write or in the case of a predicate, one or more memory reads. The locations in memory being accessed are represented by simple variables. A definition or use has an associated variable. A predicate has an associated vector of uses. The information flow predicate is not, in general, the same as a predicate in a semi-structured language, such as a Java predicate. An information flow predicate occurs in a single segment, so if one use in the predicate is executed, then all uses in the predicate are executed. An information flow predicate contains only uses and, unlike a Java predicate, cannot contain definitions or intra-segment data flow elements.
The memory access elements are listed in the table shown in
A data flow element is an ordered pair of standard memory access elements. The first memory access element in the pair is the input element and the second is the output element. A data flow that occurs within a single program segment (see below) is called an intra-segment data flow. The intra-segment data flow elements are listed in the table shown in
Intra-segment data flow elements create two classes of memory access elements: exposed and unexposed. Exposed memory access elements can participate in inter-segment data flows, whereas unexposed memory access elements are “hidden” from data flows outside of the segment containing them.
An exposed definition is a definition that is live upon exit from the segment. For example, in the segment:
-
- x=1
- y=x
- x=2
the exposed definition of x is contained in the statement “x=2.”
An exposed use is a use that can be reached by a definition outside of the segment. For example, in the segment:
-
- z=x
- x=1
- y=x
the exposed use of x is in the statement “z=x.” A segment can have only one exposed definition and one exposed use of a specific variable.
As shown in the table in
The ud token is followed by a list of two or more variables and represents a ud-join. If the list contains more than two variables, then the ud-join represents a set of two or more ud-pairs which share a common output definition. Each variable in the list except the last, is a variable in an input use. The last variable in the list is the variable in the output definition. A ud token followed by a list of exactly two variables is the degenerate form of a ud-join and represents a single ud-pair. The first variable in the list is the variable in the input use and the second variable is the variable in the output definition.
For example, in the Java fragment:
-
- z=x+y;
there are two intra-segment data flows. The first data flow is from the use of x to the definition of z, and the second data flow is from the use of y to the (same) definition of z. These two data flows (ud-pairs) are represented in DDF by the single ud-join:
-
- ud(x,y,z)
since the two pairs share the common definition of z.
This syntax convention clearly distinguishes the case in which several ud-pairs share a common output definition, as in the above example, from the case in which several ud-pairs have distinct output definitions. An example of the latter case is the Java fragment:
-
- z=x;
- z=y;
In this fragment, the first definition of z is anomalous, since it is killed by the second definition of z. Nevertheless, there are two distinct definitions of the variable z, which is represented in DDF by the two ud-joins:
-
- ud(x,z)
- ud(y,z)
In general, a source code expression of the general form:
-
- y=f(x1, x2, . . . , xn)
is represented in DDF by the ud-join:
-
- ud(x1, x2, . . . , xn, y)
The augmented control flowgraph is introduced, since it is useful for describing basic concepts related to the decision graph.
1.3.1 NodesThe nodes of the standard annotated control flowgraph are the S-Nodes. Paige, M. R., “On partitioning program graphs,” IEEE Trans. Software Eng., Vol. SE-3, November 1977, pp. 386-393.
Information flow analysis uses a new form of annotated control flowgraph called an augmented control flowgraph, which has the additional nodes:
-
- origin of the root edge
- origin of decision entry edge
- origin of decision exit edge (which is bypassed by at least one outcome)
- origin of data element edge
- origin of break edge (which is preceded by a data element edge)
- origin of loop predicate edge
- origin of loop exit edge
These nodes are added for proper generation of the decision graph.
1.3.2 EdgesThe edges of the standard annotated control flowgraph are segments. Paige, M. R., “On partitioning program graphs,” IEEE Trans. Software Eng., Vol. SE-3, November 1977, pp. 386-393. Any control flow path may be expressed as a sequence of segments. In information flow analysis, a segment is an edge of the augmented control flowgraph. The types of edges (or segments) of an augmented control flowgraph consists of those found in conventional annotated control flowgraphs plus several new types:
-
- root edge
- decision entry edge
- decision exit edge
- data element edge
- break edge
- loop entry edge
- loop predicate edge
- loop exit edge
- initial outcome edge
- simple outcome edge (normal or break)
Only certain edges may have associated data elements: a decision entry edge, a data element edge, a loop predicate edge and a simple (normal) outcome edge. When the flowgraph is rendered graphically, the data flow elements appear as annotations.
Each control flow edge has an identifier. The identifier of the edge appears immediately before the left parenthesis in the symbol for any memory access or intra-segment data flow element contained in that edge. In the Figures, the identifier of the edge is a subscript. For example, d2(x) represents the definition of ‘x’ which is contained in edge #2, and ?3(a,b,c) denotes the predicate in edge #3 that represents uses of variables ‘a’, ‘b’ and ‘c’.
A break edge is used to represent a break, return or exception. The break edge transfers control to the exit of a structure containing the break. The structure may be a decision, loop iteration or a complete loop. If the break edge is on a path in an outcome of decision A, then control can be transferred to the exit of A. Similarly, for loops, if the break edge is on a path in loop A, then control can be transferred to the exit of the current iteration or to the complete exit of loop A or to the exit of loop B, where loop A is on a path in loop B.
The DDF syntax for the break statement is:
-
- break <target>
where <target> is the label at the beginning of the statement containing the target predicate. If B is the target predicate, then control will be transferred to the exit of decision (or loop) B.
Similarly, the DDF syntax for the continue statement is:
-
- continue <target>
The Decision Data Flow language (DDF) is a Java-like language in which statements represent control flow and data flow elements. Control flow in DDF is represented by four constructs:
-
- the if statement,
- the while statement
- the break statement
- the continue statement
DDF is very low level, and serves as a machine language. Higher level structure, such as compound predicates, are translated into DDF prior to analysis. Data flow sources and sinks are represented by memory access and intra-segment data flow elements.
A single control flow segment can be represented in DDF by a list of data elements. The elements are separated by commas. Since a basic block is a program segment, a single DDF statement may correspond to several Java statements.
The Java source code and DDF for the signxy(int x,int y) method are presented in
The decision graph is an ordered tree representation of an annotated control flowgraph. Each node in the decision graph is associated with an edge of the control flowgraph.
1.5.1 NodesThere are three basic types of nodes in the decision graph:
-
- sequence node SNode
- end node EndNode
- divergence node DNode
The EndNode is an abstract type. There are three types of end nodes:
-
- leaf node LNode
- break node BNode
- convergence node CNode
There are two special types of CNode:
-
- loop entry node LoopEntryNode
- loop exit node LoopExitNode
There is one special type of DNode: loop predicate node WNode.
A class diagram for the decision graph Node is shown in
Each decision graph Node has
-
- a reference to the decision graph in which it appears
- an identifier (which consists of an index number and loop instance vector)
- a parent node
The sequence node or SNode represents sequential execution. The edge associated with the sequence node is executed first, then each of its child nodes, proceeding left to right. In addition to decision graph, identifier and parent node, each SNode has:
-
- a vector of child nodes
- a vector of interior nodes
The SNode may have any number of child nodes. Note that an SNode has no associated data elements. An example sequence node is illustrated in
The EndNode (end node) represents a single segment. An EndNode has no children. In addition to decision graph, identifier and parent node, an EndNode has:
-
- an antecedent
- interior nodes
An LNode (leaf node) is a “normal” EndNode, in the sense that it does not represent a break, a decision exit or loop entry. An LNode has a vector of data elements. An example of an LNode is Node #4 in the decision graph shown in
A BNode (break node) is an EndNode that represents a break, continue, return or exception segment. A BNode has a target ID, which is the ID of the predicate node (DNode) of an enclosing decision or loop. A BNode contains no data elements. Since a BNode is an Endnode, it has no child nodes. An example of a BNode is Node #6 in the decision graph shown in
A CNode (convergence node) is an EndNode that represents the convergence of data flows. A CNode is used to represent the convergence of data flow in a decision exit. In
A LoopEntryCNode is a special type of CNode (and therefore an EndNode) that represents the convergence of data flow in the entry of a loop. The converging data streams emanate from outside the loop and from streams within the loop body that do not exit the loop, such as those formed by continue statements. In
A LoopExitCNode is a special type of CNode (and therefore an EndNode) that represents the convergence of data flow in the exit of a loop. The converging data streams emanate from the false outcome of the loop predicate and from break statements that target the loop exit. In
The divergence node or DNode represents alternation. The DNode depicts a decision predicate. In addition to decision graph, identifier and parent node, a DNode has:
-
- an antecedent
- two child nodes, one for each decision outcome (assuming neither outcome is null)
- a vector of breaks
- a vector of uses, one use for each variable in the predicate
The predicate segment associated with the decision node is executed first. Evaluation of the predicate (true or false) determines which of the two child nodes is executed next. By convention, the first child node represents the false outcome and the second child node represents the true outcome. An example decision node is illustrated in
It is possible for a DNode to have only one child or no children at all. This type of DNode occurs when one or both outcomes are “null outcomes.” A null outcome is an outcome which contains no uses, no (live) definitions and is not a dcco. For example, an interior use partial outcome is not a null outcome, because it contains a use and is a dcco.
This document describes decision graphs (and alpha graphs) based on Boolean logic. A Boolean logic predicate has two possible values: false or true. It is possible to extend these graphs (and the alpha transform) to other logics by using n-ary predicates which can take on n possible values. In the n-ary graphs, a decision has n outcomes, a DNode may have up to n children, and its image, a predicate alpha node, may have up to n sets of children.
1.5.1.3.1 WNodeThe WNode (while node) represents repetition. The WNode depicts the predicate of a while loop and is a special type of DNode. In addition to decision graph, identifier and parent node, a WNode has:
-
- a false child which represents termination of the loop
- a true child which represents the body of the loop
- a vector of uses (one use for each variable in the loop predicate)
An example while node is illustrated in
The WNode is always preceded by a LoopEntryCNode which represents the entry of the loop. In
The WNode always has as its successor, a LoopExitNode which represents the normal exit of the loop. In
The edges of the decision graph represent parent-child relationships between nodes.
1.5.3 Normal FormThe alpha graph transform takes as its input a decision graph, which must be in normal form to be processed properly by the algorithm.
The rules for the normal form of a decision are:
-
- the parent of the DNode is an SNode
- the successor of the DNode is a CNode
If A is a DNode and B is its parent SNode, then the successor of A is that child of B which immediately follows A. The successor represents the decision exit. The decision graph of the signxy(int x,int y) example is shown in
The rules for the normal form of a while loop are:
-
- the parent of the WNode is an SNode
- the predecessor of the WNode is a LoopEntryCNode
- the successor of the WNode is a LoopExitCNode
A data element edge is an edge of the annotated control flowgraph representing the outcome of a decision which contains a data element. For example, in
The rules for the normal form of a data element edge are:
-
- the parent of the LNode (which represents the data element edge) is an SNode
- the parent of the SNode is a DNode
In
The state at a particular point in a program consists of its execution state (not yet executed, executable and executed, neither executable nor executed) and the values of the program variables. The execution state is the control state, whereas the values of the program variables constitute the data state. As the program is executed, state information is propagated from the entry nodes to the exit nodes of the information flowgraph.
An information flowgraph is an explicit representation of the flow of control state and data state in a program. The alpha graph is an information flowgraph that represents flow at the intra-method level.
The alpha graph can be described in terms of a mathematical model, an algorithmic model or a physical model. The following description emphasizes the physical model, with informal references to the data structures of the algorithmic model, since this approach appeals to physical intuition.
In the physical model, the alpha graph is viewed as a collection of control and data flows. Each data flow (or stream) has an associated variable. For example, the data flow from d2(x) to d10(x) is labeled by the variable ‘x’.
1.6.1.1 Control StateControl flow is the flow of control state from one node in the alpha graph to another node in the alpha graph. The control state assigned to nodes or edges of the alpha graph can take on one of three values:
Data flow is the flow of data state from one node in the alpha graph to another node in the alpha graph. The data state of a predicate alpha node is the set of values bound to the variables in the predicate. The data state of any other type of alpha node is the value bound to the single variable associated with that node.
1.6.2 Computational ModelPrior to execution, the control state of all nodes and edges of the alpha graph is set to CLEAR. Execution begins by setting all entry nodes of the alpha graph to PASS. During a single execution, state information (consisting of control and data) is propagated through the alpha graph in a continuous manner until all nodes are either in the PASS or BLOCK control state. As described in the section on loops, nodes in a cycle that represent multiple instances may be assigned states multiple times during a single execution of the method.
The flow rules for the propagation of state are presented in the tables shown in
The nodes of the alpha graph represent sources, sinks and repeaters of control and data flows within a method. Each node of the alpha graph is called an alpha node. An alpha node has an ID which corresponds to the identifier of its inverse image in the decision graph.
The term data input will be used to refer to a single data input or a collection of multiple data inputs. A similar convention will be used with regard to the terms: data output and control output. An alpha node has some subset of the following:
-
- data input
- data output
- control input
- control output
The five primary types of alpha nodes are illustrated in the table shown in
The fields associated with each type of alpha node are summarized in the table shown in
A definition alpha node is a data source. The data flow is labeled by the associated variable. For example, the definition alpha node d2(x) represents the source of data labeled by variable ‘x’ located in segment #2 of the corresponding annotated control flowgraph. A definition alpha node that has no data inputs is a data source and converts control state to data state. A definition alpha node that is the output of one or more ud-pairs is a data repeater and has an input for each of the ud-pairs. A definition alpha node may have one or more data outputs. A definition alpha node is the image of a definition which is associated with an LNode in the decision graph.
The flow rules for the definition alpha node are shown in the table shown in
The use alpha node is a data sink for the data flow labeled by its associated variable. For example, the use alpha node u10(x) represents a sink for the data flow labeled by variable ‘x’ located in segment #10 of the corresponding annotated control flowgraph. Normally, a use alpha node has no data outputs, but if the use alpha node is the input of a ud-pair, then it is a data repeater and will have an output. The use alpha node is the image of a use which is associated with an LNode in the decision graph.
The flow rules for the use alpha node are shown in the table shown in
The predicate alpha node represents divergence of control. A predicate alpha node may represent the divergence of control in the predicate of a decision or in the predicate of a loop. The predicate alpha node is a data sink for one or more signals, each identified by an individual associated variable. A predicate alpha node has (composite) data inputs. A predicate alpha node converts data state to control state. The control output of a predicate alpha node is divided into two sets, which correspond to the two possible values of the predicate: false and true. Each control output has an associated variable. The predicate alpha node is the image of a DNode (or WNode, which is a special type of DNode) in the decision graph.
A decision predicate is represented by a DNode in a decision graph and by a predicate alpha node in an alpha graph. The symbol for a decision predicate is the same in both graphs: a ‘?’ inside of a circle as shown in
A text reference to a decision predicate may be in one of several different formats:
-
- variable name (when it is clear from context that the variable name designates a decision predicate)
- variable name+P (for example, “bP”)
- ‘?’+identifier+variable name in parentheses (for example, “?2(x)”)
- ‘p’+identifier (for example, “p2”)
- ‘p’+identifier+one or more variable names in parentheses (for example, “?2(a,b)”)
The flow rules for the predicate alpha node are shown in the table shown in
The plus alpha node represents convergence of control and data. The plus alpha node is a data repeater. The data input of a plus alpha node consists of two or more data streams. The plus alpha node combines these streams to produce a single data output. The plus alpha node is an image of a CNode in the decision graph and has an associated variable.
The flow rules for the plus alpha node are shown in the table shown in
The control plus alpha node represents convergence of control only. The control plus alpha node is a control repeater. The control input of a control plus alpha node consists of two or more control streams. The control plus alpha node combines these streams to produce a single control output.
From a theoretical standpoint, the control plus alpha node can be considered as a special type of plus alpha node. In an implementation, the control plus alpha node would not be a subclass of plus alpha node, because its inputs and outputs are control streams instead of data streams. The control plus alpha node has no inverse image in the decision graph.
The flow rules for the control plus alpha node are presented in the table shown in
Since the loop entry plus alpha node and loop exit plus alpha nodes are loop nodes that have special properties, these two special types of plus alpha node are discussed in the next section.
The loop entry plus alpha node is the image of a LoopEntryCNode in the decision graph. Similarly, the loop exit plus alpha node is the image of a LoopExitCNode in the decision graph.
1.6.3.5 Star Alpha NodeThe star alpha node is analogous to a gate. It has a control input which determines if the signal at the data input is transferred to the data output. The star alpha node represents the convergence of data and control. The star alpha node is the image of an empty LNode or empty decision structure (or loop) in the decision graph.
The flow rules for the star alpha node are shown in the table shown in
The alpha graph is a directed graph which represents the flow of state information in a method. State information consists of both data and control. State information is propagated throughout the alpha graph by its edges. An edge represents the transfer of state from the origin node of the edge to its destination node.
Each edge of the alpha graph is an information flow element. A class diagram for the information flow elements is shown in
As shown in this diagram, there are two fundamental types of information flow elements:
-
- data flow element
- control flow element
A data flow element represents the transfer of both types of state information: data and control. In this respect, the data flow element could be considered a composite element. The nomenclature “data flow” has been retained to emphasize the primary role of this type of information flow element. A data flow element (or edge) is represented graphically by an arrow with a solid line.
If the destination node of a data edge has a control input, then the state of the control input may override the control state information carried by the data edge (see the tables in
There are two general types of data flow elements:
-
- intra-segment edge
- inter-segment edge
The intra-segment edges correspond to the intra-segment data flow elements listed in the table shown in
The feedforward edge is a special type of inter-segment edge which represents data flow from a loop node to a loop entry node. The latter nodes are discussed under the subheading, “Loops in the Alpha Graph.”
1.6.4.2 Control Flow ElementA control edge represents the flow of control state information. All control edges, except the exterior control edge, are represented by arrows with dashed lines which have a “slash,” usually positioned near the middle of the line.
There are two main types of control edges:
-
- polar
- nonpolar
A polar edge represents a decision outcome. Its origin must therefore be a predicate alpha node, and it has an associated polarity (true or false for a binary decision). A nonpolar edge represents portions of several decision outcomes. A nonpolar edge has as its origin, a control-plus alpha node.
There are three types of polar edges:
-
- exterior
- interior
- interior plus
An exterior edge has as its destination, a star alpha node, and is represented graphically by an arrow with a dashed line (with no slash through it). The exterior edge represents a dcco (def-clear complementary outcome). The outcome represented by the exterior edge must be def-clear for the variable associated with its destination. The origin of the exterior edge must have an alternate outcome that is not def-clear for the same variable.
An interior edge has as its destination, a definition alpha node that is on all paths in the outcome that the interior edge represents.
An interior plus edge represents a portion of a decision outcome which merges with outcomes of (one or more) other decisions. An interior plus edge has as its destination, a control plus alpha node.
1.6.5 Example of an Acyclic Alpha GraphSince the signxy( ) example has no loops, we shall use it as an example of an acyclic alpha graph. For reference, the Java source code and DDF for signxy( ) appears in
In a decision graph, a loop node is a LoopEntryCNode, LoopExitCNode, WNode or descendent of a WNode. In an alpha graph, a loop node is an image of a loop node in the decision graph. Most loop nodes are in a cycle and can therefore be executed multiple times. The exceptions are loop nodes which are in a break outcome and the loop exit node, which is the image of the LoopExitCNode.
In our computational model, “execution” of an alpha node consists of assigning a control state (BLOCK or PASS) to that alpha node. Each iteration of a loop is called an instance of the loop and is assigned an instance number ‘n’. In the first instance of the loop, ‘n’ is set to ‘1’. Prior to each subsequent iteration ‘n’ is incremented. If the loop is an “inner” loop nested within an “outer” loop, then the loop instance number ‘n’ is reset to ‘1’ whenever the inner loop is reentered.
In dynamic information flow analysis, there are two general representations for loops: the static alpha graph and dynamic alpha graph. In a static alpha graph, a node or edge represents all instances of that node or edge. A loop node or edge in the static alpha graph may be assigned a state multiple times. Whenever the inner loop in a nested loop is reentered, the state of all nodes in the inner loop is reset to CLEAR.
Advanced applications of dynamic information flow analysis deal with the properties the dynamic alpha graph that are relevant to a specific trace or set of traces. For example, a dynamic information flowgraph can be generated to represent the subset of flows that are possible after a specific instance of a node has been executed.
In a dynamic alpha graph, one or more nodes or edges have associated instance qualifiers. An instance qualifier is an expression which identifies the set of instances represented by the node or edge. The instance qualifier may impose a constraint on the value of the loop instance vector, which is described in the section, “Loop Transform,” or on the state of the node or edge. Normally, instance qualifiers are associated with alpha nodes, and the edge instances are implicitly defined in accordance with the instance qualifiers of the nodes.
The instance qualifier is incorporated into the ID of an alpha node or appended to the name of the alpha node as a constraint. An instance qualifier that specifies a unique value for the loop instance vector is incorporated into the ID of the alpha node. The ID of an alpha node is the index number followed by the loop instance vector. Periods are used to separate the index number from the loop instance vector and to separate the individual elements of the loop instance vector. For example, the ID of the ‘2’ (or second) instance of d6(x) is “6.2”. The full designation for this node is d6.2(x). If a node is in a nested loop, its loop instance vector will have multiple elements. For example, if the node d6(x) is in loop B which is nested inside loop A, the first instance of d6(x), in loops A and B, is d6.1.1(x). If the instance vector is incompletely specified, and there is no additional instance qualifier, the loop instance vector, by default, refers to the iteration of the minimal enclosing loop. In the previous example, d6.1(x) refers to the first instance of d6(x) in loop B.
If an instance qualifier specifies multiple instances, the instance qualifier is normally appended to the name of the node or edge, using a colon (‘:’) as a separator. For example, d6(x): n>1 is the loop node that represents all instances of d6(x) such that ‘n’ is greater than ‘1’. If the instance qualifier imposes a constraint based on state, the state is appended to the name of the node or edge. For example, d9(x): BLOCK is the loop node which represents all instances of d9(x) such that the control state of the instance is BLOCK.
A static alpha graph can be considered to be a dynamic alpha graph in which there are no instance qualifiers. The static alpha graph can also be considered as a compact “pattern” for generating a dynamic alpha graph. Each time a loop node in the static alpha graph is executed, a new loop instance node is generated in the dynamic alpha graph. The ID of the loop instance node has the same index as the loop node in the static alpha graph, and its loop vector contains the instance number of the loop. This process is called “loop expansion” and is further described in the section, “Loop Transform.” After being initialized to the CLEAR state, a loop instance node is assigned a state (PASS or BLOCK) exactly once.
The loop predicate is a predicate alpha node which is the image of the corresponding WNode in the decision graph. For example, the loop predicate ?4(a) in
The loop entry plus alpha node, which is also called the loop entry node, is one special type of plus alpha node. The other special type of plus alpha node is the loop exit node, which is explained below. The loop entry node and the loop exit node are, of course, loop alpha nodes. All other types of alpha nodes can be either a non-loop alpha node or a loop alpha node. The loop entry node is associated with a specific loop predicate. The loop entry node is a data repeater.
A loop entry node has two sets of inputs: the initializer input set and the feedforward input set. The set of inputs for a loop entry node depends upon the instance ‘n’. The initializer input set is a single data input which comes from a data source outside of the associated loop. The first instance of a loop entry node has the initializer input set. The feedforward input set consists of one or more data inputs which come from data sources in the previous iteration of the loop. All instances of the loop node after the first, have the feedforward input set.
The annotated control flowgraph for the “loop with break” example is shown in
The dependence of the input set on ‘n’ can be clearly seen in
An ordinary (non-loop) alpha node represents a single instance of the alpha node. In an ordinary plus alpha node, convergence takes place in the single instance of the alpha node. This same kind of convergence takes place in a single instance of a loop entry node if it has the feedforward input set as its input and there is more than one input in the set. For example, this “conventional” kind of convergence would be found in the second instance of a loop entry node that is the target of a continue statement inside of the loop. The new kind of convergence present in a loop entry node is the convergence of inputs associated with different instances of the alpha node. The initializer input set and the feedforward input set converge in the loop entry node, but in different instances. The input of the first instance of the loop entry node is the initializer input set. The input of the second instance of the loop entry node is (an instance of) the feedforward input set. The input of the third instance of the loop entry node is (an instance of) the feedforward input set and so forth. Note that the feedforward input set is an equivalence class.
An instance of the loop entry plus alpha node combines the appropriate set of input streams to produce a single data output.
The flow rules for the loop entry plus alpha node are presented in the table shown in
Like the plus alpha node, the loop exit node represents convergence of control and data. The loop exit node exhibits convergence in a single instance of the loop exit node. The loop exit node is a data repeater. The loop exit node is the image of a LoopExitCNode in the decision graph and has an associated variable.
In the static alpha graph, the data input of a loop exit node consists of one or more data streams. The loop exit node is the only type of plus alpha node that may have only one data input (in the static alpha graph). If there is only one data input, when the input is in the PASS state, the data at the input is transferred to the data output. If there are multiple data inputs, the input in the PASS state is transferred to the data output, when all other data inputs are in the BLOCK state. Of course, the single data output may be routed to the data inputs of multiple alpha nodes.
For example, in the static alpha graph shown in
The flow rules for the loop exit node are the same as those for the plus alpha node, as listed in the table shown in
-
- for a single execution (as opposed to iteration) of the loop, there is exactly one
- instance of the loop exit node
- this single instance of the loop exit node has an infinite number of inputs
The term “infinite” is commonly misused in the computer science literature. For our purposes, the term infinite is used to describe a number that is greater than any conceivable number that would be encountered in real machines that possess finite resources in time and space.
These two properties are illustrated by the process of loop expansion. As mentioned earlier, this process converts a static alpha graph to a dynamic alpha graph in which all loop nodes are loop instance nodes. Loop expansion is illustrated in the section, “Loop Transform,” and in
It is important to distinguish the physical execution (iteration) of a loop from the propagation of state in the expanded alpha graph. The expanded alpha graph has an infinite number of loop instances, which correspond to the potentially infinite number of loop iterations. During execution of the loop in the physical domain (for example, in the annotated flowgraph), there will be a corresponding flow of state in the expanded alpha graph. Although only a few physical iterations may be executed before the loop is exited, the flow of state in the expanded alpha graph will be propagated to all loop instances.
The first case depicted is BEFORE TERMINATION; i.e., after the loop has been entered, but before it has been exited. During the first two iterations, the inputs are in the BLOCK state. The BLOCK state is not transferred to the output of the loop exit node, because the remaining inputs (n>2) are in the CLEAR state.
The second case depicted in
The third case depicted in
The alpha level information flow transform converts one type of graph, an annotated control flowgraph, into another type of graph, an information flowgraph. Both types of graphs are directed graphs and can be considered as different forms of a signal flowgraph. A signal flowgraph is a pictorial (graph) representation of a system of simultaneous algebraic equations.
The system of equations for information flow are derived from the annotated control flowgraph. Information flow structure is contained implicitly in the annotated control flowgraph. The structure does not become readily apparent, and therefore useful, until it is represented explicitly, as it is in the information flowgraph. The information flowgraph is a direct representation of the system of information flow equations.
In a classical signal flowgraph, a node represents a physical variable (signal) and is a summing device and a repeater. An edge of the signal flowgraph represents transmission; the dependency between pairs of variables.
The annotated control flowgraph can be interpreted as a form of signal flowgraph, by associating with each node, a signal, which is the live definition of a particular variable. The signal is the live definition that is obtained at that node, if execution began at the entry node of the annotated control flowgraph. Signal flow is described with reference to a specific use, called the target use, and the variable is the one that appears in the target use.
The signal flow algebra provides a mathematical basis for the alpha level information flow transform. The alpha level information flow transform can be motivated mathematically by performing the following steps:
-
- select a target use in the annotated control flowgraph
- derive the signal flow equations from the annotated control flowgraph
- apply the rules of the signal flow algebra
- represent the transformed equations as an alpha graph
The application of these steps to an example of a simple decision is shown in
In information flow analysis, a program in the control flow domain is represented by an augmented control flowgraph which is described in the section, “Intra-method Graphs.” A simple example of an augmented flowgraph is shown in
For the derivation of information flow equations from the augmented control flowgraph, the augmented control flowgraph is organized into structures called path sets. Each path set is a subgraph of the augmented control flowgraph. Higher level path sets, such as decisions and loops, can be successively decomposed into lower level path sets. The lowest level path sets are the individual edges of the augmented control flowgraph.
2.3 Divergence in the Control FlowgraphThe predicate node is the destination of the predicate segment. Divergence of control flow paths is represented by a predicate node. Each path emanating from the predicate node has an associated polarity. The polarity of a path corresponds to the value of the predicate which activates that path. In the case of a binary decision, the polarity of such a path is either 1 or 0. For convenience, the polarity will usually be expressed by the corresponding boolean values: true or false.
Decisions and loops have predicate segments. In a decision, the predicate segment is the same as the entry segment. In a loop, the predicate and entry segments are distinct. The predicate segment is associated with the decision or loop predicate, which contains one or more predicate uses and has an associated boolean expression which determines its state. A lower case letter is typically used to represent the decision, the predicate, or the value of the predicate. The meaning of the lower case letter is established by context. The value of a predicate is
-
- 1 if the predicate evaluates to true
- 0 if the predicate evaluates to false
The complement of a predicate value b is designated as not(b) and is defined as
-
- b=1 then not(b)=0
- b=0 then not(b)=1
A predicate collectively represents its predicate uses. The value of a predicate is a function of its predicate uses. For instance, if the boolean expression associated with predicate b is
(x>3 && y>4) in segment #2
then its value can be expressed as
b=f(u2(x),u2(y))
In
An exit node is the origin of an exit segment. Convergence of control flow paths is represented by an exit node. In information flow analysis, exit nodes also represent points at which there would be convergence of paths if all breaks were removed from a path set.
The node in which all paths from a predicate node first intersect (join) is a complete exit node (or simply exit) of a path set. The exit node is the immediate forward dominator of the predicate node.
The normal exit of a path set is the node in which all control flow paths from the predicate node converge if all breaks are removed from the path set. A normal exit that is not also the complete exit of a decision is called a partial exit. A partial exit is on a path from the predicate node to the exit node.
In
At the Java method level, a control flowgraph is composed of a root edge followed by a sequence of path sets:
-
- data element edges and
- decision and loop structures
For example, the method in
A decision structure (or decision) is a set of control flow paths which represents selection. A decision consists of:
-
- decision entry (predicate) segment
- outcomes
- decision exit segment
The most important characteristic of a decision is that it has one entry and one complete exit.
Decision a in
-
- an entry (predicate) segment (edge #3)
- two complete outcomes: the false outcome is the path set {10} and the true outcome is the path set {4-5-7-8-9 and 4-5-6}
- an exit segment (edge #11)
The signal flow algebra and the alpha level information flow transform can be extended to apply to decisions consisting of more than two complete outcomes, but in this document, we shall limit our discussion to binary decisions, which have two outcomes: one for each polarity of the predicate.
2.7 Loop StructureA loop structure (or loop) is a set of control flow paths which represents repetition. A loop consists of:
-
- loop entry segment
- predicate segment
- outcomes
- loop exit segment
An example of a loop from the section, “Intra-method Graphs,” is shown in
-
- Loop a has:
- a loop entry segment (edge #3)
- a predicate segment (edge #4)
- two outcomes: the false outcome is the path set {5} and the true outcome is the path set {6-7-8-12-13 and 6-7-8-9-10-11}
- a loop exit segment (edge #14)
The origin of the loop entry segment is called the loop iteration exit, and the origin of the loop exit segment is called the loop exit. Since the true outcome contains a decision, it consists of two paths. The first path {6-7-8-12-13} remains “inside” of the loop and ends at the loop iteration exit. The second path {6-7-8-9-10-11} is a break outcome which ends at the loop exit.
2.8 Outcome StructureAn outcome consists of a set of paths of a specified polarity (true or false) that begins at the predicate node of the reference decision (or loop) and ends at an exit node or a star interior use.
The alternate outcome is the outcome with the opposite polarity. The paths in an outcome do not extend past the complete exit of the reference decision (or loop). A complete outcome ends at the complete exit of the reference decision (or loop). In
An interior use is a use (of a specified reference variable) that is on all paths in one outcome (of the reference decision or loop). There are two types of interior uses, based on the location of its antecedent. The antecedent of a use is the data source which reaches the input of the use. If the antecedent is not on a path in the outcome which contains the interior use, then it is a star interior use. Otherwise, the antecedent is a partial exit on a path in the same outcome which contains the interior use, and it is a plus interior use.
An ordinary partial outcome ends at a partial exit that is not the antecedent of a plus interior use. In
There are two types of interior use partial outcomes. A star interior use partial outcome ends at a star interior use. In
A summary of the basic outcome types is shown as a class diagram in
The basic types of outcomes may be further classified by adding properties which are listed in the following table. An outcome may be assigned one property from each row of the table. For instance, the property of being either true or false is selected from the first row of the table.
An outcome is simple if it consists of a single edge. An outcome is composite if it consists of multiple edges. A composite outcome begins with an initial outcome segment which is followed by a sequence of decisions, loops and data element segments. In
A break outcome has a break on all paths of the outcome. A break outcome is a set of paths (of a specified polarity) from the predicate node, through the break, to the break target exit. In
A normal outcome is a set of paths (of a specified polarity) from the predicate node of the decision to its normal exit. In
An outcome is not def-clear with respect to a specified variable if at least one path in the outcome is not def-clear for that variable. An outcome is def-clear with respect to a specified variable if all paths in the outcome are def-clear for that variable. In
An outcome is not complementary (with respect to a specified variable) if the alternate outcome has the same def-clear status. For example, if the true outcome of a decision is not def-clear and the false outcome is also not def-clear, then the true outcome is not complementary.
An outcome is complementary (with respect to a specified variable) if the alternate outcome has complementary def-clear status. In
A dcco is a def-clear outcome (with respect to a specified variable) of a decision, whereas there is at least one path in the alternate outcome of the decision which is not def-clear (with respect to the specified variable). The dcco is a fundamental type of path set in the theory of dynamic information flow analysis. In
A dciupo is a def-clear interior use partial outcome, and, like the dcco, it is a fundamental type of path set in the theory of dynamic information flow analysis. There are two types of def-clear interior use partial outcomes: the star interior use partial outcome and the def-clear plus interior use partial outcome. In both types, all paths in the dciupo are def-clear (with respect to a specified variable) of a decision, whereas there is at least one path in the alternate outcome of the decision which bypasses the interior use.
The image of a dcco or dciupo is a star alpha node in the alpha graph, and every star alpha node is the image of a dcco or dciupo. This is why these path sets are of such fundamental importance.
The purpose of the somewhat elaborate classification scheme for partial outcomes portrayed in
Let <theta> be a set of paths that all begin at a single entry node and end at node ‘n’. It is not necessary for all paths from the entry node to reach ‘n’. The transmission of the set of paths <theta> expresses the relationship between the signal at its entry node and the signal at ‘n’.
Recall that the signal is the live definition of a particular variable and is associated with a node of the annotated control flowgraph. The signal at node ‘n’ in the annotated control flowgraph is given by the equation shown in
The transmission <tau> <theta> above is obtained by decomposing the paths of <theta> into segments and combining the segment transmissions in accordance with the rules below.
2.9.1 Transmission of a SegmentA segment is the basic building block of a control flow path. There is only one path in a segment. The entry node of the path is the origin node of the segment, and the exit node of the path set is the destination node of the segment.
The transmission of a single segment is represented by <tau>j, where “j” is the segment number associated with that edge. If the segment is a predicate segment, then the symbol immediately following <tau> (which is shown as subscript in the Figures) may alternatively be the symbol for the predicate. For example, <tau>a denotes the transmission of predicate a.
Let ‘x’ be the variable appearing in the target use. The transmission of a single segment (edge) is shown in
The latter two rules illustrate how a predicate segment of a has two different transmission values, depending on whether the expression being calculated involves the true or false outcome of the decision.
2.9.2 Transmission of a SequenceLet A and B be two successive sets of control flow paths, such that the exit node of A is the entry node of B.
The transmission of the composite structure AB is shown in
The transmission of a decision outcome, complete or partial, is the value of the predicate (with the proper polarity) followed by ‘<dot>’ and the transmission of the paths in the outcome.
In the simple decision shown in
The exit node acts as a summing junction. The signal at the decision exit is the sum (+) of the signals associated with its incoming edges. The transmission of a normal or extended decision, is the sum of the transmissions of its two outcomes.
The transmission of the normal decision in
If the outcome (either complete or partial) is def-clear, then the star conversion transform is applied. This transform converts the <dot> to a ‘*’ in the expression for the transmission of an outcome. The star conversion law is shown in
‘κ’ is a qualifier consisting of predicate values, for example, ‘a <dot> b’. The star conversion transform derives its name from the property that the ‘*’ operator becomes a star alpha node in the alpha graph. The relationship between star conversion and a dcco can be understood by examining two cases:
-
- decision with predicate ‘a’ in which both outcomes are def-clear
- decision with predicate ‘b’ in which only one outcome is def-clear
An example of the first case is obtained by removing d4(x) from the decision in
In this example, 1′ is the transmission of either def clear outcome.
Using the signal flow algebra, the transmission of the decision in this case can be derived as shown in
Since neither outcome is a dcco, the transmission of the decision reduces to 1.
In an example of the second case, the transmission is given by the equation in
A loop is similar to a decision, insofar as it has a predicate with two outcomes (false and true). A single execution of a loop structure consists of the execution of a path which begins at the loop entry segment and ends at the loop exit or passes through an external break and ends at the exit of an enclosing decision or loop. During a single execution of the loop structure, the loop predicate and loop iteration exit may be executed multiple times. The traversal of such a path is called a loop iteration. The path set which contains all paths that begin at the loop predicate and end at the loop iteration exit is called the loop iteration path set. The origin of the loop entry segment is an exit, i.e. the loop iteration exit, because it is a point of convergence.
The transmission of the loop is dependent on ‘n’, the number of loop iterations and the specific path selected from the path set during each iteration. If there are one or more external breaks in the loop, then the transmission of the loop is also dependent upon the path set from the loop predicate through the external breaks to the exit of the loop (or to the exit of an enclosing decision or loop).
The transmission of ‘n’ complete paths in the loop iteration path set is shown in
If the n'th iteration is reached, then the value of each pi for i<n is 1 and the equation for the transmission is as shown in
The convergence that takes place in the origin of the loop entry segment (which is the loop iteration exit) is represented in the alpha graph by a loop entry plus alpha node (or simply loop entry node).
There are two conditions for the formation of a loop entry node:
-
- an initializer input from outside of the loop
- at least one feedforward input from a path in the loop iteration path set
In the dynamic alpha graph, an instance of a loop entry node has only one set of inputs. The input set of the first instance is a single initializer input. The input set of subsequent instances consists of one or more feedforward inputs. In the static alpha graph, a loop entry node has both sets of inputs. From hereon, we shall consider the loop entry node in the static alpha graph,
A loop entry node is similar to a plus alpha node, insofar as it combines multiple composite inputs to produce a single composite output. In addition, the loop entry node has the state variable ‘n’, which is the instance number of the node and a built-in decision structure which selects the correct input set (initializer or feedforward) depending on the value of n. The value of this built-in predicate is represented by the variable <lambda> as shown in
The transmission of the path set which begins at one instance of the loop entry node and ends at an instance of the loop entry is designated <tau>ENTRY. Let <tau>ENTRY.n be the value of <tau>ENTRY at instance n. Then the value of <tau>ENTRY.n is given by the equation in
The transmission of a loop (without an external break) is given by the equation in
The derivation using the signal flow algebra in
To demonstrate the operation of the signal flow algebra, we shall calculate the signal in the non-cyclic annotated control flowgraph shown in
The derivation of the signal flow equations for the non-cyclic example is shown in
The first equations are derived directly from the annotated flowgraph. The remaining equations are derived using substitutions and the rules of the signal flow algebra, which are listed in the last section of this section. The alpha graph of the non-cyclic example is shown in
To demonstrate the operation of the signal flow algebra when applied to a cyclic control flowgraph, we shall employ results from the subsection, “Transmission of a Loop.” The annotated control flowgraph in
If there is no associated rule in the right hand column of the derivation, then the equation is derived directly from the annotated flowgraph. The derivation of the signal flow equations for the cyclic example is shown in
The signal flow algebra represents sequencing constraints. The operator <open_dot> directly represents a sequencing constraint as shown in
The <dot> operator indirectly represents a sequencing constraint. The informal meaning of the <dot> operator is shown in
The predicate b must be evaluated before C can be executed.
The general strategy in using the algebra is to convert the expression for transmission into normal form as shown in
The informal meaning of the four binary operators of the signal flow algebra is summarized in
The informal BNF for the signal flow algebra expressions is as follows:
The rules (axioms and theorem) for the signal flow algebra are shown in
A signal flow algebraic expression is evaluated by substituting values for the variables in the expression. In the non-cyclic example, the derivation for the signal (live definition) at u13(x) is shown in
External breaks play a fundamental role in the operation of the primary transforms. We shall begin by informally presenting the basic concepts necessary for defining an external break. For convenience, the decision is considered as the fundamental path set. The theory may be extended to loops by simply replacing “decision” with “loop.” Unless otherwise noted, “path” refers to a non-cyclic path.
Path sets are typically decisions. A decision is denoted by the letter associated with its predicate. For example, “decision c” refers to the decision with predicate “c”. The same decision may be denoted by the single letter ‘c’, when the context makes it clear that ‘c’ does not refer to (only) the predicate.
3.2 ContainmentThe definition of external breaks is based on the concept of “containment,” which, in turn, is based on the concept of hypothetical paths. A hypothetical path is a path that does not exist in the graph, but could exist as a valid outcome if the existing outcome of a decision is replaced by the hypothetical path. In the unusual case in which there is no outcome of a specified polarity, the hypothetical path is simply added to the graph.
Path set A is contained in path set B if all existing or hypothetical paths in path set A are subpaths of existing or hypothetical paths in path set B. Containment is denoted:
-
- <path set A> <is contained in> <path set B>
or simply, “A is contained in B.” The term “path set” is intended to be interpreted in its most general sense, meaning any set of paths, including a single edge or even a single node (the trivial path set).
For example:
-
- break b1 <is contained in> decision c
means that the break b1 (a special edge of the control flowgraph) is on a path (or could be on a hypothetical path) in decision c. For convenience, in some contexts, this relationship is stated more concisely as “c has break b1” or even “c has b1.” Similarly, the relationship:
-
- b1 is an external break wrt decision c
is stated more concisely as “c has external break b1.”
3.3 Exit of a DecisionThe exit of a decision is the node in which all paths from the decision entry first meet. In
The normal exit of a decision is the node “nearest” the entry node of the decision which could serve as the decision exit after the possible replacement of existing outcomes with hypothetical paths.
For example, in
The decision predicate is normally denoted by a letter. Since a single letter may denote a decision predicate or a decision, in some contexts, a ‘P’ is appended to the letter when it specifically refers to a decision predicate. For example, in
The normal exit of a decision is denoted by the letter associated with the decision followed by an apostrophe. For example, in
In the decision graph, the normal exit is represented by the CNode that is the immediate successor of the DNode representing the decision predicate. In
The normal decision with predicate c is the set of paths from the destination of the predicate edge to the normal exit of decision c. A normal decision is denoted by the letter associated with its predicate followed by ‘N’. For example, in
The determination of containment of path sets is facilitated by the structure of the decision graph. If the predicate of one normal decision is the descendent of the predicate of a second normal decision in the decision graph, then the first normal decision is contained in the second. For example, in
-
- cN <is contained in> aN
Similarly, if a node is the descendent of a decision predicate, then the node is contained in that decision. For example, in
In a structured control flowgraph (or structured decision graph), the exit of a decision c is the normal exit of c. In a semi-structured control flowgraph (or semi-structured decision graph), the exit of a decision c may be the normal exit of c or the normal exit of a decision which contains c.
The semi-structured transfer of control which causes the exit of a decision to be different from the normal exit is represented by a special edge called a ‘break’. In Java, the break corresponds to a break, return or exception statement. In DDF, the
syntax for the break is:
-
- break <target>
where ‘target’ is the label at the beginning of the statement containing the target predicate. In most examples, the target is the letter used to denote the target decision.
Intuitively, a break is an edge which “re-routes” paths so all paths through the break bypass a possible exit of a decision. In
There are two basic types of breaks: internal and external. The classification of a break is relative to a specified decision called the “reference decision.” If the break is on a path from the entry node to the normal exit of the reference decision, the break is an internal break wrt (“with respect to”) the reference decision. For example, in
A break is an external break wrt the reference decision if the break is not on a path in the normal reference decision. For example, in
The exit of a decision with no external breaks is the normal exit. The exit of a decision c with at least one external break is not the normal exit, and is, instead, the destination of an external break b1, which is the normal exit of decision b where:
-
- cN <is contained in> bN
Since an external break wrt a decision causes the exit of the decision to extend beyond the normal exit, a decision with at least one external break is called an extended decision. In
There are three decisions associated with an external break:
An external break is defined with respect the “reference decision.” The external break bypasses the normal exit of a decision called the “medial decision.” The destination of the external break is the normal exit of the “target decision.” The medial and reference decision are not necessarily distinct.
An external break wrt reference decision c is contained in c. In particular, the destination of the external break b′ (the normal exit of the target decision) is contained in c:
-
- b′ <is contained in> c
External breaks are classified in two ways.
The first scheme for classifying external breaks is based on whether the medial and reference decisions are the same or different. If the two decisions are the same, the external break is classified as “elementary,” otherwise it is classified as “composite.”
The second scheme for classifying external breaks is based on the position of the external break wrt the predicate of the reference decision in the decision graph. In the decision graph, the predicate of a decision is represented by a DNode and a break is represented by a BNode. If the BNode which represents the external break is a descendent of the DNode which represents the reference decision predicate, then the external break is classified as a “descendent external break” (abbreviated as “DEB”). An external break that is not a DEB is classified as a “successor external break” (abbreviated as “SEB”), since it is a successor of the CNode which represents the normal exit of the reference decision.
3.9 Formal Definition of an External BreakThe formal definition of an external break is based on 4 core properties shared by all external breaks:
An elementary external break possesses properties B1-B4 and the one additional property:
This property states that the structure of the medial decision is elementary; i.e., that the medial decision is simply the normal decision c and therefore has no interesting internal structure.
In
-
- reference decision=b
- medial decision=b
- target decision=a
into B1-B4 and DEB1. In the case of elementary external break b1, all paths through b1 bypass the normal exit of the reference decision. Intuitively, edge #8 is an elementary external break wrt reference decision b, since all paths through edge #8 bypass the normal exit of b (the destination of edge #11).
Note that edge #8 is a descendent external break since it satisfies DEBT.
3.11 Composite External BreakA composite external break possesses properties B1-B4 and the two additional properties:
-
- CEB1 The normal sub-decision of the reference decision (cN) is contained
- in the medial decision (aN).
- CEB2 The normal exit (a′) of the medial decision is contained in the
- reference decision (c).
- CEB1 The normal sub-decision of the reference decision (cN) is contained
Under the second classification scheme, an elementary external break is also a descendent external break since it satisfies DEB1. A composite external break is a descendent external break if it satisfies the property:
-
- DEB2 There is no path p2 such that the reference decision predicate (cP),
- the normal exit (c′) of the reference decision and the origin of the
- external break are on p2.
- DEB2 There is no path p2 such that the reference decision predicate (cP),
In
-
- reference decision=c
- medial decision=b
- target decision=a
into B1-B4 and CEB1-CEB2. In the case of composite external break b2, decision c possesses an external break b1 (elementary or composite) which has the normal exit of the medial decision as its destination, and all paths through b2 bypass the normal exit of the medial decision. Intuitively, edge #8 is a composite external break wrt reference decision c, since all paths through edge #8 bypass the normal exit of b.
Note that edge#8 is a successor external break since it satisfies CEB-CEB2, but does not satisfy DEB2.
Intuitively, the elementary external break may be viewed as the limiting case when the reference decision approaches (and becomes identical to) the medial decision. When cN equals aN, the definition of the composite external break “collapses” to become the definition of the elementary external break.
3.12 Descendent External BreakUnder the second scheme for classifying external breaks there are two types: descendent and successor. A break is a descendent external break if it is an elementary external break (and therefore satisfies DEB1) or if it is a composite external break which satisfies DEB2. A break is a successor external break if it is a composite external break which does not satisfy DEB2.
Intuitively, this classification of external break is based on the decision graph. In the decision graph, a break is represented by a BNode, which has as its label “break <target>.” In
-
- reference decision=c
- medial decision=c
- target decision=a
Since cP is a descendent of aP:
-
- cN <is contained in> aN
which establishes B3.
Since the break in
In
-
- reference decision=c
- medial decision=b
- target decision=a
Furthermore, it does not satisfy DEB2, so it is a successor external break. B3 and CEB1-CEB2 are easily obtained from the structure of the decision graph. Since bP is a descendent of aP:
-
- bN <is contained in> aN
which establishes B3. Since cP is a descendent of bP:
-
- cN <is contained in> bN
which establishes CEB1. Since break b is a descendent of cP:
-
- b′ <is contained in> c
which establishes CEB2.
Intuitively, the BNode labeled “break a” is a successor external break wrt decision c, since it is a successor of the normal exit of the reference decision.
The classification schemes for external breaks are summarized in
There are two operations involving external breaks that are used extensively in the alpha transform:
-
- OPERATION 1: Determine whether a path set (which is typically a decision) has an external break wrt decision n.
- OPERATION 2: Find the maximal element in a path set. The maximal element is obtained by examining the targets of all breaks in the path set. The maximal element is that target in the breaks which is nearest the root of the decision graph.
Both operations are based on a search of the decision graph. The initial subtree of a path set is the subtree which has the predicate of the reference decision as its root. A search of the initial subtree is sufficient for finding only descendent external breaks (wrt the reference decision). To find both types of external break (descendent and successor), it is necessary to search the entire path set. The preferred method for searching a path set is called the “Generalized Strategy,” which is described in the section, “Generalized Search of Decision Graph.” The Generalized Strategy is the most comprehensive method for searching the decision graph and is capable of performing operation 1, operation 2 and additional operations such as:
-
- OPERATION 3: Determine if a path set is empty. A path set is empty if it does
- not contain a definition of a specified reference variable.
- OPERATION 4: Determine if a path set contains a specified target use.
The interior node strategy is an alternative method for searching the decision graph, but it can perform only operation 1 and operation 2.
In information flow analysis, the “on all paths in one outcome” relationship is fundamental. (For brevity, we shall call this relationship simply “on all paths.”) In the alpha graph, “on all paths” is represented by an interior edge.
As explained in the “Kappa Transform” section, the “on all paths” relationship in the decision graph is represented in one of two ways:
-
- 1. Direct representation (DNode/child or DNode/grandchild)
- 2. Indirect representation (interior nodes)
An outcome node is the child of a DNode. In the direct representation, an LNode containing a definition that is “on all paths” in the outcome is the outcome node (or the child of the outcome node). In the indirect representation, an LNode containing a definition that is “on all paths” in the outcome is an interior node associated with the outcome node. In the indirect representation, an interior node may also be a DNode or BNode that is “on all paths” in the associated outcome.
An interior node is defined wrt a reference decision and reference variable. A node is an interior node wrt decision c if it has the following properties:
-
- 1. The node is on a path from the normal exit of c to its extended exit.
- 2. The node is on all paths in an outcome of c.
- 3. The node is an LNode containing a definition of the reference variable or a
- DNode (or a WNode before loop expansion) or a BNode.
The root of a maximal subtree is an outcome node that does not have an external break (wrt a reference decision), whereas its parent DNode does. The interior nodes are inserted into the interior node vectors of the outcome nodes that are roots of maximal subtrees by kappa1 (the first phase of the kappa transform).
There are two types of interior nodes. The first type is an LNode which contains the definition of a (specified) reference variable. The first type is called an interior LNode, and if the definition in the LNode is involved in a data flow, the image of the definition is a definition alpha node which is the destination of a break interior edge. The second type is a DNode or BNode. The second type is called an interior DNode or interior BNode (respectively). There is a special type of interior DNode, a cyclic interior node, which is the predicate of a loop (a WNode before loop expansion or a loop predicate DNode after loop expansion).
The interior node strategy uses only the second type of interior nodes. No interior edge is generated for interior DNodes or interior BNodes.
The interior node strategy searches the initial subtree, interior BNodes and all subtrees referenced recursively by interior DNodes. A decision consists of one or more subtrees. The search begins at the initial subtree.
The search of each subtree is the same. As the search proceeds (for instance, via a preorder traversal), each BNode is examined and checked to determine if it is an external break (wrt the reference decision). If operation 1 is being conducted and an external break (wrt the reference decision) is found, then the operation is complete. If operation 2 is being conducted, and an external break (wrt the reference decision) is found, then the maximal external break is tracked (as described in the section on the Generalized Strategy).
Simultaneously, as the search proceeds, the child of each DNode is examined. If the child has an interior BNode, it is treated in the same way as a BNode in the tree. If the child contains an interior DNode, it is added to a list (such as a Java vector). After the search of the current subtree is finished, the subtrees with roots that are nodes in the list of interior DNodes are searched in a similar manner.
We shall use the strategyExample method to illustrate the interior node strategy. The DDF for this method is:
The decision graph for the strategyExample method is shown in
In subtree c, the first node that is a child of a DNode is LNode #12. This LNode has an interior DNode (DNode #14), so it is added to the interior DNode list. The only other child of a DNode in subtree c is SNode #9, which has no interior nodes. Therefore, after the search of subtree c has been completed, the interior DNode list consists of one node: DNode #14.
The search continues at DNode #14, and one external break is found (edge #15). The target of this external break is DNode #3 (decision a). Since predicate c is nearer to the root than the current value (decision b), the maximal element is set to decision a. There is no further recursion, since the children of DNodes in this subtree have no interior nodes.
4 Partial Outcome 4.1 IntroductionThe concept of a partial outcome is based on the underlying concepts of a partial exit and interior use. We begin with a brief overview from the perspective of how these structures are defined in the control flowgraph.
A partial exit is the normal exit of a decision that has an external break. In this type of decision (an extended decision), the normal exit is distinct from the exit of the decision.
An interior use is a use of the reference variable that is on all paths in the outcome of a reference decision. A star interior use is an interior use which receives its input from a data source outside of the outcome containing the use.
A partial outcome is analogous to a complete outcome. Both types of decision outcomes begin at the predicate node of the decision. Whereas a complete outcome ends at the decision exit, a partial outcome ends at a partial exit or a star interior use.
4.2 Interior UseAn interior use is a use (of a specified reference variable) that is on all paths in one outcome (of a reference decision). There are two types of interior uses:
-
- 1. A star interior use has as its antecedent, a data source which is not on any path in the outcome which contains the use.
- 2. A plus interior use has as its antecedent, a partial exit which is on a path in the outcome which contains the use.
In the example shown in
More formally, a partial outcome is the set of all paths of a specified polarity (true or false) that begin at the predicate node of a decision (called the reference decision) and end at a partial exit or a star interior use. The partial outcome ends at a node that is a predecessor of the exit node (if the reference decision has an exit).
There are two primary types of partial outcomes:
-
- 1. An ordinary partial outcome is a partial outcome that ends at a partial exit which is not the antecedent of a plus interior use.
- 2. An interior use partial outcome is a partial outcome that ends at a star interior
- use or a partial exit which is the antecedent of a plus interior use.
Interior use partial outcomes are further subdivided into two types:
-
- 1. A star interior use partial outcome is a partial outcome that ends at a star interior use.
- 2. A plus interior use partial outcome is a partial outcome that ends at a partial exit which is the antecedent of a plus interior use.
The ordinary partial outcome c′FALSE is highlighted in the example shown in
c′FALSE is an ordinary partial outcome because n is not the antecedent of a plus interior use.
4.5 Star Interior Use Partial OutcomeA star interior use partial outcome is the set of all paths from the predicate node of the reference decision to a star interior use.
The example in
The dciupo is a fundamental type of path set, because, like a dcco, its image is a star alpha node. In fact, every star alpha node is either the image of a dciupo or a dcco.
In the example, the star interior use partial outcome a′TRUE is a dciupo wrt ‘x’.
The input of a use is composite, which means it carries both data and control state information. The antecedent of a star interior use does not contain sufficient control state information to serve as the input of the star interior use. Since a use alpha node has no control input, the necessary control state information is supplied by inserting a star alpha node ahead of the interior use. The star alpha node properly represents the partial outcome created by the star interior use, since the partial outcome is a dciupo (as described above) and the star alpha node is the image of a dciupo.
When deltaBack is called on star interior use u4(x), it produces an image of the use (a use alpha node). Since u4(x) is a star interior use, which has an associated dciupo, deltaBack calls deltaBackDciupo.
deltaBackDciupo creates the image of the dciupo, which is a star alpha node and an exterior edge indicating that this alpha node represents the true outcome of a. deltaBackDciupo makes a recursive call to deltaBack on the antecedent of the use, which produces its image, the definition alpha node representing d2(x) and a data edge from the definition alpha node to the star alpha node.
deltaBackDciupo then returns control to deltaBack which creates a data edge from the star alpha node to the use alpha node.
4.6 Interior Use in Loop PredicateIf a use is contained in a loop predicate, then the set of paths from the predicate node of the decision to the use includes those paths which pass through the loop (one or more times) before ending at the use. These paths must be taken into consideration when determining if the set of paths is a partial outcome.
In the example shown in
Recall that the antecedent of a data element [edge of the control flowgraph or node of the decision graph] is the source of data flow (wrt a specified variable) that reaches that data element [edge or node]. In the decision graph, the antecedent associated with a node may not be the correct antecedent as defined above. In the decision graph, the antecedent of the DNode (which is the loop predicate containing the use) is always the ‘1’ instance of a LoopEntryCNode. If this were the correct antecedent (in all cases), then a use in a loop predicate cannot be a star interior use, since the ‘1’ instance of the LoopEntryCNode is in the same outcome as the use.
The decision graph antecedent is not the correct antecedent if the LoopEntryCNode is spurious. If there is no corresponding pull-through use for ‘variable’, then the LoopEntryCNode is spurious and the decision graph antecedent must be corrected. The corrected antecedent of the DNode (which is the loop predicate containing the use) is the antecedent of the spurious LoopEntryCNode.
For the corrected antecedent to be in the same outcome as the use, it must be a descendent of a child of the reference decision predicate. Due to loop expansion, the child of the reference decision predicate is 3 levels up in the decision graph from the loop predicate DNode which contains the use.
Example #3Example #3 shall be used to illustrate a plus interior use partial outcome. The DDF for Example #3 is:
The control flowgraph of Example #3 is shown in
The partial outcome begins at the predicate node of decision c and ends on node n, which is on a path in the false outcome of c. The partial outcome is highlighted in
Example #3 illustrates a very important property of a partial outcome that ends at a partial exit. It is not necessary that the reference decisions for the partial outcome and the partial exit coincide. In the example, the reference decision for the plus interior use partial outcome is c, whereas the reference decision for the partial exit is b.
A section of the alpha graph of Example #3 is shown in
The image of a def-clear plus interior use partial outcome is always a star alpha node. In the example, the image of the plus interior use partial outcome c′FALSE is *11(x).
4.8 Partial Exit and Reference Input NodeA node n is a partial exit if:
-
- 1. n is the normal exit of a decision J and
- 2. J has an external break which bypasses n
A loop entry CNode is a partial exit if its antecedent is a partial exit.
A reference input node is defined with respect to a partial exit. K is a reference input node with respect to partial exit n if:
-
- 1. n is the antecedent of the reference input node and
- 2. K is on a path from n to the exit of J (where n is the normal exit of J) and
- 3. J has an external break which bypasses K
Examples of reference input nodes with a data input (as opposed to a composite input) are: an empty LNode or a BNode which represents an empty break outcome or an LNode containing a star interior use or a DNode containing a star interior use or a star interior LoopEntry CNode.
4.8.1 Reference Input NodeIn the decision graph, u15(x) is contained in LNode #15 which is a reference input node with respect to the partial exit n. To illustrate the concept in the control flowgraph, we shall treat u15(x) in
A partial decision is the set of paths from a predicate node to a partial exit (that is on a path in the decision).
A partial decision is transformed in one of two different ways, depending on whether its output (the partial exit) conveys information to a data input or composite input of a node which is a reference input node with respect to the partial exit. If the input of the reference input node is a data input, then deltaStarBack is applied to the partial decision. See the section, “Delta Star Transform.” Otherwise, the input of the reference input node is a composite input and deltaBack is applied to the partial decision.
A single partial decision is transformed both ways, if there are reference input nodes with respect to its partial exit that have data and composite inputs.
5 Generalized Search of the Decision Graph 5.1 Path SetsThere are certain fundamental structures in the decision graph called path sets which are described in the section, “Star Transform.” The three major types of path sets are: (1) decision, (2) decision outcome and (3) loop. Note that these path sets are linear: i.e., the path set begins at a specific entry node and ends at a specific exit node. A trivial path set is a path set which consists of a single LNode. All other path sets have an associated reference decision. The last node of the path set is the exit of the reference decision. The reference predicate associated with a path set is the DNode that is the predicate of the reference decision. The following table shows how the reference predicate is determined.
The path sets may be subject to further constraints, such as the subset of paths that is contained within a bounding decision or the subset of paths which end at a specified target use.
A common operation performed many times during the alpha transform is to search a path set in the decision graph to determine if it satisfies a specific property. For example, the star transform searches a decision outcome to determine if it is empty. (A decision outcome is empty if there is no definition of a specified “reference” variable on any path in the outcome).
The alpha transform employs a generalized strategy for searching path sets in the decision graph. There are several Java methods in the transform which use this generalized search:
-
- getMaximalElement (returns the maximal element in the path set)
- is Empty (returns true if the path set does not contain a definition of the reference variable)
- contains (returns true if the path set contains a specified target use)
In order to elucidate the basic operation of the generalized strategy, we shall examine how the search progresses in a path set with no special constraints.
5.2 Backbone SearchThe generalized strategy is based on the subset of nodes in the path set called the backbone. The backbone consists of a subsequence of nodes that are on a path (in the control flowgraph) from the initial node to the last node in the path set. The construction of the backbone is based on the concept of a generalized successor. The generalized successor of the initial node in the path set is the normal exit of the reference decision. The generalized successor of a DNode is its normal exit. Let n1 be any other type of node (a BNode, CNode or LNode that is not the initial node). The generalized successor of n1 is the node which immediately follows n1 on the path from n1. The first node in the backbone is the initial node in the path set. The second node in the backbone is the generalized successor of the first. The second node is therefore the normal exit of the reference predicate. Assuming that the second node is not the last node in the path set, the construction of the backbone proceeds by adding the generalized successor of the second node and so forth until the last node in the path set (a CNode) has been added to the backbone.
5.3 Subtree SearchA subtree search of a node consists of a preorder traversal of all nodes in the decision graph which are descendents of that node. A subtree search of a node which has no descendents, such as an LNode, reduces to a search of that single node. The generalized strategy consists of a subtree search of all nodes in the backbone that are not CNodes, beginning at the initial node and proceeding sequentially until it reaches the last node in the backbone.
5.4 Search StrategyThe backbone of a normal decision consists of two nodes: a DNode (the initial node) and a CNode (the last node in the path set). Since the generalized strategy skips CNodes, the search of a normal decision is just a subtree search of the initial node.
In order to detect when the search is finished, the generalized strategy tracks the break targets of BNodes as the search progresses. These BNodes include BNodes in the backbone and BNodes that are in the subtrees of nodes in the backbone.
The generalized strategy can be decomposed into two search strategies: (1) the backbone search, which corresponds to traversal of the generalized successors in the backbone and (2) subtree searches of nodes in the backbone. Roughly speaking, the backbone search advances to the right, and when it cannot go further to the right, it goes upward in the decision graph until it can advance again to the right.
Now let us examine the generalized strategy in more detail. The backbone search begins at the initial node of the path set. A subtree search of the initial node is performed. The generalized search then switches over to the backbone search. The backbone search advances to the generalized successor of the initial node, which is the normal exit of the reference decision.
Since this node is a CNode, no subtree search is performed. If this CNode is not the last node in the path set, then the backbone search continues by advancing to the generalized successor. The generalized successor of the current node n is the successor of n if (1) the successor exists and (2) the successor is in the path set. The successor of n is the first node immediately to the right of n in the diagram of the decision graph. More formally, the successor of n is the next child of p, the SNode parent of n, that follows n. A subtree search of the successor is performed (if the successor is not a CNode). Whenever possible, the backbone search attempts to advance to the right in the decision graph. If the search is not finished and one of the above conditions is not met, then the backbone search advances upward in the decision tree. The generalized successor is the node which immediately follows n on the path from n. If the grandparent gp of n is a loop predicate, then it is the next node to be executed after n and the backbone search advances to gp. If gp is a decision predicate, then the next node to be executed after n is the successor of gp so the backbone search advances to the successor of gp.
5.5 Tracking of Maximal ElementAs the search progresses, it must determine if a node is in the path set. A node n1 is in the path set if (1) there is a path (in the control flowgraph) from the initial node of the path set to that node and (2) the node is not past the exit of the maximal element. If the first test is not satisfied, then the search attempts to move upward in the decision graph. If the second test is not satisfied, then the search is finished.
The concept of maximal element is based on proximity to the root. A node n1 of the decision graph is said to be “greater” than node n2 of the same graph, if n1 is an ancestor of n2 and therefore closer to the root. The maximal element of a path set is the break target in the path set which is closest to the root of the decision graph. The maximal element of a path set is the DNode which has the last node of the path set as its normal exit.
As the generalized strategy advances, it continuously updates the maximal element, which is denoted by ‘m’. The generalized strategy tracks the maximal element by examining each BNode that is encountered during the search. The BNode may be a backbone node or a node in a subtree of a backbone node. At the beginning of the search, the maximal element m is set to null. When the search reaches a BNode, it compares the break target of the BNode to the current value of m. If the break target is greater than m, then m is set to the target. (Any non-null value of m is greater than null).
All three methods (getMaximalElement, is Empty and contains) track the maximal element as the search proceeds. This is necessary for detecting when the search is finished. The is Empty method checks each LNode to find out if the node has an associated definition of the reference variable. The contains method checks each DNode and LNode to find out if the node “contains” the specified target use.
5.6 Example of the Generalized StrategyTo illustrate how the generalized strategy searches the decision graph, we shall show how the getMaximalElement method searches the decision graph of a simple Java method, strategyExample. The Java source code and DDF for the example are shown in
As a prelude to the algorithmic approach, we first identify the maximal element of path set c through inspection of the control flowgraph. The maximal element of the path set beginning at predicate c is the predicate of the decision which has the exit of decision c as its normal exit. The exit of a decision is the point at which all paths from the decision predicate first meet. From inspection of the control flowgraph in
The generalized strategy locates the maximal element through a systematic search of the decision graph. The decision graph of strategyExample is shown in
The backbone search progresses by advancing to the right. The generalized successor of the initial node is CNode 13. Since there is no subtree search of CNodes, the backbone search continues advancing to the right. The generalized successor of CNode 13 is DNode 14. During the subtree search of DNode 14, the break target of BNode 15 is compared to m. Since the break target a (DNode 3) is greater than b (DNode 5), m is set to a. The backbone search again advances to the right. The generalized successor of DNode 14 is CNode 17.
At this point, the backbone search can no longer advance to the right so it moves upward in the decision graph in order to find the generalized successor of CNode 17. The grandparent gp of CNode 17 is DNode 5. Since DNode 5 is a decision predicate, the generalized successor of CNode 17 is the successor of gp, CNode 18.
Note that if DNode 5 were a loop predicate, then the generalized successor of CNode 17 would be DNode 5. Intuitively, this is the case because the predicate of the loop is tested before the loop is exited (unless the loop is exited by a break out of the loop).
Since CNode 18 has no successor, the backbone search once again moves upward in the decision graph. The grandparent gp of CNode 18 is DNode 3. Since DNode 3 is a decision predicate, the backbone search advances to its successor, CNode 20. Normally, the search would continue to move upward, but it cannot, since CNode 20 has no grandparent. Even if CNode 20 had a grandparent, the search would be finished, because its predecessor, DNode 3, is the maximal element of the path set, making CNode 20 the last node of the path set.
The general flow of the backbone search in the decision graph is shown in
-
- 6 Sign Examples
- 6.1 Introduction
A Java method may contain independent computations. The identification of independent computations through static analysis is an important tool for efficient software testing, because such structural information can be used to reduce the number of tests.
The signXY(int x, int y) and signXandY(int x, int y) examples illustrate, in a simple and visual way, the ability of dynamic information flow analysis to detect independence in computational structures.
6.2 signXandY ExampleThe signXandY(int x, int y) method takes as its arguments two integers, x and y. It sets the sign of x (sx) to +1 if x is positive and to −1 if x is negative. Similarly, the method sets the sign of y (sy) to +1 if y is positive and to −1 if y is negative.
Java source code for signXandY example
DDF for signXandY example
The alpha transform converts DDF to one or more alpha graphs. See section, “Intra-method Graphs.” The symbols for the alpha graph nodes are shown in
The information flowgraph (alpha graph) of the signXandY example is shown in
The signXY(int x, int y) method takes as its argument two integers, x and y, and sets the sign of the product (sxy) to +1 if the product of x and y is positive and sets sxy to −1 if the product of x and y is negative.
Java source code for signXY example
DDF for signXY example
The information flowgraph (alpha graph) of the signXY example is shown in
The information flowgraph does not split into separate pieces, as in the previous example, illustrating that the internal computations are not completely independent. The information flowgraph also shows how the output of the decision with predicate ?3(x) supplies information to the decision with predicate ?7(y). This example illustrates that independence is a matter of degree, and even when there is only partial independence, the analysis can supply valuable guidance for testing.
6.4 Signal Flow EquationsThe value of a variable at a particular point in a program can be calculated, within the limits of static analysis, by solving a system of simultaneous algebraic equations. The system of equations can be derived from the annotated control flowgraph, by applying the rules of the signal flow algebra. Alternatively, the system of equations can be obtained directly from the information flowgraph through inspection or accessing it as a data structure. To illustrate the two approaches, we shall use the signXandY(int x, int y) example.
6.4.1 Signal Flow Equations from the Information FlowgraphFirst, we shall obtain the signal flow equations directly, through inspection of the left-hand information flowgraph in
There is a signal flow equation for each use in the flowgraph. The first use in the information flowgraph is u3(x) which is in a predicate node. The partition of the information flowgraph relevant to the signal flow for u3(x) is shown in
(For clarity, we shall allow the partitions in this example to overlap.) The data input of the predicate node is from the data output of the definition node, d2(x). The first signal flow equation is therefore:
<alpha>3(x)=d2(x)
where <alpha>3(x) is the signal appearing at the input of u3(x).
The second use in the information flowgraph is u11(sx). The data input of u11(sx) is the signal at the output of the plus node, +6(sx), which has two data inputs. The partition of the information flowgraph relevant to the signal at the first input of the plus node is shown in
By inspection of
not(x3)*d2(sx)
where not(x3) is the complement of the value of the predicate containing u3(x).
The partition of the information flowgraph relevant to the signal at the second input of the plus node is shown in
By inspection of
x3<dot>d4(sx)
where x3 is the value of the predicate containing u3(x). Note that x3 is a function of the signal at u3(x):
x3=f(<alpha>3(x)).
In the information flowgraph, the “on all paths in one outcome” operator ‘<dot>’ is represented by the interior control input of d4(sx).
The plus node “sums” these two inputs, so the second signal flow equation is:
<alpha>11(sx)=not(x3)*d2(sx)+x3<dot>d4(sx)
The annotated control flowgraph of the signXandY(int x, int y) example is shown in
Since edge #2 is the input of edge #3, the first signal flow equation is:
<alpha>3(x)=d2(x)
The signal at u11(sx) is the composition of the signal (with variable ‘sx’) at the output of edge #2 and the transmissions of the two decision structures: <alpha>1 T(sx)=d2(sx)<open dot>t3(sx)<open dot>t7(sx)
The derivation of the second signal flow equation from this equation appears in
-
- 7 Compound Predicates
- 7.1 Introduction
In classical path testing, the test strategy consists of generating test cases which exercise each structural path in the control flowgraph of the method under test.
The Java method “is NonNegative” will be used to illustrate the information flow path testing strategy for compound predicates. The Java source code listing for is NonNegative is:
This method has a seeded bug. The second condition in the compound predicate, b>0, should be: b>=0.
The control flowgraph of the example is shown in
An unexpanded information flowgraph of the example is shown in
The 2 structural paths correspond to 5 complete paths in the unexpanded information flowgraph:
There are many test cases which could cover the 2 control flow paths. Consider the 2 test cases:
Although this test set satisfies the all-paths test criteria, it leaves lingering doubt regarding the correctness of the method, since the strategy is not sensitive to possible bugs in the compound predicate. In particular, the seeded bug in the condition, b>0, is not found because the condition can have no effect. This condition is not exercised by the second test case due to short circuit Boolean expression evaluation in Java.
In information flow analysis, a compound predicate is treated as an internal method call made by the compiler. From the compiler's viewpoint, the example code is treated as if the following code were flattened:
The alpha graph of the method ‘and Logic( )’ is shown in
The expanded information flow path structure for is NonNegative( ) is exhibited in
This alpha graph is a composite of the alpha graphs for the compiler versions of is NonNegative( ) and Logic( ) above. The implicit flows in the compound predicate ?3(a,b) are surrounded by a dashed border. The segment numbers inside the dashed box apply to the and Logic( ) method, whereas all other segment numbers pertain to the is NonNegative( ) method. The dashed box is not a mu-box. The alpha graph has been simplified by replacing formal parameters with their values. For example, ?3(e1) inside the dashed box is equivalent to a use of the variable ‘a’, since the formal parameter ‘e1’ is bound to the value of ‘a’.
Each predicate in the expanded alpha graph has only one (data flow) input. Compare this restriction to the predicate in the unexpanded alpha graph of
There are 6 alpha paths in the expanded alpha graph from d2(a) to u6(c). The original test set covers 2 of the 3 feasible alpha paths. The remaining alpha path:
d2(a)−[?3(e1)−*5(e2)−?5(e2)−*7(v)−+8(v)−+10(v)]
?3(pval)−*5(c)−+6(c)−u7(c)
is traversed by adding one more test:
-
- a=1 b=0
which reveals the bug. Of course, the seeded bug and this latter test were contrived to elucidate the information flow analysis of a compound predicate. There are many other tests which exercise this same alpha path and are not capable of revealing the bug. In general, detection of this type of bug requires a combination of information flow testing (all feasible alpha paths) and domain testing.
Although the test set meets the criteria of all feasible alpha paths, it does not meet all-variants. The variant in which ?2(e1) is false and ?4(e2) is true, is not included in the test set, since it does not represent a path through and Logic( ).
A compound Boolean predicate is represented by a predicate tree. The predicate tree is converted into its implicit path structure by the Compound Predicate Transform.
7.2 Preprocessing StepsThe alpha graph algorithm is preceded by three preprocessors. The net effect of these preprocessors is to convert the system input into a decision graph. The system input may be Java source code or Byte Code for a Java method, or some other semi-structured language for a subroutine or module. The sequence of preprocessors is illustrated in
The first preprocessor is a source code specific parser which converts the system input into DDF for the method. The second preprocessor is a DDF parser which converts the DDF into a decorated decision graph. A decorated decision graph is an extension of the normal decision graph in which each DNode representing a compound predicate has an associated predicate tree. The predicate tree represents the logical structure of the compound predicate. The final preprocessor expands the compound predicates in the decorated decision graph by applying the Compound Predicate Transform to each DNode in the decorated decision graph that has a predicate tree.
The output is a normal decision graph. In a normal decision graph, each DNode represents a simple predicate. A simple predicate is a predicate which contains neither the binary operator ‘&&’ nor the binary logical operator ‘∥’.
7.3 DDF for Compound PredicateThe DDF for a simple predicate consists of a list of uses enclosed by parentheses. For example, the DDF for the simple predicate in the Java code fragment “if (x>y)” is:
-
- (u(x), u(y))
The DDF for a compound predicate is similar, except the predicate expression contains, in addition to uses or lists of uses, at least one of the binary logical operators (‘&&’ or ‘∥’). The DDF for a compound predicate may also contain the unary logical operator ‘!’. These logical operators are the same as their Java counterparts. For example, the DDF for the compound predicate in the Java code fragment “if (!(a==0) && (b>0))” is:
-
- if (!u(a) && u(b))
Note that the “not” operator precedes the use. In general, an operand of a binary logical operator must either be a use, a use preceded by a ‘!’, an expression delimited by parentheses or an expression delimited by parentheses preceded by a ‘!’.
The informal BNF describing the DDF syntax for a predicate follows:
The DDF for the is NonNegative example is:
The nodes in the predicate tree represent simple predicates and the three operators which appear in compound predicates. The operators are listed in the table shown in
The root of the predicate tree is an operator. Each operator in the predicate tree has one or more children. The number of children of an operator is listed in the table shown in
The predicate tree corresponding to the predicate:
-
- (!(u(a) && u(b))∥! u(c))
is shown in
The DDF parser creates predicate trees as part of the decorated decision graph. The predicate tree in the is NonNegative example appears in the decorated decision graph shown in
The predicate trees in the decorated decision graph are expanded by the Compound Predicate Transform. The result of applying this transform to the decorated decision graph in
A simple example of a loop, the “autoiterator,” is shown in
An alpha graph for this example in which each traversal is represented by a unique series of nodes and edges would be very large. In fact, the size is limited only by the finite resources of a real computing machine, since ‘x’ can be an arbitrarily large negative number. The example illustrates the problem with loops: path proliferation and the resultant state explosion. To be tractable, a method for program analysis must incorporate some means for dealing with path explosion.
One approach for enumerating paths in a control flowgraph is to use control flow analysis; that is, to set a fixed constant k which sets a maximum bound on the number of loop traversals used in classifying paths. This partitions paths into equivalence classes based on the first k traversals of loops. A similar approach could be used for enumerating paths in an information flowgraph.
However, the dynamic information flow analysis approach is different from the control flow analysis approach above. Paths in the information flowgraph are different from paths in the control flowgraph because the information flowgraph operates at a higher level of abstraction than the control flowgraph. The relationship between paths in the two types of graphs is not one-to-one. For example, a single path in a control flowgraph may correspond to the simultaneous execution of multiple paths in an information flowgraph. Conversely, a path in the information flowgraph may correspond to multiple paths in a control flowgraph. The control flow analysis technique may miss important flows, such as data flows, if those flows are completed after the bound ‘k’ is reached.
Two different types of information flowgraphs are employed to address the problem of counting paths in a program with loops. In a static information flowgraph, a single information flow element, such as a node or edge in a loop, represents multiple execution instances of the element. For example, in the static alpha graph for the example in
For clarity of exposition, this document describes how the loop transform is applied to the simple loop in Example 1. The basic principles are easily generalized to loops in dynamic alpha graphs and nested loops. Static and dynamic information flowgraphs are further described in the section, “Intra-method Graphs.”
8.2 Loop NodesTo simplify the exposition, our treatment of loops is informal.
Two special types of plus alpha nodes are found only in loops: loop entry nodes and loop exit nodes. Alpha nodes involved in loops retain their usual attributes (definition, use, star, plus), but gain additional attributes as a result of their presence in a loop.
A loop partitions the nodes of the alpha graph into two classes: nodes inside the loop and nodes outside the loop. A node is inside the loop if it can be executed more than once within the context of the loop (if it is in a cycle) or if the node is the destination of an edge which has a loop node as its origin; otherwise, the node is outside the loop. A node inside a specified loop is called a loop node.
The most important loop node is the loop predicate. A loop is identified by its loop predicate. The fundamental loop construct in dynamic information flow analysis is the while loop. Other looping constructs, such as do_while loops, are modelled using while loops. In the case of a while loop, the loop predicate is the boolean condition that appears in the while statement.
In the course of the loop transform algorithm, the ID's of loop nodes are modified so they can be recognized as nodes in loop being transformed. Also, temporary loop nodes are created which are used and eventually discarded. Both types of loop nodes are called loop instance nodes or simply instance nodes.
In the single level loop expansion used in the first step of the loop transform, the two types of instance nodes are identified by appending a ‘1’ or a ‘0’ to the loopInstance vector, which is part of the node ID. The ‘1’ or ‘0’ is called the loop instance. The ‘1’ instance of a loop node is permanent, whereas the ‘0’ instance is temporary. In the case of multilevel expansions, as mentioned in the section on loop expansion, there can be higher loop instances, such as a ‘2’ instance node or ‘3’ instance node, which are also permanent loop nodes.
In our example, the loop is not nested, so the loopInstance vector consists of a single integer which is ‘1’ if the loop instance node is permanent or a ‘0’ if the loop instance node is temporary. The node ID is the index followed by the loopInstance vector, using a period as a separator. For example, the node identifier for the permanent instance of the loop node u6(x) is u6.1(x), and the node identifier for the temporary instance is u6.0(x).
In the general case, a loop may be nested inside other loops. Such a node will have a loop instance with respect to each loop in which it participates. In the loopInstance vector, the loop instances are arranged in order of loop containment. For example, suppose loop C is nested in loop B, loop B is nested in loop A, and loop A is not nested in any loop. The order of loop containment is [A, B, C]. The loopInstance vector [1, 1, 0] indicates that the loop instance in loop A is ‘1’; the loop instance in loop B is ‘1’ and the loop instance in loop C is ‘0’. The node identifier for loop node u6(x) having the above loopInstance vector is u6.1.1.0(x). The loopInstance vector of a node which is not a loop node is empty. In a nested loop, the instance should be qualified by specifying the reference loop. By default, if the reference loop is left unspecified, the instance given is with respect to the innermost loop.
Loop instance nodes which are derived from the same node in the alpha graph and differ only by the last entry in the loopInstance vectors are called analogous nodes.
8.3 Fundamental Flows Associated with a LoopWith respect to a particular loop, there are four fundamental flows:
-
- data flow into the loop
- information flow inside the loop within a single iteration
- data flow from one iteration to the next
- data flow out of the loop
The data flows are depicted in
The four basic types of loop edges correspond to the four fundamental flows:
-
- loop entry edge
- loop information flow edge
- loop feedforward edge
- loop exit edge
A loop entry edge represents data flow into the loop. In a loop entry edge, the origin is outside of the loop and the destination is inside of the loop. The destination of a loop entry edge is a plus alpha node called a loop entry node. A loop entry edge is executed only once within the context of the loop.
A loop information flow edge represents information flow inside the loop within a single iteration. In a loop information flow edge, the origin and destination are contained in the loop. There is a path from the destination to the next instance of the origin. The loopInstance vectors of the origin and destination of a loop information flow edge are identical. A loop information flow edge may be executed more than once within the context of a loop.
A loop feedforward edge or simply, feedforward edge, represents data flow from one iteration to the next. The loopInstance vectors of the origin and destination of a feedforward edge have different last elements. A feedforward edge supplies the feedforward input to a loop entry node. Like the loop information flow edge, a feedforward edge may be executed more than once within the context of a loop.
A loop exit edge represents data flow out of the loop. The destination of a loop exit edge is a plus alpha node. If the loop is exited in the normal way; when the boolean value of the condition in the loop predicate is false, then the destination of the loop exit edge is the normal exit of the loop, which is called the loop exit node. The loop exit node is part of the loop; it is a loop node. A loop may also exit via a break that transfers control to the normal exit of the loop (the loop exit node) or to the loop exit node of an enclosing loop or to the normal exit of an enclosing decision. Like a loop entry edge, a loop exit edge is executed only once within the context of the loop.
Data flow into and out of the loop is controlled by the loop predicate and any predicates in the loop that have break outcomes. The loop entry node has special state flow properties as described in the section, “Intra-method Graphs.” The loop entry node has two sets of inputs: a initializer input and feedforward inputs. The first instance of the loop has only the initializer set as its input. This property allows data to enter the loop, even though the feedforward inputs are in the CLEAR state. Any subsequent instance of the loop entry node has the feedforward set as its input. This property allows data to propagate from instance ‘n’ to instance ‘n+1’ as illustrated by the feedforward arrow in
The loop exit node has an infinite number of inputs, as described in the section, “Intra-method Graphs.” This property prevents data from being propagated out of the loop until the loop terminates.
8.4 Loop Transform Algorithm 8.4.1 OverviewThe input to the loop transform is a decision graph. The decision graph of a Java method without loops has three basic types of nodes: DNodes, SNodes and EndNodes. There is a special type of DNode, the WNode, which represents the loop predicate prior to the loop transform. The node labeled ‘C’ in
The first child of the WNode represents the false outcome, which maps to one or more loop exit control edges in the alpha graph. The second child of the WNode represents the true outcome, which corresponds to one or more iterations of the loop. The predicate is evaluated prior to the execution of each pass through the loop. If the predicate evaluates to true, then the true outcome is executed. If the predicate evaluates to false, the loop is exited. The decision graph is obtained from the Java source code or from an intermediary representation such as DDF, as shown in
The output of the loop transform is an alpha graph. Loops are represented by cycles in the alpha graph, possible break outcome(s) and loop exit nodes. For the autoiterator example, the net effect is to take the decision graph in
The loop transform algorithm consists of three main steps:
-
- STEP 1 expansion of loops in the decision graph
- STEP 2 transformation of the decision graph into an alpha graph
- STEP 3 reconstitution of loops in the alpha graph
The first step transforms the loop into two decisions: an outer and inner decision. During this process the loop nodes are transformed into permanent loop instance nodes and other loop instance nodes, both temporary and permanent, are added to the decision graph.
The second step transforms the resulting decision graph into an alpha graph using the conventional alpha graph transform.
The third step redirects the incoming edges of temporary loop instance nodes to the permanent loop instance nodes and removes the temporary loop instance nodes.
8.4.2 Step 1 of Loop Transform 8.4.2.1 OverviewTo motivate our model of loop expansion, let us begin by examining a simpler model. In this model, there is no expansion of the loop, and step 1 would consist of just replacing the loop predicate WNode with a DNode. This effectively converts the loop into an ordinary decision. This model is sufficient for analyzing zero or one iterations of the loop, but it is incomplete. In particular, it misses one of the three fundamental flows shown in
A schematic control flow diagram of loop expansion model used in the algorithm is illustrated in
The expansion consists of temporary and permanent loop instance nodes. A temporary loop instance node is identified by inserting a ‘0’ as the last element in its loopInstance vector. A permanent loop instance node is identified by inserting a ‘1’ as the last element in its loopInstance vector. All outcomes which exit the loop, including the false outcome of the loop predicate, are converted to breaks which transfer control to the exit of the outer decision (or the exit of another enclosing loop or decision).
The next three sections explain how the loop expansion algorithm, schematized in
Loop entry edges represent data that comes from outside the loop. Data flow into the loop must pass into the true outcome of the outer decision, since the boolean value of its predicate is always true.
If, upon entry to the loop, the loop predicate as represented by the predicate of the inner decision, is true, then the data from outside the loop passes through the loop entry CNode and reaches (exposed) uses in the loop body. If the first instance of the loop predicate is false, then the data from outside the loop, after passing through the loop entry CNode, exits the loop as explained below.
If, upon entry to the loop, the loop predicate is true, the first instance of the loop body is executed. If the next evaluation of the loop predicate is true, the second instance of the loop body is executed. Single level loop expansion is sufficient for modelling data flow from an arbitrary instance n to instance n+1 of the loop, since making n arbitrary does not introduce any flows not already found in the single level model.
8.4.2.3 Feedforward Data FlowFeedforward data flow is data that flows from one instance of the loop to the next.
Data flows out of the loop via a loop exit edge. The normal exit of the loop is the exit of the outer decision in the loop expansion. The normal exit of the loop corresponds to the loop exit node. As mentioned in the section on the loop exit edge, data may also be conveyed out of the loop by a break to the normal exit of an enclosing loop or decision.
It is important to distinguish a loop iteration exit node from a loop exit node. The loop iteration exit node is executed upon the completion of each iteration of the loop. The loop exit node is executed upon completion of all iterations of the loop. In
We have presented the general concept of loop expansion in terms of its effect in the control domain.
The algorithm for the loop expansion transforms the decision graph into the general “nested decision” structure portrayed in
-
- extract the cyclic subgraph of the loop from the input decision graph
- transform the cyclic subgraph into the outer decision of the expanded loop
- transform the subgraphs from the previous step into the inner decision of the
- expanded loop
- adjust the ID of the loop exit node
The cyclic subgraph of the loop consists of the loop entry node and the subtree having the loop predicate as its root. The cyclic subgraph of the example is shown in
The pseudocode for this step is:
The pseudocode for this step is:
The pseudocode for this step is:
In the final step of the loop expansion transform, the ID of the loop exit (n9) and the endNumber of n7 are adjusted in accordance with the pseudocode:
The next step is to apply the alpha graph transform to the expanded decision graph. The result for the autoiterator example is shown in
The third and final step of the loop transform reconstitutes loop structure and removes the temporary scaffolding created during loop expansion. The loop reconstitution algorithm is divided into four steps:
-
- removal of pull-through uses and create feedforward edges
- redirection of control inputs of loop predicates from ‘0’ instance to the ‘1’ instance
- removal of all temporary nodes
- removal of last entry (‘1’) from loopInstance vector of loop nodes [optional]
This step assumes that the alpha graph is properly formed: that there are no definitions inside predicates and that there are no data flow anomalies (for example, a use that is not reached by any definition). The loop reconstitution transformed is applied to each alpha graph. In a nested loop, the loop reconstitution transform should be first applied to the innermost loop and then be successively applied to the next outer loop until all loops in the nested loop have been transformed.
8.4.4.2 Algorithm for STEP 3The simplified pseudocode for the loop reconstitution algorithm is:
The application of the first step, the removal of the pull-through use(s) and the creation of feedforward edge(s), is illustrated in
In our example, the second step, the deletion of temporary nodes, removes the artifacts of the outer loop: d9.0(true) and u4.0(true). Note that control plus alpha nodes are not removed during this step, since a control plus alpha node associated with the ‘0’ instance of a loop predicate is converted to a ‘1’ instance in the second step. The last step removes the last entry (‘1’) from loopInstance vector of loop nodes. The result of applying these two steps to the original autoiterator example is illustrated in
The last step is optional, since for certain types of analysis, such as determining depth of loop nesting, it may be desirable to retain the information contained in the loopInstance vectors.
The cleanup transform follows the loop transform. The cleanup transform removes redundant control edges and phantom nodes. The autoiterator contains a redundant control edge, the edge from ?4.1(x) to d6.1(x) in
The final alpha graph of the autoiterator example, after the cleanup transform, is shown in
The input of the partition transform is a single decision graph produced by the loop expansion transform. The partition transform converts the single decision graph into a set of one-use decision graphs. Each one-use decision graph is associated with a unique target use in the input decision graph. The partition transform clones the input decision graph and removes all the nodes which are successors of the target use to produce each one-use decision graph.
In the decision graph, a successor appears “to the right of” or “below” the target use. If the use is in a predicate (i.e., in a DNode), then the children of the DNode are removed.
The partition transform preserves:
-
- the target use and ancestors of the target use
- CNodes associated with the remaining decisions
- LoopEntryCNodes and LoopExitCNodes associated with the remaining loops
- LNodes which contain pull-through uses
There are two types of one-use decision graphs:
-
- 1. normal and
- 2. initial PseudoDUPair
The target use of a PseudoDUPair one-use decision graph is in a PseudoDUPair, whereas the target use of a normal one-use decision graph is not. The type of a one-use decision graph may be determined by examining the data elements in the target use node. If this node has only two data elements, a definition and a PseudoDUPair which contains the definition, then the one-use decision graph is a PseudoDUPair one-use decision graph. The partition transform consists of two steps:
-
- 1. the generation of the normal one-use decision graphs and
- 2. the generation of the PseudoDUPair one-use decision graphs
This order is necessary, since the second step creates DefinitionAlphaNodes for the definitions in the initial PseudoDUPairs which are not necessarily visible to other uses.
9.2 Example #4Example #4 will be used to illustrate the operation of the partition transform in the production of a single, normal one-use decision graph. The DDF for Example #4 is:
The control flowgraph of Example #4 is shown in
The decision graph in
The operation of the alpha transform is based on path sets. A path set is a set of paths in the control flowgraph or decision graph that has a single entry node. Each path set has:
-
- (1) an initial node (which is the entry node)
- (2) a reference decision
- (3) a reference variable
There is one exception to the above rule: the trivial path set, which consists of a single LNode, has no reference decision.
The three major types of path sets are:
-
- (1) decision
- (2) decision outcome
- (3) loop
Further information about path sets can be found in the section “Generalized Search of the Decision Graph.”
The operation of the star transform is based on two special types of path sets:
-
- (1) maximal reducible path sets
- (2) isolated path sets
Informally, a maximal reducible path set is the largest path set such that all paths begin at the initial node, end at the exit of the reference decision and contains no definition of the specified reference variable.
A path set is classified in accordance with its properties. We begin by defining some of the fundamental properties of reducible path sets.
A path set is linear if all paths in the path set begin at a specified entry node and end at a specified exit node. There may be paths from entry nodes different from the specified entry node that reach exit nodes in the path set or paths from predicate nodes in the path set that reach exit nodes different from the specified exit node, but such paths are not in the path set.
A path set is standard if it is linear and the entry node is the predicate node of a decision or loop and the exit node is the partial or complete exit of the same decision or loop. A further constraint may be imposed on the path set to restrict it to those paths from the entry node to the exit node that have a specified polarity (true or false). Examples of standard paths sets are (partial or complete) outcomes, decisions and loops. A path set is partial if it is standard and the exit of the path set is a partial exit. Similarly, a path set is complete if it is standard and the exit of the path set is a complete exit.
A path set is live if the path set is linear and if there exists a def-clear path (wrt a specified reference variable) from the entry node of the path set to the exit node of the path set.
A path set is cohesive if the path set is linear and if all paths which begin at the entry node and pass through a predicate node in the path set are also contained in the path set. A standard path set which has no internal predicate node consists of simple paths and is cohesive. Note that there may be paths from other entry nodes (different from the specified entry node) which reach exit nodes in the cohesive path set. Of course, such paths are not in the cohesive path set.
A path set is empty if all paths in the path set are def-clear wrt a specified reference variable and the path set does not contain the target use.
A path set is an isolated path set if there exists no path from the root of the decision graph to the initial node of the path set. An isolated path set represents structurally unreachable code.
10.1.1 Maximal Reducible Path SetIn order for a path set to be reducible, we must examine the properties of the path set itself, which is called the primary path set, and the properties of an associated path set called the secondary path set. The secondary path set consists of all paths that begin at the exit node of the primary path set and reach the target use (or, in the delta star transform, the entry node of the reference data input path set). Note that the secondary path set is a linear path set.
A path set is reducible if the primary path set is empty and complete, and the secondary path set is live. Alternatively, a path set is reducible if the primary path set is empty, partial and cohesive, and the secondary path set is empty and cohesive. If a reducible path set is an outcome in which all paths reach one or more loop exits, then the path set ends at the first loop exit. (This restriction is necessary to preserve the inputs of loop exit alpha nodes).
A path set is maximal if it is not contained in any larger path set that is of the same type (in the case of the star transform, a reducible path set). A path set is a maximal reducible path set if it is a reducible path set that is maximal.
10.2 IntroductionThe input of the star transform is a one-use decision graph produced by the partition transform. The star transform modifies the one-use decision graph by eliminating nodes which have no effect on information flow to the target use.
There are two types of path sets which have no effect on information flow:
-
- isolated path sets.
- maximal reducible path sets
For correct operation, the alpha transform requires that its input, the decision graph, contains no unreachable code. Therefore, the star transform begins by removing all isolated path sets, since such path sets are unreachable. If an isolated path set is present in the decision graph, the star transform will remove the isolated path set. The star transform calls itself recursively until all isolated path sets have been removed.
The star transform then proceeds to the next step, which is to remove each maximal reducible path set. If the maximal reducible path set is a decision outcome, then it replaces the path set with a simple path (i.e., an empty LNode or BNode).
The empty outcomes remaining after the star transform are mapped to star alpha nodes: hence the name of the transform.
10.3 Example of Reducible Path SetThe control flowgraph in
The decision is empty because it contains no definition of the reference variable ‘x’. The decision is complete because the entry node (the destination of edge #3) is the predicate node of the decision and the exit node (the origin of edge #6) is the complete exit of the decision. The secondary path set is live because there is a def-clear path (wrt ‘x’) from the origin of edge #6 to the target use u7(x).
Since the decision is empty and complete, and the secondary path set is live, the decision is a reducible path set.
10.3.1 Example of Maximal Reducible Path SetDecision a in
Decision a has no influence on the information flow (wrt ‘x’) from its entry to its exit. Since no definition of ‘x’ can be injected into the data stream that passes through the decision, the definition of ‘x’ which reaches the exit (the origin of edge #6) and u7(x) is not influenced by the path taken in decision a. Similarly, the path taken in decision a has no effect on the final control state of the exit and u7(x).
Example #5The DDF for Example #5 is:
The control flowgraph of Example #5 is shown in
The true outcome of a is empty since it is def-clear (wrt ‘x’). The true outcome of a is complete because its entry node is the predicate node of a decision and its exit (the origin of edge #10) is a complete exit. Since the primary path set is empty and complete and the secondary path set is live, the true outcome of a is reducible. The true outcome of a is maximal since it is not contained in a larger reducible path set (wrt ‘x’).
The star transform preserves:
-
- (1) the target use
- (2) ancestors of the target use
- (3) CNodes (including LoopEntryCNodes and LoopExitCNodes) associated with non-empty decisions and loops
- (4) LNodes with pull-through uses and
- (5) the false outcome of non-empty loops
The latter restriction is necessary to preserve loop exit alpha nodes.
The decision graph of Example #5 is shown in
NOTE: If subtree a had one or more external breaks, then it would not be sufficient to search (only) the subtree with the true child of a as its root, since the subtree would be neither complete nor maximal. See the section, “External Breaks”.
If a decision is maximal and reducible, then the star transform removes the entire decision. In this example, decision b was maximal reducible and has been removed. This is demonstrated in
If only one outcome of a decision is maximal reducible, the subtree corresponding to the outcome is replaced by an empty LNode. In this example, the true outcome of decision a was maximal reducible and has been replaced by the empty LNode #4. The empty LNode represents a dcco (def-clear complementary outcome) and later serves as the basis for the creation of a star alpha node by the delta transform. A dcco is an outcome that is def-clear (wrt a specified variable), whereas its alternate outcome is not.
10.4 Isolated CNodeWhen the star transform is applied to an empty outcome that is a maximal reducible path set which extends beyond the normal exit (of the decision having the entry node of the outcome as its predicate), the star transform replaces the empty outcome with a BNode which has the exit node of the outcome as its target.
In the augmented control flowgraph shown in
The result of replacing cFALSE with a BNode in the one-use decision graph corresponds to replacing cFALSE with a break. The corresponding control flowgraph is shown in
In the example, both outcomes of decision c are breaks, so there is no path from the entry node of the graph (the origin of edge #2) to the exit node of decision c. The exit edge which has the exit node of decision c as its origin is highlighted in the control flowgraph shown in
An isolated CNode may be present in a method prior to analysis or it may be produced by the star transform. Irrespective of its origin, an isolated CNode may also produce subpaths in the flowgraph which are unreachable. An isolated subpath begins at the successor of the isolated CNode and ends at the predecessor of the first CNode (along the path) that is reachable from the entry point of the method. Note that the isolated subpath does not include the isolated CNode. The set of isolated subpaths created by an isolated CNode is called an isolated path set.
In the augmented control flowgraph shown in
When the star transform replaces cFALSE with a BNode in the one-use decision graph, it produces isolated CNode #12. The isolated CNode produces an isolated subpath which is highlighted in control flowgraph shown in
The isolated CNode is not included as part of the isolated subpath and therefore not removed by the star transform, because it is part of decision c which is not isolated.
11 Kappa Transform 11.1 IntroductionThe overall control transform (kappa transform) consists of two phases: kappa1 and kappa2.
The first phase, kappa1
-
- traverses the decision graph and
- applies kappaCombine which loads the interior nodes
The second phase, kappa2(variable)
-
- traverses the modified decision graph and
- produces interior edges, interior plus edges, plus interior edges and all alpha
- nodes associated with these edges, including control plus alpha nodes
The interior edges are generated from DNode/child/grandchild edges in the decision graph. Interior edges, interior plus edges, plus interior edges and control plus alpha nodes are generated from interior nodes (using generateBreakInteriorEdges).
11.2 Central Concept of an Interior EdgeAn interior (control) edge means that the destination is on all paths in the associated outcome of the decision.
The control flowgraph for Example #11 is shown in
The child of a DNode is called an outcome node. In the previous example, the interior edge was derived from the DNode and the outcome node. The interior edge has the same polarity as the outcome node.
The DDF for Example #12 is:
DNode/grandchild relationship in the decision graph of Example #12.
11.4 DNode/Grandchildren EdgesIf the outcome node is an SNode, then several of its children may be on all paths in that outcome. In this case, an interior edge is generated for each child that:
-
- is an LNode which contains a definition of the variable in the target use and
- is not preceded by a DNode child that has an external break
The reason for the latter restriction is that those child nodes after the DNode child with the external break will not be on all paths in the outcome (of the grandparent). This restriction is illustrated in
There is a new type of interior edge that cannot be derived from the parent/child/grandchild relationship. This type is called a break interior edge, because it is caused by an external break.
Normally, if a definition is a successor of a tree, the definition will block (“kill”) all the data flows from the tree. This property is demonstrated by Example #13.
The DDF for Example #13 is:
The decision graph of Example #13 is shown in
In this example, the definition d9(x) blocks all data flows from the tree b. As a result, the data flow from SNode 4 is reduced to d9(x) as shown in the partial alpha graph of
On the other hand, if b contains an external break (wrt b), then the break produces a path that bypasses d9(x), and b is no longer “dead.” Example #14 is derived from Example #13 by replacing the true outcome of decision b with an external break (wrt b).
The DDF for Example #14 is:
The decision graph of Example #14 is shown in
The external break causes d9(x) to be on all paths from the LNode of b that does not contain the break to the exit of the extended decision (which is the same as the exit of a).
Since d9(x) is on all paths in the false outcome of b, there will be a break interior edge from b false to d9(x) as shown in the partial alpha graph of
The introduction of this new type of interior edge has some interesting consequences, as will be demonstrated using Example #15.
The control flowgraph of Example #15 is shown in
Note that two decisions in Example #15, b extended and c extended, share a common exit. This structure is characteristic of extended decisions as discussed earlier.
The new phenomenon that we would like to emphasize in this example is that the definition d13(x) is on all paths of two outcomes. The implication of this is that certain alpha nodes can now have more than one interior control input.
11.6 The Control Plus Alpha NodeThe control plus alpha node makes it possible to extend dynamic information flow analysis to semi-structured programs.
Just as the (data) plus alpha node represents the (alternate) convergence of data flow, the control plus alpha node represents the alternate convergence of control flow.
In the alpha graph of Example #15, shown in
d13(x) converge on a single control plus alpha node. The inputs to the control plus alpha node are called interior plus edges and are polarized. The output is called a plus interior edge and is not polarized.
11.7 Interior NodesThe break interior edges are encoded in the decision graph by associating interior nodes with the appropriate outcome nodes. Certain interior nodes represent the destinations of break interior edges. In the decision graph of Example #15, shown in
A break interior edge is generated from an interior node only if the interior node is an LNode.
We shall now explain how the interior nodes are generated.
11.7.1 Kappa Combinekappa1, the first phase of the kappa transform, sequences the application of kappaCombine, which generates the interior nodes. kappaCombine propagates control from right to left and has two operands:
-
- A <dot> B
Subtree A must have a DNode as its root and contain an external break relative to the root DNode. Node B must be a DNode or BNode or LNode with a definition of the variable in the target use. If these conditions are met, kappaCombine places a reference to the right operand (node B) into the interior node vector of each EndNode or SNode which is the root of a maxSubtree in A. The operation of kappaCombine is shown schematically in
Now we shall address the question of why kappaCombine places the interior nodes into the roots of maximal subtrees.
A subtree with root N is a maximal subtree with respect to predicate c if subtree N does not have an external break with respect to c, but its parent does.
Let <pi> be the parent of outcome node <lambda>, where <lambda> contains an interior node. This is shown schematically in
In
For <lambda> to be an outcome node in A that contains interior node B, node B must be on all paths in <lambda>.
This first observation implies that:
-
- the tree with root <lambda> has no
- external break with respect to A
This condition is shown schematically in
For B to be on even one path in <lambda>, the exit of <pi> must be a successor of B. This requirement is evident from the control flowgraph in
This second observation implies that:
-
- the tree with root <pi> must have an
- external break with respect to A
This condition is shown schematically in
kappa1 sequences the application of kappaCombine.
In processing the children of an SNode, when a child is encountered that is a DNode with an external break, kappa1 will not call the kappa transform on the remaining children.
The reason is the same as in generateInteriorEdges which is called by kappa2. A child of the SNode that occurs after the DNode with an external break, will not be on all paths in the outcome of the parent (of the SNode). This restriction is illustrated in
If c has an external break (wrt c), then kappaCombine will be applied to the combination b and c, but not to the combination c and e.
11.9 Kappa2kappa2 produces interior edges, interior plus edges, plus interior edges and the alpha nodes associated with these edges (including control plus alpha nodes) using
-
- generateInteriorEdges and
- generateBreakInteriorEdges
The former generates interior edges from the parent/child/grandchild relationships, whereas the latter generates interior edges, interior plus edges, plus interior edges and control plus alpha nodes from the interior nodes.
If a PredicateAlphaNode or DefinitionAlphaNode has an interior edge input and a break interior edge input is added, addlnteriorEdge will generate a control plus alpha node as shown schematically in
The basic concept underlying the data transform (also called the delta transform) is that data flows are constructed by tracing the flow of data backwards (backtracking) from the target use. Backtracking along a particular path stops when a definition is encountered, since the definition blocks all data flow that precedes it (along that path).
Example #6 shall be used to illustrate backtracking. The DDF for Example #6 is:
The control flowgraph of Example #6 is shown in
In Example #6, backtracking data flow from u7(x) along the true outcome of a leads to d4(x), which blocks the data flow from d2(x).
This technique therefore handles “killing” definitions and the non-local behavior of data flow in semi-structured programs (i.e., programs with breaks).
The delta transform consists of two phases:
-
- deltaForward and
- deltaback
The first phase, deltaForward
-
- traverses the decision graph
- applies deltaSetAntecedent which loads the
- antecedents, and
- fills the break vectors of DNodes
An antecedent is the source of data flows reaching the node with which it is associated. The antecedent is defined wrt a specific variable. Only EndNodes and DNodes have antecedents. A Node has only a single antecedent. The break vector of a DNode contains each BNode which has that DNode as its target.
With respect to variable ‘x’ in Example #6 above, the antecedent of u7(x) is segment #6. The antecedent of segment #6 is a. The true outcome of a, d4(x), has no antecedent, since the definition blocks all sources of data flow to that segment. The antecedent of segment #5 is d2(x), since this definition is the source of data which reaches the false outcome.
12.2.1 Delta Forward Subtree hasDatadeltaForward loads the antecedents of EndNodes and DNodes by propagating data forward in the decision graph, from each subtree that “has data.” A subtree has data, if the method hasData returns true when applied to the root of the subtree. hasData has two parameters: a reference decision and reference variable.
hasData returns true if each EndNode in the subtree that is on a physical path from the predicate of the reference decision to the normal exit of the reference decistion: has a definition of the reference variable or has an antecedent or is an isolated CNode or is the successor of an isolated CNode.
If there is no path from the predicate of the reference decision to its normal exit, then hasData returns false.
12.2.2 Delta Forward Data FlowdeltaForward propagates data from left to right in the decision graph. It has two operands:
-
- A <dot> B
The left operand (A) must have data (i.e., hasData applied to A returns true). A copy of the root of A is placed as an antecedent in each EndNode of B that:
-
- is either empty (i.e., does not have a definition of the variable in the target use) or that has a use of the variable and
- has the property that any node in the path from this EndNode back to B that
- has an SNode parent, is the first child of the SNode parent.
The propagation of data from A to B is shown in
The delta transform establishes a mapping from nodes in the decision graph to nodes in the alpha graph. A node in the decision graph maps to an alpha node called its “image” in the alpha graph.
deltaBack is the second phase of the delta transform. deltaBack traverses the decision graph and produces images of nodes in the decision graph (that are involved in data flows) and the associated edges in the alpha graph:
-
- alpha nodes (except control plus alpha nodes and the images of unexposed definitions and uses)
- data edges (that are not intra-segment) and
- exterior control edges The intra-segment transform, kappa2 and deltaBack produce alpha nodes. The intra-segment transform generates the images of unexposed definitions and uses, and the intra-segment data flows associated with these unexposed memory access elements. kappa2 produces all control plus alpha nodes, duplicates of some alpha nodes produced by deltaBack and extraneous nodes called “vestigial alpha nodes.” The vestigial alpha nodes do not participate in data flows and are later removed by the kappaCleanUp transform.
There are several forms of deltaBack:
-
- deltaBack (the primary form)
- deltaBackUse
- deltaStarBack
- deltaStarBackDcco
- deltaBackDcco
- deltaBackDciupo
The method name “deltaBack” will be used in the generic sense, to refer to any one of the above forms. deltaBack is recursive. When deltaBack calls itself, it selects the proper form.
deltaBack is initiated by calling deltaBackUse on a node in the decision graph which contains a target use. deltaBack uses the antecedents and break vectors created by deltaForward to trace the flow of data in the reverse direction of flow. In general, deltaBack is called on the antecedent of a decision graph node.
12.3.2 Delta Back BacktrackingAs deltaBack performs this “backtracking” of the data flow, it generates the alpha nodes involved in the flow, and the associated data flow and exterior control flow edges in the alpha graph.
In general, each time deltaBack is called on a decision graph node, it creates the image of that node, an alpha node, if the image does not yet exist in the alpha graph. It then returns a vector containing the image of the decision graph node. The exceptions return: an empty vector or a vector of “source nodes” or the vector returned by calling deltaBack on its antecedent or a vector containing the image of the dciupo associated with the node.
In general, the data flow edges of the alpha graph are generated by using the image of the current decision graph node as the destination of each data flow edge and the images returned by the recursive call to deltaBack as the origins of the data flow edges.
When deltaBackDcco or deltaStarBackDcco or deltaBackDciupo is called, it creates an image of the dcco or dcuipo, if the image does not yet exist, and the exterior control edge input of its image (a star alpha node).
12.3.3 Delta Back on a BNode 12.3.3.1 Delta Back on a BNode that is a DccoA BNode is a dcco if it represents an empty outcome: an outcome that does not contain a definition of the reference variable. deltaBack obtains its image, a star alpha node, by the call:
-
- a2=deltaBackDcco (variable)
which creates the image of the dcco if it does not yet exist. The image, a2, is inserted into the vector returned by deltaBack. The image (a star alpha node) is shown in
In the decision graph, a break outcome is empty if the parent of the BNode is a DNode or if the parent of the BNode is an SNode and the preceding definition or decision was removed by the star transform.
12.3.3.2 Delta Back on a BNode that is not a DccoIf this BNode does not represent an empty outcome, then deltaBack makes a recursive call to deltaBack on its antecedent:
The image of the antecedent (which is the first alpha node in vector av) is inserted into the vector returned by deltaBack on this BNode.
Since this type of BNode has no image (of its own), it is an exception to the general rule that deltaBack returns a vector containing the image of the decision graph node.
12.3.4 Delta Back on a CNode 12.3.4.1 Delta Back on a Normal CNodeA CNode that is not a special type of CNode (an isolated CNode or loop entry CNode or loop exit CNode) is called a normal CNode.
If the image of a normal CNode does not yet exist, deltaBack on the CNode creates its image and each incoming data flow edge (if the edge does not yet exist). deltaBack returns a vector containing the image of the CNode.
The image of a normal CNode is a plus alpha node, shown as ‘A’ in
av usually contains more than one alpha node. An example of an exception is a decision with a break outcome (which bypasses the normal CNode).
12.3.4.2 Delta Back on an Isolated CNodeAn isolated CNode corresponds to an exit node (in the augmented control flowgraph) which has no in-edges. Since it has no in-edges, the isolated CNode cannot be on a path from the entry to the exit of the method and is therefore unreachable. Since an isolated CNode is unreachable, it has no antecedent.
If the antecedent of a CNode is null, then it is an isolated CNode:
Since an isolated CNode does not participate in any data flow, it has no image, so deltaBack returns an empty vector. This type of CNode is an exception to the general rule that deltaBack returns a vector containing the image of the decision graph node.
12.3.4.3 Delta Back on Loop Entry NodesThe action of deltaBack on a LoopEntryCNode depends on its type: normal, spurious or star interior. The difference between a normal and spurious LoopEntryCNode is based on the following important principle.
Principle for the Formation of a Loop Entry Node
Two conditions are necessary for the formation of a loop entry node in the alpha graph:
-
- (1) There must be an initializer input, i.e., a data flow from a node preceding
- the loop that reaches the loop entry node.
- (2) There must be at least one feedforward input, i.e., a data flow from a node in the loop iteration path set that reaches the loop iteration exit. (In
- the alpha graph, the loop iteration exit is the same as the loop entry node.)
The loop iteration path set consists of paths from the loop predicate to the loop iteration exit (which is the image of the ‘O’ instance of the LoopEntryCNode). In the alpha graph, data flow from an instance of the loop passes through the loop entry node before it reenters the loop or exits from the loop.
12.3.4.3.1 Delta Back on a Spurious LoopEntryCNodeA spurious LoopEntryCNode is a LoopEntryCNode which has no image (loop entry plus alpha node) in the alpha graph, because it does not meet the conditions for the formation of a loop entry node.
In the decision graph, a LoopEntryCNode is spurious if either:
-
- the ‘1’ instance of the LoopEntryCNode has no antecedent (which indicates condition (1) above is not satisfied) or
- there is no pull-through use of the reference variable following the ‘0’ instance
- of the LoopEntryCNode (which indicates that condition (2) above is not satisfied)
In the example shown in
In this example, there is a definition of variable ‘y’ on a path from the loop predicate (edge #4) to the loop iteration exit (edge #3) so the loop expansion transform generates a pull-through use of ‘y’. This pull-through use is spurious since the LoopEntryCNode does not satisfy condition (1) above.
If the pull-through use of a variable is spurious, then the associated LoopEntryCNodes for that variable are spurious. The converse is not generally true; a spurious LoopEntryCNode may have no associated spurious pull-through use. The spurious pull-through use is described in the section, “Delta Back Use on a spurious pull-through use.”
If a LoopEntryCNode is a spurious LoopEntryCNode, then deltaBack does not generate an image of the LoopEntryCNode.
When applied to the ‘0’ instance of a spurious LoopEntryCNode, deltaBack does nothing and returns an empty vector.
When applied to the ‘1’ instance of a spurious LoopEntryCNode, deltaBack acts as if it were called on the antecedent of the spurious LoopEntryCNode.
12.3.4.3.2 Delta Back on a Star Interior LoopEntryCNodeThe image of a star interior LoopEntryCNode is a loop entry plus alpha node which has an associated star alpha node.
A star interior LoopEntryCNode is a LoopEntryCNode that is not spurious, is on all paths in an outcome of a decision (where the decision is not an artifact of loop expansion), and has an antecedent which is not in the same outcome as the LoopEntryCNode.
The initializer input of a star interior loop entry plus alpha node is similar to the input of an interior use. The inputs of a plus alpha node are composite inputs. Like a star interior use, the initializer input of a star interior loop entry plus alpha node receives its execution condition from an associated star alpha node a1, which is obtained from the call:
-
- a1=deltaBackDciupo (variable)
A data flow edge is created from a1 to the image of the star interior LoopEntryCNode.
12.3.4.3.3 Delta Back on a Normal LoopEntryCNodeThe image of a normal LoopEntryCNode is a loop entry plus alpha node.
A normal LoopEntryCNode is a LoopEntryCNode that is neither a spurious nor a star interior LoopEntryCNode. A normal LoopEntryCNode is handled in the same way as a normal CNode (except its image is a loop entry plus alpha node instead of a plus alpha node).
The recursive call to deltaBack returns only one alpha node in av, since the image of a loop entry CNode (after loop expansion but before loop reconstitution) has only one incoming edge: the edge which connects to the initializer input to the plus alpha node, which is its image.
12.3.4.4 Delta Back on a LoopExitCNodeThe image of a loop exit CNode is a loop exit plus alpha node.
deltaback on a loop exit CNode is otherwise the same as deltaBack on a normal CNode.
If this is the loop exit CNode of a loop which has no breaks out of the loop, then its image will have only one incoming edge.
12.3.5 Delta Back on a DNodedeltaBack on a DNode creates its image, if its image does not yet exist. If it is a loop DNode, its image is LoopPredicateAlphaNode A; otherwise its image is PredicateAlphaNode A. If the image of the DNode is created, then the images of all uses in the DNode are added to its image.
The DNode is an exception to the general rule that deltaBack returns a vector containing the image of the decision graph node. Instead, deltaBack on a DNode returns a vector of “source nodes”. Let B be the plus alpha node which is the normal exit of the decision with this DNode as its predicate. The source nodes are the origins of the incoming data flow edges which have B as their destination. The source nodes are obtained by calling deltaBack on the children of the DNode (in accordance with the rules that follow) and on each BNode that has this DNode as its target. This process is depicted schematically in
If the child is an SNode, then deltaBack is called on its last child, since the last child is the source of the data flow that reaches the normal exit of the decision. If the child (or the last child of an SNode child) is a BNode, then deltaBack is not called on that child. The call is unnecessary. If the BNode represents an external break, the data flow from the child bypasses the normal exit of the decision. If the BNode does not represent an external break, then deltaBack will be called on the BNode when deltaBack is called on each BNode that has this DNode as its target.
12.3.6 Delta Back on an LNode 12.3.6.1 Delta Back on an LNode that is a DccoAn LNode is a dcco if it does not contain a definition or use of the reference variable. deltaBack obtains its image, a star alpha node, by the call:
-
- a2=deltaBackDcco (variable)
which creates the image of the dcco if it does not yet exist. The image, a2, is inserted into the vector returned by deltaBack. The image (a star alpha node) is shown in
Note that this operation is the same as deltaBack on a BNode that is a dcco.
12.3.6.2 Delta Back on an LNode that is not a DccoIf this LNode contains a definition of the reference variable, then deltaBack creates its image, a definition alpha node (if the image does not yet exist). Recursion on deltaBack ceases, since this type of LNode has no antecedent. The image of this LNode is inserted into the vector returned by deltaBack. The image (a definition alpha node) is shown in
If the LNode contains a pull-through use, then deltaBack acts as if it were called on its antecedent:
deltaBack is initiated by calling deltaBackUse on a target use in an LNode or DNode. In the example shown in
-
- n.deltaBackUse(“x”)
When deltaBack reaches the inverse image of an entry point of the alpha graph, in this case d2(x), backtracking terminates.
deltaBackUse creates an image of the target use and the incoming data flow edge of the target use. deltaBackUse is an exception to the general rule that deltaBack returns a vector containing the image of the decision graph node. Instead, deltaBackUse returns an empty vector, since there is no further recursion on deltaBack.
12.4.1 Delta Back use on a Normal UseThe operation of deltaBackUse on an LNode varies in accordance with the type of use. There are four special types of uses: star interior, anomalous, pull-through and initial PseudoDUPair. A use that is not one of these special types is called a normal use.
deltaBackUse begins by checking if the LNode has been removed by the star transform. If it has, then deltaBackUse returns.
deltaBackUse on a normal use in an LNode creates the image of the use and makes the call:
av will contain the single alpha node a1. deltaBackUse creates a data flow edge from a1 to the image of the use. The basic action of deltaBackUse on a normal use in an LNode is shown in
The first special type of use is a star interior use. The antecedent of a star interior use is not in the partial outcome ending at the star interior use, therefore the partial outcome is def-clear. This outcome, which is a def-clear interior use partial outcome (dciupo), begins at the predicate of the minimal enclosing decision (or loop) and ends at the interior use.
deltaBackUse on a star interior use in an LNode creates the image of the use and makes the call:
-
- a2=deltaBackDciupo (variable)
which creates the image of the dciupo, the star alpha node a2. deltaBackUse creates a data flow edge from a2 to the image of the use. The basic action of deltaBackUse on a star interior use in an LNode is shown in
The second special type of use is an anomalous use. An anomalous use is a use that is not reached by a definition. An anomalous use is a classic form of data flow error and is reported as an error in the program being analyzed.
If the LNode containing a use has no antecedent, then the use is anomalous and deltaBackUse reports the error to the program analyzer.
12.4.4 Delta Back Use Overview of Pull-Through UsesThe third special type of use is a pull-through use. Pull-through uses are added to the decision graph by the loop expansion transform. The purpose of pull-through uses is to induce deltaBackUse to produce feedforward edges and loop entry nodes in the alpha graph.
12.4.4.1 Generation of Pull-Through UsesPrior to the loop expansion transform, the decision graph represents only one instance of a loop. In order to induce deltaBackUse to produce feedforward edges, two special types of nodes are added to the decision graph by the loop expansion transform: ‘0’ instances of loop entry nodes and LNodes containing pull-through uses.
The images of these nodes are temporary and are later removed by the loop reconstitution transform. The pull-through use derives its name from its action, which is to pull data through the ‘0’ instance of the loop entry node.
Recall conditions 1 and 2 for the formation of loop entry nodes. The loop expansion transform determines if the 2nd condition is met by searching the loop iteration path set for a definition of the reference variable. If such a definition exists, then the 2nd condition is satisfied. On the other hand, the loop expansion transform is incapable of performing the data flow analysis necessary for determining if the 1st condition is satisfied. This data flow analysis cannot be performed until the delta transform.
12.4.4.2 Detection of Spurious Pull-Through UsesThe loop transform therefore produces a pull-through use if the 2nd condition is satisfied. As a consequence, some of the pull-through uses generated by the loop expansion transform do not satisfy the 1st condition. Such pull-through uses are called spurious pull-through uses and must be recognized by the delta transform (in the form of deltaBackUse). A pull-through use that meets both the 1st and 2nd conditions is called a normal pull-through use.
deltaBackUse distinguishes normal and spurious pull-through uses by examining whether or not the 1st condition is satisfied. If the ‘1’ instance of the loop entry node associated with the pull-through use has an antecedent, then the loop entry node has an initializer input and the pull-through use is normal. If it has no antecedent, then there is no initializer data flow and the pull-through use is spurious.
12.4.4.3 Preservation of Pull-Through UsesThe star transform directly follows the loop expansion transform and directly precedes the delta transform. The star transform removes empty compete path sets, such as complete decisions, loops or outcomes.
The star transform preserves certain nodes in the decision graph, such as ancestors of the target use, the node containing the target use and CNodes associated with non-empty decisions or loops.
The star transform also preserves pull-through uses, so the LNodes which contain the pull-through uses are passed through intact to the delta transform.
12.4.4.4 Delta Back Use on a Pull-Through UseThe behavior of deltaBackUse is dependent on the type of pull-through use. There are two types of pull-through uses:
-
- normal and
- spurious
The action of deltaBackUse when applied to each type is based on the principle for the formation of a loop entry node.
Formally, “data flow” should be qualified as being with respect to a specified reference variable. For example, if the reference variable were ‘x’, data flow is from a definition of ‘x’ to a use of ‘x’. For convenience, we shall frequently omit the qualifier in our presentation.
12.4.4.5 Delta Back Use on a Normal Pull-Through UseA normal pull-through use represents the destination of data that is flowing out of one instance of the loop. The real destination could be in the next instance of the loop or some point outside of the loop.
deltaBackUse on a normal pull-through use operates in exactly the same way as deltaBackUse on a normal use.
In the example shown in
For a spurious pull-through use, there exists no corresponding real data flow out of the single loop instance. A spurious pull-through use occurs when there is a definition in the loop which reaches only a use or uses that are within the same instance of the loop as the definition.
deltaBackUse on a spurious pull-through use acts as if it does not exist. The suppression of backtracking has the effect of suppressing the creation of the corresponding loop entry node and feedforward edge.
In the example shown in
The fourth special type of use is an initial PseudoDUPair use. An initial PseudoDUPair use is the target use of a oneUseDecisionGraph that is not exposed because it is in a PseudoDUPair. The initial PseudoDUPair oneUseDecisionGraph is discussed in the section, “Partition Transform.”
deltaBackUse on an initial PseudoDUPair use creates the image of the PseudoDUPair (including the edge from the definition alpha node to the use alpha node).
12.4.6 Delta Back Use on Use in a DNodedeltaBackUse on a use in a DNode operates in a manner similar to deltaBackUse when applied to a use in an LNode.
deltaBackUse begins by checking if the DNode has been removed by the star transform. If it has, then deltaBackUse returns.
The presence of the use in a DNode causes deltaBackUse to perform two additional operations:
-
- create the image of this DNode if the image does not exist (a LoopPredicateAlphaNode if this is a loop DNode; otherwise a PredicateAlphaNode)
- the variable in the use is added to the ‘variables’ vector of the predicate alpha
- node
- create the image of this DNode if the image does not exist (a LoopPredicateAlphaNode if this is a loop DNode; otherwise a PredicateAlphaNode)
If the antecedent of the DNode is a spurious LoopEntryCNode, then the antecedent is corrected by setting it to be the antecedent of the LoopEntryCNode.
Otherwise deltaBackUse proceeds as if the use were in an LNode, according to the type of use (anomalous, star interior or normal).
If the DNode containing the use is a loop predicate, special tests are needed to discern if the use is a star interior or normal use. These tests are described under the heading, “Interior Use in Loop Predicate,” in the section, “Partial Outcome.”
12.5 Delta Back Dcco and DciupoThere are two fundamental types of path sets which map to a star alpha node: the dcco (def-clear complementary outcome) and dciupo (def-clear interior use partial outcome).
When deltaBack is called on a node that is a dcco (i.e, an empty LNode or BNode that represents an empty outcome), it calls deltaBackDcco.
When deltaBack is called on a node that is has an associated dciupo (i.e., a star interior LoopEntryCNode), it calls deltaBackDciupo. When deltaBackUse is called on a node that is has an associated dciupo (i.e., a star interior use in a DNode or LNode), it calls deltaBackDciupo.
The operation of deltaBackDciupo is not separately described, since it is the same as deltaBackDcco. The following description applies to deltaBackDciupo by replacing deltaBackDcco with deltaBackDciupo and “dcco” with “dciupo.”
If the image of the dcco already exists, the call to deltaBackDcco returns.
Otherwise, deltaBackDcco:
-
- creates a2, the image of this dcco (a star alpha node) as shown in
FIG. 145 . - calls deltaBack on n1, its antecedent, unless n1 is a partial exit, in which case deltaBackDcco calls deltaStarBack on n1. a1 is the first element in the vector returned by deltaBack (or by deltaStarBack).
- creates a data edge from a1 to a2. The predicate of the decision which has this dcco as an outcome is the reference predicate.
- creates an exterior edge of the appropriate polarity from the image of the reference predicate to a2
- creates a2, the image of this dcco (a star alpha node) as shown in
If deltaBackDcco is called on a LoopEntryCNode or a DNode which is a loop predicate, then the reference predicate will be 4 levels up in the decision tree due to loop expansion.
12.6 Delta Transform ExampleThe operation of the delta transform when applied to Example #6 is illustrated in
The delta transform is applied to two oneUseDecisionGraphs. In the first oneUseDecisionGraph, the target node is DNode 3 (the decision predicate) and the target use is the use of ‘a’ in DNode 3. The first step of the delta transform, delta forward, loads the antecedent LNode 2 in DNode 3. The second step of the delta transform, delta back, creates the nodes and data flow involving variable ‘a’. The trace beginning with the call to delta back use and the resulting alpha graph (which is called a “delta graph”) is shown in
In the second oneUseDecisionGraph, the target node is LNode 7 and the target use is the use of ‘x’ in LNode 7. delta forward loads the antecedents in the decision graph as shown in
The alpha graph obtained by merging the two delta graphs is shown in
Only one type of edge (excluding intra-segment data edges) is missing from the alpha graph: the interior control edge. These are produced by the control transform (also called the kappa transform).
13 Delta Star Transform 13.1 IntroductionExample #9 is presented to review the basic operation of the star transform. The DDF for Example #9 is:
The control flowgraph of Example #9 is shown in
In this example, predicate b has no effect on the live definition of ‘x’ that reaches the false outcome of decision e: edge #11, which will be mapped to a star alpha node. All paths through decision b are def-clear wrt the variable ‘x’, so it is an empty path set. Since decision b is also maximal reducible, the path set will be removed by the star transform from the one-use decision graph for u15(x).
13.1.1 A Limitation of the Star TransformExample #10 is presented to illustrate a fundamental limitation of the star transform. The DDF for Example #10 is:
The control flowgraph of Example #10 is shown in
Example #10 is similar to Example #9, except a break external wrt b has been introduced. As in Example #9, predicate b has no effect on the live definition of ‘x’ that reaches the false outcome of decision e (which is represented by edge #17).
In this example, the star transform will not remove partial decision b from the one-use decision graph for the target use u21(x) because the star transform removes only maximal reducible path sets. The partial decision b is not reducible because the primary path set (from b to the origin of edge #14) is not cohesive. It is not cohesive because there is a path from the entry of b which passes through internal predicate c and bypasses the partial exit of b.
13.1.2 Partial OutcomeIn Example #10, edge #17 receives data directly from the origin of edge #14, which is the partial exit of decision b. A partial outcome is empty if all paths in the partial outcome are def-clear (wrt a specified variable).
The partial outcome b′true is highlighted in the control flowgraph shown in
A partial decision consists of partial outcomes of both polarities extending from a common predicate node to a common partial exit.
Backtracking in the delta transform is performed by the second phase of the delta transform, deltaBack. When deltaBack is called on a dcco, it switches over to deltaBackDcco, a special form of deltaBack. If the antecedent of the dcco is a partial decision, deltaBackDcco switches over to deltaStarBack, which is another special form of deltaBack. deltaStarBack operates in a manner similar to deltaBack, except that it acts as if empty partial decisions have been removed and as if empty partial outcomes are replaced by empty LNodes and BNodes.
In Example #10, b′ is a partial decision, since edge #14 is a partial exit. If a partial decision is empty, then deltaStarBack will backtrack past the empty partial decision, which has the effect of acting as if the empty partial decision does not exist. This is analogous to the star transform, which physically removes an empty complete decision (if the secondary path set is live).
13.1.4 Maximal Data Reducible Path SetThe path sets that are (virtually) removed or replaced by the delta star transform are called maximal data reducible path sets. This operation is similar to the star transform, which physically removes or replaces maximal reducible path sets. The properties of path sets referenced below are defined in the section, “Star Transform.” Note that in the delta star transform, the entry node of the secondary path set is the exit node of the primary path set, and the exit node of the secondary path set is the entry node of the reference data input path set.
A path set is data reducible if the primary path set is empty and partial, and the secondary path set is empty. A data reducible path set is maximal if it is not contained in any larger data reducible path set.
13.2 ApplicabilitydeltaStarBack is applied to a Node K if it will be mapped to an alpha node that
has a data (as opposed to a composite) input and its antecedent is a CNode which represents a partial exit.
Any Node that is mapped to a star alpha node is a possible candidate for Node K, since a star alpha node has a data input. For example, an empty LNode maps to a star alpha node. If the antecedent of the empty LNode is a CNode that is a partial exit, then deltaStarBack is applied to the LNode. A CNode represents a partial exit wrt the Node K if its antecedent is the predicate of a decision which has at least one external break which “bypasses” the Node K.
The reason why deltaStarBack is not applied to a partial decision that is the source of information for a reference input node with a composite input, is that the transform does not preserve all the control information necessary for composite inputs. When deltaStarBack is performed, control information from external breaks that were originally in the composite outcomes is lost.
13.2.1 ConceptThe diagram in
In this diagram, K represents an alpha node with a data (not composite) input. Since J has an external break, there is a path from J which bypasses K. The exit of the upper box is therefore a partial exit.
The arrows leading from the partial exit to K indicate that the antecedent of K is the partial exit of decision J, which qualifies K as a reference input node with respect to the partial exit.
K is called the reference input node and J is called the reference decision for the application of deltaStarBack.
13.3 Analysis of Reference DecisionAs compared to deltaBack, deltaStarBack has the added capability of detecting and processing partial outcomes and partial decisions. This process is described with reference to the control flow diagram in
Assuming that the applicability conditions for deltaStarBack are met, then when deltaBack is applied to K, it will call deltaStarBack (instead of deltaBack) on the partial exit of J.
At this point, deltaStarBack adds an extra processing step. It examines J as if the external breaks (wrt J) do not exist.
If the partial decision J is empty, then deltaStarBack will act as if the partial decision J does not exist.
13.3.1 Analysis of Empty Reference DecisionAs shown in the diagram in
Note that the effect on backtracking is the same as if the empty partial decision J does not exist.
13.3.2 Backtracking Empty Partial OutcomeIf the partial decision J is not empty, then deltaStarBack proceeds in the same manner as deltaBack on the root node of J, which is a DNode. This process is described with reference to the control flow diagram in
At this point deltaStarBack adds another extra processing step. If a partial outcome in the reference decision is empty, deltaStarBack substitutes a “simulated” empty LNode for the empty outcome. deltaStarBack on the simulated empty LNode creates a star alpha node, just as it would if called on a “real” empty LNode.
If the partial outcome is not empty, then deltaStarBack calls itself on the outcome node if it is an LNode, or the last child of the outcome node, if it is an SNode.
13.4 ContinuationdeltaStarBack continues to call itself on antecedents until it either runs out of antecedents or there are no more partial decisions to process. In the latter case, it reverts to deltaBack.
The reference input node and reference decision are passed as arguments to
deltaStarBack. As it proceeds, deltaStarBack continues to call itself with the same arguments until it reaches a:
-
- predecessor partial decision—a partial decision that is “outside” the current reference decision or
- nested partial decision—a partial decision that is “inside” the current reference decision
When deltaStarBack enters a predecessor partial decision, the reference decision passed to deltaStarBack is changed to the predecessor partial decision. When deltaStarBack enters a nested partial decision, the reference decision passed to deltaStarBack is changed to the nested partial decision and the reference input node passed to deltaStarBack is changed to the node having the exit of the nested partial decision as its antecedent.
13.4.1 Predecessor Partial DecisionWhen backtracking inside the current reference decision J, if deltaStarBack is
called on an antecedent that is the exit of a predecessor partial decision J″, then deltaStarBack will call itself on J″ with the reference decision set to J″. This process is described with reference to the control flow diagram in
The current reference input node K is used to determine if the decision J″ is a partial decision. To qualify as a partial decision wrt K, J″ must possess an external break that bypasses K.
The current reference decision J is used to determine if the partial decision J″ is a predecessor partial decision. To qualify as a predecessor partial decision wrt J, J″ cannot be a descendent of J in the decision graph.
13.4.2 Nested Partial DecisionWhen backtracking inside the current reference decision J, if deltaStarBack encounters a nested partial decision, it will call itself with the new reference input node K′ and the new reference decision J′. This process is described with reference to the control flow diagram in
The new reference input node K′ is used to determine if decision J′, is a partial decision. To qualify as a partial decision wrt K′, J′ must possess an external break that bypasses K′.
The current reference decision J is used to determine if the partial decision J′ is a nested partial decision. To qualify as a nested partial decision wrt J, J′ must be a descendent of J in the decision graph.
13.5 CompletionWhen deltaStarBack is called on an antecedent that is not “inside” the current reference decision J (i.e., not a descendent of J in the decision graph) and that antecedent is not the exit of a partial decision, deltaStarBack calls deltaBack. This process is described with reference to the control flow diagram in
deltaStarBack is called on a BNode that forms a break partial outcome. The partial outcome begins at the BNode if its parent is a DNode; otherwise the partial outcome begins at its parent, which is an SNode. The partial outcome ends at the normal exit of the BNode's target or at the normal exit of the bounding decision if the normal exit of the bounding decision precedes the normal exit of the BNode's target. n1 is the antecedent of this BNode. If the break partial outcome is empty and the associated partial decision is not empty, then the partial outcome is a dcco and its image, a star alpha node is created by the call:
deltaStarBackDcco (n1, n3, n4, variable)
deltaStarBack returns a vector containing the star alpha node.
13.6.2 Delta Star Back on a BNode that is not a DccoIf the break partial outcome formed by this BNode is not a dcco, then deltaStarBack makes a recursive call to deltaStarBack on its antecedent:
-
- av=n1.deltaStarBack (n3, n4, variable)
deltaStarBack returns the image of the antecedent (which is the first alpha node in vector av).
13.7 Delta Star Back on a CNode 13.7.1 Delta Star Back on an Isolated CNodeIf deltaStarBack is called on an isolated CNode, it has no effect since the isolated CNode represents an unreachable exit. (For a more complete description of the isolated CNode, see the sections on the Star Transform and Delta Transform.)
If the antecedent of a CNode is null, then it is an isolated CNode:
Since an isolated CNode does not participate in any data flow, it has no image, so deltaStarBack returns an empty vector.
13.7.2 Delta Star Back on a Normal CNodeThe action of deltaStarBack when called on a normal CNode (i.e., a CNode that is not an isolated CNode or LoopEntryCNode or LoopExitCNode) depends on the type of CNode:
-
- partial exit of new reference decision
- partial or complete exit of a decision that is inside the current reference decision
- partial exit of a nested partial decision
- partial exit of a decision that is outside the current reference decision
- exit of a decision that is not a partial exit wrt the reference input node and is outside the current reference decision
deltaback switches over to deltaStarBack when deltaBackDcco is called on a node n (an empty LNode or BNode) and the antecedent of n is a CNode, nc, which is a partial exit (wrt n).
deltaBackDcco calls deltaStarBack on the CNode with the reference input node set to n and the reference decision set to ‘null’:
-
- nc.deltaStarBack(n, null, variable)
When deltaStarBack is called with the reference decision set to ‘null’, it will set the new reference decision n4 to n1, the antecedent of nc.
Since nc is a partial exit wrt n, the new reference decision n4 contains n.
13.7.4 Delta Star Back on CNode Partial Exit of New Reference Decision which is EmptyIf the partial decision n1 is empty (within the normal bounding decision n4 and wrt the reference variable), then deltaStarBack acts as if the empty partial decision does not exist by calling deltaStarBack on n2, which is the first node (via preorder traversal) in the partial decision n1 that has an antecedent:
-
- av=n2.deltaStarBack (n3, n4, variable)
where n3 is the reference data input node and n4 is the reference decision. deltaStarBack returns the vector av.
deltaStarBack returns the vector obtained by the recursive call to deltaStarBack on n2 as depicted in
If the partial decision n1 is not empty (within the normal bounding decision n4 and wrt the reference variable), then deltaStarBack continues recursively by calling itself on n1:
-
- av=n1.deltaStarBack (n3, n4, variable)
If the image of the CNode, does not yet exist, deltaStarBack creates its image, a plus alpha node, as shown as ‘A’ in
deltaStarBack returns a vector containing the image A of the CNode.
13.7.6 Delta Star Back on CNode Decision Inside of Reference DecisionIf the CNode is the partial or complete exit of a decision inside of the reference decision (and is not the partial exit of a nested partial decision as described below), then deltaStarBack operates in the same way as deltaStarBack on a CNode that is the partial exit of a new reference decision except that there is an input reference decision n4 which remains unchanged.
13.7.7 Delta Star Back on CNode Nested Partial DecisiondeltaStarBack switches over to deltaStarBack with a new reference input node and a new reference decision (i.e., a nested partial decision) when deltaStarBackDcco is called on a node n0 (an empty LNode or BNode) and the antecedent of n0 is a CNode which is a partial exit.
deltaStarBackDcco calls deltaStarBack on the CNode with the new reference input node set to n0 and the reference decision set to ‘null’:
-
- n1.deltaStarBack (n0, null, variable)
As described previously, calling deltaStarBack with the reference decision set to “null” causes deltaStarBack to create a new reference decision. Since the new reference decision is “inside” of the original reference decision (in deltaStarBackDcco), it is called a nested partial decision. The predicate of the nested partial decision is the antecedent of n1 in the above call.
13.7.8 Delta Star Back on CNode Predecessor Partial DecisiondeltaStarBack switches over to deltaStarBack with a new reference decision n4 when deltaStarBack is called on a CNode and n1, the antecedent of the CNode, is not contained in the current reference decision n4 and the CNode is a partial exit (wrt the reference input node n3).
In this case, deltaStarBack sets the reference decision to n1, and deltaStarBack operates in the same way as deltaStarBack on a CNode that is the partial exit of a new reference decision.
Let n0 be the reference decision passed to this invocation of deltaStarBack. Since the new reference decision n1 is “outside” of the original reference decision and is a predecessor of n0, the new reference decision n1 is called a predecessor partial decision.
13.7.9 Delta Star Back on CNode Decision Outside Reference DecisiondeltaStarBack switches over to deltaBack when deltaStarBack is called on a CNode and n1, the antecedent of the CNode, is not contained in the current reference decision n4 and the CNode is not a partial exit (wrt the reference input node n3). deltaStarBack reverts to deltaBack by making the call:
-
- av=n1.deltaBack (variable)
If the image of the CNode, does not yet exist, deltaStarBack creates its image, a plus alpha node, as shown as ‘A’ in
deltaStarBack returns a vector containing the image A of the CNode.
13.7.10 Delta Star Back on a Loop Entry CNodeThe image of a LoopEntryCNode is a loop entry plus alpha node.
deltaStarBack on a LoopEntryCNode reverts to deltaStarBack since the input of a loop entry plus alpha node is composite. deltaStarBack makes the call:
The image of a loop exit CNode is a loop exit plus alpha node.
deltaStarBack on a loop exit CNode is otherwise the same as deltaStarBack on a CNode.
13.8 Delta Star Back on a DNodedeltaStarBack on a DNode creates its image if the image does not yet exist. The image of a loop DNode is loop predicate alpha node A; otherwise the image of a DNode is predicate alpha node A.
If a child n2 of the DNode is not an external break (wrt the DNode), then deltaStarBack determines if the partial outcome beginning at n2 is empty (within the normal bounding decision n4).
If the partial outcome n2 is empty, deltaStarBack begins by determining mOutcome, which is the lesser of the maximal element in n2 and the normal bounding decision. Intuitively, mOutcome is the “size” of the partial outcome. If mOutcome does not exceed the DNode parent of n2, then n1 is used as a “simulated” empty LNode to represent the partial outcome, where n1 is the antecedent of the first node in n2 that has an antecedent. deltaStarBack calls deltaStarBackDcco on n2 which produces a star alpha node as the image of the empty partial outcome. If the partial outcome is empty and mOutcome exceeds the DNode parent of n2, then n2 is replaced by an internal BNode which has mOutcome as its target.
If the partial outcome n2 is not empty, then deltaStarBack adjusts n2 if necessary (by setting n2 to be its last child if n2 is an SNode) and makes a recursive call to deltaStarBack on n2. deltaStarBack also makes a recursive call to deltaStarBack on each BNode that has this DNode as its target.
Like deltaBack, deltaStarBack returns a vector containing source nodes as depicted schematically in
If an LNode does not have a definition (or use) of the reference variable, it is treated as a dcco by deltaStarBack. n1 is the antecedent of this LNode. deltaStarBack obtains the image of this (empty) LNode, a star alpha node, by the call:
-
- a2=deltaStarBackDcco (n1, n3, n4, variable)
which creates the image of the dcco if it does not yet exist. The image, a2, is inserted into the vector returned by deltaStarBack.
13.9.2 Delta Star Back on an LNode that is not a DccoIf this LNode contains a definition of the reference variable, then deltaStarBack creates its image, a definition alpha node (if the image does not yet exist). Recursion on deltaStarBack ceases, since this type of LNode has no antecedent. The image of this LNode is inserted into the vector returned by deltaStarBack.
13.10 Delta Star Back Dcco on a Node that is a DccodeltaStarBackDcco is called by deltaStarBack on a node that is a dcco. If the image of the dcco already exists, the call to deltaStarBackDcco returns.
If this node qualifies as the input reference node for a nested partial decision, then
deltaStarBackDcco calls deltaStarBack on n1 with n3 set to this node and n4 (the input parameter for the reference decision) set to “null.” This will cause deltaStarBack to create a new reference decision (see nested partial decision).
Otherwise, deltaStarBackDcco makes a recusive call to deltaStarBack on n1 with the other parameters unchanged.
a1 is the first element in the vector returned by the recursive call to deltaStarBack.
deltaStarBackDcco creates a2, the image of this dcco (a star alpha node), and a new data edge from a1 to a2.
This node is a partial outcome of the decision which has pa as the image of its predicate. If pa does not yet exist, deltaStarBackDcco creates it.
deltaStarBackDcco then creates an exterior edge of the appropriate polarity from pa to a2.
deltaStarBack returns a vector containing the star alpha node, a2.
13.11 Delta Star Transform ExampleExample #10 shall be used to illustrate the basic operation of deltaStarBack. A portion of the decision graph for Example #10 is shown in
Let us examine what happens when deltaBack is called on LNode #17 in the decision graph.
When deltaBack reaches LNode #17, it detects that LNode #17 meets the applicability conditions for deltaStarBack:
-
- LNode #17 is empty and therefore will be mapped to an alpha node with a data input and
- its antecedent, CNode #14, is a partial exit wrt LNode #17, since its antecedent,
- DNode #5, is the predicate of a decision that has an external break (BNode #10)
- which bypasses LNode #17.
Therefore, deltaBack calls deltaStarBack on LNode #17.
When deltaBack calls deltaStarBack from LNode #17, deltaBack sets the current reference input node to LNode #17. deltaStarBack is called on CNode #14. Since there is no current reference decision, deltaStarBack sets the current reference decision to the partial decision b′, since it is the antecedent of this CNode.
Next, deltaStarBack searches b′ for definitions of the variable in the target use. The decision graph in
Since b′ is an empty partial decision, deltaStarBack calls itself on the “simulated” antecedent of b′. The first descendent of b′ which has an antecedent is LNode #13. Its antecedent, LNode #2, is the “simulated” antecedent of b′.
The net effect is illustrated by the decision graph in
Since LNode #2 has no antecedent, deltaStarBack creates and returns its image, d2(x). This returns control to deltaStarBack on CNode #14, which returns control to deltaStarBack on LNode #17. deltaStarBack creates its image, *17(x), and a data edge from the image returned by deltaStarBack to the image of this node. The delta graph generated by this operation is shown in
The trace for delta back on LNode #17 is shown in
The kappa transform can produce extraneous alpha nodes called “vestigial” alpha nodes. The kappa clean-up transform removes vestigial alpha nodes from the alpha graph generated by the kappa transform.
A vestigial alpha node is a definition alpha node which is not involved in a data flow or a predicate alpha node which has no out edges after the vestigial definition alpha nodes have been removed by this transform.
For example, the definition d4(x) in the control flowgraph shown in
The output of the kappa transform is an alpha graph called the kappa graph. Likewise, the output of the delta transform is an alpha graph called the delta graph. For each kappa graph, there is an associated delta graph, since the input of both transforms is the same decision graph. This correspondence is shown in
Vestigial alpha nodes are identified by comparing the kappa graph with its associated delta graph. The delta graph contains only those alpha nodes which participate in a data flow. Any alpha node in the kappa graph which does not also appear in the associated delta graph is vestigial.
14.3 Removal of Vestigial Alpha NodesThe kappa clean-up transform removes vestigial alpha nodes and their associated edges.
The kappa graph in
The cleanup transform is the final step in the production of the alpha graph(s). The cleanup transform consists of two steps:
-
- the removal of redundant control edges
- the removal of phantom nodes
A redundant control edge exists when two alpha nodes are connected by an alpha path and have control inputs from the same polarity of a common predicate alpha node. Since control information is implicitly carried by the alpha path, the control input of the alpha node further along the path is redundant. Since an InteriorPlusEdge connected to a PlusInteriorNode through a control plus alpha node functions like a single interior edge, this combination must also be considered when searching for redundant control edges. In the diagram shown in
The second step of the cleanup transform is the removal of phantom nodes. A phantom node is a plus alpha node that has a single input, but is not a loop exit node. In the example shown in
One of the foundational problems in the theory and practice of software testing has been to find a structural test strategy that is both effective and efficient. A fundamental tenet in the theory of software testing is that the ideal (structural) test strategy for a high level of effectiveness is all-paths. The fundamental limitation of the all-paths test strategy is that it is a theoretical ideal and not attainable due to the astronomical number of control-flow paths in the units (for example, Java methods) commonly found in industry. There has been much research over the past decades in an attempt to discover a structural test strategy that approximates the theoretical effectiveness of the all-paths test strategy, yet is sufficiently efficient to use in practice.
In this section, we present a small Java method and two efficient strategies based on information flow analysis for the structural testing of this method (in ascending order of effectiveness): all epsilon paths and all alpha paths. Test strategies based on all epsilon paths or all alpha paths are efficient approximations to the all-paths strategy.
For convenience, the instance variables safety and power have been converted to the arguments s and p respectively. The signal flow algebra for this example is supplied to demonstrate that the fundamental property of the alpha graph: the information flowgraph is a graph representation of the signal flow equations.
16.2 PreprocessorsThe alpha transform is preceded by three preprocessors. The Java source code listing for the example MorePower method is:
The first preprocessor converts the Java source code to the internal language, DDF. The DDF may be viewed as a textual representation of the annotated control flowgraph, which is shown in
The second preprocessor converts the DDF to the decorated decision graph, which is shown in
The third preprocessor is the compound predicate transform, which performs predicate expansion as shown in
The alpha transform converts the decision graph shown in
Paths in the control flowgraph are called physical paths. A physical path corresponds to the conventional notion of a path in a program. A complete physical path extends from an entry node to an exit node of the control flowgraph. The complete physical paths in a non-cyclic control flowgraph can be obtained by listing all structurally feasible combinations of predicate states. Predicate combinations that are not structurally feasible can be determined through static analysis and eliminated from consideration. For example, if the control state of u3:1(s) is false, then the control state of u3:3(p) has no effect, because u3:3(p) is not executed. The complete physical paths for the MorePower example are listed in this manner in the table shown in
Complete paths in the alpha graph (alpha level information flowgraph) are called alpha paths. An alpha path extends from an entry node to an exit node of an alpha graph. A method is represented by a single control flowgraph. If the method contains independent information flows, it will be represented by multiple alpha graphs. Whereas the control flowgraph of a method has a single entry node, an alpha graph may have multiple entry nodes. A method has a single control flowgraph, but may have several alpha graphs. Since an information flowgraph is a parallel representation of a program, the execution of a single physical path may correspond to the execution of multiple information flow paths.
16.6 Elementary PathsEach alpha path is composed of building blocks called elementary paths or epsilon paths. An elementary path is defined in terms of endnodes and alpha join nodes. An endnode is an entry or exit node of the alpha graph. An alpha join node is a
-
- star alpha node or
- predicate node with multiple data inputs or
- definition de that is shared by multiple ud-pairs
An alpha join node represents concurrent convergence, which means that its incoming paths could be executed concurrently. An elementary path begins and ends at either an endnode of the alpha graph or an alpha join node, with no endnodes or alpha join nodes in between the terminal nodes.
The epsilon paths are derived from the alpha tree. The general rule for constructing the alpha tree is that the children of a given node in the alpha tree are its parents in the alpha graph. The algorithm for construction of the alpha tree begins with an exit node of the alpha graph, which becomes the root of the alpha tree. The algorithm is applied recursively until all endnodes of the alpha tree are entry nodes of the alpha graph. The alpha tree for the exit node u12(p) of MorePower is shown in
Note that the designation of alpha nodes in this figure and the subsequent figures and tables are abbreviated. For example, the node *10(p) is abbreviated as *10, since the latter designation uniquely identifies the alpha node.
In
-
- <epsilon>1: *10+11 u12
The algorithm proceeds by finding the next descendent of the root which is an endnode or alpha join node: *8. The second epsilon path is the sequence of nodes, beginning at *8 and progressing back toward the root:
-
- <epsilon>2: *8+9+11 u12
When all epsilon paths ending at the root have been found, the algorithm proceeds in a similar manner, by finding all epsilon paths which terminate at the first node of <epsilon>1, the first node of <epsilon>2 and so forth. The epsilon paths for the MorePower example are listed in the table shown in
The elementary path structure of the alpha paths is derived from the epsilon tree. The pseudocode for the algorithm which generates the epsilon tree is:
The algorithm begins by constructing a dummy path, <epsilon>0, which consists of a single alpha node: the root node of the alpha tree. This path will later be discarded. The algorithm is initiated by calling etree on <epsilon>0:
-
- etree ({u12})
There are three epsilon paths which end at u12: <epsilon>1, <epsilon>2 and <epsilon>3. These epsilon paths are added to vc and are added as children of <epsilon>0. The algorithm then calls etree on each of these epsilon paths and proceeds recursively. The resulting epsilon tree is shown in
Note that the algorithm for the construction of the epsilon paths could be combined with the algorithm for construction of the epsilon tree. The two are separated in this presentation for clarity.
The complete alpha paths can be derived from a preorder traversal of the alpha tree or epsilon tree. In either case, the alpha paths are obtained by finding a descendent of the root which is an endnode. An alpha path consists of the sequence of nodes on the path in the tree from the endnode to the root.
For example, a preorder traversal of the epsilon tree in
-
- <alpha>1: <epsilon>4<epsilon>1 Note that the root, <epsilon>0, is not included in the alpha path, since it is a dummy path. Continuing with the traversal produces the complete alpha paths listed in the table shown in
FIGS. 193 a and 193b.
- <alpha>1: <epsilon>4<epsilon>1 Note that the root, <epsilon>0, is not included in the alpha path, since it is a dummy path. Continuing with the traversal produces the complete alpha paths listed in the table shown in
Before discussing coverage, it is important to note that, of the nine physical paths in this particular example, only four are feasible:
-
- FEASIBLE PATHS: 1 4 8 9
To keep our treatment general, we shall assume that all physical paths are feasible.
To cover all edges of the alpha graph, three physical paths are sufficient, for example:
-
- EDGE COVER: 1 5 9
The correlation between the execution of physical paths and elementary paths is presented in the table shown in
These physical paths:
-
- NECESSARY ELEMENTARY PATHS: 1 4 7
must be contained in any elementary path cover. A possible elementary path cover is:
-
- ELEMENTARY PATH COVER: 1 2 4 5 7 9
Note that this cover consists of six (physical) paths. In fact, any elementary path cover must consist of at least six paths.
A complete alpha path cover must consist of all physical paths. This requirement is evident from the table shown in
The same theoretical foundation for software testing can be applied to automatic parallelization of programs because both fields share the same fundamental problem: finding the independent parts of a program. See
An automatic parallelization tool breaks apart a program into smaller pieces that can be scheduled to run on separate processors. For example, in
Program analysis is used to identify sequencing constraints. There are two types of sequencing constraints: necessary and unnecessary. Parallelization of a program is equivalent to the removal of the unnecessary sequencing constraints. To ensure correctness, an automatic parallelization tool must accurately identify and preserve the necessary sequencing constraints.
An automatic parallelization tool is based on some form of program analysis. The effectiveness of a tool for parallelization depends on the precision of the underlying form of program analysis in distinguishing necessary from unnecessary sequencing constraints. Higher precision leads to fewer unnecessary sequencing constraints and greater parallelization.
The two basic types of (static) program analysis are: data flow and control flow analysis. Existing program analyzers are typically based on a dependence graph. In a dependence graph, each edge represents a sequencing constraint which is either a data dependence or control dependence, but not both. For example, in the pseudo-code:
there is a data dependence between the first statement which stores a value in ‘x’ and the second statement which reads the value of ‘x’. This is a necessary sequencing constraint, since the first statement must be executed before the second statement for correct program behavior. This sequencing constraint would appear as a data dependence edge in a dependence graph.
In an information flowgraph, a single edge may represent a data flow or a control flow or a composite flow (a sequencing constraint which consists of both control and data), as described in the section, “Intra-method graphs. The use of a single edge to represent composite flow is one distinguishing characteristic of information flow analysis which leads to greater precision than program analysis based on a dependence graph.
The pseudocode for a simple example and the corresponding dependence graph is shown in
A conceptual diagram depicting how information flow analysis can applied to automatic parallization is shown in
The application of information flow analysis to the example results in two separate information flowgraphs as shown in
In the dependence graph shown in
The increased precision inherent in information flow analysis leads to increased ability to reveal opportunities for parallelization. Whereas dependence analysis, the dominant form of contemporary program analysis, results in a single graph (
This application refers to pseudocode contained in an ASCII-compliant text file named “SCRT-1-006-PSEUDOCODE.TXT” having a size of 74.0 KB (75,813 bytes), and created on 12 Feb. 2009. This text file is being filed electronically concurrently herewith and is incorporated herein by reference in its entirety.
While the preferred embodiments of the invention have been illustrated and described, as noted above, many changes can be made without departing from the spirit and scope of the invention. Accordingly, the scope of the invention is not limited by the disclosure of the preferred embodiments. Instead, the invention should be determined entirely by reference to the claims that follow.
Claims
1. A digital processor-implemented method for analyzing a directed-flow network that is representable as directed or semi-structured flows, the method comprising:
- transforming an application-specific representation of the directed-flow network into decision graphs which represent the control flow structure of said flow network, with data flow elements attached to the graphs;
- transforming said decision graphs into one or more information flowgraphs which represent the directed flows of said flow network in a unified manner, and which identify the independent and quasi-independent flows therein; and
- transforming said information flowgraphs into application-specific artifacts for identifying independent and quasi-independent flows occurring in said flow network.
2. A digital processor-implemented method for analyzing computer programs represented in semi-structured languages, the method comprising:
- transforming source code or object code of the computer program represented in a semi-structured language into decision graphs which represent the control flow structure of said program, with data flow elements attached to the graphs;
- transforming said decision graphs into one or more information flowgraphs which represent control flow and data flow in a unified manner, and which identify the independent and quasi-independent flows therein; and
- converting said information flowgraphs into the source code or object code in the original programming language for use in automatic parallelization or efficient automated software testing approximating all-paths testing.
3. A digital processor-controlled apparatus comprising at least one digital processor and at least one machine-readable storage medium, the digital processor-controlled apparatus being capable of performing the method of claim 1 or claim 2.
4. A computer-readable storage medium having instructions encoded thereon which, when executed by a computer, cause the computer to perform the method of claim 1 or claim 2.
Type: Application
Filed: Feb 12, 2009
Publication Date: Aug 27, 2009
Patent Grant number: 9043774
Inventors: William G. Bently (Bloomington, IN), David D. Duchesneau (Puyallup, WA)
Application Number: 12/370,554
International Classification: G06F 9/44 (20060101); G06F 9/45 (20060101);