Commit 3cfe0414 authored by John van Groningen's avatar John van Groningen
Browse files

optimize allocation of Par and Seq constructors to prevent heap overflow

(>100 m)
parent 599eb4f0
......@@ -204,11 +204,21 @@ add_dep_count (fi,ai) rc
combine_counts :: !RefCounts !RefCounts -> .RefCounts
combine_counts c1 c2
= {Seq 0 [|rc1,rc2] \\ rc1 <-: c1 & rc2 <-: c2}
= {combine rc1 rc2 \\ rc1 <-: c1 & rc2 <-: c2}
where
combine (Seq 0 [|]) rc2 = rc2
combine rc1 (Seq 0 [|]) = rc1
combine (Seq i1 [|]) (Seq i2 l) = Seq (i1+i2) l
combine (Seq i1 l) (Seq i2 [|]) = Seq (i1+i2) l
combine rc1 rc2 = Seq 0 [|rc1,rc2]
unify_counts :: !RefCounts !RefCounts -> RefCounts
unify_counts c1 c2
= {Par 0 [|rc1,rc2] \\ rc1 <-: c1 & rc2 <-: c2}
= {unify rc1 rc2 \\ rc1 <-: c1 & rc2 <-: c2}
where
unify (Seq 0 [|]) rc2 = rc2
unify rc1 (Seq 0 [|]) = rc1
unify rc1 rc2 = Par 0 [|rc1,rc2]
show_counts group_members group_counts
# (_,group_counts) = foldSt show group_members (0,group_counts)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment