Skip to content

Commit 455187e

Browse files
committed
WIP
1 parent 30e2d7a commit 455187e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

compiler/lib/eval.ml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ end = struct
729729
| Apply { f; args; exact } -> Apply { f = s f; args = List.map args ~f:s; exact }
730730
| Block (n, a, k, mut) -> Block (n, Array.map a ~f:s, k, mut)
731731
| Field (x, n, typ) -> Field (s x, n, typ)
732-
| Closure (l, pc, loc) -> Closure (List.map l ~f:s, subst_cont s pc, loc)
732+
| Closure (l, pc, loc) -> Closure (l, subst_cont s pc, loc)
733733
| Special _ -> e
734734
| Prim (p, l) ->
735735
Prim
@@ -783,15 +783,15 @@ end = struct
783783
in
784784
block s d blk
785785

786-
let i_equal a b =
786+
let instr_equal a b =
787787
match a, b with
788788
| Event _, Event _ -> true
789789
| Event _, _ | _, Event _ -> false
790790
| a, b -> Poly.equal a b
791791

792792
let equal a b =
793793
List.equal ~eq:Var.equal a.params b.params
794-
&& List.equal ~eq:i_equal a.body b.body
794+
&& List.equal ~eq:instr_equal a.body b.body
795795
&& Poly.equal a.branch b.branch
796796

797797
let hash (x : block) = Hashtbl.hash x
@@ -816,11 +816,12 @@ let eval_branch blocks update_branch info l =
816816
incr update_branch;
817817
Branch cont
818818
| None ->
819-
let t = SBT.create 18 in
819+
let t = SBT.create 0 in
820+
let seen_pc = Addr.Hashtbl.create 0 in
820821
Switch
821822
( x
822823
, Array.map a ~f:(function
823-
| pc, [] -> (
824+
| pc, [] when not (Addr.Hashtbl.mem seen_pc pc) -> (
824825
let block = Code.Addr.Map.find pc blocks in
825826
let sb = Simple_block.make block in
826827
match SBT.find_opt t sb with
@@ -829,6 +830,7 @@ let eval_branch blocks update_branch info l =
829830
pc', []
830831
| Some _ | None ->
831832
SBT.add t sb pc;
833+
Addr.Hashtbl.add seen_pc pc ();
832834
pc, [])
833835
| cont -> cont) ))
834836
| cont -> cont

0 commit comments

Comments
 (0)