From 95f14119f55ed27c38f78fc0a62dc743ddf32985 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Fri, 25 Oct 2024 21:52:10 +0200 Subject: [PATCH 01/50] Compiler: typo --- compiler/lib/parse_bytecode.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/lib/parse_bytecode.ml b/compiler/lib/parse_bytecode.ml index b3fbc6c1b..b52ce3d44 100644 --- a/compiler/lib/parse_bytecode.ml +++ b/compiler/lib/parse_bytecode.ml @@ -1865,7 +1865,7 @@ and compile infos pc state (instrs : instr list) = if debug_parser () then ( - Format.printf "%a = ccal \"%s\" (" Var.print x prim; + Format.printf "%a = ccall \"%s\" (" Var.print x prim; for i = 0 to nargs - 1 do if i > 0 then Format.printf ", "; Format.printf "%a" Var.print (List.nth args i) @@ -1885,7 +1885,7 @@ and compile infos pc state (instrs : instr list) = if debug_parser () then ( - Format.printf "%a = ccal \"%s\" (" Var.print x prim; + Format.printf "%a = ccall \"%s\" (" Var.print x prim; for i = 0 to nargs - 1 do if i > 0 then Format.printf ", "; Format.printf "%a" Var.print (List.nth args i) @@ -1905,7 +1905,7 @@ and compile infos pc state (instrs : instr list) = if debug_parser () then ( - Format.printf "%a = ccal \"%s\" (" Var.print x prim; + Format.printf "%a = ccall \"%s\" (" Var.print x prim; for i = 0 to nargs - 1 do if i > 0 then Format.printf ", "; Format.printf "%a" Var.print (List.nth args i) From fea3899ef814a1ce805964a7093a7c0a8cb64a8e Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Fri, 25 Oct 2024 21:58:20 +0200 Subject: [PATCH 02/50] Compiler: remove some deadcode --- compiler/lib/parse_bytecode.ml | 72 +++++++++++----------------------- 1 file changed, 23 insertions(+), 49 deletions(-) diff --git a/compiler/lib/parse_bytecode.ml b/compiler/lib/parse_bytecode.ml index b52ce3d44..667f62c5c 100644 --- a/compiler/lib/parse_bytecode.ml +++ b/compiler/lib/parse_bytecode.ml @@ -88,8 +88,6 @@ module Debug : sig val create : include_cmis:bool -> bool -> t - val fold : t -> (Code.Addr.t -> Instruct.debug_event -> 'a -> 'a) -> 'a -> 'a - val paths : t -> units:StringSet.t -> StringSet.t end = struct open Instruct @@ -315,9 +313,6 @@ end = struct | [], [] -> () | _ -> assert false - let fold t f acc = - Int_table.fold (fun k { event; _ } acc -> f k event acc) t.events_by_pc acc - let paths t ~units = let paths = Hashtbl.fold @@ -333,46 +328,38 @@ end module Blocks : sig type t - val analyse : Debug.t -> bytecode -> t - - val add : t -> int -> t - - type u - - val finish_analysis : t -> u + val analyse : bytecode -> t - val next : u -> int -> int + val next : t -> int -> int - val is_empty : u -> bool + val is_empty : t -> bool end = struct - type t = Addr.Set.t - - type u = int array + type t = int array let add blocks pc = Addr.Set.add pc blocks - let rec scan debug blocks code pc len = + let rec scan blocks code pc len = if pc < len then match (get_instr_exn code pc).kind with - | KNullary -> scan debug blocks code (pc + 1) len - | KUnary -> scan debug blocks code (pc + 2) len - | KBinary -> scan debug blocks code (pc + 3) len - | KNullaryCall -> scan debug blocks code (pc + 1) len - | KUnaryCall -> scan debug blocks code (pc + 2) len - | KBinaryCall -> scan debug blocks code (pc + 3) len + | KNullary -> scan blocks code (pc + 1) len + | KUnary -> scan blocks code (pc + 2) len + | KBinary -> scan blocks code (pc + 3) len + | KNullaryCall -> scan blocks code (pc + 1) len + | KUnaryCall -> scan blocks code (pc + 2) len + | KBinaryCall -> scan blocks code (pc + 3) len | KJump -> let offset = gets code (pc + 1) in let blocks = Addr.Set.add (pc + offset + 1) blocks in - scan debug blocks code (pc + 2) len + scan blocks code (pc + 2) len | KCond_jump -> let offset = gets code (pc + 1) in let blocks = Addr.Set.add (pc + offset + 1) blocks in - scan debug blocks code (pc + 2) len + scan blocks code (pc + 2) len | KCmp_jump -> let offset = gets code (pc + 2) in let blocks = Addr.Set.add (pc + offset + 2) blocks in - scan debug blocks code (pc + 3) len + scan blocks code (pc + 3) len | KSwitch -> let sz = getu code (pc + 1) in let blocks = ref blocks in @@ -380,19 +367,17 @@ end = struct let offset = gets code (pc + 2 + i) in blocks := Addr.Set.add (pc + offset + 2) !blocks done; - scan debug !blocks code (pc + 2 + (sz land 0xffff) + (sz lsr 16)) len + scan !blocks code (pc + 2 + (sz land 0xffff) + (sz lsr 16)) len | KClosurerec -> let nfuncs = getu code (pc + 1) in - scan debug blocks code (pc + nfuncs + 3) len - | KClosure -> scan debug blocks code (pc + 3) len - | KStop n -> scan debug blocks code (pc + n + 1) len + scan blocks code (pc + nfuncs + 3) len + | KClosure -> scan blocks code (pc + 3) len + | KStop n -> scan blocks code (pc + n + 1) len | K_will_not_happen -> assert false else ( assert (pc = len); blocks) - let finish_analysis blocks = Array.of_list (Addr.Set.elements blocks) - (* invariant: a.(i) <= x < a.(j) *) let rec find a i j x = assert (i < j); @@ -406,17 +391,13 @@ end = struct let is_empty x = Array.length x <= 1 - let analyse debug_data code = - let debug_data = - if Debug.enabled debug_data - then debug_data - else Debug.create ~include_cmis:false false - in + let analyse code = let blocks = Addr.Set.empty in let len = String.length code / 4 in let blocks = add blocks 0 in let blocks = add blocks len in - scan debug_data blocks code 0 len + let blocks = scan blocks code 0 len in + Array.of_list (Addr.Set.elements blocks) end (* Parse constants *) @@ -806,7 +787,7 @@ let method_cache_id = ref 1 let clo_offset_3 = if new_closure_repr then 3 else 2 type compile_info = - { blocks : Blocks.u + { blocks : Blocks.t ; code : string ; limit : int ; debug : Debug.t @@ -2465,14 +2446,7 @@ type one = let parse_bytecode code globals debug_data = let state = State.initial globals in Code.Var.reset (); - let blocks = Blocks.analyse debug_data code in - let blocks = - (* Disabled. [pc] might not be an appropriate place to split blocks *) - if false && Debug.enabled debug_data - then Debug.fold debug_data (fun pc _ blocks -> Blocks.add blocks pc) blocks - else blocks - in - let blocks' = Blocks.finish_analysis blocks in + let blocks' = Blocks.analyse code in let p = if not (Blocks.is_empty blocks') then ( From 450ddbbfa43602f26274ff778b3e744709602c4f Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Sat, 26 Oct 2024 09:00:18 +0200 Subject: [PATCH 03/50] Compiler: revert 1647 --- CHANGES.md | 2 -- compiler/lib/generate.ml | 3 ++- compiler/tests-compiler/direct_calls.ml | 15 +++++++-------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index cb0a41545..0e39ba7f9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,8 +9,6 @@ * Compiler: improved global dead code elimination (#2206) * Compiler: speedup json parsing, relying on Yojson.Raw (#1640) * Compiler: Decode sourcemap mappings only when necessary (#1664) -* Compiler: make indirect call using sequence instead of using the call method - [f.call(null, args)] becomes [(0,f)(args)] * Compiler: mark [TextEncoder] as reserved * Compiler: add support for the Wasm backend in parts of the pipeline, in prevision for the merge of wasm_of_ocaml diff --git a/compiler/lib/generate.ml b/compiler/lib/generate.ml index dbf057750..7784206d6 100644 --- a/compiler/lib/generate.ml +++ b/compiler/lib/generate.ml @@ -898,7 +898,8 @@ let apply_fun_raw ctx f params exact trampolined loc = (* Make sure we are performing a regular call, not a (slower) method call *) match f with - | J.EAccess _ | J.EDot _ -> J.call (J.ESeq (int 0, f)) params loc + | J.EAccess _ | J.EDot _ -> + J.call (J.dot f (Utf8_string.of_string_exn "call")) (s_var "null" :: params) loc | _ -> J.call f params loc in let apply = diff --git a/compiler/tests-compiler/direct_calls.ml b/compiler/tests-compiler/direct_calls.ml index eac493b74..e458e8391 100644 --- a/compiler/tests-compiler/direct_calls.ml +++ b/compiler/tests-compiler/direct_calls.ml @@ -84,8 +84,8 @@ let%expect_test "direct calls without --enable effects" = //end function test3(x){ function F(symbol){function f(x){return x + 1 | 0;} return [0, f];} - var M1 = F([0]), M2 = F([0]), _b_ = (0, M2[1])(2); - return [0, (0, M1[1])(1), _b_]; + var M1 = F([0]), M2 = F([0]), _b_ = M2[1].call(null, 2); + return [0, M1[1].call(null, 1), _b_]; } //end function test4(x){ @@ -94,11 +94,10 @@ let%expect_test "direct calls without --enable effects" = return [0, f]; } var M1 = F([0]), M2 = F([0]); - (0, M1[1])(1); - return (0, M2[1])(2); + M1[1].call(null, 1); + return M2[1].call(null, 2); } - //end - |}] + //end |}] let%expect_test "direct calls with --enable effects" = let code = @@ -179,8 +178,8 @@ let%expect_test "direct calls with --enable effects" = //end function test3(x, cont){ function F(symbol){function f(x){return x + 1 | 0;} return [0, f];} - var M1 = F(), M2 = F(), _c_ = (0, M2[1])(2); - return cont([0, (0, M1[1])(1), _c_]); + var M1 = F(), M2 = F(), _c_ = M2[1].call(null, 2); + return cont([0, M1[1].call(null, 1), _c_]); } //end function test4(x, cont){ From 4e12aeaa0a77ec6eea054361ad2a2ef4ec750599 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Fri, 1 Nov 2024 22:59:05 +0100 Subject: [PATCH 04/50] Misc: upgrade sedlex --- compiler/lib/flow_lexer.ml | 4 ++-- compiler/lib/parse_js.ml | 2 +- dune-project | 2 +- js_of_ocaml-compiler.opam | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/lib/flow_lexer.ml b/compiler/lib/flow_lexer.ml index 526b71096..a3449fa32 100644 --- a/compiler/lib/flow_lexer.ml +++ b/compiler/lib/flow_lexer.ml @@ -832,9 +832,9 @@ let backquote env lexbuf = let wrap f = let f env = - let start, _ = Sedlexing.lexing_positions env.Lex_env.lex_lb in + let start = Sedlexing.lexing_position_start env.Lex_env.lex_lb in let t = f env env.Lex_env.lex_lb in - let _, stop = Sedlexing.lexing_positions env.Lex_env.lex_lb in + let stop = Sedlexing.lexing_position_curr env.Lex_env.lex_lb in t, Loc.create ~last_line:(Loc.line_end' !(env.lex_last_loc)) start stop in let rec helper comments env = diff --git a/compiler/lib/parse_js.ml b/compiler/lib/parse_js.ml index e8a4e5353..13c9c4aca 100644 --- a/compiler/lib/parse_js.ml +++ b/compiler/lib/parse_js.ml @@ -85,7 +85,7 @@ end = struct Option.iter filename ~f:(Sedlexing.set_filename l); create ?report_error l - let curr_pos lexbuf = snd (Sedlexing.lexing_positions lexbuf.l) + let curr_pos lexbuf = Sedlexing.lexing_position_curr lexbuf.l let report_errors t res = match Flow_lexer.Lex_result.errors res with diff --git a/dune-project b/dune-project index e7880e1cd..e82c37fec 100644 --- a/dune-project +++ b/dune-project @@ -24,7 +24,7 @@ (ppxlib (>= 0.15.0)) (re :with-test) (cmdliner (>= 1.1.0)) - (sedlex (>= 2.3)) + (sedlex (>= 3.3)) (qcheck :with-test) menhir menhirLib diff --git a/js_of_ocaml-compiler.opam b/js_of_ocaml-compiler.opam index d8fee92ae..0a3cf50d9 100644 --- a/js_of_ocaml-compiler.opam +++ b/js_of_ocaml-compiler.opam @@ -19,7 +19,7 @@ depends: [ "ppxlib" {>= "0.15.0"} "re" {with-test} "cmdliner" {>= "1.1.0"} - "sedlex" {>= "2.3"} + "sedlex" {>= "3.3"} "qcheck" {with-test} "menhir" "menhirLib" From d11b87f8b3540bb431d7a5ad6fad715d7b40e988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Tue, 5 Nov 2024 00:06:05 +0100 Subject: [PATCH 05/50] Misc: Move the runtime files under runtime/js (#1727) The wasm_of_ocaml runtime will be under runtime/wasm. --- biome.json | 2 +- compiler/lib-runtime-files/dune | 2 +- runtime/{ => js}/array.js | 0 runtime/{ => js}/backtrace.js | 0 runtime/{ => js}/bigarray.js | 0 runtime/{ => js}/bigstring.js | 0 runtime/{ => js}/blake2.js | 0 runtime/{ => js}/compare.js | 0 runtime/{ => js}/domain.js | 0 runtime/{ => js}/dune | 0 runtime/{ => js}/dynlink.js | 0 runtime/{ => js}/effect.js | 0 runtime/{ => js}/fail.js | 0 runtime/{ => js}/format.js | 0 runtime/{ => js}/fs.js | 0 runtime/{ => js}/fs_fake.js | 0 runtime/{ => js}/fs_node.js | 0 runtime/{ => js}/gc.js | 0 runtime/{ => js}/graphics.js | 0 runtime/{ => js}/hash.js | 0 runtime/{ => js}/ieee_754.js | 0 runtime/{ => js}/int64.js | 0 runtime/{ => js}/internalMod.js | 0 runtime/{ => js}/ints.js | 0 runtime/{ => js}/io.js | 0 runtime/{ => js}/jslib.js | 0 runtime/{ => js}/jslib_js_of_ocaml.js | 0 runtime/{ => js}/lexing.js | 0 runtime/{ => js}/marshal.js | 0 runtime/{ => js}/md5.js | 0 runtime/{ => js}/mlBytes.js | 0 runtime/{ => js}/nat.js | 0 runtime/{ => js}/obj.js | 0 runtime/{ => js}/parsing.js | 0 runtime/{ => js}/prng.js | 0 runtime/{ => js}/runtime_events.js | 0 runtime/{ => js}/stdlib.js | 0 runtime/{ => js}/stdlib_modern.js | 0 runtime/{ => js}/str.js | 0 runtime/{ => js}/sync.js | 0 runtime/{ => js}/sys.js | 0 runtime/{ => js}/toplevel.js | 0 runtime/{ => js}/unix.js | 0 runtime/{ => js}/weak.js | 0 runtime/{ => js}/zstd.js | 0 runtime/{ => js}/zstd.ts | 0 46 files changed, 2 insertions(+), 2 deletions(-) rename runtime/{ => js}/array.js (100%) rename runtime/{ => js}/backtrace.js (100%) rename runtime/{ => js}/bigarray.js (100%) rename runtime/{ => js}/bigstring.js (100%) rename runtime/{ => js}/blake2.js (100%) rename runtime/{ => js}/compare.js (100%) rename runtime/{ => js}/domain.js (100%) rename runtime/{ => js}/dune (100%) rename runtime/{ => js}/dynlink.js (100%) rename runtime/{ => js}/effect.js (100%) rename runtime/{ => js}/fail.js (100%) rename runtime/{ => js}/format.js (100%) rename runtime/{ => js}/fs.js (100%) rename runtime/{ => js}/fs_fake.js (100%) rename runtime/{ => js}/fs_node.js (100%) rename runtime/{ => js}/gc.js (100%) rename runtime/{ => js}/graphics.js (100%) rename runtime/{ => js}/hash.js (100%) rename runtime/{ => js}/ieee_754.js (100%) rename runtime/{ => js}/int64.js (100%) rename runtime/{ => js}/internalMod.js (100%) rename runtime/{ => js}/ints.js (100%) rename runtime/{ => js}/io.js (100%) rename runtime/{ => js}/jslib.js (100%) rename runtime/{ => js}/jslib_js_of_ocaml.js (100%) rename runtime/{ => js}/lexing.js (100%) rename runtime/{ => js}/marshal.js (100%) rename runtime/{ => js}/md5.js (100%) rename runtime/{ => js}/mlBytes.js (100%) rename runtime/{ => js}/nat.js (100%) rename runtime/{ => js}/obj.js (100%) rename runtime/{ => js}/parsing.js (100%) rename runtime/{ => js}/prng.js (100%) rename runtime/{ => js}/runtime_events.js (100%) rename runtime/{ => js}/stdlib.js (100%) rename runtime/{ => js}/stdlib_modern.js (100%) rename runtime/{ => js}/str.js (100%) rename runtime/{ => js}/sync.js (100%) rename runtime/{ => js}/sys.js (100%) rename runtime/{ => js}/toplevel.js (100%) rename runtime/{ => js}/unix.js (100%) rename runtime/{ => js}/weak.js (100%) rename runtime/{ => js}/zstd.js (100%) rename runtime/{ => js}/zstd.ts (100%) diff --git a/biome.json b/biome.json index 5de4567ff..9a0658559 100644 --- a/biome.json +++ b/biome.json @@ -2,7 +2,7 @@ "$schema": "https://biomejs.dev/schemas/1.9.1/schema.json", "files": { "include": ["runtime"], - "ignore": ["runtime/zstd.ts"] + "ignore": ["runtime/js/zstd.ts"] }, "formatter": { "enabled": true, diff --git a/compiler/lib-runtime-files/dune b/compiler/lib-runtime-files/dune index e9e77ae73..5742162d2 100644 --- a/compiler/lib-runtime-files/dune +++ b/compiler/lib-runtime-files/dune @@ -7,7 +7,7 @@ (target files.ml) (deps gen/gen.exe - (glob_files ../../runtime/*.js)) + (glob_files ../../runtime/js/*.js)) (action (with-stdout-to %{target} diff --git a/runtime/array.js b/runtime/js/array.js similarity index 100% rename from runtime/array.js rename to runtime/js/array.js diff --git a/runtime/backtrace.js b/runtime/js/backtrace.js similarity index 100% rename from runtime/backtrace.js rename to runtime/js/backtrace.js diff --git a/runtime/bigarray.js b/runtime/js/bigarray.js similarity index 100% rename from runtime/bigarray.js rename to runtime/js/bigarray.js diff --git a/runtime/bigstring.js b/runtime/js/bigstring.js similarity index 100% rename from runtime/bigstring.js rename to runtime/js/bigstring.js diff --git a/runtime/blake2.js b/runtime/js/blake2.js similarity index 100% rename from runtime/blake2.js rename to runtime/js/blake2.js diff --git a/runtime/compare.js b/runtime/js/compare.js similarity index 100% rename from runtime/compare.js rename to runtime/js/compare.js diff --git a/runtime/domain.js b/runtime/js/domain.js similarity index 100% rename from runtime/domain.js rename to runtime/js/domain.js diff --git a/runtime/dune b/runtime/js/dune similarity index 100% rename from runtime/dune rename to runtime/js/dune diff --git a/runtime/dynlink.js b/runtime/js/dynlink.js similarity index 100% rename from runtime/dynlink.js rename to runtime/js/dynlink.js diff --git a/runtime/effect.js b/runtime/js/effect.js similarity index 100% rename from runtime/effect.js rename to runtime/js/effect.js diff --git a/runtime/fail.js b/runtime/js/fail.js similarity index 100% rename from runtime/fail.js rename to runtime/js/fail.js diff --git a/runtime/format.js b/runtime/js/format.js similarity index 100% rename from runtime/format.js rename to runtime/js/format.js diff --git a/runtime/fs.js b/runtime/js/fs.js similarity index 100% rename from runtime/fs.js rename to runtime/js/fs.js diff --git a/runtime/fs_fake.js b/runtime/js/fs_fake.js similarity index 100% rename from runtime/fs_fake.js rename to runtime/js/fs_fake.js diff --git a/runtime/fs_node.js b/runtime/js/fs_node.js similarity index 100% rename from runtime/fs_node.js rename to runtime/js/fs_node.js diff --git a/runtime/gc.js b/runtime/js/gc.js similarity index 100% rename from runtime/gc.js rename to runtime/js/gc.js diff --git a/runtime/graphics.js b/runtime/js/graphics.js similarity index 100% rename from runtime/graphics.js rename to runtime/js/graphics.js diff --git a/runtime/hash.js b/runtime/js/hash.js similarity index 100% rename from runtime/hash.js rename to runtime/js/hash.js diff --git a/runtime/ieee_754.js b/runtime/js/ieee_754.js similarity index 100% rename from runtime/ieee_754.js rename to runtime/js/ieee_754.js diff --git a/runtime/int64.js b/runtime/js/int64.js similarity index 100% rename from runtime/int64.js rename to runtime/js/int64.js diff --git a/runtime/internalMod.js b/runtime/js/internalMod.js similarity index 100% rename from runtime/internalMod.js rename to runtime/js/internalMod.js diff --git a/runtime/ints.js b/runtime/js/ints.js similarity index 100% rename from runtime/ints.js rename to runtime/js/ints.js diff --git a/runtime/io.js b/runtime/js/io.js similarity index 100% rename from runtime/io.js rename to runtime/js/io.js diff --git a/runtime/jslib.js b/runtime/js/jslib.js similarity index 100% rename from runtime/jslib.js rename to runtime/js/jslib.js diff --git a/runtime/jslib_js_of_ocaml.js b/runtime/js/jslib_js_of_ocaml.js similarity index 100% rename from runtime/jslib_js_of_ocaml.js rename to runtime/js/jslib_js_of_ocaml.js diff --git a/runtime/lexing.js b/runtime/js/lexing.js similarity index 100% rename from runtime/lexing.js rename to runtime/js/lexing.js diff --git a/runtime/marshal.js b/runtime/js/marshal.js similarity index 100% rename from runtime/marshal.js rename to runtime/js/marshal.js diff --git a/runtime/md5.js b/runtime/js/md5.js similarity index 100% rename from runtime/md5.js rename to runtime/js/md5.js diff --git a/runtime/mlBytes.js b/runtime/js/mlBytes.js similarity index 100% rename from runtime/mlBytes.js rename to runtime/js/mlBytes.js diff --git a/runtime/nat.js b/runtime/js/nat.js similarity index 100% rename from runtime/nat.js rename to runtime/js/nat.js diff --git a/runtime/obj.js b/runtime/js/obj.js similarity index 100% rename from runtime/obj.js rename to runtime/js/obj.js diff --git a/runtime/parsing.js b/runtime/js/parsing.js similarity index 100% rename from runtime/parsing.js rename to runtime/js/parsing.js diff --git a/runtime/prng.js b/runtime/js/prng.js similarity index 100% rename from runtime/prng.js rename to runtime/js/prng.js diff --git a/runtime/runtime_events.js b/runtime/js/runtime_events.js similarity index 100% rename from runtime/runtime_events.js rename to runtime/js/runtime_events.js diff --git a/runtime/stdlib.js b/runtime/js/stdlib.js similarity index 100% rename from runtime/stdlib.js rename to runtime/js/stdlib.js diff --git a/runtime/stdlib_modern.js b/runtime/js/stdlib_modern.js similarity index 100% rename from runtime/stdlib_modern.js rename to runtime/js/stdlib_modern.js diff --git a/runtime/str.js b/runtime/js/str.js similarity index 100% rename from runtime/str.js rename to runtime/js/str.js diff --git a/runtime/sync.js b/runtime/js/sync.js similarity index 100% rename from runtime/sync.js rename to runtime/js/sync.js diff --git a/runtime/sys.js b/runtime/js/sys.js similarity index 100% rename from runtime/sys.js rename to runtime/js/sys.js diff --git a/runtime/toplevel.js b/runtime/js/toplevel.js similarity index 100% rename from runtime/toplevel.js rename to runtime/js/toplevel.js diff --git a/runtime/unix.js b/runtime/js/unix.js similarity index 100% rename from runtime/unix.js rename to runtime/js/unix.js diff --git a/runtime/weak.js b/runtime/js/weak.js similarity index 100% rename from runtime/weak.js rename to runtime/js/weak.js diff --git a/runtime/zstd.js b/runtime/js/zstd.js similarity index 100% rename from runtime/zstd.js rename to runtime/js/zstd.js diff --git a/runtime/zstd.ts b/runtime/js/zstd.ts similarity index 100% rename from runtime/zstd.ts rename to runtime/js/zstd.ts From 60526e651836eba43287c68dc6cec3ff59c77427 Mon Sep 17 00:00:00 2001 From: Sylvain Boilard Date: Wed, 6 Nov 2024 07:52:16 +0100 Subject: [PATCH 06/50] Lib: Add `detailsElement` and `toggleEvent` objects. (#1728) See: - https://html.spec.whatwg.org/multipage/interactive-elements.html#the-details-element ; - https://html.spec.whatwg.org/multipage/indices.html#event-toggle ; - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details#attributes ; - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details#events . --- CHANGES.md | 1 + lib/js_of_ocaml/dom_html.ml | 22 ++++++++++++++++++++++ lib/js_of_ocaml/dom_html.mli | 22 ++++++++++++++++++++++ lib/tyxml/tyxml_cast.ml | 6 ++++-- lib/tyxml/tyxml_cast_sigs.ml | 6 ++++-- lib/tyxml/tyxml_cast_sigs.mli | 6 ++++-- 6 files changed, 57 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 0e39ba7f9..f4c935885 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -24,6 +24,7 @@ * Runtime: allow dynlink of precompiled js with separate compilation (#1676) * Runtime: reimplement the runtime of weak and ephemeron (#1707) * Lib: Modify Typed_array API for compatibility with WebAssembly +* Lib: add details element and toggle event (#1728) * Toplevel: no longer set globals for toplevel initialization ## Bug fixes diff --git a/lib/js_of_ocaml/dom_html.ml b/lib/js_of_ocaml/dom_html.ml index a58215b44..ed556ee03 100644 --- a/lib/js_of_ocaml/dom_html.ml +++ b/lib/js_of_ocaml/dom_html.ml @@ -452,6 +452,14 @@ and clipboardEvent = object method clipboardData : dataTransfer t readonly_prop end +and toggleEvent = object + inherit event + + method newState : js_string t readonly_prop + + method oldState : js_string t readonly_prop +end + and dataTransfer = object method dropEffect : js_string t prop @@ -959,6 +967,8 @@ module Event = struct let waiting = Dom.Event.make "waiting" + let toggle = Dom.Event.make "toggle" + let make = Dom.Event.make end @@ -1372,6 +1382,16 @@ class type anchorElement = object method _type : js_string t prop end +class type detailsElement = object ('self) + inherit element + + method open_ : bool t prop + + method name : js_string t prop + + method ontoggle : ('self t, toggleEvent t) event_listener prop +end + class type imageElement = object ('self) inherit element @@ -2736,6 +2756,8 @@ module CoerceTo = struct let del e = unsafeCoerce "del" e + let details e = unsafeCoerce "details" e + let div e = unsafeCoerce "div" e let dl e = unsafeCoerce "dl" e diff --git a/lib/js_of_ocaml/dom_html.mli b/lib/js_of_ocaml/dom_html.mli index 000778d8b..5e00793cd 100644 --- a/lib/js_of_ocaml/dom_html.mli +++ b/lib/js_of_ocaml/dom_html.mli @@ -458,6 +458,14 @@ and clipboardEvent = object method clipboardData : dataTransfer t readonly_prop end +and toggleEvent = object + inherit event + + method newState : js_string t readonly_prop + + method oldState : js_string t readonly_prop +end + and dataTransfer = object method dropEffect : js_string t prop @@ -1190,6 +1198,16 @@ class type anchorElement = object method _type : js_string t prop end +class type detailsElement = object ('self) + inherit element + + method open_ : bool t prop + + method name : js_string t prop + + method ontoggle : ('self t, toggleEvent t) event_listener prop +end + class type imageElement = object ('self) inherit element @@ -2503,6 +2521,8 @@ module Event : sig val waiting : mediaEvent t typ + val toggle : toggleEvent t typ + val make : string -> 'a typ end @@ -3048,6 +3068,8 @@ module CoerceTo : sig val del : #element t -> modElement t opt + val details : #element t -> detailsElement t opt + val div : #element t -> divElement t opt val embed : #element t -> embedElement t opt diff --git a/lib/tyxml/tyxml_cast.ml b/lib/tyxml/tyxml_cast.ml index 53c21ffec..9e3cad874 100644 --- a/lib/tyxml/tyxml_cast.ml +++ b/lib/tyxml/tyxml_cast.ml @@ -79,6 +79,8 @@ end) : Tyxml_cast_sigs.TO with type 'a elt = 'a C.elt = struct let of_li elt = rebuild_node "of_li" elt + let of_details elt = rebuild_node "of_details" elt + let of_dialog elt = rebuild_node "of_dialog" elt let of_div elt = rebuild_node "of_div" elt @@ -177,8 +179,6 @@ end) : Tyxml_cast_sigs.TO with type 'a elt = 'a C.elt = struct let of_dd elt = rebuild_node "of_dd" elt - let of_details elt = rebuild_node "of_details" elt - let of_dfn elt = rebuild_node "of_dfn" elt let of_dt elt = rebuild_node "of_dt" elt @@ -311,6 +311,8 @@ end) : Tyxml_cast_sigs.OF with type 'a elt = 'a C.elt = struct let of_li elt = rebuild_node "of_li" elt + let of_details elt = rebuild_node "of_details" elt + let of_dialog elt = rebuild_node "of_dialog" elt let of_div elt = rebuild_node "of_div" elt diff --git a/lib/tyxml/tyxml_cast_sigs.ml b/lib/tyxml/tyxml_cast_sigs.ml index 08d8605ce..a6ea2b76c 100644 --- a/lib/tyxml/tyxml_cast_sigs.ml +++ b/lib/tyxml/tyxml_cast_sigs.ml @@ -71,6 +71,8 @@ module type OF = sig val of_li : Dom_html.liElement Js.t -> [> Html_types.li ] elt + val of_details : Dom_html.detailsElement Js.t -> [> Html_types.details ] elt + val of_dialog : Dom_html.dialogElement Js.t -> [> Html_types.dialog ] elt val of_div : Dom_html.divElement Js.t -> [> Html_types.div ] elt @@ -182,6 +184,8 @@ module type TO = sig val of_li : [< Html_types.li ] elt -> Dom_html.liElement Js.t + val of_details : [< Html_types.details ] elt -> Dom_html.detailsElement Js.t + val of_dialog : [< Html_types.dialog ] elt -> Dom_html.dialogElement Js.t val of_div : [< Html_types.div ] elt -> Dom_html.divElement Js.t @@ -280,8 +284,6 @@ module type TO = sig val of_dd : [> Html_types.dd ] elt -> Dom_html.element Js.t - val of_details : [> Html_types.details ] elt -> Dom_html.element Js.t - val of_dfn : [> Html_types.dfn ] elt -> Dom_html.element Js.t val of_dt : [> Html_types.dt ] elt -> Dom_html.element Js.t diff --git a/lib/tyxml/tyxml_cast_sigs.mli b/lib/tyxml/tyxml_cast_sigs.mli index 42007a2ec..a09731674 100644 --- a/lib/tyxml/tyxml_cast_sigs.mli +++ b/lib/tyxml/tyxml_cast_sigs.mli @@ -70,6 +70,8 @@ module type OF = sig val of_li : Dom_html.liElement Js.t -> [> Html_types.li ] elt + val of_details : Dom_html.detailsElement Js.t -> [> Html_types.details ] elt + val of_dialog : Dom_html.dialogElement Js.t -> [> Html_types.dialog ] elt val of_div : Dom_html.divElement Js.t -> [> Html_types.div ] elt @@ -181,6 +183,8 @@ module type TO = sig val of_li : [< Html_types.li ] elt -> Dom_html.liElement Js.t + val of_details : [< Html_types.details ] elt -> Dom_html.detailsElement Js.t + val of_dialog : [< Html_types.dialog ] elt -> Dom_html.dialogElement Js.t val of_div : [< Html_types.div ] elt -> Dom_html.divElement Js.t @@ -279,8 +283,6 @@ module type TO = sig val of_dd : [> Html_types.dd ] elt -> Dom_html.element Js.t - val of_details : [> Html_types.details ] elt -> Dom_html.element Js.t - val of_dfn : [> Html_types.dfn ] elt -> Dom_html.element Js.t val of_dt : [> Html_types.dt ] elt -> Dom_html.element Js.t From e67805e8b7696c7ba48a269c3c588d182b2a0226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Wed, 6 Nov 2024 17:29:18 +0100 Subject: [PATCH 07/50] Fix compare function (#1729) --- runtime/js/compare.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/js/compare.js b/runtime/js/compare.js index 609e2e613..315d76f90 100644 --- a/runtime/js/compare.js +++ b/runtime/js/compare.js @@ -61,7 +61,7 @@ function caml_compare_val_number_custom(num, custom, swap, total) { if (comp) { var x = swap > 0 ? comp(custom, num, total) : comp(num, custom, total); if (total && Number.isNaN(x)) return swap; // total && nan - if (Number.isNan(+x)) return +x; // nan + if (Number.isNaN(+x)) return +x; // nan if ((x | 0) !== 0) return x | 0; // !nan } return swap; From 3fa88ec44eec6ec3917d798f4fdd646ef9355c71 Mon Sep 17 00:00:00 2001 From: Ty Overby Date: Wed, 6 Nov 2024 16:53:23 -0500 Subject: [PATCH 08/50] Runtime: precompute prng lxm constants (#1730) Co-authored-by: Hugo Heuzard --- CHANGES.md | 1 + compiler/tests-check-prim/main.output | 3 --- compiler/tests-check-prim/unix-unix.output | 3 --- compiler/tests-check-prim/unix-win32.output | 3 --- runtime/js/prng.js | 21 +++++++++++++++++---- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f4c935885..4a2f5c441 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -26,6 +26,7 @@ * Lib: Modify Typed_array API for compatibility with WebAssembly * Lib: add details element and toggle event (#1728) * Toplevel: no longer set globals for toplevel initialization +* Runtime: precompute constants used in `caml_lxm_next` (#1730) ## Bug fixes * Runtime: fix parsing of unsigned integers (0u2147483648) (#1633, #1666) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index b5d4c4d6b..389673df2 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -177,9 +177,6 @@ caml_obj_is_block caml_obj_is_shared caml_obj_update_tag -From +prng.js: -caml_lxm_next - From +runtime_events.js: caml_custom_event_index caml_ml_runtime_events_pause diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index 3d6399954..b5f53629c 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -286,9 +286,6 @@ caml_obj_is_block caml_obj_is_shared caml_obj_update_tag -From +prng.js: -caml_lxm_next - From +runtime_events.js: caml_custom_event_index caml_ml_runtime_events_pause diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index 9df6df3c0..04c38da71 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -251,9 +251,6 @@ caml_obj_is_block caml_obj_is_shared caml_obj_update_tag -From +prng.js: -caml_lxm_next - From +runtime_events.js: caml_custom_event_index caml_ml_runtime_events_pause diff --git a/runtime/js/prng.js b/runtime/js/prng.js index 9bce1eafb..2596b1251 100644 --- a/runtime/js/prng.js +++ b/runtime/js/prng.js @@ -1,3 +1,15 @@ +//Provides: caml_lxm_M +//Requires: caml_int64_of_string +//Requires: caml_new_string +//Version: >= 5 +var caml_lxm_M = caml_int64_of_string(caml_new_string("0xd1342543de82ef95")); + +//Provides: caml_lxm_daba +//Requires: caml_int64_of_string +//Requires: caml_new_string +//Version: >= 5 +var caml_lxm_daba = caml_int64_of_string(caml_new_string("0xdaba0b6eb09322e3")); + //Provides: caml_lxm_next //Requires: caml_int64_shift_left //Requires: caml_int64_shift_right_unsigned @@ -7,8 +19,9 @@ //Requires: caml_int64_mul //Requires: caml_ba_get_1 //Requires: caml_ba_set_1 -//Requires: caml_int64_of_string -//Requires: caml_new_string +//Requires: caml_lxm_M +//Requires: caml_lxm_daba +//Version: >= 5 function caml_lxm_next(v) { function shift_l(x, k) { return caml_int64_shift_left(x, k); @@ -37,8 +50,8 @@ function caml_lxm_next(v) { function set(a, i, x) { return caml_ba_set_1(a, i, x); } - var M = caml_int64_of_string(caml_new_string("0xd1342543de82ef95")); - var daba = caml_int64_of_string(caml_new_string("0xdaba0b6eb09322e3")); + var M = caml_lxm_M; + var daba = caml_lxm_daba; var z, q0, q1; var st = v; var a = get(st, 0); From b553b6d23c82ceb52305ab2f373d62af2048c336 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Wed, 6 Nov 2024 23:36:45 +0100 Subject: [PATCH 09/50] Tests: small cleanup --- compiler/tests-ocaml/lib-effects/dune | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/compiler/tests-ocaml/lib-effects/dune b/compiler/tests-ocaml/lib-effects/dune index 7261b03c3..ab5ff55d4 100644 --- a/compiler/tests-ocaml/lib-effects/dune +++ b/compiler/tests-ocaml/lib-effects/dune @@ -7,12 +7,7 @@ (:standard -w -38)) (js_of_ocaml (flags - (:standard --enable effects)) - ;; separate compilation doesn't work when using - ;; features such as 'effects' or 'use-js-string' - ;; because dune doesn't know that it should compile - ;; multiple versions of the dependencies - (compilation_mode whole_program)))) + (:standard --enable effects))))) (executables (enabled_if From 55fca34f36ca1577c780fb8a0f4b6d602ae56aff Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Wed, 6 Nov 2024 23:37:18 +0100 Subject: [PATCH 10/50] Compiler: small fix --- compiler/lib/vlq64.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/lib/vlq64.ml b/compiler/lib/vlq64.ml index 22f71ce5f..3c147ec26 100644 --- a/compiler/lib/vlq64.ml +++ b/compiler/lib/vlq64.ml @@ -22,7 +22,7 @@ open! Stdlib let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" let code_rev = - let a = Array.make 255 (-1) in + let a = Array.make 256 (-1) in for i = 0 to String.length alphabet - 1 do a.(Char.code alphabet.[i]) <- i done; From 71a509c1bf7fe5f116a5a8f7f15961b39af41f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Fri, 8 Nov 2024 14:24:20 +0100 Subject: [PATCH 11/50] Misc: Typos (#1732) --- CHANGES.md | 2 +- compiler/bin-js_of_ocaml/cmd_arg.ml | 4 ++-- compiler/bin-js_of_ocaml/link.ml | 2 +- lib/js_of_ocaml/sys_js.mli | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4a2f5c441..a7da30a6a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,7 +19,7 @@ * Compiler: Emit index source_map to avoid changing mappings (#1714, #1715) * Compiler: improved source map generation (#1716) * Runtime: change Sys.os_type on windows (Cygwin -> Win32) -* Runtime: backtraces are really expensive, they need to be be explicitly +* Runtime: backtraces are really expensive, they need to be explicitly requested at compile time (--enable with-js-error) or at startup (OCAMLRUNPARAM=b=1) * Runtime: allow dynlink of precompiled js with separate compilation (#1676) * Runtime: reimplement the runtime of weak and ephemeron (#1707) diff --git a/compiler/bin-js_of_ocaml/cmd_arg.ml b/compiler/bin-js_of_ocaml/cmd_arg.ml index 58cf49053..c294be23a 100644 --- a/compiler/bin-js_of_ocaml/cmd_arg.ml +++ b/compiler/bin-js_of_ocaml/cmd_arg.ml @@ -130,7 +130,7 @@ let options = in let no_sourcemap = let doc = - "Don't generate source map. All other source map related flags will be be ignored." + "Don't generate source map. All other source map related flags will be ignored." in Arg.(value & flag & info [ "no-sourcemap"; "no-source-map" ] ~doc) in @@ -395,7 +395,7 @@ let options_runtime_only = in let no_sourcemap = let doc = - "Don't generate source map. All other source map related flags will be be ignored." + "Don't generate source map. All other source map related flags will be ignored." in Arg.(value & flag & info [ "no-sourcemap"; "no-source-map" ] ~doc) in diff --git a/compiler/bin-js_of_ocaml/link.ml b/compiler/bin-js_of_ocaml/link.ml index 521ab6f70..f48c333fe 100644 --- a/compiler/bin-js_of_ocaml/link.ml +++ b/compiler/bin-js_of_ocaml/link.ml @@ -39,7 +39,7 @@ let options = in let no_sourcemap = let doc = - "Don't generate source map. All other source map related flags will be be ignored." + "Don't generate source map. All other source map related flags will be ignored." in Arg.(value & flag & info [ "no-sourcemap"; "no-source-map" ] ~doc) in diff --git a/lib/js_of_ocaml/sys_js.mli b/lib/js_of_ocaml/sys_js.mli index 0c06137ac..02f146e52 100644 --- a/lib/js_of_ocaml/sys_js.mli +++ b/lib/js_of_ocaml/sys_js.mli @@ -54,7 +54,7 @@ val read_file : name:string -> string val create_file : name:string -> content:string -> unit (** Register a file to a Pseudo Filesystem. [create_file ~name ~content] register the file [name] with content [content] - so it can be be opened with [open_in name] *) + so it can be opened with [open_in name] *) val update_file : name:string -> content:string -> unit (** Update a file in the Pseudo Filesystem. From 9570d4a662cd73a7eedee473cbefcba9e81b7741 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 18 Nov 2024 09:53:46 +0100 Subject: [PATCH 12/50] Runtime: add caml_blake2_bytes --- runtime/js/blake2.js | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/runtime/js/blake2.js b/runtime/js/blake2.js index ca17a471b..e7661230c 100644 --- a/runtime/js/blake2.js +++ b/runtime/js/blake2.js @@ -326,7 +326,7 @@ function caml_blake2_final(ctx, hashlen) { //Provides: caml_blake2_update //Requires: blake2b //Requires: caml_uint8_array_of_string -//Version: >= 5.2 +//Version: >= 5.2, < 5.3 function caml_blake2_update(ctx, buf, ofs, len) { var input = caml_uint8_array_of_string(buf); input = input.subarray(ofs, ofs + len); @@ -334,13 +334,48 @@ function caml_blake2_update(ctx, buf, ofs, len) { return 0; } +//Provides: caml_blake2_update +//Requires: blake2b +//Requires: caml_uint8_array_of_bytes +//Version: >= 5.3 +function caml_blake2_update(ctx, buf, ofs, len) { + var input = caml_uint8_array_of_bytes(buf); + input = input.subarray(ofs, ofs + len); + blake2b.Update(ctx, input); + return 0; +} + //Provides: caml_blake2_string //Requires: caml_blake2_create //Requires: caml_blake2_update //Requires: caml_blake2_final -//Version: >= 5.2 +//Version: >= 5.2, < 5.3 function caml_blake2_string(hashlen, key, buf, ofs, len) { var ctx = caml_blake2_create(hashlen, key); caml_blake2_update(ctx, buf, ofs, len); return caml_blake2_final(ctx, hashlen); } + +//Provides: caml_blake2_string +//Requires: caml_blake2_create +//Requires: caml_blake2_update +//Requires: caml_blake2_final +//Requires: caml_bytes_of_string +//Version: >= 5.3 +function caml_blake2_string(hashlen, key, buf_str, ofs, len) { + var ctx = caml_blake2_create(hashlen, key); + var buf = caml_bytes_of_string(buf_str); + caml_blake2_update(ctx, buf, ofs, len); + return caml_blake2_final(ctx, hashlen); +} + +//Provides: caml_blake2_bytes +//Requires: caml_blake2_create +//Requires: caml_blake2_update +//Requires: caml_blake2_final +//Version: >= 5.3 +function caml_blake2_bytes(hashlen, key, buf, ofs, len) { + var ctx = caml_blake2_create(hashlen, key); + caml_blake2_update(ctx, buf, ofs, len); + return caml_blake2_final(ctx, hashlen); +} From 6d8d8651cea83e84e49c7dda71da424eb67fed8a Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 18 Nov 2024 10:07:42 +0100 Subject: [PATCH 13/50] Runtime: missing array primitives --- runtime/js/array.js | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/runtime/js/array.js b/runtime/js/array.js index e276c1e40..280abb551 100644 --- a/runtime/js/array.js +++ b/runtime/js/array.js @@ -34,6 +34,13 @@ function caml_floatarray_sub(a, i, len) { return caml_array_sub(a, i, len); } +//Provides: caml_uniform_array_sub mutable +//Requires: caml_array_sub +//Version: >= 5.3 +function caml_uniform_array_sub(a, i, len) { + return caml_array_sub(a, i, len); +} + //Provides: caml_array_append mutable function caml_array_append(a1, a2) { var l1 = a1.length, @@ -55,6 +62,13 @@ function caml_floatarray_append(a1, a2) { return caml_array_append(a1, a2); } +//Provides: caml_uniform_array_append mutable +//Requires: caml_array_append +//Version: >= 5.3 +function caml_uniform_array_append(a1, a2) { + return caml_array_append(a1, a2); +} + //Provides: caml_array_concat mutable function caml_array_concat(l) { var a = [0]; @@ -82,6 +96,13 @@ function caml_floatarray_blit(a1, i1, a2, i2, len) { return caml_array_blit(a1, i1, a2, i2, len); } +//Provides: caml_uniform_array_blit +//Requires: caml_array_blit +//Version: >= 5.3 +function caml_uniform_array_blit(a1, i1, a2, i2, len) { + return caml_array_blit(a1, i1, a2, i2, len); +} + ///////////// Pervasive //Provides: caml_array_set (mutable, const, mutable) //Requires: caml_array_bound_error @@ -113,6 +134,20 @@ function caml_floatarray_fill(array, ofs, len, v) { return caml_array_fill(array, ofs, len, v); } +//Provides: caml_floatarray_fill_unboxed +//Requires: caml_array_fill +//Version: >= 5.3 +function caml_floatarray_fill_unboxed(array, ofs, len, v) { + return caml_array_fill(array, ofs, len, v); +} + +//Provides: caml_uniform_array_fill +//Requires: caml_array_fill +//Version: >= 5.3 +function caml_uniform_array_fill(array, ofs, len, v) { + return caml_array_fill(array, ofs, len, v); +} + //Provides: caml_check_bound (mutable, const) //Requires: caml_array_bound_error function caml_check_bound(array, index) { @@ -176,3 +211,17 @@ function caml_floatarray_create(len) { function caml_floatarray_make(len, init) { return caml_array_make(len, init); } + +//Provides: caml_floatarray_make_unboxed const (const) +//Requires: caml_array_make +//Version: >= 5.3 +function caml_floatarray_make_unboxed(len, init) { + return caml_array_make(len, init); +} + +//Provides: caml_uniform_array_make const (const) +//Requires: caml_array_make +//Version: >= 5.3 +function caml_uniform_array_make(len, init) { + return caml_array_make(len, init); +} From 02a7c22e930e96311d3105e630e2ebdd9153fe2a Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 18 Nov 2024 10:07:59 +0100 Subject: [PATCH 14/50] Runtime: runtime_events primitive --- runtime/js/runtime_events.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/runtime/js/runtime_events.js b/runtime/js/runtime_events.js index 1811ec9d1..74cd39743 100644 --- a/runtime/js/runtime_events.js +++ b/runtime/js/runtime_events.js @@ -56,3 +56,9 @@ function caml_runtime_events_free_cursor(cursor) { function caml_runtime_events_read_poll(cursor, callbacks, num) { return 0; } + +//Provides: caml_ml_runtime_events_path const +//Version: >= 5.3 +function caml_ml_runtime_events_path(_unit) { + return 0; +} From 941dcd1d6bca75a75fba797a580ffe216b4f1c0f Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 18 Nov 2024 10:24:01 +0100 Subject: [PATCH 15/50] Tests: check-prim uses dynlink.js --- compiler/tests-check-prim/dune | 12 ++++++------ compiler/tests-check-prim/main.output | 10 +++++----- compiler/tests-check-prim/main.output5 | 10 +++++----- compiler/tests-check-prim/unix-unix.output | 10 +++++----- compiler/tests-check-prim/unix-unix.output5 | 10 +++++----- compiler/tests-check-prim/unix-win32.output | 10 +++++----- compiler/tests-check-prim/unix-win32.output5 | 10 +++++----- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/compiler/tests-check-prim/dune b/compiler/tests-check-prim/dune index 88cf01f81..0ceb977c0 100644 --- a/compiler/tests-check-prim/dune +++ b/compiler/tests-check-prim/dune @@ -23,7 +23,7 @@ (action (with-stdout-to %{targets} - (run %{bin:js_of_ocaml} check-runtime +toplevel.js %{dep:main.bc})))) + (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:main.bc})))) (rule (targets unix-unix.output) @@ -36,7 +36,7 @@ (action (with-stdout-to %{targets} - (run %{bin:js_of_ocaml} check-runtime +toplevel.js %{dep:unix.bc})))) + (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:unix.bc})))) (rule (targets unix-win32.output) @@ -49,7 +49,7 @@ (action (with-stdout-to %{targets} - (run %{bin:js_of_ocaml} check-runtime +toplevel.js %{dep:unix.bc})))) + (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:unix.bc})))) (rule (targets main.output5) @@ -60,7 +60,7 @@ (action (with-stdout-to %{targets} - (run %{bin:js_of_ocaml} check-runtime +toplevel.js %{dep:main.bc})))) + (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:main.bc})))) (rule (targets unix-unix.output5) @@ -73,7 +73,7 @@ (action (with-stdout-to %{targets} - (run %{bin:js_of_ocaml} check-runtime +toplevel.js %{dep:unix.bc})))) + (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:unix.bc})))) (rule (targets unix-win32.output5) @@ -86,4 +86,4 @@ (action (with-stdout-to %{targets} - (run %{bin:js_of_ocaml} check-runtime +toplevel.js %{dep:unix.bc})))) + (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:unix.bc})))) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index 389673df2..3e3e1e3f9 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -3,11 +3,6 @@ Missing From main.bc: caml_alloc_dummy_function -caml_dynlink_add_primitive -caml_dynlink_close_lib -caml_dynlink_get_current_libs -caml_dynlink_lookup_symbol -caml_dynlink_open_lib caml_int64_add_native caml_int64_and_native caml_int64_div_native @@ -58,6 +53,11 @@ caml_ml_domain_set_name caml_ml_domain_unique_token caml_recommended_domain_count +From +dynlink.js: +caml_add_debug_info +caml_register_code_fragment +caml_remove_debug_info + From +effect.js: caml_alloc_stack caml_continuation_use_and_update_handler_noexc diff --git a/compiler/tests-check-prim/main.output5 b/compiler/tests-check-prim/main.output5 index 470dc712b..fba3b828c 100644 --- a/compiler/tests-check-prim/main.output5 +++ b/compiler/tests-check-prim/main.output5 @@ -5,11 +5,6 @@ From main.bc: caml_alloc_dummy_function caml_continuation_use caml_drop_continuation -caml_dynlink_add_primitive -caml_dynlink_close_lib -caml_dynlink_get_current_libs -caml_dynlink_lookup_symbol -caml_dynlink_open_lib caml_int_as_pointer caml_reset_afl_instrumentation caml_signbit @@ -37,6 +32,11 @@ caml_hash_mix_bigstring From +domain.js: caml_ml_domain_set_name +From +dynlink.js: +caml_add_debug_info +caml_register_code_fragment +caml_remove_debug_info + From +effect.js: jsoo_effect_not_supported diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index b5f53629c..f360ffafb 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -3,11 +3,6 @@ Missing From unix.bc: caml_alloc_dummy_function -caml_dynlink_add_primitive -caml_dynlink_close_lib -caml_dynlink_get_current_libs -caml_dynlink_lookup_symbol -caml_dynlink_open_lib caml_int64_add_native caml_int64_and_native caml_int64_div_native @@ -167,6 +162,11 @@ caml_ml_domain_set_name caml_ml_domain_unique_token caml_recommended_domain_count +From +dynlink.js: +caml_add_debug_info +caml_register_code_fragment +caml_remove_debug_info + From +effect.js: caml_alloc_stack caml_continuation_use_and_update_handler_noexc diff --git a/compiler/tests-check-prim/unix-unix.output5 b/compiler/tests-check-prim/unix-unix.output5 index 3ac8083bb..047d68880 100644 --- a/compiler/tests-check-prim/unix-unix.output5 +++ b/compiler/tests-check-prim/unix-unix.output5 @@ -5,11 +5,6 @@ From unix.bc: caml_alloc_dummy_function caml_continuation_use caml_drop_continuation -caml_dynlink_add_primitive -caml_dynlink_close_lib -caml_dynlink_get_current_libs -caml_dynlink_lookup_symbol -caml_dynlink_open_lib caml_int_as_pointer caml_reset_afl_instrumentation caml_signbit @@ -148,6 +143,11 @@ caml_hash_mix_bigstring From +domain.js: caml_ml_domain_set_name +From +dynlink.js: +caml_add_debug_info +caml_register_code_fragment +caml_remove_debug_info + From +effect.js: jsoo_effect_not_supported diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index 04c38da71..791d9a627 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -3,11 +3,6 @@ Missing From unix.bc: caml_alloc_dummy_function -caml_dynlink_add_primitive -caml_dynlink_close_lib -caml_dynlink_get_current_libs -caml_dynlink_lookup_symbol -caml_dynlink_open_lib caml_int64_add_native caml_int64_and_native caml_int64_div_native @@ -132,6 +127,11 @@ caml_ml_domain_set_name caml_ml_domain_unique_token caml_recommended_domain_count +From +dynlink.js: +caml_add_debug_info +caml_register_code_fragment +caml_remove_debug_info + From +effect.js: caml_alloc_stack caml_continuation_use_and_update_handler_noexc diff --git a/compiler/tests-check-prim/unix-win32.output5 b/compiler/tests-check-prim/unix-win32.output5 index 7db584011..59898b85e 100644 --- a/compiler/tests-check-prim/unix-win32.output5 +++ b/compiler/tests-check-prim/unix-win32.output5 @@ -5,11 +5,6 @@ From unix.bc: caml_alloc_dummy_function caml_continuation_use caml_drop_continuation -caml_dynlink_add_primitive -caml_dynlink_close_lib -caml_dynlink_get_current_libs -caml_dynlink_lookup_symbol -caml_dynlink_open_lib caml_int_as_pointer caml_reset_afl_instrumentation caml_signbit @@ -114,6 +109,11 @@ caml_hash_mix_bigstring From +domain.js: caml_ml_domain_set_name +From +dynlink.js: +caml_add_debug_info +caml_register_code_fragment +caml_remove_debug_info + From +effect.js: jsoo_effect_not_supported From 147b78461ad4278a740bef635ba49f6756d6b0bc Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 18 Nov 2024 10:46:15 +0100 Subject: [PATCH 16/50] Tests: recursive value compilation --- compiler/tests-compiler/dune.inc | 15 ++++++ compiler/tests-compiler/rec.ml | 82 ++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 compiler/tests-compiler/rec.ml diff --git a/compiler/tests-compiler/dune.inc b/compiler/tests-compiler/dune.inc index b1a61b366..530342849 100644 --- a/compiler/tests-compiler/dune.inc +++ b/compiler/tests-compiler/dune.inc @@ -659,6 +659,21 @@ (preprocess (pps ppx_expect))) +(library + ;; compiler/tests-compiler/rec.ml + (name rec_15) + (enabled_if true) + (modules rec) + (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) + (inline_tests + (enabled_if true) + (deps + (file %{project_root}/compiler/bin-js_of_ocaml/js_of_ocaml.exe) + (file %{project_root}/compiler/bin-jsoo_minify/jsoo_minify.exe))) + (flags (:standard -open Jsoo_compiler_expect_tests_helper)) + (preprocess + (pps ppx_expect))) + (library ;; compiler/tests-compiler/scopes.ml (name scopes_15) diff --git a/compiler/tests-compiler/rec.ml b/compiler/tests-compiler/rec.ml new file mode 100644 index 000000000..216bd7c45 --- /dev/null +++ b/compiler/tests-compiler/rec.ml @@ -0,0 +1,82 @@ +(* Js_of_ocaml compiler + * http://www.ocsigen.org/js_of_ocaml/ + * Copyright (C) 2024 Hugo Heuzard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, with linking exception; + * either version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *) + +open Util + +let%expect_test "let rec" = + let p = + {| + let rec a x = + (* syntactic function *) + b x + and b = + (* non-syntactic function *) + let tbl : (int, int) Hashtbl.t = Hashtbl.create 17 in + fun x -> `T (tbl, c, a 0) + and c = + (* block *) + Some (d, default) + and d = + (* 'dynamic' value (not recursive *) + Array.make 5 0 + and default = + (* constant, with (spurious) use + of a recursive neighbor *) + let _ = a in + 42 + |} + in + let p = compile_and_parse p in + print_program p; + [%expect + {| + (function(globalThis){ + "use strict"; + var + runtime = globalThis.jsoo_runtime, + caml_update_dummy = runtime.caml_update_dummy; + function caml_call1(f, a0){ + return (f.l >= 0 ? f.l : f.l = f.length) === 1 + ? f(a0) + : runtime.caml_call_gen(f, [a0]); + } + function caml_call2(f, a0, a1){ + return (f.l >= 0 ? f.l : f.l = f.length) === 2 + ? f(a0, a1) + : runtime.caml_call_gen(f, [a0, a1]); + } + var + global_data = runtime.caml_get_global_data(), + Stdlib_Hashtbl = global_data.Stdlib__Hashtbl, + a = function _d_(_c_){return _d_.fun(_c_);}, + b = function _b_(_a_){return _b_.fun(_a_);}, + c = [], + d = runtime.caml_make_vect(5, 0), + default$0 = 42; + caml_update_dummy(a, function(x){return caml_call1(b, x);}); + var tbl = caml_call2(Stdlib_Hashtbl[1], 0, 17); + caml_update_dummy + (b, function(x){return [0, 84, [0, tbl, c, caml_call1(a, 0)]];}); + caml_update_dummy(c, [0, [0, d, default$0]]); + var Test = [0, a, b, c, d, default$0]; + runtime.caml_register_global(1, Test, "Test"); + return; + } + (globalThis)); + //end |}] From 46fbbcc9a474f293798e0ec2533157f0a1046ffb Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 18 Nov 2024 11:08:59 +0100 Subject: [PATCH 17/50] Tests: promote with new compilation strategy --- compiler/tests-compiler/dune.inc | 17 ++++- compiler/tests-compiler/gen-rules/gen.ml | 21 ++++--- compiler/tests-compiler/rec.ml | 3 +- compiler/tests-compiler/rec52.ml | 80 ++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 10 deletions(-) create mode 100644 compiler/tests-compiler/rec52.ml diff --git a/compiler/tests-compiler/dune.inc b/compiler/tests-compiler/dune.inc index 530342849..27e0cd65f 100644 --- a/compiler/tests-compiler/dune.inc +++ b/compiler/tests-compiler/dune.inc @@ -666,7 +666,22 @@ (modules rec) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests - (enabled_if true) + (enabled_if (< %{ocaml_version} 5.2)) + (deps + (file %{project_root}/compiler/bin-js_of_ocaml/js_of_ocaml.exe) + (file %{project_root}/compiler/bin-jsoo_minify/jsoo_minify.exe))) + (flags (:standard -open Jsoo_compiler_expect_tests_helper)) + (preprocess + (pps ppx_expect))) + +(library + ;; compiler/tests-compiler/rec52.ml + (name rec52_15) + (enabled_if true) + (modules rec52) + (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) + (inline_tests + (enabled_if (>= %{ocaml_version} 5.2)) (deps (file %{project_root}/compiler/bin-js_of_ocaml/js_of_ocaml.exe) (file %{project_root}/compiler/bin-jsoo_minify/jsoo_minify.exe))) diff --git a/compiler/tests-compiler/gen-rules/gen.ml b/compiler/tests-compiler/gen-rules/gen.ml index 7a216c040..bbfe0e092 100644 --- a/compiler/tests-compiler/gen-rules/gen.ml +++ b/compiler/tests-compiler/gen-rules/gen.ml @@ -47,6 +47,8 @@ let prefix : string = type enabled_if = | GE5 + | GE52 + | LT52 | B64 | Any @@ -58,8 +60,17 @@ let lib_enabled_if = function let test_enabled_if = function | "obj" | "lazy" -> GE5 | "gh1051" -> B64 + | "rec52" -> GE52 + | "rec" -> LT52 | _ -> Any +let enabled_if = function + | Any -> "true" + | GE5 -> "(>= %{ocaml_version} 5)" + | GE52 -> "(>= %{ocaml_version} 5.2)" + | LT52 -> "(< %{ocaml_version} 5.2)" + | B64 -> "%{arch_sixtyfour}" + let () = Array.to_list (Sys.readdir ".") |> List.filter ~f:is_implem @@ -87,12 +98,6 @@ let () = basename basename (Hashtbl.hash prefix mod 100) - (match lib_enabled_if basename with - | Any -> "true" - | GE5 -> "(>= %{ocaml_version} 5)" - | B64 -> "%{arch_sixtyfour}") + (enabled_if (lib_enabled_if basename)) basename - (match test_enabled_if basename with - | Any -> "true" - | GE5 -> "(>= %{ocaml_version} 5)" - | B64 -> "%{arch_sixtyfour}")) + (enabled_if (test_enabled_if basename))) diff --git a/compiler/tests-compiler/rec.ml b/compiler/tests-compiler/rec.ml index 216bd7c45..a5085f4ef 100644 --- a/compiler/tests-compiler/rec.ml +++ b/compiler/tests-compiler/rec.ml @@ -79,4 +79,5 @@ let%expect_test "let rec" = return; } (globalThis)); - //end |}] + //end + |}] diff --git a/compiler/tests-compiler/rec52.ml b/compiler/tests-compiler/rec52.ml new file mode 100644 index 000000000..18d766eea --- /dev/null +++ b/compiler/tests-compiler/rec52.ml @@ -0,0 +1,80 @@ +(* Js_of_ocaml compiler + * http://www.ocsigen.org/js_of_ocaml/ + * Copyright (C) 2024 Hugo Heuzard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, with linking exception; + * either version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *) + +open Util + +let%expect_test "let rec" = + let p = + {| + let rec a x = + (* syntactic function *) + b x + and b = + (* non-syntactic function *) + let tbl : (int, int) Hashtbl.t = Hashtbl.create 17 in + fun x -> `T (tbl, c, a 0) + and c = + (* block *) + Some (d, default) + and d = + (* 'dynamic' value (not recursive *) + Array.make 5 0 + and default = + (* constant, with (spurious) use + of a recursive neighbor *) + let _ = a in + 42 + |} + in + let p = compile_and_parse p in + print_program p; + [%expect + {| + (function(globalThis){ + "use strict"; + var + runtime = globalThis.jsoo_runtime, + caml_update_dummy = runtime.caml_update_dummy; + function caml_call2(f, a0, a1){ + return (f.l >= 0 ? f.l : f.l = f.length) === 2 + ? f(a0, a1) + : runtime.caml_call_gen(f, [a0, a1]); + } + var + global_data = runtime.caml_get_global_data(), + Stdlib_Hashtbl = global_data.Stdlib__Hashtbl, + letrec_function_context = [], + c = [], + d = runtime.caml_make_vect(5, 0), + default$0 = 42; + function a(x){return b(x);} + function b(x){ + var _a_ = b(0); + return [0, 84, [0, letrec_function_context[1], c, _a_]]; + } + var tbl = caml_call2(Stdlib_Hashtbl[1], 0, 17); + caml_update_dummy(letrec_function_context, [0, tbl]); + caml_update_dummy(c, [0, [0, d, default$0]]); + var Test = [0, a, b, c, d, default$0]; + runtime.caml_register_global(1, Test, "Test"); + return; + } + (globalThis)); + //end + |}] From 1ded1bc121e4fd2361545439258f58df4ed246ce Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 18 Nov 2024 11:18:30 +0100 Subject: [PATCH 18/50] Runtime: add caml_signbit --- compiler/tests-check-prim/main.output | 1 - compiler/tests-check-prim/main.output5 | 1 - compiler/tests-check-prim/unix-unix.output | 1 - compiler/tests-check-prim/unix-unix.output5 | 1 - compiler/tests-check-prim/unix-win32.output | 1 - compiler/tests-check-prim/unix-win32.output5 | 1 - runtime/js/ieee_754.js | 1 + 7 files changed, 1 insertion(+), 6 deletions(-) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index 3e3e1e3f9..08da34b1b 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -14,7 +14,6 @@ caml_int64_sub_native caml_int64_xor_native caml_int_as_pointer caml_reset_afl_instrumentation -caml_signbit debugger is_digit_normalized diff --git a/compiler/tests-check-prim/main.output5 b/compiler/tests-check-prim/main.output5 index fba3b828c..039d70e30 100644 --- a/compiler/tests-check-prim/main.output5 +++ b/compiler/tests-check-prim/main.output5 @@ -7,7 +7,6 @@ caml_continuation_use caml_drop_continuation caml_int_as_pointer caml_reset_afl_instrumentation -caml_signbit debugger is_digit_normalized diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index f360ffafb..0ad864c14 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -14,7 +14,6 @@ caml_int64_sub_native caml_int64_xor_native caml_int_as_pointer caml_reset_afl_instrumentation -caml_signbit caml_unix_map_file_bytecode debugger is_digit_normalized diff --git a/compiler/tests-check-prim/unix-unix.output5 b/compiler/tests-check-prim/unix-unix.output5 index 047d68880..6241bc6a4 100644 --- a/compiler/tests-check-prim/unix-unix.output5 +++ b/compiler/tests-check-prim/unix-unix.output5 @@ -7,7 +7,6 @@ caml_continuation_use caml_drop_continuation caml_int_as_pointer caml_reset_afl_instrumentation -caml_signbit caml_unix_accept caml_unix_access caml_unix_alarm diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index 791d9a627..25545295d 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -14,7 +14,6 @@ caml_int64_sub_native caml_int64_xor_native caml_int_as_pointer caml_reset_afl_instrumentation -caml_signbit caml_unix_map_file_bytecode debugger is_digit_normalized diff --git a/compiler/tests-check-prim/unix-win32.output5 b/compiler/tests-check-prim/unix-win32.output5 index 59898b85e..6187fe492 100644 --- a/compiler/tests-check-prim/unix-win32.output5 +++ b/compiler/tests-check-prim/unix-win32.output5 @@ -7,7 +7,6 @@ caml_continuation_use caml_drop_continuation caml_int_as_pointer caml_reset_afl_instrumentation -caml_signbit caml_unix_accept caml_unix_access caml_unix_bind diff --git a/runtime/js/ieee_754.js b/runtime/js/ieee_754.js index aa657f8c5..96491ec15 100644 --- a/runtime/js/ieee_754.js +++ b/runtime/js/ieee_754.js @@ -281,6 +281,7 @@ function caml_copysign_float(x, y) { } //Provides: caml_signbit_float const +//Alias: caml_signbit function caml_signbit_float(x) { if (x === 0) x = 1 / x; return x < 0 ? 1 : 0; From a1c6cc9786a6146959ffda87d4103060cfef8520 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 18 Nov 2024 11:28:13 +0100 Subject: [PATCH 19/50] Runtime: add is_digit_normalized --- compiler/tests-check-prim/main.output | 1 - compiler/tests-check-prim/main.output5 | 1 - compiler/tests-check-prim/unix-unix.output | 1 - compiler/tests-check-prim/unix-unix.output5 | 1 - compiler/tests-check-prim/unix-win32.output | 1 - compiler/tests-check-prim/unix-win32.output5 | 1 - runtime/js/nat.js | 5 +++++ 7 files changed, 5 insertions(+), 6 deletions(-) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index 08da34b1b..e89c17d2b 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -15,7 +15,6 @@ caml_int64_xor_native caml_int_as_pointer caml_reset_afl_instrumentation debugger -is_digit_normalized Unused ------- diff --git a/compiler/tests-check-prim/main.output5 b/compiler/tests-check-prim/main.output5 index 039d70e30..5508398b5 100644 --- a/compiler/tests-check-prim/main.output5 +++ b/compiler/tests-check-prim/main.output5 @@ -8,7 +8,6 @@ caml_drop_continuation caml_int_as_pointer caml_reset_afl_instrumentation debugger -is_digit_normalized Unused ------- diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index 0ad864c14..d214af919 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -16,7 +16,6 @@ caml_int_as_pointer caml_reset_afl_instrumentation caml_unix_map_file_bytecode debugger -is_digit_normalized unix_accept unix_access unix_alarm diff --git a/compiler/tests-check-prim/unix-unix.output5 b/compiler/tests-check-prim/unix-unix.output5 index 6241bc6a4..0c8f1ef23 100644 --- a/compiler/tests-check-prim/unix-unix.output5 +++ b/compiler/tests-check-prim/unix-unix.output5 @@ -119,7 +119,6 @@ caml_unix_waitpid caml_unix_write caml_unix_write_bigarray debugger -is_digit_normalized Unused ------- diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index 25545295d..b8be6abe4 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -16,7 +16,6 @@ caml_int_as_pointer caml_reset_afl_instrumentation caml_unix_map_file_bytecode debugger -is_digit_normalized unix_accept unix_access unix_bind diff --git a/compiler/tests-check-prim/unix-win32.output5 b/compiler/tests-check-prim/unix-win32.output5 index 6187fe492..a546ef866 100644 --- a/compiler/tests-check-prim/unix-win32.output5 +++ b/compiler/tests-check-prim/unix-win32.output5 @@ -85,7 +85,6 @@ caml_unix_waitpid caml_unix_write caml_unix_write_bigarray debugger -is_digit_normalized Unused ------- diff --git a/runtime/js/nat.js b/runtime/js/nat.js index 0af2a0689..5ce9d1455 100644 --- a/runtime/js/nat.js +++ b/runtime/js/nat.js @@ -143,6 +143,11 @@ function is_digit_zero(nat, ofs) { return 0; } +//Provides: is_digit_normalized +function is_digit_normalized(nat, ofs) { + return 1; +} + //Provides: is_digit_odd function is_digit_odd(nat, ofs) { if (nat.data[ofs] & 1) return 1; From 214352415e1edac4e38ec09e4f23ddb473ed6eb0 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 18 Nov 2024 12:00:19 +0100 Subject: [PATCH 20/50] Runtime: adjust runtime for 5.1 --- runtime/js/domain.js | 1 + runtime/js/gc.js | 1 + runtime/js/io.js | 2 ++ runtime/js/runtime_events.js | 24 +++++++++++++++++++++--- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/runtime/js/domain.js b/runtime/js/domain.js index d441b2d0d..6d79fa38b 100644 --- a/runtime/js/domain.js +++ b/runtime/js/domain.js @@ -51,6 +51,7 @@ function caml_atomic_exchange(ref, v) { } //Provides: caml_atomic_make_contended +//Version: >= 5.2 function caml_atomic_make_contended(a) { return [0, a]; } diff --git a/runtime/js/gc.js b/runtime/js/gc.js index b531156f5..d226af438 100644 --- a/runtime/js/gc.js +++ b/runtime/js/gc.js @@ -92,6 +92,7 @@ function caml_memprof_stop(unit) { } //Provides: caml_memprof_discard +//Version: >= 5.2 function caml_memprof_discard(t) { return 0; } diff --git a/runtime/js/io.js b/runtime/js/io.js index 35182f876..f1c6c4cdc 100644 --- a/runtime/js/io.js +++ b/runtime/js/io.js @@ -338,6 +338,7 @@ function caml_ml_input(chanid, b, i, l) { //Provides: caml_ml_input_bigarray //Requires: caml_ml_input_block //Requires: caml_ba_to_typed_array +//Version: >= 5.2 function caml_ml_input_bigarray(chanid, b, i, l) { var ba = caml_ba_to_typed_array(b); return caml_ml_input_block(chanid, ba, i, l); @@ -584,6 +585,7 @@ function caml_ml_output_bytes(chanid, buffer, offset, len) { //Provides: caml_ml_output_bigarray //Requires: caml_ba_to_typed_array, caml_ml_output_ta +//Version: >= 5.2 function caml_ml_output_bigarray(chanid, buffer, offset, len) { var buffer = caml_ba_to_typed_array(buffer); return caml_ml_output_ta(chanid, buffer, offset, len); diff --git a/runtime/js/runtime_events.js b/runtime/js/runtime_events.js index 74cd39743..3b37775c3 100644 --- a/runtime/js/runtime_events.js +++ b/runtime/js/runtime_events.js @@ -19,25 +19,43 @@ function caml_runtime_events_user_resolve() { } //Provides: caml_ml_runtime_events_start -//Alias: caml_runtime_events_start +//Version: >= 5.2 function caml_ml_runtime_events_start() { return 0; } +//Provides: caml_runtime_events_start +//Version: < 5.2 +function caml_runtime_events_start() { + return 0; +} + //Provides: caml_ml_runtime_events_pause -//Alias: caml_runtime_events_pause +//Version: >= 5.2 function caml_ml_runtime_events_pause() { return 0; } +//Provides: caml_runtime_events_pause +//Version: < 5.2 +function caml_runtime_events_pause() { + return 0; +} + //Provides: caml_ml_runtime_events_are_active //Version: >= 5.2 function caml_ml_runtime_events_are_active() { return 0; } +//Provides: caml_runtime_events_resume +//Version: < 5.2 +function caml_runtime_events_resume() { + return 0; +} + //Provides: caml_ml_runtime_events_resume -//Alias: caml_runtime_events_resume +//Version: >= 5.2 function caml_ml_runtime_events_resume() { return 0; } From b7903e846e3f3c9243ac70ca7704480a60190eb6 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 18 Nov 2024 12:02:48 +0100 Subject: [PATCH 21/50] Runtime: adjust runtime for 5.0 --- runtime/js/runtime_events.js | 3 +++ runtime/js/sys.js | 1 + 2 files changed, 4 insertions(+) diff --git a/runtime/js/runtime_events.js b/runtime/js/runtime_events.js index 3b37775c3..62b3cae0d 100644 --- a/runtime/js/runtime_events.js +++ b/runtime/js/runtime_events.js @@ -1,14 +1,17 @@ //Provides: caml_custom_event_index +//Version: >= 5.1 var caml_custom_event_index = 0; //Provides: caml_runtime_events_user_register //Requires: caml_custom_event_index +//Version: >= 5.1 function caml_runtime_events_user_register(event_name, event_tag, event_type) { caml_custom_event_index += 1; return [0, caml_custom_event_index, event_name, event_type, event_tag]; } //Provides: caml_runtime_events_user_write +//Version: >= 5.1 function caml_runtime_events_user_write(event, event_content) { return 0; } diff --git a/runtime/js/sys.js b/runtime/js/sys.js index 466ad111e..448292bd5 100644 --- a/runtime/js/sys.js +++ b/runtime/js/sys.js @@ -365,6 +365,7 @@ function caml_xdg_defaults(_unit) { //Provides: caml_sys_is_regular_file //Requires: resolve_fs_device +//Version: >= 5.1 function caml_sys_is_regular_file(name) { var root = resolve_fs_device(name); return root.device.isFile(root.rest); From c9b00c0f65f9f5a7dd86c458c7621ae3516dca86 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 18 Nov 2024 12:05:47 +0100 Subject: [PATCH 22/50] Runtime: adjust runtime for 4.14 --- compiler/tests-check-prim/dune | 42 ++++++++++++++++++--- compiler/tests-check-prim/main.output | 17 --------- compiler/tests-check-prim/unix-unix.output | 17 --------- compiler/tests-check-prim/unix-win32.output | 16 -------- runtime/js/runtime_events.js | 10 +++-- 5 files changed, 43 insertions(+), 59 deletions(-) diff --git a/compiler/tests-check-prim/dune b/compiler/tests-check-prim/dune index 0ceb977c0..6c506b6b0 100644 --- a/compiler/tests-check-prim/dune +++ b/compiler/tests-check-prim/dune @@ -23,7 +23,12 @@ (action (with-stdout-to %{targets} - (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:main.bc})))) + (run + %{bin:js_of_ocaml} + check-runtime + +dynlink.js + +toplevel.js + %{dep:main.bc})))) (rule (targets unix-unix.output) @@ -36,7 +41,12 @@ (action (with-stdout-to %{targets} - (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:unix.bc})))) + (run + %{bin:js_of_ocaml} + check-runtime + +dynlink.js + +toplevel.js + %{dep:unix.bc})))) (rule (targets unix-win32.output) @@ -49,7 +59,12 @@ (action (with-stdout-to %{targets} - (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:unix.bc})))) + (run + %{bin:js_of_ocaml} + check-runtime + +dynlink.js + +toplevel.js + %{dep:unix.bc})))) (rule (targets main.output5) @@ -60,7 +75,12 @@ (action (with-stdout-to %{targets} - (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:main.bc})))) + (run + %{bin:js_of_ocaml} + check-runtime + +dynlink.js + +toplevel.js + %{dep:main.bc})))) (rule (targets unix-unix.output5) @@ -73,7 +93,12 @@ (action (with-stdout-to %{targets} - (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:unix.bc})))) + (run + %{bin:js_of_ocaml} + check-runtime + +dynlink.js + +toplevel.js + %{dep:unix.bc})))) (rule (targets unix-win32.output5) @@ -86,4 +111,9 @@ (action (with-stdout-to %{targets} - (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:unix.bc})))) + (run + %{bin:js_of_ocaml} + check-runtime + +dynlink.js + +toplevel.js + %{dep:unix.bc})))) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index e89c17d2b..52e2ae1de 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -39,7 +39,6 @@ caml_atomic_cas caml_atomic_exchange caml_atomic_fetch_add caml_atomic_load -caml_atomic_make_contended caml_domain_dls caml_domain_dls_get caml_domain_dls_set @@ -75,7 +74,6 @@ jsoo_create_file jsoo_create_file_extern From +gc.js: -caml_memprof_discard caml_memprof_set From +graphics.js: @@ -136,8 +134,6 @@ caml_mod From +io.js: caml_input_value_to_outside_heap -caml_ml_input_bigarray -caml_ml_output_bigarray From +jslib.js: caml_is_js @@ -175,18 +171,6 @@ caml_obj_is_block caml_obj_is_shared caml_obj_update_tag -From +runtime_events.js: -caml_custom_event_index -caml_ml_runtime_events_pause -caml_ml_runtime_events_resume -caml_ml_runtime_events_start -caml_runtime_events_create_cursor -caml_runtime_events_free_cursor -caml_runtime_events_read_poll -caml_runtime_events_user_register -caml_runtime_events_user_resolve -caml_runtime_events_user_write - From +stdlib.js: caml_build_symbols caml_is_printable @@ -218,7 +202,6 @@ caml_register_channel_for_spacetime caml_set_static_env caml_spacetime_enabled caml_spacetime_only_works_for_native_code -caml_sys_is_regular_file From +toplevel.js: caml_dynlink_get_bytecode_sections diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index d214af919..b50df6961 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -148,7 +148,6 @@ caml_atomic_cas caml_atomic_exchange caml_atomic_fetch_add caml_atomic_load -caml_atomic_make_contended caml_domain_dls caml_domain_dls_get caml_domain_dls_set @@ -184,7 +183,6 @@ jsoo_create_file jsoo_create_file_extern From +gc.js: -caml_memprof_discard caml_memprof_set From +graphics.js: @@ -245,8 +243,6 @@ caml_mod From +io.js: caml_input_value_to_outside_heap -caml_ml_input_bigarray -caml_ml_output_bigarray From +jslib.js: caml_is_js @@ -284,18 +280,6 @@ caml_obj_is_block caml_obj_is_shared caml_obj_update_tag -From +runtime_events.js: -caml_custom_event_index -caml_ml_runtime_events_pause -caml_ml_runtime_events_resume -caml_ml_runtime_events_start -caml_runtime_events_create_cursor -caml_runtime_events_free_cursor -caml_runtime_events_read_poll -caml_runtime_events_user_register -caml_runtime_events_user_resolve -caml_runtime_events_user_write - From +stdlib.js: caml_build_symbols caml_is_printable @@ -327,7 +311,6 @@ caml_register_channel_for_spacetime caml_set_static_env caml_spacetime_enabled caml_spacetime_only_works_for_native_code -caml_sys_is_regular_file From +toplevel.js: caml_dynlink_get_bytecode_sections diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index b8be6abe4..ad9aff052 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -149,7 +149,6 @@ jsoo_create_file jsoo_create_file_extern From +gc.js: -caml_memprof_discard caml_memprof_set From +graphics.js: @@ -210,8 +209,6 @@ caml_mod From +io.js: caml_input_value_to_outside_heap -caml_ml_input_bigarray -caml_ml_output_bigarray From +jslib.js: caml_is_js @@ -249,18 +246,6 @@ caml_obj_is_block caml_obj_is_shared caml_obj_update_tag -From +runtime_events.js: -caml_custom_event_index -caml_ml_runtime_events_pause -caml_ml_runtime_events_resume -caml_ml_runtime_events_start -caml_runtime_events_create_cursor -caml_runtime_events_free_cursor -caml_runtime_events_read_poll -caml_runtime_events_user_register -caml_runtime_events_user_resolve -caml_runtime_events_user_write - From +stdlib.js: caml_build_symbols caml_is_printable @@ -292,7 +277,6 @@ caml_register_channel_for_spacetime caml_set_static_env caml_spacetime_enabled caml_spacetime_only_works_for_native_code -caml_sys_is_regular_file From +toplevel.js: caml_dynlink_get_bytecode_sections diff --git a/runtime/js/runtime_events.js b/runtime/js/runtime_events.js index 62b3cae0d..d52a274f0 100644 --- a/runtime/js/runtime_events.js +++ b/runtime/js/runtime_events.js @@ -17,6 +17,7 @@ function caml_runtime_events_user_write(event, event_content) { } //Provides: caml_runtime_events_user_resolve +//Version: >= 5.0 function caml_runtime_events_user_resolve() { return 0; } @@ -28,7 +29,7 @@ function caml_ml_runtime_events_start() { } //Provides: caml_runtime_events_start -//Version: < 5.2 +//Version: >= 5.0, < 5.2 function caml_runtime_events_start() { return 0; } @@ -40,7 +41,7 @@ function caml_ml_runtime_events_pause() { } //Provides: caml_runtime_events_pause -//Version: < 5.2 +//Version: >= 5.0, < 5.2 function caml_runtime_events_pause() { return 0; } @@ -52,7 +53,7 @@ function caml_ml_runtime_events_are_active() { } //Provides: caml_runtime_events_resume -//Version: < 5.2 +//Version: >=5.0, < 5.2 function caml_runtime_events_resume() { return 0; } @@ -64,16 +65,19 @@ function caml_ml_runtime_events_resume() { } //Provides: caml_runtime_events_create_cursor +//Version: >= 5.0 function caml_runtime_events_create_cursor(target) { return {}; } //Provides: caml_runtime_events_free_cursor +//Version: >= 5.0 function caml_runtime_events_free_cursor(cursor) { return 0; } //Provides: caml_runtime_events_read_poll +//Version: >= 5.0 function caml_runtime_events_read_poll(cursor, callbacks, num) { return 0; } From d5f2f628a678fda522b5bf3ad9f812389851fea1 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 18 Nov 2024 15:50:41 +0100 Subject: [PATCH 23/50] Runtime: adjust domain.js --- compiler/tests-check-prim/main.output | 16 ---------------- compiler/tests-check-prim/main.output5 | 3 --- compiler/tests-check-prim/unix-unix.output | 16 ---------------- compiler/tests-check-prim/unix-unix.output5 | 3 --- compiler/tests-check-prim/unix-win32.output | 17 ----------------- compiler/tests-check-prim/unix-win32.output5 | 3 --- runtime/js/domain.js | 20 +++++++++++++------- 7 files changed, 13 insertions(+), 65 deletions(-) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index 52e2ae1de..9dc29eed9 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -34,22 +34,6 @@ caml_bigstring_blit_string_to_ba caml_bigstring_memcmp caml_hash_mix_bigstring -From +domain.js: -caml_atomic_cas -caml_atomic_exchange -caml_atomic_fetch_add -caml_atomic_load -caml_domain_dls -caml_domain_dls_get -caml_domain_dls_set -caml_domain_id -caml_domain_spawn -caml_ml_domain_cpu_relax -caml_ml_domain_id -caml_ml_domain_set_name -caml_ml_domain_unique_token -caml_recommended_domain_count - From +dynlink.js: caml_add_debug_info caml_register_code_fragment diff --git a/compiler/tests-check-prim/main.output5 b/compiler/tests-check-prim/main.output5 index 5508398b5..3820c1272 100644 --- a/compiler/tests-check-prim/main.output5 +++ b/compiler/tests-check-prim/main.output5 @@ -27,9 +27,6 @@ caml_bigstring_blit_string_to_ba caml_bigstring_memcmp caml_hash_mix_bigstring -From +domain.js: -caml_ml_domain_set_name - From +dynlink.js: caml_add_debug_info caml_register_code_fragment diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index b50df6961..a647b67cf 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -143,22 +143,6 @@ caml_bigstring_blit_string_to_ba caml_bigstring_memcmp caml_hash_mix_bigstring -From +domain.js: -caml_atomic_cas -caml_atomic_exchange -caml_atomic_fetch_add -caml_atomic_load -caml_domain_dls -caml_domain_dls_get -caml_domain_dls_set -caml_domain_id -caml_domain_spawn -caml_ml_domain_cpu_relax -caml_ml_domain_id -caml_ml_domain_set_name -caml_ml_domain_unique_token -caml_recommended_domain_count - From +dynlink.js: caml_add_debug_info caml_register_code_fragment diff --git a/compiler/tests-check-prim/unix-unix.output5 b/compiler/tests-check-prim/unix-unix.output5 index 0c8f1ef23..e0b77c8df 100644 --- a/compiler/tests-check-prim/unix-unix.output5 +++ b/compiler/tests-check-prim/unix-unix.output5 @@ -138,9 +138,6 @@ caml_bigstring_blit_string_to_ba caml_bigstring_memcmp caml_hash_mix_bigstring -From +domain.js: -caml_ml_domain_set_name - From +dynlink.js: caml_add_debug_info caml_register_code_fragment diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index ad9aff052..bad80e88a 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -108,23 +108,6 @@ caml_bigstring_blit_string_to_ba caml_bigstring_memcmp caml_hash_mix_bigstring -From +domain.js: -caml_atomic_cas -caml_atomic_exchange -caml_atomic_fetch_add -caml_atomic_load -caml_atomic_make_contended -caml_domain_dls -caml_domain_dls_get -caml_domain_dls_set -caml_domain_id -caml_domain_spawn -caml_ml_domain_cpu_relax -caml_ml_domain_id -caml_ml_domain_set_name -caml_ml_domain_unique_token -caml_recommended_domain_count - From +dynlink.js: caml_add_debug_info caml_register_code_fragment diff --git a/compiler/tests-check-prim/unix-win32.output5 b/compiler/tests-check-prim/unix-win32.output5 index a546ef866..a40536491 100644 --- a/compiler/tests-check-prim/unix-win32.output5 +++ b/compiler/tests-check-prim/unix-win32.output5 @@ -104,9 +104,6 @@ caml_bigstring_blit_string_to_ba caml_bigstring_memcmp caml_hash_mix_bigstring -From +domain.js: -caml_ml_domain_set_name - From +dynlink.js: caml_add_debug_info caml_register_code_fragment diff --git a/runtime/js/domain.js b/runtime/js/domain.js index 6d79fa38b..e2808c306 100644 --- a/runtime/js/domain.js +++ b/runtime/js/domain.js @@ -1,8 +1,10 @@ //Provides: caml_domain_dls +//Version: >= 5 var caml_domain_dls = [0]; //Provides: caml_domain_dls_set //Requires: caml_domain_dls +//Version: >= 5 function caml_domain_dls_set(a) { caml_domain_dls = a; } @@ -18,16 +20,19 @@ function caml_domain_dls_compare_and_set(old, n) { //Provides: caml_domain_dls_get //Requires: caml_domain_dls +//Version: >= 5 function caml_domain_dls_get(unit) { return caml_domain_dls; } //Provides: caml_atomic_load +//Version: >= 5 function caml_atomic_load(ref) { return ref[1]; } //Provides: caml_atomic_cas +//Version: >= 5 function caml_atomic_cas(ref, o, n) { if (ref[1] === o) { ref[1] = n; @@ -37,6 +42,7 @@ function caml_atomic_cas(ref, o, n) { } //Provides: caml_atomic_fetch_add +//Version: >= 5 function caml_atomic_fetch_add(ref, i) { var old = ref[1]; ref[1] += i; @@ -44,6 +50,7 @@ function caml_atomic_fetch_add(ref, i) { } //Provides: caml_atomic_exchange +//Version: >= 5 function caml_atomic_exchange(ref, v) { var r = ref[1]; ref[1] = v; @@ -57,18 +64,14 @@ function caml_atomic_make_contended(a) { } //Provides: caml_ml_domain_unique_token -//Version: < 5.2 +//Version: >= 5.0, < 5.2 var caml_ml_domain_unique_token_ = [0]; function caml_ml_domain_unique_token(unit) { return caml_ml_domain_unique_token_; } -//Provides: caml_ml_domain_set_name -function caml_ml_domain_set_name(_name) { - return 0; -} - //Provides: caml_recommended_domain_count +//Version: >= 5 function caml_recommended_domain_count(unit) { return 1; } @@ -81,6 +84,7 @@ function caml_ml_domain_index(unit) { } //Provides: caml_domain_id +//Version: >= 5 var caml_domain_id = 0; //Provides: caml_domain_spawn @@ -105,7 +109,7 @@ function caml_domain_spawn(f, term_sync) { //Requires: caml_ml_mutex_unlock //Requires: caml_domain_id //Requires: caml_callback -//Version: < 5.2 +//Version: >= 5.0, < 5.2 var caml_domain_latest_idx = 1; function caml_domain_spawn(f, mutex) { var id = caml_domain_latest_idx++; @@ -119,11 +123,13 @@ function caml_domain_spawn(f, mutex) { //Provides: caml_ml_domain_id //Requires: caml_domain_id +//Version: >= 5.0 function caml_ml_domain_id(unit) { return caml_domain_id; } //Provides: caml_ml_domain_cpu_relax +//Version: >= 5 function caml_ml_domain_cpu_relax(unit) { return 0; } From be27f2f10f341ed6be067cc2bd96d7de16aad846 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 18 Nov 2024 21:59:00 +0100 Subject: [PATCH 24/50] Runtime: adjust spacetime prims --- compiler/tests-check-prim/main.output | 3 --- compiler/tests-check-prim/main.output5 | 3 --- compiler/tests-check-prim/unix-unix.output | 3 --- compiler/tests-check-prim/unix-unix.output5 | 3 --- compiler/tests-check-prim/unix-win32.output | 3 --- compiler/tests-check-prim/unix-win32.output5 | 3 --- runtime/js/sys.js | 3 +++ 7 files changed, 3 insertions(+), 18 deletions(-) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index 9dc29eed9..f2803fd94 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -182,10 +182,7 @@ From +sys.js: caml_fatal_uncaught_exception caml_format_exception caml_is_special_exception -caml_register_channel_for_spacetime caml_set_static_env -caml_spacetime_enabled -caml_spacetime_only_works_for_native_code From +toplevel.js: caml_dynlink_get_bytecode_sections diff --git a/compiler/tests-check-prim/main.output5 b/compiler/tests-check-prim/main.output5 index 3820c1272..794cf0dc3 100644 --- a/compiler/tests-check-prim/main.output5 +++ b/compiler/tests-check-prim/main.output5 @@ -160,10 +160,7 @@ From +sys.js: caml_fatal_uncaught_exception caml_format_exception caml_is_special_exception -caml_register_channel_for_spacetime caml_set_static_env -caml_spacetime_enabled -caml_spacetime_only_works_for_native_code caml_sys_const_naked_pointers_checked From +toplevel.js: diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index a647b67cf..74f2272cf 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -291,10 +291,7 @@ From +sys.js: caml_fatal_uncaught_exception caml_format_exception caml_is_special_exception -caml_register_channel_for_spacetime caml_set_static_env -caml_spacetime_enabled -caml_spacetime_only_works_for_native_code From +toplevel.js: caml_dynlink_get_bytecode_sections diff --git a/compiler/tests-check-prim/unix-unix.output5 b/compiler/tests-check-prim/unix-unix.output5 index e0b77c8df..019f7b817 100644 --- a/compiler/tests-check-prim/unix-unix.output5 +++ b/compiler/tests-check-prim/unix-unix.output5 @@ -271,10 +271,7 @@ From +sys.js: caml_fatal_uncaught_exception caml_format_exception caml_is_special_exception -caml_register_channel_for_spacetime caml_set_static_env -caml_spacetime_enabled -caml_spacetime_only_works_for_native_code caml_sys_const_naked_pointers_checked From +toplevel.js: diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index bad80e88a..a49fc638e 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -256,10 +256,7 @@ From +sys.js: caml_fatal_uncaught_exception caml_format_exception caml_is_special_exception -caml_register_channel_for_spacetime caml_set_static_env -caml_spacetime_enabled -caml_spacetime_only_works_for_native_code From +toplevel.js: caml_dynlink_get_bytecode_sections diff --git a/compiler/tests-check-prim/unix-win32.output5 b/compiler/tests-check-prim/unix-win32.output5 index a40536491..bd93117de 100644 --- a/compiler/tests-check-prim/unix-win32.output5 +++ b/compiler/tests-check-prim/unix-win32.output5 @@ -237,10 +237,7 @@ From +sys.js: caml_fatal_uncaught_exception caml_format_exception caml_is_special_exception -caml_register_channel_for_spacetime caml_set_static_env -caml_spacetime_enabled -caml_spacetime_only_works_for_native_code caml_sys_const_naked_pointers_checked From +toplevel.js: diff --git a/runtime/js/sys.js b/runtime/js/sys.js index 448292bd5..c87ccf2a7 100644 --- a/runtime/js/sys.js +++ b/runtime/js/sys.js @@ -337,6 +337,7 @@ function caml_ml_runtime_warnings_enabled(_unit) { } //Provides: caml_spacetime_enabled const (const) +//Version: < 4.12 function caml_spacetime_enabled(_unit) { return 0; } @@ -347,12 +348,14 @@ function caml_sys_const_naked_pointers_checked(_unit) { } //Provides: caml_register_channel_for_spacetime const (const) +//Version: < 4.12 function caml_register_channel_for_spacetime(_channel) { return 0; } //Provides: caml_spacetime_only_works_for_native_code //Requires: caml_failwith +//Version: < 4.12 function caml_spacetime_only_works_for_native_code() { caml_failwith("Spacetime profiling only works for native code"); } From 7f8a23995e102256289d7e3253942ff3381741a7 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 18 Nov 2024 22:45:39 +0100 Subject: [PATCH 25/50] Runtime: adjust str prims --- compiler/tests-check-prim/dune | 4 ++-- compiler/tests-check-prim/main.output | 9 --------- compiler/tests-check-prim/main.output5 | 9 --------- compiler/tests-check-prim/unix-unix.output | 9 --------- compiler/tests-check-prim/unix-unix.output5 | 9 --------- compiler/tests-check-prim/unix-win32.output | 9 --------- compiler/tests-check-prim/unix-win32.output5 | 9 --------- runtime/js/str.js | 5 ----- 8 files changed, 2 insertions(+), 61 deletions(-) diff --git a/compiler/tests-check-prim/dune b/compiler/tests-check-prim/dune index 6c506b6b0..5a0767a94 100644 --- a/compiler/tests-check-prim/dune +++ b/compiler/tests-check-prim/dune @@ -1,6 +1,6 @@ (executables (names main) - (libraries js_of_ocaml num) + (libraries js_of_ocaml num str) (link_flags (:standard -linkall)) (modules main) @@ -8,7 +8,7 @@ (executables (names unix) - (libraries js_of_ocaml num unix) + (libraries js_of_ocaml num str unix) (link_flags (:standard -linkall)) (modules unix) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index f2803fd94..43f1ddc56 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -162,15 +162,6 @@ caml_maybe_print_stats caml_register_global jsoo_toplevel_reloc -From +str.js: -caml_str_initialize -re_match -re_partial_match -re_replacement_text -re_search_backward -re_search_forward -re_string_match - From +sync.js: MlMutex caml_ml_mutex_lock diff --git a/compiler/tests-check-prim/main.output5 b/compiler/tests-check-prim/main.output5 index 794cf0dc3..637b10478 100644 --- a/compiler/tests-check-prim/main.output5 +++ b/compiler/tests-check-prim/main.output5 @@ -147,15 +147,6 @@ caml_maybe_print_stats caml_register_global jsoo_toplevel_reloc -From +str.js: -caml_str_initialize -re_match -re_partial_match -re_replacement_text -re_search_backward -re_search_forward -re_string_match - From +sys.js: caml_fatal_uncaught_exception caml_format_exception diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index 74f2272cf..649dec829 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -271,15 +271,6 @@ caml_maybe_print_stats caml_register_global jsoo_toplevel_reloc -From +str.js: -caml_str_initialize -re_match -re_partial_match -re_replacement_text -re_search_backward -re_search_forward -re_string_match - From +sync.js: MlMutex caml_ml_mutex_lock diff --git a/compiler/tests-check-prim/unix-unix.output5 b/compiler/tests-check-prim/unix-unix.output5 index 019f7b817..e20e4722e 100644 --- a/compiler/tests-check-prim/unix-unix.output5 +++ b/compiler/tests-check-prim/unix-unix.output5 @@ -258,15 +258,6 @@ caml_maybe_print_stats caml_register_global jsoo_toplevel_reloc -From +str.js: -caml_str_initialize -re_match -re_partial_match -re_replacement_text -re_search_backward -re_search_forward -re_string_match - From +sys.js: caml_fatal_uncaught_exception caml_format_exception diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index a49fc638e..fa3c52a75 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -236,15 +236,6 @@ caml_maybe_print_stats caml_register_global jsoo_toplevel_reloc -From +str.js: -caml_str_initialize -re_match -re_partial_match -re_replacement_text -re_search_backward -re_search_forward -re_string_match - From +sync.js: MlMutex caml_ml_mutex_lock diff --git a/compiler/tests-check-prim/unix-win32.output5 b/compiler/tests-check-prim/unix-win32.output5 index bd93117de..11d98c737 100644 --- a/compiler/tests-check-prim/unix-win32.output5 +++ b/compiler/tests-check-prim/unix-win32.output5 @@ -224,15 +224,6 @@ caml_maybe_print_stats caml_register_global jsoo_toplevel_reloc -From +str.js: -caml_str_initialize -re_match -re_partial_match -re_replacement_text -re_search_backward -re_search_forward -re_string_match - From +sys.js: caml_fatal_uncaught_exception caml_format_exception diff --git a/runtime/js/str.js b/runtime/js/str.js index e8fa271e4..8c39ee65c 100644 --- a/runtime/js/str.js +++ b/runtime/js/str.js @@ -389,8 +389,3 @@ function re_replacement_text(repl, groups, orig) { } return caml_string_of_jsbytes(res); } - -//Provides: caml_str_initialize -function caml_str_initialize(unit) { - return 0; -} From 1bbb4853c2ddd0d76a7eea1420cc08e62db257ef Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 18 Nov 2024 23:01:58 +0100 Subject: [PATCH 26/50] Runtime: adjust marshal prims --- compiler/tests-check-prim/main.output | 1 - compiler/tests-check-prim/main.output5 | 1 - compiler/tests-check-prim/unix-unix.output | 1 - compiler/tests-check-prim/unix-unix.output5 | 1 - compiler/tests-check-prim/unix-win32.output | 1 - compiler/tests-check-prim/unix-win32.output5 | 1 - runtime/js/marshal.js | 1 + 7 files changed, 1 insertion(+), 6 deletions(-) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index 43f1ddc56..d950d89ff 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -127,7 +127,6 @@ caml_wrap_exception From +marshal.js: BigStringReader -caml_input_value_from_string caml_marshal_constants From +mlBytes.js: diff --git a/compiler/tests-check-prim/main.output5 b/compiler/tests-check-prim/main.output5 index 637b10478..a67bf527e 100644 --- a/compiler/tests-check-prim/main.output5 +++ b/compiler/tests-check-prim/main.output5 @@ -111,7 +111,6 @@ caml_wrap_exception From +marshal.js: BigStringReader -caml_input_value_from_string caml_marshal_constants From +mlBytes.js: diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index 649dec829..0f6cae5bb 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -236,7 +236,6 @@ caml_wrap_exception From +marshal.js: BigStringReader -caml_input_value_from_string caml_marshal_constants From +mlBytes.js: diff --git a/compiler/tests-check-prim/unix-unix.output5 b/compiler/tests-check-prim/unix-unix.output5 index e20e4722e..1f40de113 100644 --- a/compiler/tests-check-prim/unix-unix.output5 +++ b/compiler/tests-check-prim/unix-unix.output5 @@ -222,7 +222,6 @@ caml_wrap_exception From +marshal.js: BigStringReader -caml_input_value_from_string caml_marshal_constants From +mlBytes.js: diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index fa3c52a75..7bdfb885e 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -201,7 +201,6 @@ caml_wrap_exception From +marshal.js: BigStringReader -caml_input_value_from_string caml_marshal_constants From +mlBytes.js: diff --git a/compiler/tests-check-prim/unix-win32.output5 b/compiler/tests-check-prim/unix-win32.output5 index 11d98c737..b0f7e3bb1 100644 --- a/compiler/tests-check-prim/unix-win32.output5 +++ b/compiler/tests-check-prim/unix-win32.output5 @@ -188,7 +188,6 @@ caml_wrap_exception From +marshal.js: BigStringReader -caml_input_value_from_string caml_marshal_constants From +mlBytes.js: diff --git a/runtime/js/marshal.js b/runtime/js/marshal.js index ddb93f6f9..7e4aec531 100644 --- a/runtime/js/marshal.js +++ b/runtime/js/marshal.js @@ -233,6 +233,7 @@ function caml_float_of_bytes(a) { //Provides: caml_input_value_from_string mutable //Requires: MlStringReader, caml_input_value_from_reader +//Version: < 4.12 function caml_input_value_from_string(s, ofs) { var reader = new MlStringReader(s, typeof ofs === "number" ? ofs : ofs[0]); return caml_input_value_from_reader(reader, ofs); From 5ee1b724da15fc2f9e54e03e623ba864105a1d83 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 19 Nov 2024 11:35:08 +0100 Subject: [PATCH 27/50] Runtime: adjust obj prims --- compiler/tests-check-prim/main.output | 10 ---------- compiler/tests-check-prim/main.output5 | 6 ------ compiler/tests-check-prim/unix-unix.output | 10 ---------- compiler/tests-check-prim/unix-unix.output5 | 6 ------ compiler/tests-check-prim/unix-win32.output | 10 ---------- compiler/tests-check-prim/unix-win32.output5 | 6 ------ runtime/js/obj.js | 11 +++++++++++ 7 files changed, 11 insertions(+), 48 deletions(-) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index d950d89ff..23a58d4b8 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -144,16 +144,6 @@ caml_to_js_string From +nat.js: compare_nat_real -From +obj.js: -caml_lazy_read_result -caml_lazy_reset_to_lazy -caml_lazy_update_to_forcing -caml_lazy_update_to_forward -caml_obj_compare_and_swap -caml_obj_is_block -caml_obj_is_shared -caml_obj_update_tag - From +stdlib.js: caml_build_symbols caml_is_printable diff --git a/compiler/tests-check-prim/main.output5 b/compiler/tests-check-prim/main.output5 index a67bf527e..c64613ae5 100644 --- a/compiler/tests-check-prim/main.output5 +++ b/compiler/tests-check-prim/main.output5 @@ -127,12 +127,6 @@ caml_to_js_string From +nat.js: compare_nat_real -From +obj.js: -caml_obj_is_block -caml_obj_make_forward -caml_obj_set_tag -caml_obj_truncate - From +runtime_events.js: caml_runtime_events_create_cursor caml_runtime_events_free_cursor diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index 0f6cae5bb..7d697d6fd 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -253,16 +253,6 @@ caml_to_js_string From +nat.js: compare_nat_real -From +obj.js: -caml_lazy_read_result -caml_lazy_reset_to_lazy -caml_lazy_update_to_forcing -caml_lazy_update_to_forward -caml_obj_compare_and_swap -caml_obj_is_block -caml_obj_is_shared -caml_obj_update_tag - From +stdlib.js: caml_build_symbols caml_is_printable diff --git a/compiler/tests-check-prim/unix-unix.output5 b/compiler/tests-check-prim/unix-unix.output5 index 1f40de113..b50e12dae 100644 --- a/compiler/tests-check-prim/unix-unix.output5 +++ b/compiler/tests-check-prim/unix-unix.output5 @@ -238,12 +238,6 @@ caml_to_js_string From +nat.js: compare_nat_real -From +obj.js: -caml_obj_is_block -caml_obj_make_forward -caml_obj_set_tag -caml_obj_truncate - From +runtime_events.js: caml_runtime_events_create_cursor caml_runtime_events_free_cursor diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index 7bdfb885e..ab8fc0eb2 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -218,16 +218,6 @@ caml_to_js_string From +nat.js: compare_nat_real -From +obj.js: -caml_lazy_read_result -caml_lazy_reset_to_lazy -caml_lazy_update_to_forcing -caml_lazy_update_to_forward -caml_obj_compare_and_swap -caml_obj_is_block -caml_obj_is_shared -caml_obj_update_tag - From +stdlib.js: caml_build_symbols caml_is_printable diff --git a/compiler/tests-check-prim/unix-win32.output5 b/compiler/tests-check-prim/unix-win32.output5 index b0f7e3bb1..ef476487e 100644 --- a/compiler/tests-check-prim/unix-win32.output5 +++ b/compiler/tests-check-prim/unix-win32.output5 @@ -204,12 +204,6 @@ caml_to_js_string From +nat.js: compare_nat_real -From +obj.js: -caml_obj_is_block -caml_obj_make_forward -caml_obj_set_tag -caml_obj_truncate - From +runtime_events.js: caml_runtime_events_create_cursor caml_runtime_events_free_cursor diff --git a/runtime/js/obj.js b/runtime/js/obj.js index 405d87560..1dd73d985 100644 --- a/runtime/js/obj.js +++ b/runtime/js/obj.js @@ -39,6 +39,7 @@ function caml_alloc_dummy_infix() { } //Provides: caml_obj_is_block const (const) +//Version: < 4.12 function caml_obj_is_block(x) { return +Array.isArray(x); } @@ -55,6 +56,7 @@ function caml_obj_tag(x) { } //Provides: caml_obj_set_tag (mutable, const) +//Version: < 5.0 function caml_obj_set_tag(x, tag) { x[0] = tag; return 0; @@ -86,6 +88,7 @@ function caml_obj_dup(x) { //Provides: caml_obj_truncate (mutable, const) //Requires: caml_invalid_argument +//Version: < 5.0 function caml_obj_truncate(x, s) { if (s <= 0 || s + 1 > x.length) caml_invalid_argument("Obj.truncate"); if (x.length !== s + 1) x.length = s + 1; @@ -93,6 +96,7 @@ function caml_obj_truncate(x, s) { } //Provides: caml_obj_make_forward +//Version: < 5.0 function caml_obj_make_forward(b, v) { b[0] = 250; b[1] = v; @@ -100,6 +104,7 @@ function caml_obj_make_forward(b, v) { } //Provides: caml_obj_compare_and_swap +//Version: >= 5.0 function caml_obj_compare_and_swap(x, i, old, n) { if (x[i + 1] === old) { x[i + 1] = n; @@ -109,6 +114,7 @@ function caml_obj_compare_and_swap(x, i, old, n) { } //Provides: caml_obj_is_shared +//Version: >= 5.0 function caml_obj_is_shared(x) { return 1; } @@ -182,6 +188,7 @@ function caml_obj_add_offset(v, offset) { } //Provides: caml_obj_update_tag +//Version: >= 5.0 function caml_obj_update_tag(b, o, n) { if (b[0] === o) { b[0] = n; @@ -192,6 +199,7 @@ function caml_obj_update_tag(b, o, n) { //Provides: caml_lazy_update_to_forcing //Requires: caml_obj_update_tag +//Version: >= 5.0 function caml_lazy_update_to_forcing(o) { if ( Array.isArray(o) && @@ -206,6 +214,7 @@ function caml_lazy_update_to_forcing(o) { //Provides: caml_lazy_update_to_forward //Requires: caml_obj_update_tag +//Version: >= 5.0 function caml_lazy_update_to_forward(o) { caml_obj_update_tag(o, 244, 250); return 0; // unit @@ -213,6 +222,7 @@ function caml_lazy_update_to_forward(o) { //Provides: caml_lazy_reset_to_lazy //Requires: caml_obj_update_tag +//Version: >= 5.0 function caml_lazy_reset_to_lazy(o) { caml_obj_update_tag(o, 244, 246); return 0; @@ -220,6 +230,7 @@ function caml_lazy_reset_to_lazy(o) { //Provides: caml_lazy_read_result //Requires: caml_obj_tag +//Version: >= 5.0 function caml_lazy_read_result(o) { return caml_obj_tag(o) === 250 ? o[1] : o; } From 46a5d083ef8c3a84c09d24ade9e29c32f6f02836 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 19 Nov 2024 11:47:18 +0100 Subject: [PATCH 28/50] Runtime: adjust nat prims --- compiler/tests-check-prim/main.output | 3 --- compiler/tests-check-prim/main.output5 | 3 --- compiler/tests-check-prim/unix-unix.output | 3 --- compiler/tests-check-prim/unix-unix.output5 | 3 --- compiler/tests-check-prim/unix-win32.output | 3 --- compiler/tests-check-prim/unix-win32.output5 | 3 --- runtime/js/nat.js | 6 ------ 7 files changed, 24 deletions(-) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index 23a58d4b8..2274479a5 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -141,9 +141,6 @@ caml_string_set64 caml_string_unsafe_set caml_to_js_string -From +nat.js: -compare_nat_real - From +stdlib.js: caml_build_symbols caml_is_printable diff --git a/compiler/tests-check-prim/main.output5 b/compiler/tests-check-prim/main.output5 index c64613ae5..068327b77 100644 --- a/compiler/tests-check-prim/main.output5 +++ b/compiler/tests-check-prim/main.output5 @@ -124,9 +124,6 @@ caml_string_set64 caml_string_unsafe_set caml_to_js_string -From +nat.js: -compare_nat_real - From +runtime_events.js: caml_runtime_events_create_cursor caml_runtime_events_free_cursor diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index 7d697d6fd..9003d2b6a 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -250,9 +250,6 @@ caml_string_set64 caml_string_unsafe_set caml_to_js_string -From +nat.js: -compare_nat_real - From +stdlib.js: caml_build_symbols caml_is_printable diff --git a/compiler/tests-check-prim/unix-unix.output5 b/compiler/tests-check-prim/unix-unix.output5 index b50e12dae..f52cae365 100644 --- a/compiler/tests-check-prim/unix-unix.output5 +++ b/compiler/tests-check-prim/unix-unix.output5 @@ -235,9 +235,6 @@ caml_string_set64 caml_string_unsafe_set caml_to_js_string -From +nat.js: -compare_nat_real - From +runtime_events.js: caml_runtime_events_create_cursor caml_runtime_events_free_cursor diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index ab8fc0eb2..13f23075c 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -215,9 +215,6 @@ caml_string_set64 caml_string_unsafe_set caml_to_js_string -From +nat.js: -compare_nat_real - From +stdlib.js: caml_build_symbols caml_is_printable diff --git a/compiler/tests-check-prim/unix-win32.output5 b/compiler/tests-check-prim/unix-win32.output5 index ef476487e..947189714 100644 --- a/compiler/tests-check-prim/unix-win32.output5 +++ b/compiler/tests-check-prim/unix-win32.output5 @@ -201,9 +201,6 @@ caml_string_set64 caml_string_unsafe_set caml_to_js_string -From +nat.js: -compare_nat_real - From +runtime_events.js: caml_runtime_events_create_cursor caml_runtime_events_free_cursor diff --git a/runtime/js/nat.js b/runtime/js/nat.js index 5ce9d1455..cbeb1db26 100644 --- a/runtime/js/nat.js +++ b/runtime/js/nat.js @@ -423,12 +423,6 @@ function compare_nat(nat1, ofs1, len1, nat2, ofs2, len2) { return 0; } -//Provides: compare_nat_real -//Requires: compare_nat -function compare_nat_real(nat1, nat2) { - return compare_nat(nat1, 0, nat1.data.length, nat2, 0, nat2.data.length); -} - //Provides: land_digit_nat function land_digit_nat(nat1, ofs1, nat2, ofs2) { nat1.data[ofs1] &= nat2.data[ofs2]; From 329a9e671de4fbc636f3bde1b434151fcb8d2b7c Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 19 Nov 2024 11:51:46 +0100 Subject: [PATCH 29/50] Runtime: adjust hash prims --- compiler/tests-check-prim/main.output | 3 --- compiler/tests-check-prim/unix-unix.output | 3 --- compiler/tests-check-prim/unix-win32.output | 3 --- runtime/js/hash.js | 1 + 4 files changed, 1 insertion(+), 9 deletions(-) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index 2274479a5..442e8e195 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -109,9 +109,6 @@ caml_gr_text_size caml_gr_wait_event caml_gr_window_id -From +hash.js: -caml_string_hash - From +ints.js: caml_div caml_mod diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index 9003d2b6a..d65407ddc 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -218,9 +218,6 @@ caml_gr_text_size caml_gr_wait_event caml_gr_window_id -From +hash.js: -caml_string_hash - From +ints.js: caml_div caml_mod diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index 13f23075c..f27a7755b 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -183,9 +183,6 @@ caml_gr_text_size caml_gr_wait_event caml_gr_window_id -From +hash.js: -caml_string_hash - From +ints.js: caml_div caml_mod diff --git a/runtime/js/hash.js b/runtime/js/hash.js index d20ee1498..61f7b617a 100644 --- a/runtime/js/hash.js +++ b/runtime/js/hash.js @@ -275,6 +275,7 @@ function caml_hash(count, limit, seed, obj) { //Provides: caml_string_hash //Requires: caml_hash_mix_final, caml_hash_mix_string +//Version: >= 5.0 function caml_string_hash(h, v) { var h = caml_hash_mix_string(h, v); var h = caml_hash_mix_final(h); From 91962000e3e245c6cc6e5ec29c2742ac258eecdb Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 19 Nov 2024 11:55:31 +0100 Subject: [PATCH 30/50] Runtime: adjust io prims --- compiler/tests-check-prim/main.output | 3 --- compiler/tests-check-prim/unix-unix.output | 3 --- compiler/tests-check-prim/unix-win32.output | 3 --- runtime/js/io.js | 1 + 4 files changed, 1 insertion(+), 9 deletions(-) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index 442e8e195..6e1d5ac65 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -113,9 +113,6 @@ From +ints.js: caml_div caml_mod -From +io.js: -caml_input_value_to_outside_heap - From +jslib.js: caml_is_js caml_trampoline diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index d65407ddc..2aeebb41d 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -222,9 +222,6 @@ From +ints.js: caml_div caml_mod -From +io.js: -caml_input_value_to_outside_heap - From +jslib.js: caml_is_js caml_trampoline diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index f27a7755b..caead2a46 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -187,9 +187,6 @@ From +ints.js: caml_div caml_mod -From +io.js: -caml_input_value_to_outside_heap - From +jslib.js: caml_is_js caml_trampoline diff --git a/runtime/js/io.js b/runtime/js/io.js index f1c6c4cdc..3a56fbd1b 100644 --- a/runtime/js/io.js +++ b/runtime/js/io.js @@ -406,6 +406,7 @@ function caml_input_value(chanid) { //Provides: caml_input_value_to_outside_heap //Requires: caml_input_value +//Version: >= 5 function caml_input_value_to_outside_heap(c) { return caml_input_value(c); } From d414b70cef1415e29b1bac0ace4dde5df0cf6940 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 19 Nov 2024 12:03:17 +0100 Subject: [PATCH 31/50] Runtime: adjust toplevel prims --- compiler/tests-check-prim/main.output | 6 ------ compiler/tests-check-prim/main.output5 | 6 ------ compiler/tests-check-prim/unix-unix.output | 6 ------ compiler/tests-check-prim/unix-unix.output5 | 6 ------ compiler/tests-check-prim/unix-win32.output | 6 ------ compiler/tests-check-prim/unix-win32.output5 | 6 ------ runtime/js/toplevel.js | 18 ++---------------- 7 files changed, 2 insertions(+), 52 deletions(-) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index 6e1d5ac65..df681a986 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -157,12 +157,6 @@ caml_set_static_env From +toplevel.js: caml_dynlink_get_bytecode_sections -caml_static_alloc -caml_static_free -caml_terminfo_backup -caml_terminfo_resume -caml_terminfo_setup -caml_terminfo_standout jsoo_toplevel_init_compile jsoo_toplevel_init_reloc diff --git a/compiler/tests-check-prim/main.output5 b/compiler/tests-check-prim/main.output5 index 068327b77..0488c5e26 100644 --- a/compiler/tests-check-prim/main.output5 +++ b/compiler/tests-check-prim/main.output5 @@ -146,12 +146,6 @@ caml_sys_const_naked_pointers_checked From +toplevel.js: caml_get_section_table -caml_static_alloc -caml_static_free -caml_terminfo_backup -caml_terminfo_resume -caml_terminfo_setup -caml_terminfo_standout jsoo_toplevel_init_compile jsoo_toplevel_init_reloc diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index 2aeebb41d..aea5735a1 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -266,12 +266,6 @@ caml_set_static_env From +toplevel.js: caml_dynlink_get_bytecode_sections -caml_static_alloc -caml_static_free -caml_terminfo_backup -caml_terminfo_resume -caml_terminfo_setup -caml_terminfo_standout jsoo_toplevel_init_compile jsoo_toplevel_init_reloc diff --git a/compiler/tests-check-prim/unix-unix.output5 b/compiler/tests-check-prim/unix-unix.output5 index f52cae365..9354bdebd 100644 --- a/compiler/tests-check-prim/unix-unix.output5 +++ b/compiler/tests-check-prim/unix-unix.output5 @@ -257,12 +257,6 @@ caml_sys_const_naked_pointers_checked From +toplevel.js: caml_get_section_table -caml_static_alloc -caml_static_free -caml_terminfo_backup -caml_terminfo_resume -caml_terminfo_setup -caml_terminfo_standout jsoo_toplevel_init_compile jsoo_toplevel_init_reloc diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index caead2a46..3fbab74fc 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -231,12 +231,6 @@ caml_set_static_env From +toplevel.js: caml_dynlink_get_bytecode_sections -caml_static_alloc -caml_static_free -caml_terminfo_backup -caml_terminfo_resume -caml_terminfo_setup -caml_terminfo_standout jsoo_toplevel_init_compile jsoo_toplevel_init_reloc diff --git a/compiler/tests-check-prim/unix-win32.output5 b/compiler/tests-check-prim/unix-win32.output5 index 947189714..d9720fd22 100644 --- a/compiler/tests-check-prim/unix-win32.output5 +++ b/compiler/tests-check-prim/unix-win32.output5 @@ -223,12 +223,6 @@ caml_sys_const_naked_pointers_checked From +toplevel.js: caml_get_section_table -caml_static_alloc -caml_static_free -caml_terminfo_backup -caml_terminfo_resume -caml_terminfo_setup -caml_terminfo_standout jsoo_toplevel_init_compile jsoo_toplevel_init_reloc diff --git a/runtime/js/toplevel.js b/runtime/js/toplevel.js index b0e9f0599..9d54018f8 100644 --- a/runtime/js/toplevel.js +++ b/runtime/js/toplevel.js @@ -17,22 +17,6 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -//Provides: caml_terminfo_setup -function caml_terminfo_setup() { - return 1; -} // Bad_term -//Provides: caml_terminfo_backup -function caml_terminfo_backup() { - return 0; -} -//Provides: caml_terminfo_standout -function caml_terminfo_standout() { - return 0; -} -//Provides: caml_terminfo_resume -function caml_terminfo_resume() { - return 0; -} //Provides: caml_terminfo_rows function caml_terminfo_rows() { return 0; @@ -151,11 +135,13 @@ function caml_static_release_bytecode() { //Provides: caml_static_alloc //Requires: caml_create_bytes +//Version: < 4.12 function caml_static_alloc(len) { return caml_create_bytes(len); } //Provides: caml_static_free +//Version: < 4.12 function caml_static_free() { return 0; } From 44119746145858beb5b03e4dc9498ecf74859b3c Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 19 Nov 2024 12:12:58 +0100 Subject: [PATCH 32/50] Runtime: adjust dynlink prims --- compiler/tests-check-prim/main.output | 5 ----- compiler/tests-check-prim/main.output5 | 5 ----- compiler/tests-check-prim/unix-unix.output | 5 ----- compiler/tests-check-prim/unix-unix.output5 | 5 ----- compiler/tests-check-prim/unix-win32.output | 5 ----- compiler/tests-check-prim/unix-win32.output5 | 5 ----- runtime/js/dynlink.js | 3 +++ 7 files changed, 3 insertions(+), 30 deletions(-) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index df681a986..963a247c7 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -34,11 +34,6 @@ caml_bigstring_blit_string_to_ba caml_bigstring_memcmp caml_hash_mix_bigstring -From +dynlink.js: -caml_add_debug_info -caml_register_code_fragment -caml_remove_debug_info - From +effect.js: caml_alloc_stack caml_continuation_use_and_update_handler_noexc diff --git a/compiler/tests-check-prim/main.output5 b/compiler/tests-check-prim/main.output5 index 0488c5e26..cc822bf09 100644 --- a/compiler/tests-check-prim/main.output5 +++ b/compiler/tests-check-prim/main.output5 @@ -27,11 +27,6 @@ caml_bigstring_blit_string_to_ba caml_bigstring_memcmp caml_hash_mix_bigstring -From +dynlink.js: -caml_add_debug_info -caml_register_code_fragment -caml_remove_debug_info - From +effect.js: jsoo_effect_not_supported diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index aea5735a1..466252a15 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -143,11 +143,6 @@ caml_bigstring_blit_string_to_ba caml_bigstring_memcmp caml_hash_mix_bigstring -From +dynlink.js: -caml_add_debug_info -caml_register_code_fragment -caml_remove_debug_info - From +effect.js: caml_alloc_stack caml_continuation_use_and_update_handler_noexc diff --git a/compiler/tests-check-prim/unix-unix.output5 b/compiler/tests-check-prim/unix-unix.output5 index 9354bdebd..8e6def9da 100644 --- a/compiler/tests-check-prim/unix-unix.output5 +++ b/compiler/tests-check-prim/unix-unix.output5 @@ -138,11 +138,6 @@ caml_bigstring_blit_string_to_ba caml_bigstring_memcmp caml_hash_mix_bigstring -From +dynlink.js: -caml_add_debug_info -caml_register_code_fragment -caml_remove_debug_info - From +effect.js: jsoo_effect_not_supported diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index 3fbab74fc..f92265455 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -108,11 +108,6 @@ caml_bigstring_blit_string_to_ba caml_bigstring_memcmp caml_hash_mix_bigstring -From +dynlink.js: -caml_add_debug_info -caml_register_code_fragment -caml_remove_debug_info - From +effect.js: caml_alloc_stack caml_continuation_use_and_update_handler_noexc diff --git a/compiler/tests-check-prim/unix-win32.output5 b/compiler/tests-check-prim/unix-win32.output5 index d9720fd22..76028150a 100644 --- a/compiler/tests-check-prim/unix-win32.output5 +++ b/compiler/tests-check-prim/unix-win32.output5 @@ -104,11 +104,6 @@ caml_bigstring_blit_string_to_ba caml_bigstring_memcmp caml_hash_mix_bigstring -From +dynlink.js: -caml_add_debug_info -caml_register_code_fragment -caml_remove_debug_info - From +effect.js: jsoo_effect_not_supported diff --git a/runtime/js/dynlink.js b/runtime/js/dynlink.js index 064827861..5f0f1dba4 100644 --- a/runtime/js/dynlink.js +++ b/runtime/js/dynlink.js @@ -73,16 +73,19 @@ function caml_dynlink_get_current_libs() { } //Provides: caml_register_code_fragment +//Version: < 4.10 function caml_register_code_fragment(code, codesize, digest) { return 0; } //Provides: caml_add_debug_info +//Version: < 4.13 function caml_add_debug_info(code, size, events) { return 0; } //Provides: caml_remove_debug_info +//Version: < 4.13 function caml_remove_debug_info(code) { return 0; } From 3e33f3d5a727221e6148a7e660dbf736dc96a12f Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 19 Nov 2024 12:18:46 +0100 Subject: [PATCH 33/50] Runtime: adjust mlbytes prims --- compiler/tests-check-prim/main.output | 4 -- compiler/tests-check-prim/main.output5 | 4 -- compiler/tests-check-prim/unix-unix.output | 4 -- compiler/tests-check-prim/unix-unix.output5 | 4 -- compiler/tests-check-prim/unix-win32.output | 4 -- compiler/tests-check-prim/unix-win32.output5 | 4 -- runtime/js/mlBytes.js | 49 -------------------- 7 files changed, 73 deletions(-) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index 963a247c7..1b05e1d21 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -124,10 +124,6 @@ caml_array_of_string caml_bytes_of_utf16_jsstring caml_new_string caml_string_concat -caml_string_set16 -caml_string_set32 -caml_string_set64 -caml_string_unsafe_set caml_to_js_string From +stdlib.js: diff --git a/compiler/tests-check-prim/main.output5 b/compiler/tests-check-prim/main.output5 index cc822bf09..4af107e12 100644 --- a/compiler/tests-check-prim/main.output5 +++ b/compiler/tests-check-prim/main.output5 @@ -113,10 +113,6 @@ caml_array_of_bytes caml_array_of_string caml_bytes_of_utf16_jsstring caml_string_concat -caml_string_set16 -caml_string_set32 -caml_string_set64 -caml_string_unsafe_set caml_to_js_string From +runtime_events.js: diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index 466252a15..e81994788 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -233,10 +233,6 @@ caml_array_of_string caml_bytes_of_utf16_jsstring caml_new_string caml_string_concat -caml_string_set16 -caml_string_set32 -caml_string_set64 -caml_string_unsafe_set caml_to_js_string From +stdlib.js: diff --git a/compiler/tests-check-prim/unix-unix.output5 b/compiler/tests-check-prim/unix-unix.output5 index 8e6def9da..812ca0a46 100644 --- a/compiler/tests-check-prim/unix-unix.output5 +++ b/compiler/tests-check-prim/unix-unix.output5 @@ -224,10 +224,6 @@ caml_array_of_bytes caml_array_of_string caml_bytes_of_utf16_jsstring caml_string_concat -caml_string_set16 -caml_string_set32 -caml_string_set64 -caml_string_unsafe_set caml_to_js_string From +runtime_events.js: diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index f92265455..dede1e2e1 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -198,10 +198,6 @@ caml_array_of_string caml_bytes_of_utf16_jsstring caml_new_string caml_string_concat -caml_string_set16 -caml_string_set32 -caml_string_set64 -caml_string_unsafe_set caml_to_js_string From +stdlib.js: diff --git a/compiler/tests-check-prim/unix-win32.output5 b/compiler/tests-check-prim/unix-win32.output5 index 76028150a..c82c2545c 100644 --- a/compiler/tests-check-prim/unix-win32.output5 +++ b/compiler/tests-check-prim/unix-win32.output5 @@ -190,10 +190,6 @@ caml_array_of_bytes caml_array_of_string caml_bytes_of_utf16_jsstring caml_string_concat -caml_string_set16 -caml_string_set32 -caml_string_set64 -caml_string_unsafe_set caml_to_js_string From +runtime_events.js: diff --git a/runtime/js/mlBytes.js b/runtime/js/mlBytes.js index fe7e7f9c3..e1110094b 100644 --- a/runtime/js/mlBytes.js +++ b/runtime/js/mlBytes.js @@ -353,20 +353,6 @@ function caml_bytes_set16(s, i, i16) { return 0; } -//Provides: caml_string_set16 -//Requires: caml_failwith -//If: js-string -function caml_string_set16(s, i, i16) { - caml_failwith("caml_string_set16"); -} - -//Provides: caml_string_set16 -//Requires: caml_bytes_set16 -//If: !js-string -function caml_string_set16(s, i, i16) { - return caml_bytes_set16(s, i, i16); -} - //Provides: caml_bytes_set32 //Requires: caml_bytes_bound_error, caml_bytes_unsafe_set function caml_bytes_set32(s, i, i32) { @@ -382,20 +368,6 @@ function caml_bytes_set32(s, i, i32) { return 0; } -//Provides: caml_string_set32 -//Requires: caml_failwith -//If: js-string -function caml_string_set32(s, i, i32) { - caml_failwith("caml_string_set32"); -} - -//Provides: caml_string_set32 -//Requires: caml_bytes_set32 -//If: !js-string -function caml_string_set32(s, i, i32) { - return caml_bytes_set32(s, i, i32); -} - //Provides: caml_bytes_set64 //Requires: caml_bytes_bound_error, caml_bytes_unsafe_set //Requires: caml_int64_to_bytes @@ -408,20 +380,6 @@ function caml_bytes_set64(s, i, i64) { return 0; } -//Provides: caml_string_set64 -//Requires: caml_failwith -//If: js-string -function caml_string_set64(s, i, i64) { - caml_failwith("caml_string_set64"); -} - -//Provides: caml_string_set64 -//Requires: caml_bytes_set64 -//If: !js-string -function caml_string_set64(s, i, i64) { - return caml_bytes_set64(s, i, i64); -} - //Provides: caml_bytes_set //Requires: caml_bytes_bound_error, caml_bytes_unsafe_set function caml_bytes_set(s, i, c) { @@ -712,13 +670,6 @@ function caml_string_unsafe_get(s, i) { return s.charCodeAt(i); } -//Provides: caml_string_unsafe_set -//Requires: caml_failwith -//If: js-string -function caml_string_unsafe_set(s, i, c) { - caml_failwith("caml_string_unsafe_set"); -} - //Provides: caml_ml_string_length const //If: js-string function caml_ml_string_length(s) { From c8524eb2fdc2555dbb43a425c774c88f2b31fdc4 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 19 Nov 2024 13:25:22 +0100 Subject: [PATCH 34/50] Runtime: remove caml_new_string --- compiler/tests-check-prim/main.output | 1 - compiler/tests-check-prim/unix-unix.output | 1 - compiler/tests-check-prim/unix-win32.output | 1 - runtime/js/mlBytes.js | 6 ------ runtime/js/prng.js | 8 ++++---- 5 files changed, 4 insertions(+), 13 deletions(-) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index 1b05e1d21..fbc864dc1 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -122,7 +122,6 @@ From +mlBytes.js: caml_array_of_bytes caml_array_of_string caml_bytes_of_utf16_jsstring -caml_new_string caml_string_concat caml_to_js_string diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index e81994788..68191ebac 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -231,7 +231,6 @@ From +mlBytes.js: caml_array_of_bytes caml_array_of_string caml_bytes_of_utf16_jsstring -caml_new_string caml_string_concat caml_to_js_string diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index dede1e2e1..006d26429 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -196,7 +196,6 @@ From +mlBytes.js: caml_array_of_bytes caml_array_of_string caml_bytes_of_utf16_jsstring -caml_new_string caml_string_concat caml_to_js_string diff --git a/runtime/js/mlBytes.js b/runtime/js/mlBytes.js index e1110094b..a39ae3a10 100644 --- a/runtime/js/mlBytes.js +++ b/runtime/js/mlBytes.js @@ -883,12 +883,6 @@ function caml_js_to_byte_string(s) { return caml_string_of_jsbytes(s); } -//Provides: caml_new_string -//Requires: caml_string_of_jsbytes -function caml_new_string(s) { - return caml_string_of_jsbytes(s); -} - //Provides: caml_js_from_string mutable (const) //Requires: caml_jsstring_of_string function caml_js_from_string(s) { diff --git a/runtime/js/prng.js b/runtime/js/prng.js index 2596b1251..4f2d974d0 100644 --- a/runtime/js/prng.js +++ b/runtime/js/prng.js @@ -1,14 +1,14 @@ //Provides: caml_lxm_M //Requires: caml_int64_of_string -//Requires: caml_new_string +//Requires: caml_string_of_jsstring //Version: >= 5 -var caml_lxm_M = caml_int64_of_string(caml_new_string("0xd1342543de82ef95")); +var caml_lxm_M = caml_int64_of_string(caml_string_of_jsstring("0xd1342543de82ef95")); //Provides: caml_lxm_daba //Requires: caml_int64_of_string -//Requires: caml_new_string +//Requires: caml_string_of_jsstring //Version: >= 5 -var caml_lxm_daba = caml_int64_of_string(caml_new_string("0xdaba0b6eb09322e3")); +var caml_lxm_daba = caml_int64_of_string(caml_string_of_jsstring("0xdaba0b6eb09322e3")); //Provides: caml_lxm_next //Requires: caml_int64_shift_left From 6d9e874eb04259d494afede768bc7b2058a5ecd7 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 19 Nov 2024 13:30:16 +0100 Subject: [PATCH 35/50] Runtime: adjust gc prims --- compiler/tests-check-prim/main.output | 3 --- compiler/tests-check-prim/main.output5 | 8 -------- compiler/tests-check-prim/unix-unix.output | 3 --- compiler/tests-check-prim/unix-unix.output5 | 8 -------- compiler/tests-check-prim/unix-win32.output | 3 --- compiler/tests-check-prim/unix-win32.output5 | 8 -------- runtime/js/gc.js | 6 ++++++ 7 files changed, 6 insertions(+), 33 deletions(-) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index fbc864dc1..9be8596b6 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -52,9 +52,6 @@ caml_fs_init jsoo_create_file jsoo_create_file_extern -From +gc.js: -caml_memprof_set - From +graphics.js: caml_gr_arc_aux caml_gr_blit_image diff --git a/compiler/tests-check-prim/main.output5 b/compiler/tests-check-prim/main.output5 index 4af107e12..f685d9f19 100644 --- a/compiler/tests-check-prim/main.output5 +++ b/compiler/tests-check-prim/main.output5 @@ -37,14 +37,6 @@ caml_fs_init jsoo_create_file jsoo_create_file_extern -From +gc.js: -caml_eventlog_pause -caml_eventlog_resume -caml_gc_huge_fallback_count -caml_get_major_bucket -caml_get_major_credit -caml_memprof_set - From +graphics.js: caml_gr_arc_aux caml_gr_blit_image diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index 68191ebac..9cd292b17 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -161,9 +161,6 @@ caml_fs_init jsoo_create_file jsoo_create_file_extern -From +gc.js: -caml_memprof_set - From +graphics.js: caml_gr_arc_aux caml_gr_blit_image diff --git a/compiler/tests-check-prim/unix-unix.output5 b/compiler/tests-check-prim/unix-unix.output5 index 812ca0a46..7902a823d 100644 --- a/compiler/tests-check-prim/unix-unix.output5 +++ b/compiler/tests-check-prim/unix-unix.output5 @@ -148,14 +148,6 @@ caml_fs_init jsoo_create_file jsoo_create_file_extern -From +gc.js: -caml_eventlog_pause -caml_eventlog_resume -caml_gc_huge_fallback_count -caml_get_major_bucket -caml_get_major_credit -caml_memprof_set - From +graphics.js: caml_gr_arc_aux caml_gr_blit_image diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index 006d26429..b9f108ae0 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -126,9 +126,6 @@ caml_fs_init jsoo_create_file jsoo_create_file_extern -From +gc.js: -caml_memprof_set - From +graphics.js: caml_gr_arc_aux caml_gr_blit_image diff --git a/compiler/tests-check-prim/unix-win32.output5 b/compiler/tests-check-prim/unix-win32.output5 index c82c2545c..b45443271 100644 --- a/compiler/tests-check-prim/unix-win32.output5 +++ b/compiler/tests-check-prim/unix-win32.output5 @@ -114,14 +114,6 @@ caml_fs_init jsoo_create_file jsoo_create_file_extern -From +gc.js: -caml_eventlog_pause -caml_eventlog_resume -caml_gc_huge_fallback_count -caml_get_major_bucket -caml_get_major_credit -caml_memprof_set - From +graphics.js: caml_gr_arc_aux caml_gr_blit_image diff --git a/runtime/js/gc.js b/runtime/js/gc.js index d226af438..3692f8997 100644 --- a/runtime/js/gc.js +++ b/runtime/js/gc.js @@ -52,6 +52,7 @@ function caml_gc_get() { } //Provides: caml_memprof_set +//Version: = 4.10 function caml_memprof_set(_control) { return 0; } @@ -98,16 +99,19 @@ function caml_memprof_discard(t) { } //Provides: caml_eventlog_resume +//Version: < 5.0 function caml_eventlog_resume(unit) { return 0; } //Provides: caml_eventlog_pause +//Version: < 5.0 function caml_eventlog_pause(unit) { return 0; } //Provides: caml_gc_huge_fallback_count +//Version: < 5.0 function caml_gc_huge_fallback_count(unit) { return 0; } @@ -128,11 +132,13 @@ function caml_get_minor_free(unit) { } //Provides: caml_get_major_bucket +//Version: < 5.0 function caml_get_major_bucket(n) { return 0; } //Provides: caml_get_major_credit +//Version: < 5.0 function caml_get_major_credit(n) { return 0; } From 0fe8005964c7d43769c52735fddac3658fff3894 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 19 Nov 2024 13:37:14 +0100 Subject: [PATCH 36/50] Runtime: adjust effects prims --- compiler/tests-check-prim/main.output | 8 -------- compiler/tests-check-prim/unix-unix.output | 8 -------- compiler/tests-check-prim/unix-win32.output | 8 -------- runtime/js/effect.js | 9 +++++++++ 4 files changed, 9 insertions(+), 24 deletions(-) diff --git a/compiler/tests-check-prim/main.output b/compiler/tests-check-prim/main.output index 9be8596b6..3051f6b6e 100644 --- a/compiler/tests-check-prim/main.output +++ b/compiler/tests-check-prim/main.output @@ -35,14 +35,6 @@ caml_bigstring_memcmp caml_hash_mix_bigstring From +effect.js: -caml_alloc_stack -caml_continuation_use_and_update_handler_noexc -caml_continuation_use_noexc -caml_get_continuation_callstack -caml_ml_condition_broadcast -caml_ml_condition_new -caml_ml_condition_signal -caml_ml_condition_wait jsoo_effect_not_supported From +fs.js: diff --git a/compiler/tests-check-prim/unix-unix.output b/compiler/tests-check-prim/unix-unix.output index 9cd292b17..a5b4b7b99 100644 --- a/compiler/tests-check-prim/unix-unix.output +++ b/compiler/tests-check-prim/unix-unix.output @@ -144,14 +144,6 @@ caml_bigstring_memcmp caml_hash_mix_bigstring From +effect.js: -caml_alloc_stack -caml_continuation_use_and_update_handler_noexc -caml_continuation_use_noexc -caml_get_continuation_callstack -caml_ml_condition_broadcast -caml_ml_condition_new -caml_ml_condition_signal -caml_ml_condition_wait jsoo_effect_not_supported From +fs.js: diff --git a/compiler/tests-check-prim/unix-win32.output b/compiler/tests-check-prim/unix-win32.output index b9f108ae0..284f7eb51 100644 --- a/compiler/tests-check-prim/unix-win32.output +++ b/compiler/tests-check-prim/unix-win32.output @@ -109,14 +109,6 @@ caml_bigstring_memcmp caml_hash_mix_bigstring From +effect.js: -caml_alloc_stack -caml_continuation_use_and_update_handler_noexc -caml_continuation_use_noexc -caml_get_continuation_callstack -caml_ml_condition_broadcast -caml_ml_condition_new -caml_ml_condition_signal -caml_ml_condition_wait jsoo_effect_not_supported From +fs.js: diff --git a/runtime/js/effect.js b/runtime/js/effect.js index d80a44493..3856e76bf 100644 --- a/runtime/js/effect.js +++ b/runtime/js/effect.js @@ -130,6 +130,7 @@ function caml_perform_effect(eff, cont, k0) { //Provides: caml_alloc_stack //Requires: caml_pop_fiber, caml_fiber_stack, caml_call_gen, caml_stack_check_depth, caml_trampoline_return //If: effects +//Version: >= 5.0 function caml_alloc_stack(hv, hx, hf) { function call(i, x) { var f = caml_fiber_stack.h[i]; @@ -151,11 +152,13 @@ function caml_alloc_stack(hv, hx, hf) { //Provides: caml_alloc_stack //If: !effects +//Version: >= 5.0 function caml_alloc_stack(hv, hx, hf) { return 0; } //Provides: caml_continuation_use_noexc +//Version: >= 5.0 function caml_continuation_use_noexc(cont) { var stack = cont[1]; cont[1] = 0; @@ -164,6 +167,7 @@ function caml_continuation_use_noexc(cont) { //Provides: caml_continuation_use_and_update_handler_noexc //Requires: caml_continuation_use_noexc +//Version: >= 5.0 function caml_continuation_use_and_update_handler_noexc( cont, hval, @@ -176,26 +180,31 @@ function caml_continuation_use_and_update_handler_noexc( } //Provides: caml_get_continuation_callstack +//Version: >= 5.0 function caml_get_continuation_callstack() { return [0]; } //Provides: caml_ml_condition_new +//Version: >= 5.0 function caml_ml_condition_new(unit) { return { condition: 1 }; } //Provides: caml_ml_condition_wait +//Version: >= 5.0 function caml_ml_condition_wait(t, mutext) { return 0; } //Provides: caml_ml_condition_broadcast +//Version: >= 5.0 function caml_ml_condition_broadcast(t) { return 0; } //Provides: caml_ml_condition_signal +//Version: >= 5.0 function caml_ml_condition_signal(t) { return 0; } From 63f9d75dd12fb3159e1c329edf57e948baf65193 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 19 Nov 2024 13:46:09 +0100 Subject: [PATCH 37/50] Changes --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index a7da30a6a..81d9bd1bb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -27,6 +27,8 @@ * Lib: add details element and toggle event (#1728) * Toplevel: no longer set globals for toplevel initialization * Runtime: precompute constants used in `caml_lxm_next` (#1730) +* Runtime: cleanup runtime +* Runtime: add support for OCaml 5.3 ## Bug fixes * Runtime: fix parsing of unsigned integers (0u2147483648) (#1633, #1666) From 493c06404382d1a0be038f74bca43f4bd75c37b2 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 19 Nov 2024 13:46:59 +0100 Subject: [PATCH 38/50] Runtime: fmt --- runtime/js/prng.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/runtime/js/prng.js b/runtime/js/prng.js index 4f2d974d0..b4aaad6fa 100644 --- a/runtime/js/prng.js +++ b/runtime/js/prng.js @@ -2,13 +2,17 @@ //Requires: caml_int64_of_string //Requires: caml_string_of_jsstring //Version: >= 5 -var caml_lxm_M = caml_int64_of_string(caml_string_of_jsstring("0xd1342543de82ef95")); +var caml_lxm_M = caml_int64_of_string( + caml_string_of_jsstring("0xd1342543de82ef95"), +); //Provides: caml_lxm_daba //Requires: caml_int64_of_string //Requires: caml_string_of_jsstring //Version: >= 5 -var caml_lxm_daba = caml_int64_of_string(caml_string_of_jsstring("0xdaba0b6eb09322e3")); +var caml_lxm_daba = caml_int64_of_string( + caml_string_of_jsstring("0xdaba0b6eb09322e3"), +); //Provides: caml_lxm_next //Requires: caml_int64_shift_left From d4be1c05432f74ee996786cc9aca280058689f78 Mon Sep 17 00:00:00 2001 From: hhugo Date: Wed, 20 Nov 2024 15:45:08 +0100 Subject: [PATCH 39/50] Fix CI with macos runners (#1737) --- .github/workflows/build.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3b017d9e5..927e38546 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -97,6 +97,14 @@ jobs: # try to install them anyways, so we save an apt-roundtrip. sudo aptitude -o Acquire::Retries=30 install gcc-multilib g++-multilib pkg-config libgmp-dev libgmp-dev:i386 libx11-dev:i386 -y + - name: macos fix + if: runner.os == 'Macos' + run: | + brew update + brew upgrade + brew install pkgconf + # work around https://github.com/actions/runner-images/issues/10984 + - name: Checkout tree uses: actions/checkout@v4 From 1189e53fa3966b0028912c561ebedbc8da2a16ae Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Wed, 20 Nov 2024 17:04:41 +0100 Subject: [PATCH 40/50] CI: move --- .github/workflows/build.yml | 36 +--------------------------- .github/workflows/lint.yml | 48 +++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 927e38546..0c9afe965 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -154,38 +154,4 @@ jobs: branch: wikidoc folder: doc-dev clean: true - target-folder: doc/dev/ - - lint-opam: - runs-on: ubuntu-latest - steps: - - name: Checkout tree - uses: actions/checkout@v4 - - name: Set-up OCaml - uses: ocaml/setup-ocaml@v3 - with: - ocaml-compiler: "5.2" - dune-cache: true - - uses: ocaml/setup-ocaml/lint-opam@v3 - - lint-fmt: - runs-on: ubuntu-latest - steps: - - name: Checkout tree - uses: actions/checkout@v4 - - name: Set-up OCaml - uses: ocaml/setup-ocaml@v3 - with: - ocaml-compiler: "5.2" - dune-cache: true - - uses: ocaml/setup-ocaml/lint-fmt@v3 - - lint-runtime: - runs-on: ubuntu-latest - steps: - - name: Checkout tree - uses: actions/checkout@v4 - - name: Set-up Biome - uses: biomejs/setup-biome@v2 - - name: Run biome - run: biome ci + target-folder: doc/dev/ \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..36f9a8c5e --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,48 @@ +name: lint + +on: + pull_request: + push: + branches: + - master + +jobs: + lint-opam: + runs-on: ubuntu-latest + steps: + - name: Checkout tree + uses: actions/checkout@v4 + - name: Set-up OCaml + uses: ocaml/setup-ocaml@v3 + with: + ocaml-compiler: "5.2" + dune-cache: true + - name: Pin dune + run: | + opam pin add -n dune.3.17 https://github.com/ocaml/dune.git + - uses: ocaml/setup-ocaml/lint-opam@v3 + + lint-fmt: + runs-on: ubuntu-latest + steps: + - name: Checkout tree + uses: actions/checkout@v4 + - name: Set-up OCaml + uses: ocaml/setup-ocaml@v3 + with: + ocaml-compiler: "5.2" + dune-cache: true + - name: Pin dune + run: | + opam pin add -n dune.3.17 https://github.com/ocaml/dune.git + - uses: ocaml/setup-ocaml/lint-fmt@v3 + + lint-runtime: + runs-on: ubuntu-latest + steps: + - name: Checkout tree + uses: actions/checkout@v4 + - name: Set-up Biome + uses: biomejs/setup-biome@v2 + - name: Run biome + run: biome ci From d1566a4d7da377132d839a8863aecff104f6f134 Mon Sep 17 00:00:00 2001 From: hhugo Date: Fri, 22 Nov 2024 11:28:16 +0100 Subject: [PATCH 41/50] Release 5.9 (#1735) --- CHANGES.md | 4 ++-- VERSION | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 81d9bd1bb..e0d314ad2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,10 +1,11 @@ -# dev +# 5.9.0 (2024-11-22) - Lille ## Features/Changes * Misc: update testsuite to OCaml 5.2 * Misc: CI uses opam.2.2 and no longer use sunset repo * Misc: yojson is no longer optional * Misc: reduce the diff with the wasm_of_ocaml fork +* Misc: finalize support for OCaml 5.3 * Compiler: speedup global_flow/global_deadcode pass on large bytecode * Compiler: improved global dead code elimination (#2206) * Compiler: speedup json parsing, relying on Yojson.Raw (#1640) @@ -28,7 +29,6 @@ * Toplevel: no longer set globals for toplevel initialization * Runtime: precompute constants used in `caml_lxm_next` (#1730) * Runtime: cleanup runtime -* Runtime: add support for OCaml 5.3 ## Bug fixes * Runtime: fix parsing of unsigned integers (0u2147483648) (#1633, #1666) diff --git a/VERSION b/VERSION index 5e21ca5a8..b3d91f9cf 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.8.2 +5.9.0 From 5220982ba0cc1aa3e034226438105684f689ab35 Mon Sep 17 00:00:00 2001 From: hhugo Date: Sat, 23 Nov 2024 10:59:36 +0100 Subject: [PATCH 42/50] Misc: adjust opam constraint (#1742) --- dune-project | 2 +- js_of_ocaml-compiler.opam | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dune-project b/dune-project index e82c37fec..0407b41f3 100644 --- a/dune-project +++ b/dune-project @@ -29,7 +29,7 @@ menhir menhirLib menhirSdk - yojson) + (yojson (>= 1.6))) (depopts ocamlfind) (conflicts diff --git a/js_of_ocaml-compiler.opam b/js_of_ocaml-compiler.opam index 0a3cf50d9..131e3e5c1 100644 --- a/js_of_ocaml-compiler.opam +++ b/js_of_ocaml-compiler.opam @@ -24,7 +24,7 @@ depends: [ "menhir" "menhirLib" "menhirSdk" - "yojson" + "yojson" {>= "1.6"} "odoc" {with-doc} ] depopts: ["ocamlfind"] From 3785e99c6b1b38403bb146c91c95c6437225dc90 Mon Sep 17 00:00:00 2001 From: hhugo Date: Mon, 25 Nov 2024 15:26:24 +0100 Subject: [PATCH 43/50] Lib: small refactoring around js exception printing (#1743) --- lib/js_of_ocaml/js.ml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/js_of_ocaml/js.ml b/lib/js_of_ocaml/js.ml index e9972add3..9422def2c 100644 --- a/lib/js_of_ocaml/js.ml +++ b/lib/js_of_ocaml/js.ml @@ -812,15 +812,16 @@ let parseFloat (s : js_string t) : number_t = let s = Unsafe.fun_call Unsafe.global##.parseFloat [| Unsafe.inject s |] in if isNaN s then failwith "parseFloat" else s -let _ = - Printexc.register_printer (function - | Js_error.Exn e -> Some (Js_error.to_string e) - | _ -> None) - let _ = Printexc.register_printer (fun e -> - let e : < .. > t = Obj.magic e in - if instanceof e array_constructor then None else Some (to_string e##toString)) + if instanceof (Obj.magic e : < .. > t) error_constr + then + let e = Js_error.of_error (Obj.magic e : error t) in + Some (Js_error.to_string e) + else + match e with + | Js_error.Exn e -> Some (Js_error.to_string e) + | _ -> None) let export_js (field : js_string t) x = Unsafe.set From 3e12e52464b794663e49a109457465a711211ace Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Wed, 20 Nov 2024 17:04:41 +0100 Subject: [PATCH 44/50] CI: move --- .github/workflows/build.yml | 42 +------------------------------------ .github/workflows/lint.yml | 42 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5d4917a71..d371f1699 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -164,44 +164,4 @@ jobs: branch: wikidoc folder: doc-dev clean: true - target-folder: doc/dev/ - - lint-opam: - runs-on: ubuntu-latest - steps: - - name: Checkout tree - uses: actions/checkout@v4 - - name: Set-up OCaml - uses: ocaml/setup-ocaml@v3 - with: - ocaml-compiler: "5.2" - dune-cache: true - - name: Pin dune - run: | - opam pin add -n dune.3.17 https://github.com/ocaml/dune.git - - uses: ocaml/setup-ocaml/lint-opam@v3 - - lint-fmt: - runs-on: ubuntu-latest - steps: - - name: Checkout tree - uses: actions/checkout@v4 - - name: Set-up OCaml - uses: ocaml/setup-ocaml@v3 - with: - ocaml-compiler: "5.2" - dune-cache: true - - name: Pin dune - run: | - opam pin add -n dune.3.17 https://github.com/ocaml/dune.git - - uses: ocaml/setup-ocaml/lint-fmt@v3 - - lint-runtime: - runs-on: ubuntu-latest - steps: - - name: Checkout tree - uses: actions/checkout@v4 - - name: Set-up Biome - uses: biomejs/setup-biome@v2 - - name: Run biome - run: biome ci + target-folder: doc/dev/ \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..e912e7b97 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,42 @@ +name: lint + +on: + pull_request: + push: + branches: + - master + +jobs: + lint-opam: + runs-on: ubuntu-latest + steps: + - name: Checkout tree + uses: actions/checkout@v4 + - name: Set-up OCaml + uses: ocaml/setup-ocaml@v3 + with: + ocaml-compiler: "5.2" + dune-cache: true + - uses: ocaml/setup-ocaml/lint-opam@v3 + + lint-fmt: + runs-on: ubuntu-latest + steps: + - name: Checkout tree + uses: actions/checkout@v4 + - name: Set-up OCaml + uses: ocaml/setup-ocaml@v3 + with: + ocaml-compiler: "5.2" + dune-cache: true + - uses: ocaml/setup-ocaml/lint-fmt@v3 + + lint-runtime: + runs-on: ubuntu-latest + steps: + - name: Checkout tree + uses: actions/checkout@v4 + - name: Set-up Biome + uses: biomejs/setup-biome@v2 + - name: Run biome + run: biome ci From ae1284b138ccedb47bdb751fd95383f9f60dacd0 Mon Sep 17 00:00:00 2001 From: hhugo Date: Mon, 25 Nov 2024 15:37:20 +0100 Subject: [PATCH 45/50] Fix ci mac (#1744) --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0c9afe965..eeab8020b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -102,6 +102,7 @@ jobs: run: | brew update brew upgrade + brew unlink pkg-config@0.29.2 brew install pkgconf # work around https://github.com/actions/runner-images/issues/10984 From 825941b2f87d059ffb9c83ac6fd7611133c59247 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 18 Nov 2024 10:46:15 +0100 Subject: [PATCH 46/50] Tests: recursive value compilation --- compiler/tests-compiler/dune.inc | 15 ++++++ compiler/tests-compiler/rec.ml | 82 ++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 compiler/tests-compiler/rec.ml diff --git a/compiler/tests-compiler/dune.inc b/compiler/tests-compiler/dune.inc index 4524092ab..3bba93cd9 100644 --- a/compiler/tests-compiler/dune.inc +++ b/compiler/tests-compiler/dune.inc @@ -659,6 +659,21 @@ (preprocess (pps ppx_expect))) +(library + ;; compiler/tests-compiler/rec.ml + (name rec_15) + (enabled_if %{env:js-enabled=}) + (modules rec) + (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) + (inline_tests + (enabled_if true) + (deps + (file %{project_root}/compiler/bin-js_of_ocaml/js_of_ocaml.exe) + (file %{project_root}/compiler/bin-jsoo_minify/jsoo_minify.exe))) + (flags (:standard -open Jsoo_compiler_expect_tests_helper)) + (preprocess + (pps ppx_expect))) + (library ;; compiler/tests-compiler/scopes.ml (name scopes_15) diff --git a/compiler/tests-compiler/rec.ml b/compiler/tests-compiler/rec.ml new file mode 100644 index 000000000..216bd7c45 --- /dev/null +++ b/compiler/tests-compiler/rec.ml @@ -0,0 +1,82 @@ +(* Js_of_ocaml compiler + * http://www.ocsigen.org/js_of_ocaml/ + * Copyright (C) 2024 Hugo Heuzard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, with linking exception; + * either version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *) + +open Util + +let%expect_test "let rec" = + let p = + {| + let rec a x = + (* syntactic function *) + b x + and b = + (* non-syntactic function *) + let tbl : (int, int) Hashtbl.t = Hashtbl.create 17 in + fun x -> `T (tbl, c, a 0) + and c = + (* block *) + Some (d, default) + and d = + (* 'dynamic' value (not recursive *) + Array.make 5 0 + and default = + (* constant, with (spurious) use + of a recursive neighbor *) + let _ = a in + 42 + |} + in + let p = compile_and_parse p in + print_program p; + [%expect + {| + (function(globalThis){ + "use strict"; + var + runtime = globalThis.jsoo_runtime, + caml_update_dummy = runtime.caml_update_dummy; + function caml_call1(f, a0){ + return (f.l >= 0 ? f.l : f.l = f.length) === 1 + ? f(a0) + : runtime.caml_call_gen(f, [a0]); + } + function caml_call2(f, a0, a1){ + return (f.l >= 0 ? f.l : f.l = f.length) === 2 + ? f(a0, a1) + : runtime.caml_call_gen(f, [a0, a1]); + } + var + global_data = runtime.caml_get_global_data(), + Stdlib_Hashtbl = global_data.Stdlib__Hashtbl, + a = function _d_(_c_){return _d_.fun(_c_);}, + b = function _b_(_a_){return _b_.fun(_a_);}, + c = [], + d = runtime.caml_make_vect(5, 0), + default$0 = 42; + caml_update_dummy(a, function(x){return caml_call1(b, x);}); + var tbl = caml_call2(Stdlib_Hashtbl[1], 0, 17); + caml_update_dummy + (b, function(x){return [0, 84, [0, tbl, c, caml_call1(a, 0)]];}); + caml_update_dummy(c, [0, [0, d, default$0]]); + var Test = [0, a, b, c, d, default$0]; + runtime.caml_register_global(1, Test, "Test"); + return; + } + (globalThis)); + //end |}] From e16f8e3ee670ce4a806a2f90f0734a069f61a42c Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 26 Nov 2024 14:02:16 +0100 Subject: [PATCH 47/50] Misc: remove macos CI fix --- .github/workflows/build.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eeab8020b..78ee7afaa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -97,15 +97,6 @@ jobs: # try to install them anyways, so we save an apt-roundtrip. sudo aptitude -o Acquire::Retries=30 install gcc-multilib g++-multilib pkg-config libgmp-dev libgmp-dev:i386 libx11-dev:i386 -y - - name: macos fix - if: runner.os == 'Macos' - run: | - brew update - brew upgrade - brew unlink pkg-config@0.29.2 - brew install pkgconf - # work around https://github.com/actions/runner-images/issues/10984 - - name: Checkout tree uses: actions/checkout@v4 From 285376a5516b47f10aded71694f325a6d28b8420 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 18 Nov 2024 11:08:59 +0100 Subject: [PATCH 48/50] Tests: promote with new compilation strategy --- compiler/tests-compiler/dune.inc | 17 ++++- compiler/tests-compiler/gen-rules/gen.ml | 9 ++- compiler/tests-compiler/rec.ml | 3 +- compiler/tests-compiler/rec52.ml | 80 ++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 compiler/tests-compiler/rec52.ml diff --git a/compiler/tests-compiler/dune.inc b/compiler/tests-compiler/dune.inc index 3bba93cd9..4a4f76bf4 100644 --- a/compiler/tests-compiler/dune.inc +++ b/compiler/tests-compiler/dune.inc @@ -666,7 +666,22 @@ (modules rec) (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) (inline_tests - (enabled_if true) + (enabled_if (< %{ocaml_version} 5.2)) + (deps + (file %{project_root}/compiler/bin-js_of_ocaml/js_of_ocaml.exe) + (file %{project_root}/compiler/bin-jsoo_minify/jsoo_minify.exe))) + (flags (:standard -open Jsoo_compiler_expect_tests_helper)) + (preprocess + (pps ppx_expect))) + +(library + ;; compiler/tests-compiler/rec52.ml + (name rec52_15) + (enabled_if %{env:js-enabled=}) + (modules rec52) + (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper) + (inline_tests + (enabled_if (>= %{ocaml_version} 5.2)) (deps (file %{project_root}/compiler/bin-js_of_ocaml/js_of_ocaml.exe) (file %{project_root}/compiler/bin-jsoo_minify/jsoo_minify.exe))) diff --git a/compiler/tests-compiler/gen-rules/gen.ml b/compiler/tests-compiler/gen-rules/gen.ml index ef0415518..bee62eb18 100644 --- a/compiler/tests-compiler/gen-rules/gen.ml +++ b/compiler/tests-compiler/gen-rules/gen.ml @@ -47,6 +47,8 @@ let prefix : string = type enabled_if = | GE5 + | GE52 + | LT52 | B64 | Any @@ -58,12 +60,15 @@ let lib_enabled_if = function let test_enabled_if = function | "obj" | "lazy" -> GE5 | "gh1051" -> B64 + | "rec52" -> GE52 + | "rec" -> LT52 | _ -> Any -let enabled_if cond = - match cond with +let enabled_if = function | Any -> "true" | GE5 -> "(>= %{ocaml_version} 5)" + | GE52 -> "(>= %{ocaml_version} 5.2)" + | LT52 -> "(< %{ocaml_version} 5.2)" | B64 -> "%{arch_sixtyfour}" let js_enabled = function diff --git a/compiler/tests-compiler/rec.ml b/compiler/tests-compiler/rec.ml index 216bd7c45..a5085f4ef 100644 --- a/compiler/tests-compiler/rec.ml +++ b/compiler/tests-compiler/rec.ml @@ -79,4 +79,5 @@ let%expect_test "let rec" = return; } (globalThis)); - //end |}] + //end + |}] diff --git a/compiler/tests-compiler/rec52.ml b/compiler/tests-compiler/rec52.ml new file mode 100644 index 000000000..18d766eea --- /dev/null +++ b/compiler/tests-compiler/rec52.ml @@ -0,0 +1,80 @@ +(* Js_of_ocaml compiler + * http://www.ocsigen.org/js_of_ocaml/ + * Copyright (C) 2024 Hugo Heuzard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, with linking exception; + * either version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *) + +open Util + +let%expect_test "let rec" = + let p = + {| + let rec a x = + (* syntactic function *) + b x + and b = + (* non-syntactic function *) + let tbl : (int, int) Hashtbl.t = Hashtbl.create 17 in + fun x -> `T (tbl, c, a 0) + and c = + (* block *) + Some (d, default) + and d = + (* 'dynamic' value (not recursive *) + Array.make 5 0 + and default = + (* constant, with (spurious) use + of a recursive neighbor *) + let _ = a in + 42 + |} + in + let p = compile_and_parse p in + print_program p; + [%expect + {| + (function(globalThis){ + "use strict"; + var + runtime = globalThis.jsoo_runtime, + caml_update_dummy = runtime.caml_update_dummy; + function caml_call2(f, a0, a1){ + return (f.l >= 0 ? f.l : f.l = f.length) === 2 + ? f(a0, a1) + : runtime.caml_call_gen(f, [a0, a1]); + } + var + global_data = runtime.caml_get_global_data(), + Stdlib_Hashtbl = global_data.Stdlib__Hashtbl, + letrec_function_context = [], + c = [], + d = runtime.caml_make_vect(5, 0), + default$0 = 42; + function a(x){return b(x);} + function b(x){ + var _a_ = b(0); + return [0, 84, [0, letrec_function_context[1], c, _a_]]; + } + var tbl = caml_call2(Stdlib_Hashtbl[1], 0, 17); + caml_update_dummy(letrec_function_context, [0, tbl]); + caml_update_dummy(c, [0, [0, d, default$0]]); + var Test = [0, a, b, c, d, default$0]; + runtime.caml_register_global(1, Test, "Test"); + return; + } + (globalThis)); + //end + |}] From 5e25815f46487ad42197c4765a99566a03dd358f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Mon, 25 Nov 2024 14:55:05 +0100 Subject: [PATCH 49/50] CI: explicitly set version of all jsoo packages --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d371f1699..580e6e264 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -122,7 +122,7 @@ jobs: - run: opam install . --best-effort if: ${{ matrix.skip-test }} - - run: cat VERSION | xargs opam pin wasm_of_ocaml-compiler . -n --with-version + - run: cat VERSION | xargs opam pin . -n --with-version if: ${{ !matrix.skip-test }} shell: bash From 1f11a80561b778752857bdcd3bd2b2b5fe805f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Mon, 25 Nov 2024 14:53:53 +0100 Subject: [PATCH 50/50] Formatting --- compiler/tests-check-prim/dune | 36 ++++++---------------------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/compiler/tests-check-prim/dune b/compiler/tests-check-prim/dune index 5a0767a94..4b786374d 100644 --- a/compiler/tests-check-prim/dune +++ b/compiler/tests-check-prim/dune @@ -23,11 +23,7 @@ (action (with-stdout-to %{targets} - (run - %{bin:js_of_ocaml} - check-runtime - +dynlink.js - +toplevel.js + (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:main.bc})))) (rule @@ -41,11 +37,7 @@ (action (with-stdout-to %{targets} - (run - %{bin:js_of_ocaml} - check-runtime - +dynlink.js - +toplevel.js + (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:unix.bc})))) (rule @@ -59,11 +51,7 @@ (action (with-stdout-to %{targets} - (run - %{bin:js_of_ocaml} - check-runtime - +dynlink.js - +toplevel.js + (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:unix.bc})))) (rule @@ -75,11 +63,7 @@ (action (with-stdout-to %{targets} - (run - %{bin:js_of_ocaml} - check-runtime - +dynlink.js - +toplevel.js + (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:main.bc})))) (rule @@ -93,11 +77,7 @@ (action (with-stdout-to %{targets} - (run - %{bin:js_of_ocaml} - check-runtime - +dynlink.js - +toplevel.js + (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:unix.bc})))) (rule @@ -111,9 +91,5 @@ (action (with-stdout-to %{targets} - (run - %{bin:js_of_ocaml} - check-runtime - +dynlink.js - +toplevel.js + (run %{bin:js_of_ocaml} check-runtime +dynlink.js +toplevel.js %{dep:unix.bc}))))