Skip to content

Commit 246f894

Browse files
ospencerphated
andauthored
feat(compiler)!: Reduce size of runtime heap (#1807)
* feat(compiler): Reduce size of runtime heap * update contrib docs --------- Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>
1 parent 8ccea28 commit 246f894

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

docs/contributor/runtime.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ When we speak of the Grain runtime, we largely mean the memory allocator, garbag
44

55
## The Runtime Heap
66

7-
Currently, the Grain runtime heap spans half a WebAssembly page of memory. The low 1K of memory is reserved for Binaryen optimizations, the next few bytes are reserved for some static pointers (which we'll go over next), and the rest of half-page is space used for runtime allocations. It's important to note that this space is unmanaged. After all, we don't have a memory manager yet—we want to compile the memory manager. Allocations are done just by incrementing a bytes counter. This means that no space can be reclaimed—as such, runtime modules should do no dynamic allocations. Ideally, the only allocations that should occur are for the closures of top-level functions that are used by other modules.
7+
Currently, the Grain runtime heap reserves 2048 bytes of WebAssembly memory. The low 1K of memory is reserved for Binaryen optimizations, the next few bytes are reserved for some static pointers (which we'll go over next), and the rest of the space is used for runtime allocations. It's important to note that this space is unmanaged. After all, we don't have a memory manager yet—we want to compile the memory manager. Allocations are done just by incrementing a bytes counter. This means that no space can be reclaimed—as such, runtime modules should do no dynamic allocations. Ideally, the only allocations that should occur are for the closures of top-level functions that are used by other modules.
88

99
## Static Runtime Pointers
1010

stdlib/runtime/malloc.gr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ let logMallocHeaderSize = 3n
7676
*/
7777
let mut heapSize = 0n
7878

79-
provide let _RESERVED_RUNTIME_SPACE = 0x4000n
79+
provide let _RESERVED_RUNTIME_SPACE = 0x800n
8080

8181
/**
8282
* The base the heap. The block at this address will be size 0 and

0 commit comments

Comments
 (0)