6 #ifndef KAGOME_RUNTIME_BINARYEN_WASM_MEMORY_IMPL_HPP 7 #define KAGOME_RUNTIME_BINARYEN_WASM_MEMORY_IMPL_HPP 9 #include <binaryen/shell-interface.h> 15 #include <unordered_map> 17 #include <binaryen/wasm.h> 25 class MemoryAllocator;
39 MemoryImpl(wasm::ShellExternalInterface::Memory *memory,
40 std::unique_ptr<MemoryAllocator> &&allocator);
41 MemoryImpl(wasm::ShellExternalInterface::Memory *memory,
71 const std::array<uint8_t, 16> &value)
override;
73 gsl::span<const uint8_t> value)
override;
82 if (new_size >=
size_) {
93 wasm::ShellExternalInterface::Memory *
memory_;
101 #endif // KAGOME_RUNTIME_BINARYEN_WASM_MEMORY_IMPL_HPP
Class represents arbitrary (including empty) byte buffer.
uint32_t load32u(WasmPointer addr) const override
MemoryImpl & operator=(const MemoryImpl ©)=delete
uint32_t WasmSize
Size type is uint32_t because we are working in 32 bit address space.
void store64(WasmPointer addr, int64_t value) override
uint8_t load8u(WasmPointer addr) const override
void storeBuffer(kagome::runtime::WasmPointer addr, gsl::span< const uint8_t > value) override
int8_t load8s(WasmPointer addr) const override
std::string loadStr(kagome::runtime::WasmPointer addr, kagome::runtime::WasmSize length) const override
void store128(WasmPointer addr, const std::array< uint8_t, 16 > &value) override
uint64_t load64u(WasmPointer addr) const override
void store8(WasmPointer addr, int8_t value) override
int64_t load64s(WasmPointer addr) const override
~MemoryImpl() override=default
std::shared_ptr< soralog::Logger > Logger
wasm::ShellExternalInterface::Memory * memory_
void resize(WasmSize new_size) override
uint64_t WasmSpan
combination of pointer and size, where less significant part represents wasm pointer, and most significant represents size
std::optional< WasmSize > deallocate(WasmPointer ptr) override
std::unique_ptr< MemoryAllocator > allocator_
uint32_t WasmPointer
type of wasm memory is 32 bit integer
WasmPointer allocate(WasmSize size) override
int16_t load16s(WasmPointer addr) const override
uint16_t load16u(WasmPointer addr) const override
MemoryImpl(wasm::ShellExternalInterface::Memory *memory, std::unique_ptr< MemoryAllocator > &&allocator)
common::Buffer loadN(kagome::runtime::WasmPointer addr, kagome::runtime::WasmSize n) const override
void store32(WasmPointer addr, int32_t value) override
void store16(WasmPointer addr, int16_t value) override
std::array< uint8_t, 16 > load128(WasmPointer addr) const override
WasmSize size() const override
Return the size of the memory.
int32_t load32s(WasmPointer addr) const override