From 44ea9d908173ebc271a293062adafb1b470538a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Tue, 12 May 2026 13:08:43 +0200 Subject: [PATCH 1/4] Oxcaml: add block index primitives --- .../js_of_ocaml_compiler_runtime_files.ml | 1 + compiler/lib-runtime-files/tests/all.ml | 2 + compiler/tests-check-prim/main.5.2+ox.output | 5 +- .../tests-check-prim/unix-Unix.5.2+ox.output | 5 +- runtime/js/block_index.js | 88 ++++++++ runtime/wasm/block_index.wat | 191 ++++++++++++++++++ 6 files changed, 290 insertions(+), 2 deletions(-) create mode 100644 runtime/js/block_index.js create mode 100644 runtime/wasm/block_index.wat diff --git a/compiler/lib-runtime-files/js_of_ocaml_compiler_runtime_files.ml b/compiler/lib-runtime-files/js_of_ocaml_compiler_runtime_files.ml index 8cb9815ec53..f390594b814 100644 --- a/compiler/lib-runtime-files/js_of_ocaml_compiler_runtime_files.ml +++ b/compiler/lib-runtime-files/js_of_ocaml_compiler_runtime_files.ml @@ -23,6 +23,7 @@ let runtime = ; backtrace ; bigarray ; bigstring + ; block_index ; compare ; fail ; format diff --git a/compiler/lib-runtime-files/tests/all.ml b/compiler/lib-runtime-files/tests/all.ml index db51141780e..b6a3014208a 100644 --- a/compiler/lib-runtime-files/tests/all.ml +++ b/compiler/lib-runtime-files/tests/all.ml @@ -16,6 +16,7 @@ let%expect_test _ = +bigarray.js +bigstring.js +blake2.js + +block_index.js +compare.js +domain.js +dynlink.js @@ -63,6 +64,7 @@ let%expect_test _ = +bigarray.js +bigstring.js +blake2.js + +block_index.js +compare.js +domain.js +effect.js diff --git a/compiler/tests-check-prim/main.5.2+ox.output b/compiler/tests-check-prim/main.5.2+ox.output index 560bb929cc7..edb3436f497 100644 --- a/compiler/tests-check-prim/main.5.2+ox.output +++ b/compiler/tests-check-prim/main.5.2+ox.output @@ -137,7 +137,6 @@ caml_bytes_setf32_indexed_by_int64 caml_bytes_setf32_indexed_by_int8 caml_bytes_setf32_indexed_by_nativeint caml_continuation_use -caml_deepen_idx_bytecode caml_drop_continuation caml_dynamic_get caml_dynamic_make @@ -259,6 +258,10 @@ caml_bigstring_blit_string_to_ba caml_bigstring_memcmp caml_hash_mix_bigstring +From +block_index.js: +caml_get_idx_bytecode +caml_set_idx_bytecode + From +effect.js: caml_continuation_use_and_update_handler_noexc jsoo_effect_not_supported diff --git a/compiler/tests-check-prim/unix-Unix.5.2+ox.output b/compiler/tests-check-prim/unix-Unix.5.2+ox.output index 689f0c86e3e..6a95d444245 100644 --- a/compiler/tests-check-prim/unix-Unix.5.2+ox.output +++ b/compiler/tests-check-prim/unix-Unix.5.2+ox.output @@ -137,7 +137,6 @@ caml_bytes_setf32_indexed_by_int64 caml_bytes_setf32_indexed_by_int8 caml_bytes_setf32_indexed_by_nativeint caml_continuation_use -caml_deepen_idx_bytecode caml_drop_continuation caml_dynamic_get caml_dynamic_make @@ -335,6 +334,10 @@ caml_bigstring_blit_string_to_ba caml_bigstring_memcmp caml_hash_mix_bigstring +From +block_index.js: +caml_get_idx_bytecode +caml_set_idx_bytecode + From +effect.js: caml_continuation_use_and_update_handler_noexc jsoo_effect_not_supported diff --git a/runtime/js/block_index.js b/runtime/js/block_index.js new file mode 100644 index 00000000000..694218c742d --- /dev/null +++ b/runtime/js/block_index.js @@ -0,0 +1,88 @@ +// Js_of_ocaml runtime support +// http://www.ocsigen.org/js_of_ocaml/ +// +// 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. + +///////////// Block indices +// In bytecode, JSOO, and WASM, valid block indices are represented as tag-0 +// blocks containing the sequence of field positions. +// +// On JSOO, blocks are arrays whose [0] element is the tag and whose subsequent +// elements are the fields. +// +// For more information on block indices and their bytecode representation, see +// https://github.com/oxcaml/oxcaml/blob/main/jane/doc/extensions/_03-unboxed-types/03-block-indices.md#representation-of-block-indices +// +// We additionally adopt the convention in JSOO that some known-invalid indices +// are represented as a tag-1 block whose only field is the number of times the +// pointer has been advanced. Reads/writes from/to such an index raise. +// +// Our motivation for permitting a representation of these invalid indices is +// that pointers should generally be safe to create and manipulate, and the +// only points of unsafety should be reads and writes. + +//Provides: caml_get_idx_bytecode mutable (mutable, const) +//Requires: caml_invalid_argument +//Version: >= 5.2, < 5.3 +//OxCaml +function caml_get_idx_bytecode(base, idx) { + if (idx[0] !== 0) { + caml_invalid_argument( + "caml_get_idx_bytecode: attempted to read from an invalid index", + ); + } + var depth = idx.length - 1; + var res = base; + for (var i = 1; i <= depth; i++) { + res = res[idx[i] + 1]; + } + return res; +} + +//Provides: caml_set_idx_bytecode (mutable, const, mutable) +//Requires: caml_invalid_argument +//Version: >= 5.2, < 5.3 +//OxCaml +function caml_set_idx_bytecode(base, idx, v) { + if (idx[0] !== 0) { + caml_invalid_argument( + "caml_set_idx_bytecode: attempted to write to an invalid index", + ); + } + var depth = idx.length - 1; + var dst = base; + for (var i = 1; i < depth; i++) { + dst = dst[idx[i] + 1]; + } + dst[idx[depth] + 1] = v; + return 0; +} + +//Provides: caml_deepen_idx_bytecode const (const, const) +//Version: >= 5.2, < 5.3 +//OxCaml +function caml_deepen_idx_bytecode(idx_prefix, idx_suffix) { + var prefix_depth = idx_prefix.length - 1; + var suffix_depth = idx_suffix.length - 1; + var block = new Array(1 + prefix_depth + suffix_depth); + block[0] = 0; + for (var i = 0; i < prefix_depth; i++) { + block[1 + i] = idx_prefix[1 + i]; + } + for (var i = 0; i < suffix_depth; i++) { + block[1 + prefix_depth + i] = idx_suffix[1 + i]; + } + return block; +} diff --git a/runtime/wasm/block_index.wat b/runtime/wasm/block_index.wat new file mode 100644 index 00000000000..9ab2e126598 --- /dev/null +++ b/runtime/wasm/block_index.wat @@ -0,0 +1,191 @@ +;; Wasm_of_ocaml runtime support +;; http://www.ocsigen.org/js_of_ocaml/ +;; +;; 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. + +(module + (import "fail" "caml_invalid_argument" (func $caml_invalid_argument (param (ref eq)))) + + (type $block (array (mut (ref eq)))) + (type $string (array (mut i8))) + (type $float (struct (field f64))) + (type $float_array (array (mut f64))) + + (data $invalid_get_idx + "caml_get_idx_bytecode: attempted to read from an invalid index") + (data $invalid_set_idx + "caml_set_idx_bytecode: attempted to write to an invalid index") + + ;; caml_get_idx_bytecode : base -> idx -> result + ;; idx is a block (tag 0) of integer field positions. + ;; Iterates through the positions, indexing into nested blocks. + ;; Special case: if base is a float array (all-float record), box the result. + ;; Raises if [idx] has a non-zero tag (an "invalid" index). + (func (export "caml_get_idx_bytecode") + (param $base (ref eq)) (param $idx (ref eq)) (result (ref eq)) + (local $idx_block (ref $block)) + (local $depth i32) + (local $i i32) + (local $pos i32) + (local $res (ref eq)) + (local $fa (ref $float_array)) + (local.set $idx_block (ref.cast (ref $block) (local.get $idx))) + (local.set $depth + (i32.sub (array.len (local.get $idx_block)) (i32.const 1))) + ;; Invalid (non-zero-tag) index: raise. + (if (i32.ne + (i31.get_s + (ref.cast (ref i31) + (array.get $block (local.get $idx_block) (i32.const 0)))) + (i32.const 0)) + (then + (call $caml_invalid_argument + (array.new_data $string $invalid_get_idx + (i32.const 0) (i32.const 62))))) + ;; Float array case: base is $float_array, depth must be 1 + (drop (block $not_float_array (result (ref eq)) + (local.set $fa + (br_on_cast_fail $not_float_array (ref eq) (ref $float_array) + (local.get $base))) + (local.set $pos + (i31.get_s + (ref.cast (ref i31) + (array.get $block (local.get $idx_block) (i32.const 1))))) + (return + (struct.new $float + (array.get $float_array (local.get $fa) (local.get $pos)))))) + ;; General case: iterate through block fields + (local.set $res (local.get $base)) + (local.set $i (i32.const 1)) + (loop $loop + (if (i32.le_u (local.get $i) (local.get $depth)) + (then + (local.set $pos + (i31.get_s + (ref.cast (ref i31) + (array.get $block (local.get $idx_block) + (local.get $i))))) + (local.set $res + (array.get $block + (ref.cast (ref $block) (local.get $res)) + (i32.add (local.get $pos) (i32.const 1)))) + (local.set $i (i32.add (local.get $i) (i32.const 1))) + (br $loop)))) + (local.get $res)) + + ;; caml_set_idx_bytecode : base -> idx -> value -> unit + ;; idx is a block (tag 0) of integer field positions. + ;; Traverses to the parent block, then sets the final field. + ;; Special case: if base is a float array (all-float record), unbox the value. + ;; Raises if [idx] has a non-zero tag (an "invalid" index). + (func (export "caml_set_idx_bytecode") + (param $base (ref eq)) (param $idx (ref eq)) (param $v (ref eq)) + (result (ref eq)) + (local $idx_block (ref $block)) + (local $depth i32) + (local $i i32) + (local $pos i32) + (local $dst (ref eq)) + (local $fa (ref $float_array)) + (local.set $idx_block (ref.cast (ref $block) (local.get $idx))) + (local.set $depth + (i32.sub (array.len (local.get $idx_block)) (i32.const 1))) + ;; Invalid (non-zero-tag) index: raise. + (if (i32.ne + (i31.get_s + (ref.cast (ref i31) + (array.get $block (local.get $idx_block) (i32.const 0)))) + (i32.const 0)) + (then + (call $caml_invalid_argument + (array.new_data $string $invalid_set_idx + (i32.const 0) (i32.const 61))))) + ;; Float array case: base is $float_array, depth must be 1 + (drop (block $not_float_array (result (ref eq)) + (local.set $fa + (br_on_cast_fail $not_float_array (ref eq) (ref $float_array) + (local.get $base))) + (local.set $pos + (i31.get_s + (ref.cast (ref i31) + (array.get $block (local.get $idx_block) (i32.const 1))))) + (array.set $float_array (local.get $fa) (local.get $pos) + (struct.get $float 0 (ref.cast (ref $float) (local.get $v)))) + (return (ref.i31 (i32.const 0))))) + ;; General case + (local.set $dst (local.get $base)) + (local.set $i (i32.const 1)) + ;; Traverse to the parent (all but the last position) + (loop $loop + (if (i32.lt_u (local.get $i) (local.get $depth)) + (then + (local.set $pos + (i31.get_s + (ref.cast (ref i31) + (array.get $block (local.get $idx_block) + (local.get $i))))) + (local.set $dst + (array.get $block + (ref.cast (ref $block) (local.get $dst)) + (i32.add (local.get $pos) (i32.const 1)))) + (local.set $i (i32.add (local.get $i) (i32.const 1))) + (br $loop)))) + ;; Set the final field + (local.set $pos + (i31.get_s + (ref.cast (ref i31) + (array.get $block (local.get $idx_block) + (local.get $depth))))) + (array.set $block + (ref.cast (ref $block) (local.get $dst)) + (i32.add (local.get $pos) (i32.const 1)) + (local.get $v)) + (ref.i31 (i32.const 0))) + + ;; caml_deepen_idx_bytecode : idx_prefix -> idx_suffix -> idx + ;; Concatenates two block indices into a new one. + (func (export "caml_deepen_idx_bytecode") + (param $idx_prefix (ref eq)) (param $idx_suffix (ref eq)) + (result (ref eq)) + (local $prefix (ref $block)) + (local $suffix (ref $block)) + (local $prefix_depth i32) + (local $suffix_depth i32) + (local $result (ref $block)) + (local.set $prefix (ref.cast (ref $block) (local.get $idx_prefix))) + (local.set $suffix (ref.cast (ref $block) (local.get $idx_suffix))) + (local.set $prefix_depth + (i32.sub (array.len (local.get $prefix)) (i32.const 1))) + (local.set $suffix_depth + (i32.sub (array.len (local.get $suffix)) (i32.const 1))) + ;; Allocate result block: tag 0, size = prefix_depth + suffix_depth + (local.set $result + (array.new $block (ref.i31 (i32.const 0)) + (i32.add + (i32.add (local.get $prefix_depth) (local.get $suffix_depth)) + (i32.const 1)))) + ;; Copy prefix fields + (array.copy $block $block + (local.get $result) (i32.const 1) + (local.get $prefix) (i32.const 1) + (local.get $prefix_depth)) + ;; Copy suffix fields + (array.copy $block $block + (local.get $result) + (i32.add (local.get $prefix_depth) (i32.const 1)) + (local.get $suffix) (i32.const 1) + (local.get $suffix_depth)) + (local.get $result)) +) From 155f1515b9e834ff67faa6b8e47580a309aae6c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Tue, 12 May 2026 13:09:17 +0200 Subject: [PATCH 2/4] Oxcaml: add stubs for caml_max_domain_count Introduced in oxcaml/oxcaml#5522. --- compiler/tests-check-prim/main.5.2+ox.output | 3 +++ compiler/tests-check-prim/unix-Unix.5.2+ox.output | 3 +++ runtime/js/domain.js | 7 +++++++ runtime/wasm/domain.wat | 4 ++++ 4 files changed, 17 insertions(+) diff --git a/compiler/tests-check-prim/main.5.2+ox.output b/compiler/tests-check-prim/main.5.2+ox.output index edb3436f497..34ce30e7930 100644 --- a/compiler/tests-check-prim/main.5.2+ox.output +++ b/compiler/tests-check-prim/main.5.2+ox.output @@ -262,6 +262,9 @@ From +block_index.js: caml_get_idx_bytecode caml_set_idx_bytecode +From +domain.js: +caml_max_domain_count + From +effect.js: caml_continuation_use_and_update_handler_noexc jsoo_effect_not_supported diff --git a/compiler/tests-check-prim/unix-Unix.5.2+ox.output b/compiler/tests-check-prim/unix-Unix.5.2+ox.output index 6a95d444245..81367b65a41 100644 --- a/compiler/tests-check-prim/unix-Unix.5.2+ox.output +++ b/compiler/tests-check-prim/unix-Unix.5.2+ox.output @@ -338,6 +338,9 @@ From +block_index.js: caml_get_idx_bytecode caml_set_idx_bytecode +From +domain.js: +caml_max_domain_count + From +effect.js: caml_continuation_use_and_update_handler_noexc jsoo_effect_not_supported diff --git a/runtime/js/domain.js b/runtime/js/domain.js index e06742791b7..1430640ab68 100644 --- a/runtime/js/domain.js +++ b/runtime/js/domain.js @@ -188,6 +188,13 @@ function caml_recommended_domain_count(_unit) { return 1; } +//Provides: caml_max_domain_count +//Version: >= 5.2, < 5.3 +//OxCaml +function caml_max_domain_count(_unit) { + return 1; +} + //Provides: caml_ml_domain_index //Requires: caml_domain_id //Version: >= 5.03 diff --git a/runtime/wasm/domain.wat b/runtime/wasm/domain.wat index 719e3c85670..f3a6ec866cc 100644 --- a/runtime/wasm/domain.wat +++ b/runtime/wasm/domain.wat @@ -239,6 +239,10 @@ (param (ref eq)) (result (ref eq)) (ref.i31 (i32.const 1))) + (func (export "caml_max_domain_count") + (param (ref eq)) (result (ref eq)) + (ref.i31 (i32.const 1))) + (global $caml_domain_id (export "caml_domain_id") (mut i32) (i32.const 0)) (global $caml_domain_latest_id (export "caml_domain_latest_id") (mut i32) (i32.const 1)) From 1925b6fb10cd1d67cfdeec045f25ba78655b9164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Thu, 18 Jun 2026 16:12:58 +0200 Subject: [PATCH 3/4] Oxcaml: add oxcaml flag in the JavaScript linker --- compiler/lib/linker.ml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/lib/linker.ml b/compiler/lib/linker.ml index d17823cb608..0a00573bd3f 100644 --- a/compiler/lib/linker.ml +++ b/compiler/lib/linker.ml @@ -197,11 +197,16 @@ module Fragment = struct ; deprecated : string option } + let oxcaml = true [@@if oxcaml] + + let oxcaml = false [@@if not oxcaml] + let allowed_flags = List.fold_left ~f:(fun m (k, v) -> StringMap.add k v m) ~init:StringMap.empty [ "js-string", Config.Flag.use_js_string + ; ("oxcaml", fun () -> oxcaml) ; ( "effects" , fun () -> match Config.effects () with From 13189066731b57e5f064a0d031c46d2c7bc67615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Thu, 18 Jun 2026 16:39:17 +0200 Subject: [PATCH 4/4] Oxcaml: gate oxcaml-specific runtime primitives on //If: oxcaml Convert the //OxCaml marker comments into //If: oxcaml linker conditions, and relax their version constraints from ">= 5.2, < 5.3" to ">= 5.2". Fragments whose primitive also has a higher-version sibling keep an upper bound that tiles with it (< 5.4 for atomic field / sys primitives, < 5.5 for the Gc.Tweak stubs) so OCaml 5.4 is covered without duplicate-provides conflicts. --- runtime/js/array.js | 2 +- runtime/js/block_index.js | 12 +- runtime/js/domain.js | 90 +++++++------- runtime/js/effect.js | 4 +- runtime/js/fail.js | 4 +- runtime/js/float32.js | 256 +++++++++++++++++++------------------- runtime/js/gc.js | 18 +-- runtime/js/hash.js | 4 +- runtime/js/int64.js | 16 +-- runtime/js/ints.js | 12 +- runtime/js/obj.js | 16 +-- runtime/js/stdlib.js | 4 +- runtime/js/sys.js | 28 ++--- 13 files changed, 233 insertions(+), 233 deletions(-) diff --git a/runtime/js/array.js b/runtime/js/array.js index bb1688863d9..a965b0197e8 100644 --- a/runtime/js/array.js +++ b/runtime/js/array.js @@ -234,7 +234,7 @@ function caml_array_create_float(len) { //Provides: caml_array_create_float const (const) //Requires: caml_array_bound_error //Version: >= 5.2, < 5.3 -//OxCaml +//If: oxcaml function caml_array_create_float(len) { if (len >>> 0 >= ((0x7fffffff / 8) | 0)) caml_array_bound_error(); var len = (len + 1) | 0; diff --git a/runtime/js/block_index.js b/runtime/js/block_index.js index 694218c742d..4ec7974db94 100644 --- a/runtime/js/block_index.js +++ b/runtime/js/block_index.js @@ -35,8 +35,8 @@ //Provides: caml_get_idx_bytecode mutable (mutable, const) //Requires: caml_invalid_argument -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_get_idx_bytecode(base, idx) { if (idx[0] !== 0) { caml_invalid_argument( @@ -53,8 +53,8 @@ function caml_get_idx_bytecode(base, idx) { //Provides: caml_set_idx_bytecode (mutable, const, mutable) //Requires: caml_invalid_argument -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_set_idx_bytecode(base, idx, v) { if (idx[0] !== 0) { caml_invalid_argument( @@ -71,8 +71,8 @@ function caml_set_idx_bytecode(base, idx, v) { } //Provides: caml_deepen_idx_bytecode const (const, const) -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_deepen_idx_bytecode(idx_prefix, idx_suffix) { var prefix_depth = idx_prefix.length - 1; var suffix_depth = idx_suffix.length - 1; diff --git a/runtime/js/domain.js b/runtime/js/domain.js index 1430640ab68..7ebd23eedba 100644 --- a/runtime/js/domain.js +++ b/runtime/js/domain.js @@ -27,14 +27,14 @@ function caml_domain_dls_get(_unit) { } //Provides: caml_domain_tls -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml var caml_domain_tls = [0]; //Provides: caml_domain_tls_set //Requires: caml_domain_tls -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_domain_tls_set(a) { caml_domain_tls = a; return 0; @@ -42,8 +42,8 @@ function caml_domain_tls_set(a) { //Provides: caml_domain_tls_get //Requires: caml_domain_tls -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_domain_tls_get(_unit) { return caml_domain_tls; } @@ -81,8 +81,8 @@ function caml_atomic_cas_field(b, i, o, n) { } //Provides: caml_atomic_compare_exchange -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_atomic_compare_exchange(ref, o, n) { var old = ref[1]; if (old === o) ref[1] = n; @@ -106,40 +106,40 @@ function caml_atomic_fetch_add_field(b, i, n) { } //Provides: caml_atomic_add -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_atomic_add(ref, i) { ref[1] += i; return 0; } //Provides: caml_atomic_sub -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_atomic_sub(ref, i) { ref[1] -= i; return 0; } //Provides: caml_atomic_land -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_atomic_land(ref, i) { ref[1] &= i; return 0; } //Provides: caml_atomic_lor -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_atomic_lor(ref, i) { ref[1] |= i; return 0; } //Provides: caml_atomic_lxor -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_atomic_lxor(ref, i) { ref[1] ^= i; return 0; @@ -162,8 +162,8 @@ function caml_atomic_exchange_field(b, i, v) { } //Provides: caml_atomic_set -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_atomic_set(ref, v) { ref[1] = v; return 0; @@ -189,8 +189,8 @@ function caml_recommended_domain_count(_unit) { } //Provides: caml_max_domain_count -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_max_domain_count(_unit) { return 1; } @@ -205,7 +205,7 @@ function caml_ml_domain_index(_unit) { //Provides: caml_ml_domain_index //Requires: caml_domain_id //Version: >= 5.2, < 5.3 -//OxCaml +//If: oxcaml function caml_ml_domain_index(_unit) { return caml_domain_id; } @@ -305,23 +305,23 @@ function caml_domain_count(_unit) { } //Provides: caml_atomic_load_field -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2, < 5.4 +//If: oxcaml function caml_atomic_load_field(ref, field) { return ref[field + 1]; } //Provides: caml_atomic_add_field -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_atomic_add_field(ref, field, i) { ref[field + 1] += i; return 0; } //Provides: caml_atomic_fetch_add_field -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2, < 5.4 +//If: oxcaml function caml_atomic_fetch_add_field(ref, field, i) { var old = ref[field + 1]; ref[field + 1] += i; @@ -329,8 +329,8 @@ function caml_atomic_fetch_add_field(ref, field, i) { } //Provides: caml_atomic_cas_field -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2, < 5.4 +//If: oxcaml function caml_atomic_cas_field(ref, field, o, n) { if (ref[field + 1] === o) { ref[field + 1] = n; @@ -340,8 +340,8 @@ function caml_atomic_cas_field(ref, field, o, n) { } //Provides: caml_atomic_compare_exchange_field -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_atomic_compare_exchange_field(ref, field, o, n) { var old = ref[field + 1]; if (old === o) { @@ -351,16 +351,16 @@ function caml_atomic_compare_exchange_field(ref, field, o, n) { } //Provides: caml_atomic_set_field -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_atomic_set_field(ref, field, v) { ref[field + 1] = v; return 0; } //Provides: caml_atomic_exchange_field -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2, < 5.4 +//If: oxcaml function caml_atomic_exchange_field(ref, field, v) { var old = ref[field + 1]; ref[field + 1] = v; @@ -368,32 +368,32 @@ function caml_atomic_exchange_field(ref, field, v) { } //Provides: caml_atomic_sub_field -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_atomic_sub_field(ref, field, i) { ref[field + 1] -= i; return 0; } //Provides: caml_atomic_land_field -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_atomic_land_field(ref, field, i) { ref[field + 1] &= i; return 0; } //Provides: caml_atomic_lor_field -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_atomic_lor_field(ref, field, i) { ref[field + 1] |= i; return 0; } //Provides: caml_atomic_lxor_field -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_atomic_lxor_field(ref, field, i) { ref[field + 1] ^= i; return 0; diff --git a/runtime/js/effect.js b/runtime/js/effect.js index 99f770807f9..c2d85033ac5 100644 --- a/runtime/js/effect.js +++ b/runtime/js/effect.js @@ -267,8 +267,8 @@ function caml_continuation_use_and_update_handler_noexc( } //Provides: caml_continuation_update_handler_noexc -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_continuation_update_handler_noexc(cont, hval, hexn, heff) { var stack = cont[1]; if (stack === 0) return cont; diff --git a/runtime/js/fail.js b/runtime/js/fail.js index 037c3cc544e..0ad1f8cfa13 100644 --- a/runtime/js/fail.js +++ b/runtime/js/fail.js @@ -84,8 +84,8 @@ function caml_array_bound_error() { //Provides: caml_no_bytecode_impl //Requires: caml_failwith -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_no_bytecode_impl() { caml_failwith("No bytecode implementation provided for this external"); } diff --git a/runtime/js/float32.js b/runtime/js/float32.js index 6f789ea1034..597e8719c48 100644 --- a/runtime/js/float32.js +++ b/runtime/js/float32.js @@ -12,231 +12,231 @@ */ //Provides: caml_float_of_float32 const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_float_of_float32(x) { return x; } //Provides: caml_float32_of_float const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_float32_of_float(x) { return Math.fround(x); } //Provides: caml_float32_of_int const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_float32_of_int(x) { return Math.fround(x); } //Provides: caml_int_of_float32 const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_int_of_float32(x) { return x | 0; } //Provides: caml_float32_of_bits_bytecode const //Requires: caml_int32_float_of_bits -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml const caml_float32_of_bits_bytecode = caml_int32_float_of_bits; //Provides: caml_float32_to_bits_bytecode const //Requires: caml_int32_bits_of_float -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml const caml_float32_to_bits_bytecode = caml_int32_bits_of_float; //Provides: caml_float32_of_int64_bytecode const //Requires: caml_int64_to_float -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_float32_of_int64_bytecode(x) { return Math.fround(caml_int64_to_float(x)); } //Provides: caml_float32_to_int64_bytecode const //Requires: caml_int64_of_float -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml const caml_float32_to_int64_bytecode = caml_int64_of_float; //Provides: caml_float32_of_string (const) //Requires: caml_parse_float -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_float32_of_string(x) { return Math.fround(caml_parse_float(x, "float32_of_string")); } //Provides: caml_format_float32 const //Requires: caml_format_float -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml const caml_format_float32 = caml_format_float; //Provides: caml_float32_compare const //Requires: caml_float_compare -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml const caml_float32_compare = caml_float_compare; //Provides: caml_add_float32 const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_add_float32(x, y) { return Math.fround(x + y); } //Provides: caml_sub_float32 const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_sub_float32(x, y) { return Math.fround(x - y); } //Provides: caml_mul_float32 const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_mul_float32(x, y) { return Math.fround(x * y); } //Provides: caml_div_float32 const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_div_float32(x, y) { return Math.fround(x / y); } //Provides: caml_fmod_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_fmod_float32_bytecode(x, y) { return Math.fround(x % y); } //Provides: caml_neg_float32 const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_neg_float32(x) { return -x; // Result is exact } //Provides: caml_abs_float32 const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_abs_float32(x) { return Math.abs(x); // Result is exact } //Provides: caml_modf_float32 const //Requires: caml_modf_float -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml const caml_modf_float32 = caml_modf_float; // Result is exact //Provides: caml_acos_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_acos_float32_bytecode(x) { return Math.fround(Math.acos(x)); } //Provides: caml_asin_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_asin_float32_bytecode(x) { return Math.fround(Math.asin(x)); } //Provides: caml_atan_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_atan_float32_bytecode(x) { return Math.fround(Math.atan(x)); } //Provides: caml_atan2_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_atan2_float32_bytecode(x, y) { return Math.fround(Math.atan2(x, y)); } //Provides: caml_ceil_float32_bytecode const //Alias: caml_simd_float32_round_pos_inf_bytecode -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_ceil_float32_bytecode(x) { return Math.fround(Math.ceil(x)); } //Provides: caml_cos_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_cos_float32_bytecode(x) { return Math.fround(Math.cos(x)); } //Provides: caml_exp_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_exp_float32_bytecode(x) { return Math.fround(Math.exp(x)); } //Provides: caml_floor_float32_bytecode const //Alias: caml_simd_float32_round_neg_inf_bytecode -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_floor_float32_bytecode(x) { return Math.fround(Math.floor(x)); } //Provides: caml_log_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_log_float32_bytecode(x) { return Math.fround(Math.log(x)); } //Provides: caml_power_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_power_float32_bytecode(x, y) { return Math.fround(Math.pow(x, y)); } //Provides: caml_sin_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_sin_float32_bytecode(x) { return Math.fround(Math.sin(x)); } //Provides: caml_sqrt_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_sqrt_float32_bytecode(x) { return Math.fround(Math.sqrt(x)); } //Provides: caml_tan_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_tan_float32_bytecode(x) { return Math.fround(Math.tan(x)); } //Provides: caml_nextafter_float32_bytecode const //Requires: caml_int32_bits_of_float, caml_int32_float_of_bits -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_nextafter_float32_bytecode(x, y) { if (Number.isNaN(x) || Number.isNaN(y)) return Number.NaN; if (x === y) return y; @@ -252,15 +252,15 @@ function caml_nextafter_float32_bytecode(x, y) { //Provides: caml_trunc_float32_bytecode const //Alias: caml_simd_float32_round_towards_zero_bytecode -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_trunc_float32_bytecode(x) { return Math.fround(Math.trunc(x)); } //Provides: caml_classify_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_classify_float32_bytecode(x) { if (Number.isFinite(x)) { if (Math.abs(x) >= 1.1754943508222875e-38) return 0; @@ -272,110 +272,110 @@ function caml_classify_float32_bytecode(x) { //Provides: caml_ldexp_float32_bytecode const //Requires: caml_ldexp_float -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_ldexp_float32_bytecode(x, y) { return Math.fround(caml_ldexp_float(x, y)); } //Provides: caml_frexp_float32 const //Requires: caml_frexp_float -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml const caml_frexp_float32 = caml_frexp_float; // Result is exact //Provides: caml_copysign_float32_bytecode const //Requires: caml_copysign_float -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml const caml_copysign_float32_bytecode = caml_copysign_float; // Result is exact //Provides: caml_signbit_float32_bytecode const //Requires: caml_signbit_float -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml const caml_signbit_float32_bytecode = caml_signbit_float; //Provides: caml_expm1_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_expm1_float32_bytecode(x) { return Math.fround(Math.expm1(x)); } //Provides: caml_exp2_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_exp2_float32_bytecode(x) { return Math.fround(Math.pow(2, x)); } //Provides: caml_log1p_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_log1p_float32_bytecode(x) { return Math.fround(Math.log1p(x)); } //Provides: caml_log2_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_log2_float32_bytecode(x) { return Math.fround(Math.log2(x)); } //Provides: caml_hypot_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_hypot_float32_bytecode(x, y) { return Math.fround(Math.hypot(x, y)); } //Provides: caml_log10_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_log10_float32_bytecode(x) { return Math.fround(Math.log10(x)); } //Provides: caml_cosh_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_cosh_float32_bytecode(x) { return Math.fround(Math.cosh(x)); } //Provides: caml_acosh_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_acosh_float32_bytecode(x) { return Math.fround(Math.acosh(x)); } //Provides: caml_sinh_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_sinh_float32_bytecode(x) { return Math.fround(Math.sinh(x)); } //Provides: caml_asinh_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_asinh_float32_bytecode(x) { return Math.fround(Math.asinh(x)); } //Provides: caml_tanh_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_tanh_float32_bytecode(x) { return Math.fround(Math.tanh(x)); } //Provides: caml_atanh_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_atanh_float32_bytecode(x) { return Math.fround(Math.atanh(x)); } @@ -383,46 +383,46 @@ function caml_atanh_float32_bytecode(x) { //Provides: caml_round_float32_bytecode const //Requires: caml_round_float //Alias: caml_simd_float32_round_current_bytecode -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_round_float32_bytecode(x) { return Math.fround(caml_round_float(x)); } //Provides: caml_cbrt_float32_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_cbrt_float32_bytecode(x) { return Math.fround(Math.cbrt(x)); } //Provides: caml_erf_float32_bytecode const //Requires: caml_erf_float -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_erf_float32_bytecode(x) { return Math.fround(caml_erf_float(x)); } //Provides: caml_erfc_float32_bytecode const //Requires: caml_erfc_float -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_erfc_float32_bytecode(x) { return Math.fround(caml_erfc_float(x)); } //Provides: caml_fma_float32_bytecode const //Requires: caml_fma_float -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_fma_float32_bytecode(x, y, z) { return Math.fround(caml_fma_float(x, y, z)); } //Provides: caml_simd_float32_min_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml // Mirrors x86 MINSS: returns y when the comparison fails (NaN or equal, // including ±0), unlike Math.min which propagates NaN and treats -0 < +0. function caml_simd_float32_min_bytecode(x, y) { @@ -430,8 +430,8 @@ function caml_simd_float32_min_bytecode(x, y) { } //Provides: caml_simd_float32_max_bytecode const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml // Mirrors x86 MAXSS; see caml_simd_float32_min_bytecode. function caml_simd_float32_max_bytecode(x, y) { return x > y ? x : y; @@ -439,48 +439,48 @@ function caml_simd_float32_max_bytecode(x, y) { //Provides: caml_simd_cast_float32_int64_bytecode const //Requires: caml_int64_of_float -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_simd_cast_float32_int64_bytecode(x) { return caml_int64_of_float(Math.round(x)); } //Provides: caml_ba_uint8_getf32 //Requires: caml_ba_uint8_get32, caml_float32_of_bits_bytecode -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_ba_uint8_getf32(ba, i) { return caml_float32_of_bits_bytecode(caml_ba_uint8_get32(ba, i)); } //Provides: caml_ba_uint8_setf32 //Requires: caml_ba_uint8_set32, caml_float32_to_bits_bytecode -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_ba_uint8_setf32(ba, i, v) { return caml_ba_uint8_set32(ba, i, caml_float32_to_bits_bytecode(v)); } //Provides: caml_string_getf32 //Requires: caml_string_get32, caml_float32_of_bits_bytecode -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_string_getf32(ba, i) { return caml_float32_of_bits_bytecode(caml_string_get32(ba, i)); } //Provides: caml_bytes_getf32 //Requires: caml_bytes_get32, caml_float32_of_bits_bytecode -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_bytes_getf32(ba, i) { return caml_float32_of_bits_bytecode(caml_bytes_get32(ba, i)); } //Provides: caml_bytes_setf32 //Requires: caml_bytes_set32, caml_float32_to_bits_bytecode -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_bytes_setf32(ba, i, v) { return caml_bytes_set32(ba, i, caml_float32_to_bits_bytecode(v)); } diff --git a/runtime/js/gc.js b/runtime/js/gc.js index 52e4e091817..1582193b04a 100644 --- a/runtime/js/gc.js +++ b/runtime/js/gc.js @@ -103,8 +103,8 @@ function caml_memprof_is_sampling(_unit) { } //Provides: caml_memprof_participate -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_memprof_participate(_config) { return 0; } @@ -159,15 +159,15 @@ function caml_get_major_credit(_n) { //Provides: caml_gc_tweak_get //Requires: caml_invalid_argument //Version: >= 5.5 -//OxCaml +//If: oxcaml function caml_gc_tweak_get(_name) { caml_invalid_argument("Gc.Tweak: parameter not found"); } //Provides: caml_gc_tweak_get //Requires: caml_invalid_argument -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2, < 5.5 +//If: oxcaml function caml_gc_tweak_get(_name) { caml_invalid_argument("Gc.Tweak: parameter not found"); } @@ -181,8 +181,8 @@ function caml_gc_tweak_set(_name, _v) { //Provides: caml_gc_tweak_set //Requires: caml_invalid_argument -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2, < 5.5 +//If: oxcaml function caml_gc_tweak_set(_name, _value) { caml_invalid_argument("Gc.Tweak: parameter not found"); } @@ -194,8 +194,8 @@ function caml_gc_tweak_list_active(_unit) { } //Provides: caml_gc_tweak_list_active -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2, < 5.5 +//If: oxcaml function caml_gc_tweak_list_active(_unit) { return 0; } diff --git a/runtime/js/hash.js b/runtime/js/hash.js index 7efff5924db..c629ea429be 100644 --- a/runtime/js/hash.js +++ b/runtime/js/hash.js @@ -262,8 +262,8 @@ function caml_hash(count, limit, seed, obj) { //Provides: caml_hash_exn //Requires: caml_hash -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml var caml_hash_exn = caml_hash; //Provides: caml_string_hash diff --git a/runtime/js/int64.js b/runtime/js/int64.js index e691ef58951..d0026ab2dcd 100644 --- a/runtime/js/int64.js +++ b/runtime/js/int64.js @@ -356,8 +356,8 @@ function caml_int64_to_int32(x) { //Provides: caml_checked_int64_to_int //Requires: caml_int64_of_int32, caml_array_bound_error -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_checked_int64_to_int(x) { var y = x.toInt(); if (x.compare(caml_int64_of_int32(y)) !== 0) caml_array_bound_error(); @@ -365,15 +365,15 @@ function caml_checked_int64_to_int(x) { } //Provides: caml_array_unsafe_get_indexed_by_int64 mutable (mutable, const) -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_array_unsafe_get_indexed_by_int64(array, index) { return array[index.toInt() + 1]; } //Provides: caml_array_unsafe_set_indexed_by_int64 (mutable, const, mutable) -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_array_unsafe_set_indexed_by_int64(array, index, newval) { array[index.toInt() + 1] = newval; return 0; @@ -507,8 +507,8 @@ function caml_int64_hash(v) { //Provides: caml_reinterpret_unboxed_int64_as_tagged_int63 //Requires: caml_failwith -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_reinterpret_unboxed_int64_as_tagged_int63(_v) { caml_failwith( "caml_reinterpret_unboxed_int64_as_tagged_int63 is not supported in javascript.", diff --git a/runtime/js/ints.js b/runtime/js/ints.js index fd7924894d1..52eac02ad0b 100644 --- a/runtime/js/ints.js +++ b/runtime/js/ints.js @@ -135,8 +135,8 @@ function caml_int_of_string(s) { //Provides: caml_parse_small_int //Requires: caml_ml_string_length, caml_string_unsafe_get //Requires: caml_parse_sign_and_base, caml_parse_digit, caml_failwith -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_parse_small_int(err_msg, width, s) { var r = caml_parse_sign_and_base(s); var i = r[0], @@ -175,16 +175,16 @@ function caml_parse_small_int(err_msg, width, s) { //Provides: caml_int8_of_string (const) //Requires: caml_parse_small_int -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_int8_of_string(s) { return caml_parse_small_int("Int8.of_string", 8, s); } //Provides: caml_int16_of_string (const) //Requires: caml_parse_small_int -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_int16_of_string(s) { return caml_parse_small_int("Int16.of_string", 16, s); } diff --git a/runtime/js/obj.js b/runtime/js/obj.js index f7decb9d993..fb0268f4d8e 100644 --- a/runtime/js/obj.js +++ b/runtime/js/obj.js @@ -65,23 +65,23 @@ function caml_update_dummy_lazy(dummy, newval) { } //Provides: caml_obj_is_stack -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_obj_is_stack(_x) { return 0; } //Provides: caml_succ_scannable_prefix_len -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_succ_scannable_prefix_len(_x) { return 0; } //Provides: caml_obj_uniquely_reachable_words //Requires: caml_failwith -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_obj_uniquely_reachable_words(_x) { caml_failwith("Obj.uniquely_reachable_words is not available in javascript."); } @@ -333,8 +333,8 @@ function caml_ml_gc_ramp_down(_suspended_collection_work) { //Provides: caml_int_as_pointer //Requires: caml_failwith -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_int_as_pointer(i) { // Special-case null pointers for [or_null]. if (i === 0) return null; diff --git a/runtime/js/stdlib.js b/runtime/js/stdlib.js index 9e148191c98..8834638b59e 100644 --- a/runtime/js/stdlib.js +++ b/runtime/js/stdlib.js @@ -356,8 +356,8 @@ function caml_maybe_print_stats(_unit) { //Provides: caml_with_async_exns //Requires: caml_callback -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_with_async_exns(body_callback) { return caml_callback(body_callback, [0]); } diff --git a/runtime/js/sys.js b/runtime/js/sys.js index a82c0e010cb..919bfcea03a 100644 --- a/runtime/js/sys.js +++ b/runtime/js/sys.js @@ -158,8 +158,8 @@ function caml_sys_getenv_opt(name) { //Requires: caml_string_of_jsstring //Requires: caml_jsstring_of_string //Requires: jsoo_sys_getenv -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2, < 5.4 +//If: oxcaml function caml_sys_getenv_opt(name) { var r = jsoo_sys_getenv(caml_jsstring_of_string(name)); if (r === undefined) return 0; @@ -361,36 +361,36 @@ function caml_sys_isatty(chan) { } //Provides: caml_sys_const_runtime5 const -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_sys_const_runtime5(_unit) { return 1; } //Provides: arch -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml var arch = globalThis.process?.arch === "arm64" ? "arm64" : "amd64"; //Provides: caml_sys_const_arch_amd64 const //Requires: arch -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_sys_const_arch_amd64(_unit) { return arch === "amd64" ? 1 : 0; } //Provides: caml_sys_const_arch_arm64 const //Requires: arch -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_sys_const_arch_arm64(_unit) { return arch === "arm64" ? 1 : 0; } //Provides: caml_is_boot_compiler -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2 +//If: oxcaml function caml_is_boot_compiler(_unit) { return 0; } @@ -458,8 +458,8 @@ function caml_sys_io_buffer_size(_unit) { //Provides: caml_sys_io_buffer_size //Requires: caml_io_buffer_size -//Version: >= 5.2, < 5.3 -//OxCaml +//Version: >= 5.2, < 5.4 +//If: oxcaml function caml_sys_io_buffer_size(_unit) { return caml_io_buffer_size; }