Remark: in the paper "Counting Immutable Beans" the concepts of
free and live variables coincide because the paper does not consider
join points. For example, consider the function body B
let x := ctor_0;
jmp block_1 x
in a context where we have the join point block_1
defined as
block_1 (x : obj) : obj :=
let z := ctor_0 x y;
ret z
The variable y
is live in the function body B
since it occurs in
block_1
which is "invoked" by B
.
We use State Context
instead of ReaderT Context Id
because we remove
non local joint points from Context
whenever we visit them instead of
maintaining a set of visited non local join points.
Remark: we don't need to track local join points because we assume there is no variable or join point shadowing in our IR.
Equations
Instances For
Equations
Instances For
Equations
- Lean.IR.IsLive.visitJP w x = pure (Lean.IR.HasIndex.visitJP w x)
Instances For
Equations
Instances For
Equations
- Lean.IR.IsLive.visitArgs w as = pure (Lean.IR.HasIndex.visitArgs w as)
Instances For
Equations
Instances For
Return true if x
is live in the function body b
in the context ctx
.
Remark: the context only needs to contain all (free) join point declarations.
Recall that we say that a join point j
is free in b
if b
contains
FnBody.jmp j ys
and j
is not local.
Equations
- Lean.IR.FnBody.hasLiveVar b ctx x = StateT.run' (Lean.IR.IsLive.visitFnBody x.idx b) ctx
Instances For
Equations
Instances For
Equations
- Lean.IR.JPLiveVarMap = Lean.RBMap Lean.IR.JoinPointId Lean.IR.LiveVarSet fun j₁ j₂ => compare j₁.idx j₂.idx
Instances For
Equations
- Lean.IR.instInhabitedLiveVarSet = { default := ∅ }
Equations
- Lean.IR.mkLiveVarSet x = Lean.RBTree.insert Lean.RBTree.empty x
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
Instances For
Equations
- Lean.IR.collectLiveVars b m v = Lean.IR.LiveVars.collectFnBody b m v