summaryrefslogtreecommitdiff
path: root/rts/js/string.js
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2023-04-27 16:58:21 +0200
committerSylvain Henry <sylvain@haskus.fr>2023-05-03 10:55:20 +0200
commiteed582b504a14b307bef635b25a10e2ce2c9110e (patch)
treef252e1540d5d293d486d5993de9de7e264c86650 /rts/js/string.js
parent0646d828de9c45e2bd0b83cd5367798af4cdb8f2 (diff)
downloadhaskell-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/string.js')
-rw-r--r--rts/js/string.js41
1 files changed, 0 insertions, 41 deletions
diff --git a/rts/js/string.js b/rts/js/string.js
index da5e0c610e..fd76e4405d 100644
--- a/rts/js/string.js
+++ b/rts/js/string.js
@@ -602,47 +602,6 @@ function h$hs_iconv_close(iconv) {
return 0;
}
-// ptr* -> ptr (array)
-function h$derefPtrA(ptr, ptr_off) {
- return ptr.arr[ptr_off][0];
-}
-// ptr* -> ptr (offset)
-function h$derefPtrO(ptr, ptr_off) {
- return ptr.arr[ptr_off][1];
-}
-
-// word** -> word ptr[x][y]
-function h$readPtrPtrU32(ptr, ptr_off, x, y) {
- x = x || 0;
- y = y || 0;
- var arr = ptr.arr[ptr_off + 4 * x];
- return arr[0].dv.getInt32(arr[1] + 4 * y, true);
-}
-
-// char** -> char ptr[x][y]
-function h$readPtrPtrU8(ptr, ptr_off, x, y) {
- x = x || 0;
- y = y || 0;
- var arr = ptr.arr[ptr_off + 4 * x];
- return arr[0].dv.getUint8(arr[1] + y);
-}
-
-// word** ptr[x][y] = v
-function h$writePtrPtrU32(ptr, ptr_off, v, x, y) {
- x = x || 0;
- y = y || 0;
- var arr = ptr.arr[ptr_off + 4 * x];
- arr[0].dv.putInt32(arr[1] + y, v);
-}
-
-// unsigned char** ptr[x][y] = v
-function h$writePtrPtrU8(ptr, ptr_off, v, x, y) {
- x = x || 0;
- y = y || 0;
- var arr = ptr.arr[ptr_off+ 4 * x];
- arr[0].dv.putUint8(arr[1] + y, v);
-}
-
// convert JavaScript String to a Haskell String
#ifdef GHCJS_PROF
function h$toHsString(str, cc) {