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 /compiler/GHC/StgToJS/Linker | |
| 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 'compiler/GHC/StgToJS/Linker')
| -rw-r--r-- | compiler/GHC/StgToJS/Linker/Utils.hs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/GHC/StgToJS/Linker/Utils.hs b/compiler/GHC/StgToJS/Linker/Utils.hs index 539bc8e593..dcb9807db1 100644 --- a/compiler/GHC/StgToJS/Linker/Utils.hs +++ b/compiler/GHC/StgToJS/Linker/Utils.hs @@ -138,6 +138,10 @@ genCommonCppDefs profiling = mconcat then "#define MK_PTR(val,offset) (h$c2(h$baseZCGHCziPtrziPtr_con_e, (val), (offset), h$CCS_SYSTEM))\n" else "#define MK_PTR(val,offset) (h$c2(h$baseZCGHCziPtrziPtr_con_e, (val), (offset)))\n" + -- Put Addr# in ByteArray# or at Addr# (same thing) + , "#define PUT_ADDR(a,o,va,vo) if (!(a).arr) (a).arr = []; (a).arr[o] = va; (a).dv.setInt32(o,vo,true);\n" + , "#define GET_ADDR(a,o,ra,ro) var ra = (((a).arr && (a).arr[o]) ? (a).arr[o] : null_); var ro = (a).dv.getInt32(o,true);\n" + -- Data.Maybe.Maybe , "#define HS_NOTHING h$baseZCGHCziMaybeziNothing\n" , "#define IS_NOTHING(cl) ((cl).f === h$baseZCGHCziMaybeziNothing_con_e)\n" |
