Skip to content

Commit 9c8913a

Browse files
OlivierNicolevouillonhhugo
authored
Compiler: explicit initialization of builtin prims (#1662)
* Generate: explicit initialization * fixup! Generate: explicit initialization --------- Co-authored-by: Jérôme Vouillon <[email protected]> Co-authored-by: Hugo Heuzard <[email protected]>
1 parent 3881e6a commit 9c8913a

File tree

6 files changed

+8
-6
lines changed

6 files changed

+8
-6
lines changed

compiler/bin-js_of_ocaml/check_runtime.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ let print_groups output l =
4343
output_string output (Printf.sprintf "%s\n" name)))
4444

4545
let f (runtime_files, bytecode, target_env) =
46+
Linker.reset ();
4647
let runtime_files, builtin =
4748
List.partition_map runtime_files ~f:(fun name ->
4849
match Builtins.find name with

compiler/bin-js_of_ocaml/compile.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ let run
9191
let include_cmis = toplevel && not no_cmis in
9292
let custom_header = common.Jsoo_cmdline.Arg.custom_header in
9393
Jsoo_cmdline.Arg.eval common;
94+
Linker.reset ();
9495
(match output_file with
9596
| `Stdout, _ -> ()
9697
| `Name name, _ when debug_mem () -> Debug.start_profiling name

compiler/bin-js_of_ocaml/link.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ let f
151151
; toplevel
152152
} =
153153
Jsoo_cmdline.Arg.eval common;
154+
Linker.reset ();
154155
let with_output f =
155156
match output_file with
156157
| None -> f stdout

compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ let () =
2929
let global = J.pure_js_expr "globalThis" in
3030
Config.Flag.set "use-js-string" (Jsoo_runtime.Sys.Config.use_js_string ());
3131
Config.Flag.set "effects" (Jsoo_runtime.Sys.Config.effects ());
32+
Linker.reset ();
3233
(* this needs to stay synchronized with toplevel.js *)
3334
let toplevel_compile (s : string) (debug : Instruct.debug_event list array) :
3435
unit -> J.t =

compiler/lib/generate.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,5 +2054,3 @@ let init () =
20542054
Hashtbl.iter
20552055
(fun name (k, _) -> Primitive.register name k None None)
20562056
internal_primitives
2057-
2058-
let () = init ()

compiler/lib/primitive.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,17 @@ let register p k kargs arity =
9898
(string_of_kind k));
9999
add_external p;
100100
(match arity with
101-
| Some a -> Hashtbl.add arities p a
101+
| Some a -> Hashtbl.replace arities p a
102102
| _ -> ());
103103
(match kargs with
104-
| Some k -> Hashtbl.add kind_args_tbl p k
104+
| Some k -> Hashtbl.replace kind_args_tbl p k
105105
| _ -> ());
106-
Hashtbl.add kinds p k
106+
Hashtbl.replace kinds p k
107107

108108
let alias nm nm' =
109109
add_external nm';
110110
add_external nm;
111-
Hashtbl.add aliases nm nm'
111+
Hashtbl.replace aliases nm nm'
112112

113113
let named_values = ref StringSet.empty
114114

0 commit comments

Comments
 (0)