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
- b.hasLiveVar 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₂ : Lean.IR.JoinPointId) => compare j₁.idx j₂.idx
Instances For
Equations
- Lean.IR.instInhabitedLiveVarSet = { default := ∅ }
Equations
- Lean.IR.mkLiveVarSet x = Lean.RBTree.empty.insert x
Instances For
Equations
Instances For
Equations
- Lean.IR.LiveVars.collectExpr (Lean.IR.Expr.ctor i ys) = Lean.IR.LiveVars.collectArgs ys
- Lean.IR.LiveVars.collectExpr (Lean.IR.Expr.reset n x_1) = Lean.IR.LiveVars.collectVar x_1
- Lean.IR.LiveVars.collectExpr (Lean.IR.Expr.reuse x_1 i updtHeader ys) = Lean.IR.LiveVars.collectVar x_1 ∘ Lean.IR.LiveVars.collectArgs ys
- Lean.IR.LiveVars.collectExpr (Lean.IR.Expr.proj i x_1) = Lean.IR.LiveVars.collectVar x_1
- Lean.IR.LiveVars.collectExpr (Lean.IR.Expr.uproj i x_1) = Lean.IR.LiveVars.collectVar x_1
- Lean.IR.LiveVars.collectExpr (Lean.IR.Expr.sproj n offset x_1) = Lean.IR.LiveVars.collectVar x_1
- Lean.IR.LiveVars.collectExpr (Lean.IR.Expr.fap c ys) = Lean.IR.LiveVars.collectArgs ys
- Lean.IR.LiveVars.collectExpr (Lean.IR.Expr.pap c ys) = Lean.IR.LiveVars.collectArgs ys
- Lean.IR.LiveVars.collectExpr (Lean.IR.Expr.ap x_1 ys) = Lean.IR.LiveVars.collectVar x_1 ∘ Lean.IR.LiveVars.collectArgs ys
- Lean.IR.LiveVars.collectExpr (Lean.IR.Expr.box ty x_1) = Lean.IR.LiveVars.collectVar x_1
- Lean.IR.LiveVars.collectExpr (Lean.IR.Expr.unbox x_1) = Lean.IR.LiveVars.collectVar x_1
- Lean.IR.LiveVars.collectExpr (Lean.IR.Expr.lit v) = Lean.IR.LiveVars.skip
- Lean.IR.LiveVars.collectExpr (Lean.IR.Expr.isShared x_1) = Lean.IR.LiveVars.collectVar x_1
Instances For
Equations
- Lean.IR.updateJPLiveVarMap j ys v m = Lean.RBMap.insert m j ((Lean.IR.LiveVars.bindParams ys ∘ Lean.IR.LiveVars.collectFnBody v m) ∅)
Instances For
Equations
Instances For
Equations
- Lean.IR.collectLiveVars b m v = Lean.IR.LiveVars.collectFnBody b m v