From 7dbb19ab2e6ef3d42ee4488d0883e1c6525fc911 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 28 Jul 2025 15:21:13 +0200 Subject: [PATCH 01/10] WIP --- compiler/lib/flow.ml | 10 +++++++--- compiler/lib/generate.ml | 11 +++++++++++ compiler/lib/specialize_js.ml | 29 +++++++++++++++++++++++++++++ examples/boulderdash/boulderdash.ml | 10 +++++++++- examples/boulderdash/custom.js | 6 ++++++ examples/boulderdash/dune | 1 + lib/runtime/jsoo_runtime.ml | 2 ++ 7 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 examples/boulderdash/custom.js diff --git a/compiler/lib/flow.ml b/compiler/lib/flow.ml index 13de7ffb74..59084f0f0c 100644 --- a/compiler/lib/flow.ml +++ b/compiler/lib/flow.ml @@ -47,9 +47,13 @@ module Info = struct } let def t x = - match t.info_defs.(Code.Var.idx x) with - | Phi _ | Param -> None - | Expr x -> Some x + let idx = Code.Var.idx x in + if Array.length t.info_defs <= idx + then None + else + match t.info_defs.(idx) with + | Phi _ | Param -> None + | Expr x -> Some x let possibly_mutable t x = Code.Var.ISet.mem t.info_possibly_mutable x diff --git a/compiler/lib/generate.ml b/compiler/lib/generate.ml index 30eb8198c2..8bee374170 100644 --- a/compiler/lib/generate.ml +++ b/compiler/lib/generate.ml @@ -1547,6 +1547,17 @@ let rec translate_expr ctx loc x e level : (_ * J.statement_list) Expr_builder.t | Some s -> Printf.sprintf ", file %S" s) pi.Parse_info.line pi.Parse_info.col)) + | Extern "caml_jsoo_runtime", [ Pc (String nm) ] when J.is_ident nm -> + let prim = Share.get_prim (runtime_fun ctx) nm ctx.Ctx.share in + return prim + | Extern "caml_jsoo_runtime", [ (Pc _ | Pv _) ] -> + failwith + (Printf.sprintf + "%scaml_jsoo_runtime expects a string literal." + (match (loc : J.location) with + | Pi { name = Some name; col; line; _ } -> + Printf.sprintf "%s:%d:%d: " name line col + | Pi _ | N | U -> "")) | Extern "%js_array", l -> let* args = list_map (fun x -> access' ~ctx x) l in return (J.array args) diff --git a/compiler/lib/specialize_js.ml b/compiler/lib/specialize_js.ml index dda64b1063..1e18da69b1 100644 --- a/compiler/lib/specialize_js.ml +++ b/compiler/lib/specialize_js.ml @@ -288,6 +288,35 @@ let specialize_instrs ~target opt_count info l = match l with | [] -> List.rev acc | i :: r -> ( + let i = + match i with + | Let (x, Apply { f; args; exact = false }) -> ( + match Info.def info f with + | None -> i + | Some (Prim (Extern "caml_jsoo_runtime", [ name ])) -> ( + let name = + match name with + | Pc (String name) -> Some name + | Pc _ -> None + | Pv x -> ( + match Info.def info x with + | Some (Constant (String name)) -> Some name + | Some _ | None -> None) + in + match name with + | None -> i + | Some name -> ( + let name = Primitive.resolve name in + match Primitive.arity name with + | exception Not_found -> i + | n -> + if List.compare_length_with args ~len:n = 0 + then + Let (x, Prim (Extern name, List.map args ~f:(fun x -> Pv x))) + else i)) + | Some _ -> i) + | _ -> i + in (* We make bound checking explicit. Then, we can remove duplicated bound checks. Also, it appears to be more efficient to inline the array access. The bound checking function returns the array, diff --git a/examples/boulderdash/boulderdash.ml b/examples/boulderdash/boulderdash.ml index 09acaaef59..0b6a7ce73f 100644 --- a/examples/boulderdash/boulderdash.ml +++ b/examples/boulderdash/boulderdash.ml @@ -510,4 +510,12 @@ let start _ = Dom.appendChild body div; Lwt.return () -let () = Lwt.async start +let () = + let p : Js.js_string Js.t = Jsoo_runtime.Sys.external_ "process" in + let o : _ Js.t = Jsoo_runtime.Sys.external_ "obj" in + let del : 'a -> Jsoo_runtime.Js.t -> unit = + Jsoo_runtime.Sys.external_ "caml_js_delete" + in + del o (Jsoo_runtime.Js.string "process"); + print_endline (Js.to_string p); + Lwt.async start diff --git a/examples/boulderdash/custom.js b/examples/boulderdash/custom.js new file mode 100644 index 0000000000..3784b6b3e4 --- /dev/null +++ b/examples/boulderdash/custom.js @@ -0,0 +1,6 @@ +//Provides: process +var process = "process" + + +//Provides: obj +var obj = { "process": 42 } diff --git a/examples/boulderdash/dune b/examples/boulderdash/dune index 973c7b6921..496c57e99f 100644 --- a/examples/boulderdash/dune +++ b/examples/boulderdash/dune @@ -4,6 +4,7 @@ (modes js wasm) (js_of_ocaml (compilation_mode separate) + (javascript_files custom.js) (build_runtime_flags :standard --file %{dep:maps.txt} --file maps)) (link_deps (glob_files maps/*.map)) diff --git a/lib/runtime/jsoo_runtime.ml b/lib/runtime/jsoo_runtime.ml index 4dee5f64a9..d9d00a38c8 100644 --- a/lib/runtime/jsoo_runtime.ml +++ b/lib/runtime/jsoo_runtime.ml @@ -124,6 +124,8 @@ module Sys = struct external restore_channel : out_channel -> redirection -> unit = "caml_ml_channel_restore" + external external_ : string -> 'a = "caml_jsoo_runtime" + module Config = struct external use_js_string : unit -> bool = "caml_jsoo_flags_use_js_string" From b93e4be0bf26c52b1b64e99bd47347c310409959 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 21 Oct 2025 19:22:59 +0200 Subject: [PATCH 02/10] X --- lib/runtime/js_of_ocaml_runtime_stubs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/runtime/js_of_ocaml_runtime_stubs.c b/lib/runtime/js_of_ocaml_runtime_stubs.c index 44ea7ecb8a..a39c146e15 100644 --- a/lib/runtime/js_of_ocaml_runtime_stubs.c +++ b/lib/runtime/js_of_ocaml_runtime_stubs.c @@ -208,6 +208,10 @@ void caml_jsoo_flags_use_js_string () { caml_fatal_error("Unimplemented Javascript primitive caml_jsoo_flags_use_js_string!"); } +void caml_jsoo_runtime () { + caml_fatal_error("Unimplemented Javascript primitive caml_jsoo_runtime!"); +} + void caml_jsstring_of_string () { caml_fatal_error("Unimplemented Javascript primitive caml_jsstring_of_string!"); } From ef9966e64036383d2117df15d40041f33448bd1d Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 21 Oct 2025 19:30:23 +0200 Subject: [PATCH 03/10] WIP --- examples/boulderdash/custom.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/boulderdash/custom.js b/examples/boulderdash/custom.js index 3784b6b3e4..f3caeb9a97 100644 --- a/examples/boulderdash/custom.js +++ b/examples/boulderdash/custom.js @@ -1,6 +1,5 @@ //Provides: process -var process = "process" - +var process = "process"; //Provides: obj -var obj = { "process": 42 } +var obj = { process: 42 }; From 07ed5a11bba69fafe24a474103c215aadfb6bd64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Wed, 22 Oct 2025 12:56:45 +0200 Subject: [PATCH 04/10] Wasm implementation --- compiler/lib-wasm/gc_target.ml | 16 ++++++++++++++++ compiler/lib/specialize_js.ml | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/compiler/lib-wasm/gc_target.ml b/compiler/lib-wasm/gc_target.ml index eaaa6b6498..216f188421 100644 --- a/compiler/lib-wasm/gc_target.ml +++ b/compiler/lib-wasm/gc_target.ml @@ -1932,6 +1932,22 @@ let internal_primitives = in let l = List.map ~f:transl_prim_arg vl in JavaScript.invoke_fragment name l); + register "caml_jsoo_runtime" (fun _ l -> + match l with + | [ Pc (String name) ] when J.is_ident name -> + let* x = + register_import + ~import_module:"js" + ~name + (Global { mut = false; typ = JavaScript.anyref }) + in + let* wrap = + register_import + ~name:"wrap" + (Fun { params = [ JavaScript.anyref ]; result = [ Type.value ] }) + in + return (W.Call (wrap, [ GlobalGet x ])) + | _ -> failwith "Jsoo_runtime.Sys.external_ expects a string literal."); !l let externref = W.Ref { nullable = true; typ = Extern } diff --git a/compiler/lib/specialize_js.ml b/compiler/lib/specialize_js.ml index 1e18da69b1..1b0880560c 100644 --- a/compiler/lib/specialize_js.ml +++ b/compiler/lib/specialize_js.ml @@ -188,6 +188,11 @@ let specialize_instr opt_count ~target info i = incr opt_count; Let (x, Prim (Extern "%direct_int_mod", [ y; z ])) | _ -> i) + | Let (x, Prim (Extern "caml_jsoo_runtime", [ nm ])), _ -> ( + match the_string_of info nm with + | Some nm when Javascript.is_ident nm -> + Let (x, Prim (Extern "caml_jsoo_runtime", [ Pc (String nm) ])) + | _ -> i) | _, _ -> i let skip_event cont (Event _ :: l | l) = cont l From a8d8688e8cfff652f81886f7a816813473bb0d5a Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Thu, 23 Oct 2025 09:02:35 +0200 Subject: [PATCH 05/10] WIP --- .../boulderdash => compiler/tests-jsoo}/custom.js | 0 compiler/tests-jsoo/dune | 11 +++++++++++ compiler/tests-jsoo/test_custom.ml | 8 ++++++++ examples/boulderdash/boulderdash.ml | 10 +--------- examples/boulderdash/dune | 1 - 5 files changed, 20 insertions(+), 10 deletions(-) rename {examples/boulderdash => compiler/tests-jsoo}/custom.js (100%) create mode 100644 compiler/tests-jsoo/test_custom.ml diff --git a/examples/boulderdash/custom.js b/compiler/tests-jsoo/custom.js similarity index 100% rename from examples/boulderdash/custom.js rename to compiler/tests-jsoo/custom.js diff --git a/compiler/tests-jsoo/dune b/compiler/tests-jsoo/dune index 60c7a46832..6e65848a53 100644 --- a/compiler/tests-jsoo/dune +++ b/compiler/tests-jsoo/dune @@ -48,6 +48,7 @@ test_bigarray test_marshal_compressed test_parsing + test_custom calc_parser calc_lexer)) (libraries unix compiler-libs.common js_of_ocaml-compiler) @@ -66,6 +67,16 @@ (modules test_float16 test_bigarray) (modes js wasm native)) +(test + (name test_custom) + (modules test_custom) + (libraries js_of_ocaml) + (js_of_ocaml + (javascript_files custom.js)) + (wasm_of_ocaml + (javascript_files custom.js)) + (modes js wasm)) + (ocamlyacc calc_parser) (ocamllex calc_lexer) diff --git a/compiler/tests-jsoo/test_custom.ml b/compiler/tests-jsoo/test_custom.ml new file mode 100644 index 0000000000..cef780dfbc --- /dev/null +++ b/compiler/tests-jsoo/test_custom.ml @@ -0,0 +1,8 @@ +open Js_of_ocaml + +let () = + let p : Js.js_string Js.t = Jsoo_runtime.Sys.external_ "process" in + let o : _ Js.t = Jsoo_runtime.Sys.external_ "obj" in + let del = Jsoo_runtime.Sys.external_ "caml_js_delete" in + ignore (Js.Unsafe.fun_call del [| o; Js.Unsafe.coerce (Js.string "process") |]); + print_endline (Js.to_string p) diff --git a/examples/boulderdash/boulderdash.ml b/examples/boulderdash/boulderdash.ml index 0b6a7ce73f..09acaaef59 100644 --- a/examples/boulderdash/boulderdash.ml +++ b/examples/boulderdash/boulderdash.ml @@ -510,12 +510,4 @@ let start _ = Dom.appendChild body div; Lwt.return () -let () = - let p : Js.js_string Js.t = Jsoo_runtime.Sys.external_ "process" in - let o : _ Js.t = Jsoo_runtime.Sys.external_ "obj" in - let del : 'a -> Jsoo_runtime.Js.t -> unit = - Jsoo_runtime.Sys.external_ "caml_js_delete" - in - del o (Jsoo_runtime.Js.string "process"); - print_endline (Js.to_string p); - Lwt.async start +let () = Lwt.async start diff --git a/examples/boulderdash/dune b/examples/boulderdash/dune index 496c57e99f..973c7b6921 100644 --- a/examples/boulderdash/dune +++ b/examples/boulderdash/dune @@ -4,7 +4,6 @@ (modes js wasm) (js_of_ocaml (compilation_mode separate) - (javascript_files custom.js) (build_runtime_flags :standard --file %{dep:maps.txt} --file maps)) (link_deps (glob_files maps/*.map)) From 80073bbc0c7a1c0b1992306f0adda3be1296b99e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Thu, 23 Oct 2025 18:23:09 +0200 Subject: [PATCH 06/10] Make the test work with wasm_of_ocaml --- compiler/tests-jsoo/custom.wat | 7 +++++++ compiler/tests-jsoo/dune | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 compiler/tests-jsoo/custom.wat diff --git a/compiler/tests-jsoo/custom.wat b/compiler/tests-jsoo/custom.wat new file mode 100644 index 0000000000..790b3abf36 --- /dev/null +++ b/compiler/tests-jsoo/custom.wat @@ -0,0 +1,7 @@ +;; This ensures that the referenced JavaScript values are linked in the +;; runtime with separate compilation and is optimized away in case of +;; whole program compilation. + +(global (export "_caml_js_delete") (import "js" "caml_js_delete") anyref) +(global (export "_process") (import "js" "process") anyref) +(global (export "_obj") (import "js" "obj") anyref) diff --git a/compiler/tests-jsoo/dune b/compiler/tests-jsoo/dune index 6e65848a53..66ba857404 100644 --- a/compiler/tests-jsoo/dune +++ b/compiler/tests-jsoo/dune @@ -74,7 +74,7 @@ (js_of_ocaml (javascript_files custom.js)) (wasm_of_ocaml - (javascript_files custom.js)) + (javascript_files custom.js custom.wat)) (modes js wasm)) (ocamlyacc calc_parser) From 920bb9b7015865f50131fefce56545bf6192cf49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Fri, 24 Oct 2025 13:51:22 +0200 Subject: [PATCH 07/10] Revert unnecessary changes --- compiler/lib/flow.ml | 10 +++------- compiler/lib/specialize_js.ml | 29 ----------------------------- 2 files changed, 3 insertions(+), 36 deletions(-) diff --git a/compiler/lib/flow.ml b/compiler/lib/flow.ml index 59084f0f0c..13de7ffb74 100644 --- a/compiler/lib/flow.ml +++ b/compiler/lib/flow.ml @@ -47,13 +47,9 @@ module Info = struct } let def t x = - let idx = Code.Var.idx x in - if Array.length t.info_defs <= idx - then None - else - match t.info_defs.(idx) with - | Phi _ | Param -> None - | Expr x -> Some x + match t.info_defs.(Code.Var.idx x) with + | Phi _ | Param -> None + | Expr x -> Some x let possibly_mutable t x = Code.Var.ISet.mem t.info_possibly_mutable x diff --git a/compiler/lib/specialize_js.ml b/compiler/lib/specialize_js.ml index 1b0880560c..68e8d23e35 100644 --- a/compiler/lib/specialize_js.ml +++ b/compiler/lib/specialize_js.ml @@ -293,35 +293,6 @@ let specialize_instrs ~target opt_count info l = match l with | [] -> List.rev acc | i :: r -> ( - let i = - match i with - | Let (x, Apply { f; args; exact = false }) -> ( - match Info.def info f with - | None -> i - | Some (Prim (Extern "caml_jsoo_runtime", [ name ])) -> ( - let name = - match name with - | Pc (String name) -> Some name - | Pc _ -> None - | Pv x -> ( - match Info.def info x with - | Some (Constant (String name)) -> Some name - | Some _ | None -> None) - in - match name with - | None -> i - | Some name -> ( - let name = Primitive.resolve name in - match Primitive.arity name with - | exception Not_found -> i - | n -> - if List.compare_length_with args ~len:n = 0 - then - Let (x, Prim (Extern name, List.map args ~f:(fun x -> Pv x))) - else i)) - | Some _ -> i) - | _ -> i - in (* We make bound checking explicit. Then, we can remove duplicated bound checks. Also, it appears to be more efficient to inline the array access. The bound checking function returns the array, From c0dd53ecb2e7c5172b2a8f03f29a233b429ef2a1 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 28 Oct 2025 10:57:57 +0100 Subject: [PATCH 08/10] WIP --- compiler/tests-check-prim/main.4.14.output | 1 + compiler/tests-check-prim/main.5.4.output | 1 + compiler/tests-check-prim/unix-Unix.4.14.output | 1 + compiler/tests-check-prim/unix-Unix.5.4.output | 1 + compiler/tests-check-prim/unix-Win32.4.14.output | 1 + 5 files changed, 5 insertions(+) diff --git a/compiler/tests-check-prim/main.4.14.output b/compiler/tests-check-prim/main.4.14.output index 22874e2666..accec9c711 100644 --- a/compiler/tests-check-prim/main.4.14.output +++ b/compiler/tests-check-prim/main.4.14.output @@ -14,6 +14,7 @@ caml_int64_or_native caml_int64_sub_native caml_int64_xor_native caml_int_as_pointer +caml_jsoo_runtime caml_reset_afl_instrumentation debugger diff --git a/compiler/tests-check-prim/main.5.4.output b/compiler/tests-check-prim/main.5.4.output index db911809bf..4d0f2eca1c 100644 --- a/compiler/tests-check-prim/main.5.4.output +++ b/compiler/tests-check-prim/main.5.4.output @@ -5,6 +5,7 @@ From main.bc: caml_assume_no_perform caml_continuation_use caml_int_as_pointer +caml_jsoo_runtime caml_reset_afl_instrumentation debugger diff --git a/compiler/tests-check-prim/unix-Unix.4.14.output b/compiler/tests-check-prim/unix-Unix.4.14.output index e69cd8d7c6..b841d77f03 100644 --- a/compiler/tests-check-prim/unix-Unix.4.14.output +++ b/compiler/tests-check-prim/unix-Unix.4.14.output @@ -14,6 +14,7 @@ caml_int64_or_native caml_int64_sub_native caml_int64_xor_native caml_int_as_pointer +caml_jsoo_runtime caml_reset_afl_instrumentation caml_unix_map_file_bytecode debugger diff --git a/compiler/tests-check-prim/unix-Unix.5.4.output b/compiler/tests-check-prim/unix-Unix.5.4.output index 6a1bf3dbd4..541f1981c6 100644 --- a/compiler/tests-check-prim/unix-Unix.5.4.output +++ b/compiler/tests-check-prim/unix-Unix.5.4.output @@ -5,6 +5,7 @@ From unix.bc: caml_assume_no_perform caml_continuation_use caml_int_as_pointer +caml_jsoo_runtime caml_reset_afl_instrumentation caml_unix_accept caml_unix_alarm diff --git a/compiler/tests-check-prim/unix-Win32.4.14.output b/compiler/tests-check-prim/unix-Win32.4.14.output index 947b6d951a..71554351ea 100644 --- a/compiler/tests-check-prim/unix-Win32.4.14.output +++ b/compiler/tests-check-prim/unix-Win32.4.14.output @@ -14,6 +14,7 @@ caml_int64_or_native caml_int64_sub_native caml_int64_xor_native caml_int_as_pointer +caml_jsoo_runtime caml_reset_afl_instrumentation caml_unix_map_file_bytecode debugger From 7bc56d7833d65d829b80633b844634ceed50ff42 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 28 Oct 2025 11:00:46 +0100 Subject: [PATCH 09/10] WIP --- .../tests-check-prim/unix-Win32.5.4.output | 221 ++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 compiler/tests-check-prim/unix-Win32.5.4.output diff --git a/compiler/tests-check-prim/unix-Win32.5.4.output b/compiler/tests-check-prim/unix-Win32.5.4.output new file mode 100644 index 0000000000..541f1981c6 --- /dev/null +++ b/compiler/tests-check-prim/unix-Win32.5.4.output @@ -0,0 +1,221 @@ +Missing +------- + +From unix.bc: +caml_assume_no_perform +caml_continuation_use +caml_int_as_pointer +caml_jsoo_runtime +caml_reset_afl_instrumentation +caml_unix_accept +caml_unix_alarm +caml_unix_bind +caml_unix_chown +caml_unix_chroot +caml_unix_clear_close_on_exec +caml_unix_clear_nonblock +caml_unix_connect +caml_unix_dup +caml_unix_dup2 +caml_unix_environment +caml_unix_environment_unsafe +caml_unix_execv +caml_unix_execve +caml_unix_execvp +caml_unix_execvpe +caml_unix_fchown +caml_unix_fork +caml_unix_getaddrinfo +caml_unix_getgroups +caml_unix_gethostbyaddr +caml_unix_gethostbyname +caml_unix_gethostname +caml_unix_getitimer +caml_unix_getlogin +caml_unix_getnameinfo +caml_unix_getpeername +caml_unix_getpid +caml_unix_getppid +caml_unix_getprotobyname +caml_unix_getprotobynumber +caml_unix_getservbyname +caml_unix_getservbyport +caml_unix_getsockname +caml_unix_getsockopt +caml_unix_initgroups +caml_unix_kill +caml_unix_listen +caml_unix_lockf +caml_unix_map_file_bytecode +caml_unix_mkfifo +caml_unix_nice +caml_unix_pipe +caml_unix_putenv +caml_unix_realpath +caml_unix_recv +caml_unix_recvfrom +caml_unix_select +caml_unix_send +caml_unix_sendto +caml_unix_set_close_on_exec +caml_unix_set_nonblock +caml_unix_setgid +caml_unix_setgroups +caml_unix_setitimer +caml_unix_setsid +caml_unix_setsockopt +caml_unix_setuid +caml_unix_shutdown +caml_unix_sigpending +caml_unix_sigprocmask +caml_unix_sigsuspend +caml_unix_sigwait +caml_unix_sleep +caml_unix_socket +caml_unix_socketpair +caml_unix_spawn +caml_unix_string_of_inet_addr +caml_unix_tcdrain +caml_unix_tcflow +caml_unix_tcflush +caml_unix_tcgetattr +caml_unix_tcsendbreak +caml_unix_tcsetattr +caml_unix_umask +caml_unix_wait +caml_unix_waitpid +debugger + +Unused +------- + +From +array.js: +caml_check_bound + +From +bigarray.js: +caml_ba_create_from (deprecated) +caml_ba_init + +From +bigstring.js: +caml_bigstring_blit_ba_to_ba +caml_bigstring_blit_ba_to_bytes +caml_bigstring_blit_bytes_to_ba +caml_bigstring_blit_string_to_ba +caml_bigstring_memcmp +caml_hash_mix_bigstring + +From +effect.js: +jsoo_effect_not_supported + +From +fs.js: +caml_ba_map_file +caml_ba_map_file_bytecode +caml_fs_init +jsoo_create_file +jsoo_create_file_extern + +From +graphics.js: +caml_gr_arc_aux +caml_gr_blit_image +caml_gr_clear_graph +caml_gr_close_graph +caml_gr_close_subwindow +caml_gr_create_image +caml_gr_current_x +caml_gr_current_y +caml_gr_display_mode +caml_gr_doc_of_state +caml_gr_draw_arc +caml_gr_draw_char +caml_gr_draw_image +caml_gr_draw_rect +caml_gr_draw_str +caml_gr_draw_string +caml_gr_dump_image +caml_gr_fill_arc +caml_gr_fill_poly +caml_gr_fill_rect +caml_gr_lineto +caml_gr_make_image +caml_gr_moveto +caml_gr_open_graph +caml_gr_open_subwindow +caml_gr_plot +caml_gr_point_color +caml_gr_remember_mode +caml_gr_resize_window +caml_gr_set_color +caml_gr_set_font +caml_gr_set_line_width +caml_gr_set_text_size +caml_gr_set_window_title +caml_gr_sigio_handler +caml_gr_sigio_signal +caml_gr_size_x +caml_gr_size_y +caml_gr_state +caml_gr_state_create +caml_gr_state_get +caml_gr_state_init +caml_gr_state_set +caml_gr_synchronize +caml_gr_text_size +caml_gr_wait_event +caml_gr_window_id + +From +hash.js: +caml_hash_mix_int64 + +From +ints.js: +caml_div +caml_mod + +From +jslib.js: +caml_is_js +caml_trampoline +caml_trampoline_return +caml_wrap_exception + +From +marshal.js: +caml_marshal_constants + +From +mlBytes.js: +caml_array_of_bytes (deprecated) +caml_array_of_string (deprecated) +caml_bytes_of_utf16_jsstring +caml_new_string (deprecated) +caml_string_concat +caml_to_js_string (deprecated) + +From +runtime_events.js: +caml_runtime_events_create_cursor +caml_runtime_events_free_cursor +caml_runtime_events_read_poll +caml_runtime_events_user_resolve + +From +stdlib.js: +caml_is_printable +caml_maybe_print_stats + +From +sys.js: +caml_fatal_uncaught_exception +caml_format_exception +caml_is_special_exception +caml_set_static_env +caml_sys_const_naked_pointers_checked + +From +toplevel.js: +jsoo_get_runtime_aliases +jsoo_toplevel_init_compile +jsoo_toplevel_init_reloc + +From +unix.js: +caml_strerror +caml_unix_cleanup +caml_unix_filedescr_of_fd +caml_unix_findclose +caml_unix_findfirst +caml_unix_findnext +caml_unix_startup +unix_error_message + From 57b483c2b283204c91f3929b064e96699e0b3c17 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Thu, 30 Oct 2025 09:47:00 +0100 Subject: [PATCH 10/10] WIP --- CHANGES.md | 1 + .../tests-check-prim/unix-Win32.5.4.output | 49 +++++-------------- 2 files changed, 12 insertions(+), 38 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d4ebaea628..840507ab06 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ * Compiler/wasm: make the type of some Wasm primitives more precise (#2100) * Compiler: reference unboxing (#1958) * Runtime: improved handling of NaNs (#2110) +* Lib: allow to reference values from the runtime (#2086) ## Bug fixes * Compiler: fix purity of comparison functions (again) (#2092) diff --git a/compiler/tests-check-prim/unix-Win32.5.4.output b/compiler/tests-check-prim/unix-Win32.5.4.output index 541f1981c6..886a6f2376 100644 --- a/compiler/tests-check-prim/unix-Win32.5.4.output +++ b/compiler/tests-check-prim/unix-Win32.5.4.output @@ -8,47 +8,35 @@ caml_int_as_pointer caml_jsoo_runtime caml_reset_afl_instrumentation caml_unix_accept -caml_unix_alarm caml_unix_bind -caml_unix_chown -caml_unix_chroot caml_unix_clear_close_on_exec caml_unix_clear_nonblock caml_unix_connect +caml_unix_create_process caml_unix_dup caml_unix_dup2 caml_unix_environment -caml_unix_environment_unsafe caml_unix_execv caml_unix_execve caml_unix_execvp caml_unix_execvpe -caml_unix_fchown -caml_unix_fork +caml_unix_filedescr_of_channel caml_unix_getaddrinfo -caml_unix_getgroups caml_unix_gethostbyaddr caml_unix_gethostbyname caml_unix_gethostname -caml_unix_getitimer -caml_unix_getlogin caml_unix_getnameinfo caml_unix_getpeername caml_unix_getpid -caml_unix_getppid caml_unix_getprotobyname caml_unix_getprotobynumber caml_unix_getservbyname caml_unix_getservbyport caml_unix_getsockname caml_unix_getsockopt -caml_unix_initgroups -caml_unix_kill caml_unix_listen caml_unix_lockf caml_unix_map_file_bytecode -caml_unix_mkfifo -caml_unix_nice caml_unix_pipe caml_unix_putenv caml_unix_realpath @@ -59,30 +47,14 @@ caml_unix_send caml_unix_sendto caml_unix_set_close_on_exec caml_unix_set_nonblock -caml_unix_setgid -caml_unix_setgroups -caml_unix_setitimer -caml_unix_setsid caml_unix_setsockopt -caml_unix_setuid caml_unix_shutdown -caml_unix_sigpending -caml_unix_sigprocmask -caml_unix_sigsuspend -caml_unix_sigwait caml_unix_sleep caml_unix_socket caml_unix_socketpair -caml_unix_spawn caml_unix_string_of_inet_addr -caml_unix_tcdrain -caml_unix_tcflow -caml_unix_tcflush -caml_unix_tcgetattr -caml_unix_tcsendbreak -caml_unix_tcsetattr -caml_unix_umask -caml_unix_wait +caml_unix_system +caml_unix_terminate_process caml_unix_waitpid debugger @@ -211,11 +183,12 @@ jsoo_toplevel_init_reloc From +unix.js: caml_strerror -caml_unix_cleanup -caml_unix_filedescr_of_fd -caml_unix_findclose -caml_unix_findfirst -caml_unix_findnext -caml_unix_startup +caml_unix_fchmod +caml_unix_getegid +caml_unix_geteuid +caml_unix_getgid +caml_unix_getpwnam +caml_unix_getuid +caml_unix_rewinddir unix_error_message