Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

precompute prng lxm constants #1730

Merged
merged 5 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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