Skip to content

JS: `stgToJS` allocates 4 MB byte array but comment suggests it should be 4 KB

Summary

In compiler/GHC/StgToJS/CodeGen.hs

stgToJS logger config stg_binds0 this_mod spt_entries foreign_stubs cccs output_fn = do
  ...
  bh <- openBinMem (4 * 1024 * 1000) -- a bit less than 4kB
  ...

But the comment is incorrect, this is not 4 KB, but 4 MB.

The relevant code in openBinMem is:

openBinMem :: Int -> IO WriteBinHandle
openBinMem size
   ...
   arr <- mallocForeignPtrBytes size

The comment should be updated, or openBinMem (4 * 1000) should be used.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information