Skip to content

Commit 0060b0a

Browse files
vouillonhhugo
authored andcommitted
Fix Wasm output for functions with explicit type index
1 parent f0c6237 commit 0060b0a

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

compiler/lib-wasm/wasm_output.ml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,13 @@ end = struct
340340
fields;
341341
!func_idx, func_names, !global_idx, global_names, !tag_idx, tag_names
342342

343-
let output_functions ch (func_idx, func_names, func_types, fields) =
343+
let output_functions ch (type_names, func_idx, func_names, func_types, fields) =
344344
let l =
345345
List.fold_left
346346
~f:(fun acc field ->
347347
match field with
348-
| Function { signature; _ } -> signature :: acc
348+
| Function { typ = Some typ; _ } -> Code.Var.Hashtbl.find type_names typ :: acc
349+
| Function { signature; _ } -> Hashtbl.find func_types signature :: acc
349350
| Type _ | Import _ | Data _ | Global _ | Tag _ -> acc)
350351
~init:[]
351352
fields
@@ -361,10 +362,7 @@ end = struct
361362
~init:func_idx
362363
fields
363364
in
364-
output_vec
365-
(fun ch typ -> output_uint ch (Hashtbl.find func_types typ))
366-
ch
367-
(List.rev l)
365+
output_vec (fun ch typ -> output_uint ch typ) ch (List.rev l)
368366

369367
let int_un_op (arith, comp, trunc, reinterpret) ch op =
370368
match op with
@@ -1177,7 +1175,11 @@ end = struct
11771175
let func_idx, func_names, global_idx, global_names, _, tag_names =
11781176
output_section 2 output_imports ch (func_types, type_names, fields)
11791177
in
1180-
output_section 3 output_functions ch (func_idx, func_names, func_types, fields);
1178+
output_section
1179+
3
1180+
output_functions
1181+
ch
1182+
(type_names, func_idx, func_names, func_types, fields);
11811183
let st =
11821184
{ type_names
11831185
; func_names

0 commit comments

Comments
 (0)