[Git][ghc/ghc][wip/win32-high-heap] rts: Allocate MBlocks with MAP_TOP_DOWN on Windows

Ben Gamari gitlab at gitlab.haskell.org
Wed Nov 25 16:25:18 UTC 2020



Ben Gamari pushed to branch wip/win32-high-heap at Glasgow Haskell Compiler / GHC


Commits:
839255bc by Ben Gamari at 2020-11-25T11:25:13-05:00
rts: Allocate MBlocks with MAP_TOP_DOWN on Windows

As noted in #18991, we would previously allocate heap in low memory.
Due to this the linker, which typically *needs* low memory, would end up
competing with the heap. In longer builds we end up running out of
low memory entirely, leading to linking failures.

- - - - -


1 changed file:

- rts/win32/OSMem.c


Changes:

=====================================
rts/win32/OSMem.c
=====================================
@@ -50,8 +50,11 @@ allocNew(uint32_t n) {
     alloc_rec* rec;
     rec = (alloc_rec*)stgMallocBytes(sizeof(alloc_rec),"getMBlocks: allocNew");
     rec->size = ((W_)n+1)*MBLOCK_SIZE;
+    // N.B. We use MEM_TOP_DOWN here to ensure that we leave the bottom of the
+    // address space available for the linker and libraries, which in general
+    // want to live in low memory. See #18991.
     rec->base =
-        VirtualAlloc(NULL, rec->size, MEM_RESERVE, PAGE_READWRITE);
+        VirtualAlloc(NULL, rec->size, MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE);
     if(rec->base==0) {
         stgFree((void*)rec);
         rec=0;



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/839255bc7ce4f5472144185766ad206350c14c3d

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/839255bc7ce4f5472144185766ad206350c14c3d
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20201125/c8c22dc9/attachment.html>


More information about the ghc-commits mailing list