Aspect System Dependence Graph (AOSG)
- AOSG is a formal program representation that extends traditional SDGs by explicitly modeling aspect-specific constructs such as pointcuts, advice, and communication nodes.
- The construction algorithm builds separate dependence graphs for base and aspect code then weaves them via dedicated edges, facilitating accurate dynamic and static slicing.
- AOSG enhances program analysis in aspect-oriented environments by delivering precise control and data dependence tracking, even in concurrent execution contexts.
An Aspect System Dependence Graph (AOSG) is a directed program representation that extends the classical System Dependence Graph (SDG) to handle the unique modularity and weaving constructs of aspect-oriented programming (AOP). AOSGs explicitly encode base code, advice, pointcuts, and the aspect weaving process by integrating specialized node and edge types, providing a formal substrate for precise program analysis tasks such as dynamic slicing. This formalism is central to enabling accurate, aspect-aware analysis workflows for languages such as AspectJ, including static and dynamic data/control dependence tracking in the presence of cross-cutting concerns (Ray et al., 2014, Ray et al., 2014).
1. Formal Structure of the AOSG
An AOSG for an aspect-oriented program is a directed graph that generalizes an SDG by including dedicated abstractions for both base and aspect elements:
- :
- : nodes for ordinary statements or predicates in base code
- : pointcut start nodes (one dummy per pointcut declaration)
- : advice entry/exit nodes (one per advice body)
- : C-Nodes (“communication” nodes) for synchronizing base/aspect logic when multiple cross-cutting links are present
- :
- : control-dependence edges (post-dominator based)
- : data-dependence edges linking defs to uses without intervening redefinitions
- : interprocedural actual/formal parameter edges
- : aspect-membership (weaving) edges connecting base join-points to advice or C-Nodes
Key relations are:
- Control dependence: iff post-dominates ’s control predicate.
- Data dependence: iff there exists var with in and in , with reaching uninhibited.
- Aspect-membership: iff is a base-code join-point selected by a pointcut, is the corresponding advice entry or C-Node.
This edge/node partitioning captures both traditional program dependence and AOP-specific cross-cutting behavior (Ray et al., 2014).
2. Algorithmic Construction of the AOSG
Construction follows four primary stages:
- Build base SDG by analyzing control and data dependences in non-aspect code using control flow graphs (CFGs) and def-use relations.
- Build Aspect Dependence Graphs (ADG) for each advice, pointcut, and introduction, using method/procedure-like dependence analysis.
- Determine aspect-membership edges by connecting join-points in base code (that match pointcuts) to corresponding advice entries in via , optionally via C-Nodes if multiple advices or introductions require logical synchronization.
- Weave SDG and ADG by assigning interprocedural parameter edges, connecting actual and formal parameters for advice invocations, and leveraging C-Nodes when needed for logical grouping.
This multi-phase construction explicitly models both the static and dynamic connectivity generated by AspectJ-like weaving. Introductions (inter-type declarations) are encoded as new fields/methods attached by (Ray et al., 2014, Ray et al., 2014).
3. Comparison with Traditional System Dependence Graphs
Characteristic differences between the AOSG and classical SDG are outlined below.
| Feature | SDG | AOSG (ASDG) |
|---|---|---|
| Vertices | Base code statements/predicates | + Pointcut starts (), advice (), C-Nodes () |
| Edges | Control, data, parameter | + Aspect-membership (weaving) edges () |
| Inter-modular Flow | Calls, parameters | Advice/join-point weaving, introductions |
| Cross-cutting Handling | Not explicit | Explicit edge and node modeling |
AOSG (synonymous with “Aspect System Dependence Graph” or “ASDG” in some literature) provides explicit mechanisms for tracking aspect weaving and cross-cutting effects, enabling finer-grained, aspect-aware analyses not possible in classical SDG frameworks (Ray et al., 2014).
4. Concrete Example: AspectJ Program and Its AOSG
Consider the simplified AspectJ example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
public class Prime { static int n; public static void main(String[] args) { n = Integer.parseInt(args[0]); if (isprime(n)) System.out.println("Prime"); else System.out.println("Not Prime"); System.out.println("Result: "+n); } static boolean isprime(int n) { ... } } public aspect PrimeAspect { pointcut pc(int n): call(Boolean Prime.isprime(int)) && args(n); before(int n): pc(n) { System.out.println("Testing :"+n); } after(int n) returning(boolean r): pc(n) { System.out.println("Status :"+n+" → "+r); } } |
Key AOSG nodes and edges:
- Nodes: =
n = ..., =if (isprime(n)), = insidemain, = dummy pointcut start, = advice entry (before), = advice entry (after), = C-Node (optional). - Edges:
- in and for
- in
- , in
- Parameter edges for advice invocation
A schematic fragment:
1 2 3 4 5 |
v1 ––(ctrl,data)→ v2 ––(ctrl)→ v3
↘
(asm)→ a_before ––(ctrl,data)→ print
↘
(asm)→ a_after ––(ctrl,data)→ print |
This construction exposes how aspect weaving and advice executions are incorporated at the program dependence graph level (Ray et al., 2014).
5. Dynamic Slicing via the AOSG
The runtime dynamic slicing algorithm using AOSG proceeds as follows:
- For each node and variable , maintain , initialized to ; also maintain .
- All edges in are unmarked before execution.
- On execution of statement (mapping to node ):
- Let (possibly ).
- Unmark any previously marked edge for .
- If , mark .
- Update .
- 2. If is a node, set .
- 3. If is an advice entry, mark edges and relevant parameter edges.
- 4. If is a method entry, update parameter edges accordingly.
A slicing query for is computed as .
This runtime protocol directly encodes execution history on the graph by marking/unmarking edges, requiring no trace file. Traversing marked edges from a slicing criterion yields the dynamic slice “on demand” (Ray et al., 2014).
6. Extensions: Concurrency and the CASDG
AOSG generalizes to concurrent programs as the Concurrent Aspect-oriented System Dependence Graph (CASDG):
- CASDG adds nodes and edges for thread-related relationships:
- Synchronization-dependence (wait/notify)
- Non-synchronized edges (sleep, spawn)
- Communication-dependence (data flow between threads)
- Exception-check edges (try/catch)
Construction proceeds by building the base SDG, then ADGs for each aspect, then weaving, and finally injecting concurrency edges. The concurrent dynamic slicing algorithm augments the marking/unmarking protocol to update slices across thread, synchronization, and communication edges, ensuring inter-thread dependences are tracked during slicing. The formal recurrence:
encompasses all marked predecessor nodes, including those from concurrency-specific dependence classes (Ray et al., 2014).
7. Applications and Significance in Program Analysis
AOSG underpins advanced program analysis, especially dynamic slicing of aspect-oriented software. Its key benefits include:
- Precision: The graph marks only the dependences exercised during the run, eliminating spurious statements from slices.
- Efficiency: No trace file is required; the history is encoded in the marks on the AOSG and pointers, enabling instant querying at arbitrary program points.
- Aspect-awareness: Aspect weaving, cross-cutting interactions, introductions, and advice precedence are all represented, enabling analyses sensitive to AOP mechanisms.
- Extensibility: The approach is modular, allowing extension for concurrency and other advanced programming paradigms (Ray et al., 2014, Ray et al., 2014).
These properties make AOSG the foundation for precise and scalable dynamic slicing in AspectJ and comparable languages, directly supporting tasks in debugging, program understanding, and security analysis.