Kagome
Polkadot Runtime Engine in C++17
|
#include <memory_impl.hpp>
Public Member Functions | |
MemoryImpl (wasm::ShellExternalInterface::Memory *memory, std::unique_ptr< MemoryAllocator > &&allocator) | |
MemoryImpl (wasm::ShellExternalInterface::Memory *memory, WasmSize heap_base) | |
MemoryImpl (const MemoryImpl ©)=delete | |
MemoryImpl & | operator= (const MemoryImpl ©)=delete |
MemoryImpl (MemoryImpl &&move)=delete | |
MemoryImpl & | operator= (MemoryImpl &&move)=delete |
~MemoryImpl () override=default | |
WasmPointer | allocate (WasmSize size) override |
std::optional< WasmSize > | deallocate (WasmPointer ptr) override |
int8_t | load8s (WasmPointer addr) const override |
uint8_t | load8u (WasmPointer addr) const override |
int16_t | load16s (WasmPointer addr) const override |
uint16_t | load16u (WasmPointer addr) const override |
int32_t | load32s (WasmPointer addr) const override |
uint32_t | load32u (WasmPointer addr) const override |
int64_t | load64s (WasmPointer addr) const override |
uint64_t | load64u (WasmPointer addr) const override |
std::array< uint8_t, 16 > | load128 (WasmPointer addr) const override |
common::Buffer | loadN (kagome::runtime::WasmPointer addr, kagome::runtime::WasmSize n) const override |
std::string | loadStr (kagome::runtime::WasmPointer addr, kagome::runtime::WasmSize length) const override |
void | store8 (WasmPointer addr, int8_t value) override |
void | store16 (WasmPointer addr, int16_t value) override |
void | store32 (WasmPointer addr, int32_t value) override |
void | store64 (WasmPointer addr, int64_t value) override |
void | store128 (WasmPointer addr, const std::array< uint8_t, 16 > &value) override |
void | storeBuffer (kagome::runtime::WasmPointer addr, gsl::span< const uint8_t > value) override |
WasmSpan | storeBuffer (gsl::span< const uint8_t > value) override |
allocates buffer in memory and copies value into memory More... | |
void | resize (WasmSize new_size) override |
WasmSize | size () const override |
Return the size of the memory. More... | |
Public Member Functions inherited from kagome::runtime::Memory | |
virtual | ~Memory ()=default |
Private Attributes | |
wasm::ShellExternalInterface::Memory * | memory_ |
WasmSize | size_ |
std::unique_ptr< MemoryAllocator > | allocator_ |
log::Logger | logger_ |
Additional Inherited Members | |
Static Public Attributes inherited from kagome::runtime::Memory | |
static constexpr uint32_t | kMaxMemorySize |
Memory implementation for wasm environment Most code is taken from Binaryen's implementation here: https://github.com/WebAssembly/binaryen/blob/master/src/shell-interface.h#L37
Definition at line 37 of file memory_impl.hpp.
kagome::runtime::binaryen::MemoryImpl::MemoryImpl | ( | wasm::ShellExternalInterface::Memory * | memory, |
std::unique_ptr< MemoryAllocator > && | allocator | ||
) |
Definition at line 13 of file memory_impl.cpp.
kagome::runtime::binaryen::MemoryImpl::MemoryImpl | ( | wasm::ShellExternalInterface::Memory * | memory, |
WasmSize | heap_base | ||
) |
Definition at line 22 of file memory_impl.cpp.
|
delete |
|
delete |
|
overridedefault |
|
overridevirtual |
Allocates memory of given size and returns address in the memory
size | allocated memory size |
Implements kagome::runtime::Memory.
Definition at line 32 of file memory_impl.cpp.
|
overridevirtual |
Deallocates memory in provided region
ptr | address of deallocated memory |
Implements kagome::runtime::Memory.
Definition at line 36 of file memory_impl.cpp.
|
overridevirtual |
Implements kagome::runtime::Memory.
Definition at line 72 of file memory_impl.cpp.
|
overridevirtual |
Implements kagome::runtime::Memory.
Definition at line 48 of file memory_impl.cpp.
|
overridevirtual |
Implements kagome::runtime::Memory.
Definition at line 52 of file memory_impl.cpp.
|
overridevirtual |
Implements kagome::runtime::Memory.
Definition at line 56 of file memory_impl.cpp.
|
overridevirtual |
Implements kagome::runtime::Memory.
Definition at line 60 of file memory_impl.cpp.
|
overridevirtual |
Implements kagome::runtime::Memory.
Definition at line 64 of file memory_impl.cpp.
|
overridevirtual |
Implements kagome::runtime::Memory.
Definition at line 68 of file memory_impl.cpp.
|
overridevirtual |
Load integers from provided address
Implements kagome::runtime::Memory.
Definition at line 40 of file memory_impl.cpp.
|
overridevirtual |
Implements kagome::runtime::Memory.
Definition at line 44 of file memory_impl.cpp.
|
overridevirtual |
Load bytes from provided address into the buffer of size n
addr | address in memory to load bytes |
n | number of bytes to be loaded |
Implements kagome::runtime::Memory.
Definition at line 77 of file memory_impl.cpp.
|
overridevirtual |
Load string from address into buffer of size n
addr | address in memory to load bytes |
n | number of bytes |
Implements kagome::runtime::Memory.
Definition at line 88 of file memory_impl.cpp.
|
delete |
|
delete |
|
inlineoverridevirtual |
Resizes memory to the given size
new_size |
We use this condition to avoid deallocated_ pointers fixup
Implements kagome::runtime::Memory.
Definition at line 77 of file memory_impl.hpp.
|
inlineoverridevirtual |
Return the size of the memory.
Implements kagome::runtime::Memory.
Definition at line 88 of file memory_impl.hpp.
|
overridevirtual |
Implements kagome::runtime::Memory.
Definition at line 119 of file memory_impl.cpp.
|
overridevirtual |
Implements kagome::runtime::Memory.
Definition at line 104 of file memory_impl.cpp.
|
overridevirtual |
Implements kagome::runtime::Memory.
Definition at line 109 of file memory_impl.cpp.
|
overridevirtual |
Implements kagome::runtime::Memory.
Definition at line 114 of file memory_impl.cpp.
|
overridevirtual |
Store integers at given address of the wasm memory
Implements kagome::runtime::Memory.
Definition at line 99 of file memory_impl.cpp.
|
overridevirtual |
Implements kagome::runtime::Memory.
Definition at line 125 of file memory_impl.cpp.
|
overridevirtual |
allocates buffer in memory and copies value into memory
value | buffer to store |
Implements kagome::runtime::Memory.
Definition at line 134 of file memory_impl.cpp.
|
private |
Definition at line 95 of file memory_impl.hpp.
|
private |
Definition at line 97 of file memory_impl.hpp.
|
private |
Definition at line 93 of file memory_impl.hpp.
|
private |
Definition at line 94 of file memory_impl.hpp.