1package riscv23import"gno.land/p/moul/x/vm/vmkit/v0"45// Memory is the guest's flat address space, with a snapshot that carries only6// the pages it actually touched.7//8
Functions
not supported for pure packages by the node (vm/qfuncs)
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.
// The shape is the one the bf ladder argued for. Running memory is a flat
9// []byte because a load or a store happens on a large fraction of instructions
10// and an avl lookup per access would dominate the interpreter the way
11// vmkit.Meter.Charge did there. Snapshot cost is solved separately, by a dirty
12// bitmap: a program that writes one page pauses in one page, not in a megabyte,
13// which is the same trick that lets a bf hello world pause in 43 bytes.
14//
15// That answers the open question on the design issue ("memory size versus
16// snapshot cost") without paying for it on every instruction.
17const (
18// PageSize is the snapshot granularity, not an MMU page: there is no
19// address translation here, only bookkeeping about what changed.
20 PageSize = 4096
21
22// MemSize is the address space. 1 MiB is far more than a no_std guest
23// needs and small enough that the flat allocation is not the cost.
24 MemSize = 1 << 20
25
26 pageCount = MemSize / PageSize
27)
28
29// Memory is a flat address space plus the record of which pages were written.