6 #ifndef KAGOME_CORE_RUNTIME_COMMON_MEMORY_ALLOCATOR_HPP 7 #define KAGOME_CORE_RUNTIME_COMMON_MEMORY_ALLOCATOR_HPP 10 #include <unordered_map> 38 return math::roundUp<kAlignment>(t);
54 std::optional<WasmSize> deallocate(
WasmPointer ptr);
58 return offset_ > addr and offset_ - addr >=
sizeof(T);
62 return offset_ > addr and offset_ - addr >= size;
66 std::optional<WasmSize> getDeallocatedChunkSize(
WasmPointer ptr)
const;
67 std::optional<WasmSize> getAllocatedChunkSize(
WasmPointer ptr)
const;
68 size_t getAllocatedChunksNum()
const;
69 size_t getDeallocatedChunksNum()
const;
110 #endif // KAGOME_CORE_RUNTIME_COMMON_MEMORY_ALLOCATOR_HPP std::function< size_t()> getSize
uint32_t WasmSize
Size type is uint32_t because we are working in 32 bit address space.
std::function< void(size_t)> resize
std::unordered_map< WasmPointer, WasmSize > allocated_
constexpr size_t kDefaultHeapBase
static constexpr T roundUpAlign(T t)
std::map< WasmPointer, WasmSize > deallocated_
std::shared_ptr< soralog::Logger > Logger
bool checkAddress(WasmPointer addr, size_t size) noexcept
uint32_t WasmPointer
type of wasm memory is 32 bit integer
constexpr uint8_t kAlignment
bool checkAddress(WasmPointer addr) noexcept