---
title: Aspect System Dependence Graph (AOSG)
url: https://www.emergentmind.com/topics/aspect-system-dependence-graph-aosg
type: topic
---

# Aspect System Dependence Graph (AOSG)

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 [1403.0100, 1404.3382].

## 1. Formal Structure of the AOSG

An AOSG for an aspect-oriented program $P$ is a directed graph $G = (V, E)$ that generalizes an SDG by including dedicated abstractions for both base and aspect elements:

- $V = V_n \cup V_p \cup V_a \cup V_c$:
  - $V_n$: nodes for ordinary statements or predicates in base code
  - $V_p$: pointcut start nodes (one dummy per pointcut declaration)
  - $V_a$: advice entry/exit nodes (one per advice body)
  - $V_c$: C-Nodes (“communication” nodes) for synchronizing base/aspect logic when multiple cross-cutting links are present

- $E = E_{ctrl} \cup E_{data} \cup E_{param} \cup E_{asm}$:
  - $E_{ctrl}$: control-dependence edges (post-dominator based)
  - $E_{data}$: data-dependence edges linking defs to uses without intervening redefinitions
  - $E_{param}$: interprocedural actual/formal parameter edges
  - $E_{asm}$: aspect-membership (weaving) edges connecting base join-points to advice or C-Nodes

Key relations are:

- Control dependence: $(u, v) \in E_{ctrl}$ iff $u$ post-dominates $v$’s control predicate.
- Data dependence: $(u, v) \in E_{data}$ iff there exists var $\in Vars$ with $u$ in $defSet(var)$ and $v$ in $useSet(var)$, with $u$ reaching $v$ uninhibited.
- Aspect-membership: $(j, a) \in E_{asm}$ iff $j$ is a base-code join-point selected by a pointcut, $a$ is the corresponding advice entry or C-Node.

This edge/node partitioning captures both traditional program dependence and AOP-specific cross-cutting behavior [1403.0100].

## 2. Algorithmic Construction of the AOSG

Construction follows four primary stages:

1. **Build base SDG** by analyzing control and data dependences in non-aspect code using control flow graphs (CFGs) and def-use relations.
2. **Build Aspect Dependence Graphs (ADG)** for each advice, pointcut, and introduction, using method/procedure-like dependence analysis.
3. **Determine aspect-membership edges** by connecting join-points in base code (that match pointcuts) to corresponding advice entries in $V_a$ via $E_{asm}$, optionally via C-Nodes if multiple advices or introductions require logical synchronization.
4. **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 $E_{asm}$ [1403.0100, 1404.3382].

## 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 ($V_p$), advice ($V_a$), C-Nodes ($V_c$) |
| Edges                  | Control, data, parameter              | + Aspect-membership (weaving) edges ($E_{asm}$)             |
| 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 [1404.3382].

## 4. Concrete Example: AspectJ Program and Its AOSG

Consider the simplified AspectJ example:

```java
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: $v_1$ = `n = ...`, $v_2$ = `if (isprime(n))`, $v_3$ = inside `main`, $p_1$ = dummy pointcut start, $a_{before}$ = advice entry (before), $a_{after}$ = advice entry (after), $c_1$ = C-Node (optional).
- Edges: 
    - $(v_1 \to v_2)$ in $E_{ctrl}$ and $E_{data}$ for $n$
    - $(v_2 \to v_3)$ in $E_{ctrl}$
    - $(v_2 \to a_{before})$, $(v_2 \to a_{after})$ in $E_{asm}$
    - Parameter edges for advice invocation

A schematic fragment:

```
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 [1403.0100].

## 5. Dynamic Slicing via the AOSG

The runtime dynamic slicing algorithm using AOSG proceeds as follows:

- For each node $u$ and variable $var$, maintain $dslice(u,var) \subseteq V$, initialized to $\emptyset$; also maintain $RecentDef(var)$.
- All edges in $E_{ctrl} \cup E_{data} \cup E_{asm}$ are unmarked before execution.
- On execution of statement $S$ (mapping to node $u$):
    1. For each variable used at $u$:
        - Let $D = RecentDef(var)$ (possibly $NULL$).
        - Unmark any previously marked $(x \to u)$ edge for $var$.
        - If $D \neq NULL$, mark $(D \to u)$.
        - Update $dslice(u, var) \gets \{D\} \cup dslice(D, var)$.
    2. If $u$ is a $def(var)$ node, set $RecentDef(var) := u$.
    3. If $u$ is an advice entry, mark $(join \to advice)$ edges and relevant parameter edges.
    4. If $u$ is a method entry, update parameter edges accordingly.

A slicing query for $\langle u_0, var_0 \rangle$ is computed as $S = \bigcup_{v \in dslice(u_0, var_0)} \{v\} \cup \{u_0\}$.

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” [1403.0100].

## 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:

$$
dynamicSlice(w, var) = \{w\} \cup \bigcup_{u \in Pred_m(w)} dynamicSlice(u, var)
$$

encompasses all marked predecessor nodes, including those from concurrency-specific dependence classes [1404.3382].

## 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 $RecentDef$ 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 [1403.0100, 1404.3382].

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.

Source: https://www.emergentmind.com/topics/aspect-system-dependence-graph-aosg