rw scStep to use instantiateU

by **extremely** rough estimate, this performs 40% less allocations and 4% more reductions
This commit is contained in:
crumbtoo
2023-11-14 11:47:19 -07:00
parent 8d431c9581
commit 2dd5ee1f2c

View File

@@ -196,12 +196,13 @@ step st =
TiState (f:ap:s) d h g sts
scStep :: Name -> [Name] -> Expr -> TiState -> TiState
scStep n as b (TiState s d h g sts) =
TiState s' d h'' g sts
scStep n as e (TiState s d h g sts) =
TiState s' d h' g sts
where
h'' = update h' (s !! length as) (NInd resAddr)
s' = resAddr : drop (length as + 1) s
(h', resAddr) = instantiate b h env
s' = rootAddr : drop (length as + 1) s
rootAddr = (s !! length as)
h' = instantiateU e rootAddr h env
env = argBinds ++ g
argBinds = as `zip` argAddrs
argAddrs = getArgs h s
@@ -322,6 +323,11 @@ letrecExample = Program
, ScDef "main" [] $ "f" :$ Prim (IntP 3) :$ Prim (IntP 4)
]
idExample :: Program
idExample = Program
[ ScDef "main" [] $ "id" :$ Prim (IntP 3)
]
indExample1 :: Program
indExample1 = Program
[ ScDef "main" [] $ "twice" :$ "twice" :$ "id" :$ Prim (IntP 3)