13 std::unique_ptr<MemoryAllocator> &&allocator)
14 : allocator_{std::move(allocator)},
24 std::make_unique<MemoryAllocator>(
27 [
this]() {
return size(); }},
40 return load<int8_t>(addr);
43 return load<uint8_t>(addr);
46 return load<int16_t>(addr);
49 return load<uint16_t>(addr);
52 return load<int32_t>(addr);
55 return load<uint32_t>(addr);
58 return load<int64_t>(addr);
61 return load<uint64_t>(addr);
64 auto byte_array = loadArray<uint8_t>(addr, 16);
65 std::array<uint8_t, 16> array;
66 std::copy_n(byte_array, 16, array.begin());
73 auto byte_array = loadArray<uint8_t>(addr, n);
81 for (
auto i = addr; i < addr + n; i++) {
82 res.push_back(load<uint8_t>(i));
89 store<int8_t>(addr, value);
92 store<int16_t>(addr, value);
95 store<int32_t>(addr, value);
98 store<int64_t>(addr, value);
101 const std::array<uint8_t, 16> &value) {
105 gsl::span<const uint8_t> value) {
110 auto wasm_pointer =
allocate(value.size());
111 if (wasm_pointer == 0) {
115 auto res =
PtrSize(wasm_pointer, value.size()).combine();
void store16(WasmPointer addr, int16_t value) override
Class represents arbitrary (including empty) byte buffer.
WasmSize size() const override
Return the size of the memory.
uint8_t load8u(WasmPointer addr) const override
int32_t load32s(WasmPointer addr) const override
uint32_t WasmSize
Size type is uint32_t because we are working in 32 bit address space.
WAVM::Runtime::Memory * memory_
void storeBuffer(WasmPointer addr, gsl::span< const uint8_t > value) override
int8_t load8s(WasmPointer addr) const override
uint16_t load16u(WasmPointer addr) const override
#define SL_TRACE_FUNC_CALL(logger, ret,...)
void store64(WasmPointer addr, int64_t value) override
WasmPointer allocate(WasmSize size) override
std::array< uint8_t, 16 > load128(WasmPointer addr) const override
void store32(WasmPointer addr, int32_t value) override
common::Buffer loadN(WasmPointer addr, WasmSize n) const override
uint32_t load32u(WasmPointer addr) const override
int64_t load64s(WasmPointer addr) const override
void resize(WasmSize new_size) override
constexpr size_t kInitialMemorySize
void store128(WasmPointer addr, const std::array< uint8_t, 16 > &value) override
MemoryImpl(WAVM::Runtime::Memory *memory, std::unique_ptr< MemoryAllocator > &&allocator)
uint64_t WasmSpan
combination of pointer and size, where less significant part represents wasm pointer, and most significant represents size
void storeArray(WasmPointer addr, gsl::span< T > array)
uint32_t WasmPointer
type of wasm memory is 32 bit integer
int16_t load16s(WasmPointer addr) const override
Logger createLogger(const std::string &tag)
std::unique_ptr< MemoryAllocator > allocator_
std::optional< WasmSize > deallocate(WasmPointer ptr) override
uint64_t load64u(WasmPointer addr) const override
std::string loadStr(WasmPointer addr, WasmSize n) const override
void store8(WasmPointer addr, int8_t value) override