Struct wasmtime_runtime::MemoryImageSlot
source · pub struct MemoryImageSlot { /* private fields */ }
Expand description
A single slot handled by the copy-on-write memory initialization mechanism.
The mmap scheme is:
base ==> (points here)
- (image.offset bytes) anonymous zero memory, pre-image
- (image.len bytes) CoW mapping of memory image
- (up to static_size) anonymous zero memory, post-image
The ordering of mmaps to set this up is:
-
once, when pooling allocator is created:
- one large mmap to create 8GiB * instances * memories slots
-
per instantiation of new image in a slot:
- mmap of anonymous zero memory, from 0 to max heap size (static_size)
- mmap of CoW’d image, from
image.offset
toimage.offset + image.len
. This overwrites part of the anonymous zero memory, potentially splitting it into a pre- and post-region. - mprotect(PROT_NONE) on the part of the heap beyond the initial heap size; we re-mprotect it with R+W bits when the heap is grown.