|
Wasmtime
|
A WebAssembly linear memory. More...
#include <memory.hh>
Public Member Functions | |
| Memory (wasmtime_memory_t memory) | |
| Creates a new memory from the raw underlying C API representation. | |
| MemoryType | type (Store::Context cx) const |
| Returns the type of this memory. | |
| uint64_t | size (Store::Context cx) const |
| Returns the size, in WebAssembly pages, of this memory. | |
| Span< uint8_t > | data (Store::Context cx) const |
| Result< uint64_t > | grow (Store::Context cx, uint64_t delta) const |
| uint64_t | page_size (Store::Context cx) const |
| uint8_t | page_size_log2 (Store::Context cx) const |
| const wasmtime_memory_t & | capi () const |
| Returns the raw underlying C API memory this is using. | |
Static Public Member Functions | |
| static Result< Memory > | create (Store::Context cx, const MemoryType &ty) |
| Creates a new host-defined memory with the type specified. | |
Friends | |
| class | Instance |
A WebAssembly linear memory.
This class represents a WebAssembly memory, either created through instantiating a module or a host memory.
Note that this type does not itself own any resources. It points to resources owned within a Store and the Store must be passed in as the first argument to the functions defined on Table. Note that if the wrong Store is passed in then the process will be aborted.
|
inline |
Returns a span of where this memory is located in the host.
Note that embedders need to be very careful in their usage of the returned span. It can be invalidated with calls to grow and/or calls into WebAssembly.
|
inline |
Grows the memory by delta WebAssembly pages.
On success returns the previous size of this memory in units of WebAssembly pages.
|
inline |
Returns the size of a page, in bytes, for this memory.
WebAssembly memories are made up of a whole number of pages, so the byte size will always be a multiple of their page size. Different Wasm memories may have different page sizes.
By default this is 64KiB (aka 0x10000, 2**16, 1<<16, or 65536) but the custom-page-sizes proposal allows opting into a page size of 1. Future extensions might allow any power of two as a page size.
|
inline |
Returns the log2 of this memory's page size, in bytes.
WebAssembly memories are made up of a whole number of pages, so the byte size will always be a multiple of their page size. Different Wasm memories may have different page sizes.
By default the page size is 64KiB (aka 0x10000, 2**16, 1<<16, or 65536) but the custom-page-sizes proposal allows opting into a page size of 1. Future extensions might allow any power of two as a page size.