Skip to content

Commit 83b7c68

Browse files
committed
Reduce constant string threshold
dune-build-info use a 64-byte placeholder. This ensures that such strings are encoded as a sequence of bytes in the wasm module.
1 parent 8b6a216 commit 83b7c68

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

compiler/lib/wasm/wa_gc_target.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,9 @@ module Memory = struct
890890
end
891891

892892
module Constant = struct
893-
let string_length_threshold = 100
893+
(* dune-build-info use a 64-byte placeholder. This ensures that such
894+
strings are encoded as a sequence of bytes in the wasm module. *)
895+
let string_length_threshold = 64
894896

895897
let store_in_global ?(name = "const") c =
896898
let name = Code.Var.fresh_n name in
@@ -991,7 +993,7 @@ module Constant = struct
991993
return (Const_named ("str_" ^ s), W.StructNew (ty, [ GlobalGet (V x) ]))
992994
| String s ->
993995
let* ty = Type.string_type in
994-
if String.length s > string_length_threshold
996+
if String.length s >= string_length_threshold
995997
then
996998
let name = Code.Var.fresh_n "string" in
997999
let* () = register_data_segment name ~active:false [ DataBytes s ] in

0 commit comments

Comments
 (0)