Stream: general

Topic: Differentiating two Memory structs


view this post on Zulip Coulson Liang (Jun 19 2024 at 21:00):

Hi! I saw this wasmtime::runtime::vm::memory defined as a box of runtime linear memory

pub struct Memory(pub(crate) Box<dyn RuntimeLinearMemory>);

But there is also wasmtime::runtime::memory

pub struct Memory(Stored<crate::runtime::vm::ExportMemory>);

I know the first one and its implementations like MmapMemory, but what is the second struct for?

view this post on Zulip Alex Crichton (Jun 19 2024 at 21:02):

The second structure is wasmtime::Memory, the public crate export, and it points to the other basically

view this post on Zulip Alex Crichton (Jun 19 2024 at 21:02):

The first Memory used to be in a crate called wasmtime-runtime which was later merged into the wasmtime crate and we haven't gotten around to renaming everything necessarily to suit.

view this post on Zulip Coulson Liang (Jun 19 2024 at 21:14):

Oh thank you! BTW, I suppose the start address of a Linear Memory doesn't change through out it's lifetime?

view this post on Zulip Alex Crichton (Jun 19 2024 at 21:34):

It might, but it typically won't. The default settings of Wasmtime means that it won't change over time as all memories are "static" meaning we make a huge virtual memory reservation. Wasmtime can be tuned, however, to have "dynamic" memories where manual bounds checks are inserted in compiled code and in this case the base pointer of memory may move on growth


Last updated: Nov 22 2024 at 17:03 UTC