Skip to content

Commit 9f19bc3

Browse files
authored
Wasm_of_ocaml: clean up + small fixes (#1836)
* Rename module Wa_runtime to Runtime_files * Fix: do not wrap twice fragment invocations * Wasm linker: fix parsing of limits
1 parent 6d6fc9d commit 9f19bc3

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

compiler/bin-wasm_of_ocaml/compile.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ let link_and_optimize
9191
let enable_source_maps = Option.is_some opt_sourcemap_file in
9292
Fs.with_intermediate_file (Filename.temp_file "runtime" ".wasm")
9393
@@ fun runtime_file ->
94-
Fs.write_file ~name:runtime_file ~contents:Wa_runtime.wasm_runtime;
94+
Fs.write_file ~name:runtime_file ~contents:Runtime_files.wasm_runtime;
9595
Fs.with_intermediate_file (Filename.temp_file "wasm-merged" ".wasm")
9696
@@ fun temp_file ->
9797
opt_with
@@ -113,7 +113,7 @@ let link_and_optimize
113113
@@ fun opt_temp_sourcemap' ->
114114
let primitives =
115115
Binaryen.dead_code_elimination
116-
~dependencies:Wa_runtime.dependencies
116+
~dependencies:Runtime_files.dependencies
117117
~opt_input_sourcemap:opt_temp_sourcemap
118118
~opt_output_sourcemap:opt_temp_sourcemap'
119119
~input_file:temp_file
@@ -133,7 +133,7 @@ let link_and_optimize
133133
let link_runtime ~profile runtime_wasm_files output_file =
134134
Fs.with_intermediate_file (Filename.temp_file "runtime" ".wasm")
135135
@@ fun runtime_file ->
136-
Fs.write_file ~name:runtime_file ~contents:Wa_runtime.wasm_runtime;
136+
Fs.write_file ~name:runtime_file ~contents:Runtime_files.wasm_runtime;
137137
Fs.with_intermediate_file (Filename.temp_file "wasm-merged" ".wasm")
138138
@@ fun temp_file ->
139139
Binaryen.link
@@ -216,7 +216,7 @@ let build_js_runtime ~primitives ?runtime_arguments () =
216216
in
217217
let prelude = Link.output_js always_required_js in
218218
let init_fun =
219-
match Parse_js.parse (Parse_js.Lexer.of_string Wa_runtime.js_runtime) with
219+
match Parse_js.parse (Parse_js.Lexer.of_string Runtime_files.js_runtime) with
220220
| [ (Expression_statement f, _) ] -> f
221221
| _ -> assert false
222222
in

compiler/bin-wasm_of_ocaml/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
(:standard -safe-string)))
2323

2424
(rule
25-
(target wa_runtime.ml)
25+
(target runtime_files.ml)
2626
(deps
2727
gen/gen.exe
2828
../../runtime/wasm/runtime.wasm

compiler/lib-wasm/gc_target.ml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,11 +1406,6 @@ let () =
14061406
in
14071407
let register_js_expr prim_name =
14081408
register prim_name (fun transl_prim_arg l ->
1409-
let* wrap =
1410-
register_import
1411-
~name:"wrap"
1412-
(Fun { params = [ JavaScript.anyref ]; result = [ Value.value ] })
1413-
in
14141409
match l with
14151410
| Code.[ Pc (String str) ] -> (
14161411
try
@@ -1422,8 +1417,7 @@ let () =
14221417
EArrow
14231418
(J.fun_ [] [ Return_statement (Some e, N), N ] N, true, AUnknown))
14241419
in
1425-
let* js_val = JavaScript.invoke_fragment name [] in
1426-
return (W.Call (wrap, [ js_val ]))
1420+
JavaScript.invoke_fragment name []
14271421
with Parse_js.Parsing_error pi ->
14281422
failwith
14291423
(Printf.sprintf

compiler/lib-wasm/wasm_link.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,7 @@ module Scan = struct
14021402
let limits pos =
14031403
let c = get pos in
14041404
assert (c < 8);
1405-
if c land 1 = 0 then pos |> int else pos |> int |> int
1405+
if c land 1 = 0 then pos + 1 |> int else pos + 1 |> int |> int
14061406
in
14071407
let tabletype pos =
14081408
mark pos;

0 commit comments

Comments
 (0)