Skip to content

Commit 5f736b1

Browse files
committed
Use Js_of_ocaml_compiler.Structure instead of Wa_structure
Module Structure was basically copied from Wa_structure.
1 parent 364c37c commit 5f736b1

File tree

8 files changed

+17
-301
lines changed

8 files changed

+17
-301
lines changed

compiler/lib/generate.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,7 @@ and compile_block_no_loop st queue (pc : Addr.t) ~fall_through scope_stack =
16421642
| true -> never, [ J.Labelled_statement (l, (J.Block inner, J.N)), J.N ] @ code
16431643
| false -> never, inner @ code)
16441644
in
1645-
let never_after, after = loop ~scope_stack ~fall_through (List.rev new_scopes) in
1645+
let never_after, after = loop ~scope_stack ~fall_through new_scopes in
16461646
never_after, seq @ after
16471647

16481648
and compile_decision_tree kind st scope_stack loc cx dtree ~fall_through =

compiler/lib/structure.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ let is_loop_header g pc =
147147
Addr.Set.exists (fun pc' -> Hashtbl.find g.block_order pc' >= o) s
148148

149149
let sort_in_post_order t l =
150-
List.sort ~cmp:(fun a b -> compare (block_order t a) (block_order t b)) l
150+
List.sort ~cmp:(fun a b -> compare (block_order t b) (block_order t a)) l
151+
152+
let blocks_in_reverse_post_order g = g.reverse_post_order
151153

152154
(*
153155

compiler/lib/structure.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ val is_loop_header : t -> Addr.t -> bool
2121

2222
val sort_in_post_order : t -> Addr.t list -> Addr.t list
2323

24+
val blocks_in_reverse_post_order : t -> Code.Addr.t list
25+
2426
val get_nodes : t -> Addr.Set.t

compiler/lib/wasm/wa_generate.ml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -856,15 +856,15 @@ module Generate (Target : Wa_target_sig.S) = struct
856856
~pc
857857
~params
858858
in
859-
let g = Wa_structure.build_graph ctx.blocks pc in
860-
let dom = Wa_structure.dominator_tree g in
859+
let g = Structure.build_graph ctx.blocks pc in
860+
let dom = Structure.dominator_tree g in
861861
let rec translate_tree result_typ fall_through pc context =
862862
let block = Addr.Map.find pc ctx.blocks in
863863
let keep_ouside pc' =
864864
match fst block.branch with
865865
| Switch _ -> true
866866
| Cond (_, (pc1, _), (pc2, _)) when pc' = pc1 && pc' = pc2 -> true
867-
| _ -> Wa_structure.is_merge_node g pc'
867+
| _ -> Structure.is_merge_node g pc'
868868
in
869869
let code ~context =
870870
translate_node_within
@@ -873,13 +873,13 @@ module Generate (Target : Wa_target_sig.S) = struct
873873
~pc
874874
~l:
875875
(pc
876-
|> Wa_structure.get_edges dom
876+
|> Structure.get_edges dom
877877
|> Addr.Set.elements
878878
|> List.filter ~f:keep_ouside
879-
|> Wa_structure.sort_in_post_order g)
879+
|> Structure.sort_in_post_order g)
880880
~context
881881
in
882-
if Wa_structure.is_loop_header g pc
882+
if Structure.is_loop_header g pc
883883
then
884884
loop { params = []; result = result_typ } (code ~context:(`Block pc :: context))
885885
else code ~context
@@ -943,7 +943,7 @@ module Generate (Target : Wa_target_sig.S) = struct
943943
List.filter
944944
~f:(fun pc' ->
945945
Stack.stack_adjustment_needed stack_ctx ~src:pc ~dst:pc')
946-
(List.rev (Addr.Set.elements (Wa_structure.get_edges dom pc)))
946+
(List.rev (Addr.Set.elements (Structure.get_edges dom pc)))
947947
in
948948
let br_table e a context =
949949
let len = Array.length a in
@@ -999,8 +999,8 @@ module Generate (Target : Wa_target_sig.S) = struct
999999
match fall_through with
10001000
| `Block dst' when dst = dst' -> return ()
10011001
| _ ->
1002-
if (src >= 0 && Wa_structure.is_backward g src dst)
1003-
|| Wa_structure.is_merge_node g dst
1002+
if (src >= 0 && Structure.is_backward g src dst)
1003+
|| Structure.is_merge_node g dst
10041004
then instr (Br (label_index context dst, None))
10051005
else translate_tree result_typ fall_through dst context
10061006
in

compiler/lib/wasm/wa_globalize.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ let traverse_block p st pc =
104104
List.fold_left ~f:(fun st i -> traverse_instruction st i) ~init:st b.Code.body
105105

106106
let f p g closures =
107-
let l = Wa_structure.blocks_in_reverse_post_order g in
107+
let l = Structure.blocks_in_reverse_post_order g in
108108
let in_loop = Freevars.find_loops_in_closure p p.Code.start in
109109
let st =
110110
List.fold_left

compiler/lib/wasm/wa_globalize.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818

1919
val f :
2020
Code.program
21-
-> Wa_structure.control_flow_graph
21+
-> Structure.t
2222
-> Wa_closure_conversion.closure Code.Var.Map.t
2323
-> Code.Var.Set.t

compiler/lib/wasm/wa_structure.ml

Lines changed: 0 additions & 251 deletions
This file was deleted.

compiler/lib/wasm/wa_structure.mli

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)