diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2023-04-27 16:58:21 +0200 |
---|---|---|
committer | Sylvain Henry <sylvain@haskus.fr> | 2023-05-03 10:55:20 +0200 |
commit | eed582b504a14b307bef635b25a10e2ce2c9110e (patch) | |
tree | f252e1540d5d293d486d5993de9de7e264c86650 /rts/js/staticpointer.js | |
parent | 0646d828de9c45e2bd0b83cd5367798af4cdb8f2 (diff) | |
download | haskell-wip/js-boundsCheck.tar.gz |
Fix remaining issues with bound checking (#23123)wip/js-boundsCheck
While fixing these I've also changed the way we store addresses into
ByteArray#. Addr# are composed of two parts: a JavaScript array and an
offset (32-bit number).
Suppose we want to store an Addr# in a ByteArray# foo at offset i.
Before this patch, we were storing both fields as a tuple in the "arr"
array field:
foo.arr[i] = [addr_arr, addr_offset];
Now we only store the array part in the "arr" field and the offset
directly in the array:
foo.dv.setInt32(i, addr_offset):
foo.arr[i] = addr_arr;
It avoids wasting space for the tuple.
Diffstat (limited to 'rts/js/staticpointer.js')
-rw-r--r-- | rts/js/staticpointer.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/rts/js/staticpointer.js b/rts/js/staticpointer.js index 9733490df5..80eda18dff 100644 --- a/rts/js/staticpointer.js +++ b/rts/js/staticpointer.js @@ -16,7 +16,7 @@ function h$hs_spt_insert(key1,key2,key3,key4,ref) { ba.i3[1] = key1; ba.i3[2] = key4; ba.i3[3] = key3; - h$static_pointer_table_keys.push([ba,0]); + h$static_pointer_table_keys.push(ba); h$retain({ root: ref, _key: -1 }); } var s = h$static_pointer_table; @@ -33,8 +33,9 @@ function h$hs_spt_key_count() { function h$hs_spt_keys(tgt_d, tgt_o, n) { var ks = h$static_pointer_table_keys; - if(!tgt_d.arr) tgt_d.arr = []; - for(var i=0;(i<n&&i<ks.length);i++) tgt_d.arr[tgt_o+4*i] = ks[i]; + for(var i=0;(i<n&&i<ks.length);i++) { + PUT_ADDR(tgt_d, tgt_o+4*i, ks[i], 0); + } return Math.min(n,ks.length); } |