Skip to content

Commit

Permalink
Runtime: precompute prng lxm constants (#1730)
Browse files Browse the repository at this point in the history
Co-authored-by: Hugo Heuzard <hugo.heuzard@gmail.com>
  • Loading branch information
TyOverby and hhugo authored Nov 6, 2024
1 parent e67805e commit 3fa88ec
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions compiler/tests-check-prim/main.output
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions compiler/tests-check-prim/unix-unix.output
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions compiler/tests-check-prim/unix-win32.output
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 17 additions & 4 deletions runtime/js/prng.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3fa88ec

Please sign in to comment.