From 3b671288c38ac867d32fabdf1e89db5bbbdba38b Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 23 Sep 2024 13:17:44 +0200 Subject: [PATCH] Runtime: add support for OCaml 5.3 --- compiler/lib/generate.ml | 1 + runtime/array.js | 58 ++++++++++++++++++++++++++++++++++------ runtime/domain.js | 7 +++++ runtime/stdlib.js | 6 +++++ 4 files changed, 64 insertions(+), 8 deletions(-) diff --git a/compiler/lib/generate.ml b/compiler/lib/generate.ml index 15b239d751..4535394bc1 100644 --- a/compiler/lib/generate.ml +++ b/compiler/lib/generate.ml @@ -2051,6 +2051,7 @@ let init () = ; "caml_check_bound_float", "caml_check_bound" ; "caml_alloc_dummy_float", "caml_alloc_dummy" ; "caml_make_array", "%identity" + ; "caml_array_of_uniform_array", "%identity" ; "caml_ensure_stack_capacity", "%identity" ; "caml_js_from_float", "%identity" ; "caml_js_to_float", "%identity" diff --git a/runtime/array.js b/runtime/array.js index 95f44e78b2..e276c1e409 100644 --- a/runtime/array.js +++ b/runtime/array.js @@ -27,6 +27,13 @@ function caml_array_sub(a, i, len) { return a2; } +//Provides: caml_floatarray_sub mutable +//Requires: caml_array_sub +//Version: >= 5.3 +function caml_floatarray_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, @@ -41,6 +48,13 @@ function caml_array_append(a1, a2) { return a; } +//Provides: caml_floatarray_append mutable +//Requires: caml_array_append +//Version: >= 5.3 +function caml_floatarray_append(a1, a2) { + return caml_array_append(a1, a2); +} + //Provides: caml_array_concat mutable function caml_array_concat(l) { var a = [0]; @@ -63,13 +77,9 @@ function caml_array_blit(a1, i1, a2, i2, len) { } //Provides: caml_floatarray_blit +//Requires: caml_array_blit function caml_floatarray_blit(a1, i1, a2, i2, len) { - if (i2 <= i1) { - for (var j = 1; j <= len; j++) a2[i2 + j] = a1[i1 + j]; - } else { - for (var j = len; j >= 1; j--) a2[i2 + j] = a1[i1 + j]; - } - return 0; + return caml_array_blit(a1, i1, a2, i2, len); } ///////////// Pervasive @@ -96,6 +106,13 @@ function caml_array_fill(array, ofs, len, v) { return 0; } +//Provides: caml_floatarray_fill +//Requires: caml_array_fill +//Version: >= 5.3 +function caml_floatarray_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) { @@ -103,9 +120,9 @@ function caml_check_bound(array, index) { return array; } -//Provides: caml_make_vect const (const, mutable) +//Provides: caml_array_make const (const, mutable) //Requires: caml_array_bound_error -function caml_make_vect(len, init) { +function caml_array_make(len, init) { if (len < 0) caml_array_bound_error(); var len = (len + 1) | 0; var b = new Array(len); @@ -114,6 +131,12 @@ function caml_make_vect(len, init) { return b; } +//Provides: caml_make_vect const (const, mutable) +//Requires: caml_array_make +function caml_make_vect(len, init) { + return caml_array_make(len, init); +} + //Provides: caml_make_float_vect const (const) //Requires: caml_array_bound_error function caml_make_float_vect(len) { @@ -124,6 +147,18 @@ function caml_make_float_vect(len) { for (var i = 1; i < len; i++) b[i] = 0; return b; } + +//Provides: caml_array_create_float const (const) +//Requires: caml_array_bound_error +//Version: >= 5.3 +function caml_array_create_float(len) { + if (len < 0) caml_array_bound_error(); + var len = (len + 1) | 0; + var b = new Array(len); + b[0] = 254; + for (var i = 1; i < len; i++) b[i] = 0; + return b; +} //Provides: caml_floatarray_create const (const) //Requires: caml_array_bound_error function caml_floatarray_create(len) { @@ -134,3 +169,10 @@ function caml_floatarray_create(len) { for (var i = 1; i < len; i++) b[i] = 0; return b; } + +//Provides: caml_floatarray_make const (const) +//Requires: caml_array_make +//Version: >= 5.3 +function caml_floatarray_make(len, init) { + return caml_array_make(len, init); +} diff --git a/runtime/domain.js b/runtime/domain.js index 55c7638bba..d441b2d0d4 100644 --- a/runtime/domain.js +++ b/runtime/domain.js @@ -72,6 +72,13 @@ function caml_recommended_domain_count(unit) { return 1; } +//Provides: caml_ml_domain_index +//Requires: caml_domain_id +//Version: >= 5.03 +function caml_ml_domain_index(unit) { + return caml_domain_id; +} + //Provides: caml_domain_id var caml_domain_id = 0; diff --git a/runtime/stdlib.js b/runtime/stdlib.js index 3e878681cf..30c394248f 100644 --- a/runtime/stdlib.js +++ b/runtime/stdlib.js @@ -196,3 +196,9 @@ function caml_is_printable(c) { function caml_maybe_print_stats(unit) { return 0; } + +//Provides: caml_process_pending_actions_with_root +//Version: >= 5.3 +function caml_process_pending_actions_with_root(extra_root) { + return 0; +}