Skip to content

Commit

Permalink
Runtime: add support for OCaml 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Sep 23, 2024
1 parent ac48804 commit 3b67128
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 8 deletions.
1 change: 1 addition & 0 deletions compiler/lib/generate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
58 changes: 50 additions & 8 deletions runtime/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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];
Expand All @@ -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
Expand All @@ -96,16 +106,23 @@ 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) {
if (index >>> 0 >= array.length - 1) caml_array_bound_error();
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);
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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);
}
7 changes: 7 additions & 0 deletions runtime/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 6 additions & 0 deletions runtime/stdlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 3b67128

Please sign in to comment.