mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
Data Structures | Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Private Attributes
m::WasmEngine Struct Referenceabstract

A WasmEngine provides an environment to compile and execute WebAssembly modules. More...

#include <WebAssembly.hpp>

Collaboration diagram for m::WasmEngine:
[legend]

Data Structures

struct  WasmContext
 A WasmContext holds associated information of a WebAssembly module instance. More...
 

Public Member Functions

 WasmEngine ()=default
 
virtual ~WasmEngine ()
 
 WasmEngine (const WasmEngine &)=delete
 
 WasmEngine (WasmEngine &&)=default
 
virtual void compile (const MatchBase &plan) const =0
 Compiles the already computed physical covering represented by plan using this WasmEngine.
 
virtual void execute (const MatchBase &plan)=0
 Executes the already computed physical covering represented by plan using this WasmEngine.
 

Static Public Member Functions

static WasmContextCreate_Wasm_Context_For_ID (unsigned id, const MatchBase &plan, WasmContext::config_t configuration=WasmContext::config_t(0x0), std::size_t size=WASM_MAX_MEMORY)
 Creates a new WasmContext for ID id with size bytes of virtual address space.
 
static std::pair< std::reference_wrapper< WasmContext >, bool > Ensure_Wasm_Context_For_ID (unsigned id, const MatchBase &plan, WasmContext::config_t configuration=WasmContext::config_t(0x0), std::size_t size=WASM_MAX_MEMORY)
 If none exists, creates a new WasmContext for ID id with size bytes of virtual address space.
 
static void Dispose_Wasm_Context (unsigned id)
 Disposes the WasmContext with ID id.
 
static void Dispose_Wasm_Context (const WasmContext &ctx)
 Disposes the WasmContext ctx.
 
static WasmContextGet_Wasm_Context_By_ID (unsigned id)
 Returns a reference to the WasmContext with ID id.
 
static bool Has_Wasm_Context (unsigned id)
 Tests if the WasmContext with ID id exists.
 

Static Public Attributes

static constexpr std::size_t WASM_PAGE_SIZE = 1UL << 16
 the size of a WebAssembly memory page, 64 KiB.
 
static constexpr std::size_t WASM_MAX_MEMORY = (1UL << 32) - (1UL << 16)
 The maximum memory of a WebAssembly module: 2^32 - 2^16 bytes ≈ 4 GiB.
 
static constexpr std::size_t WASM_ALIGNMENT = 8
 The alignment that is suitable for all built-in types.
 

Static Private Attributes

static std::unordered_map< unsigned, std::unique_ptr< WasmContext > > contexts_
 

‍maps unique IDs to WasmContext instances


 

Detailed Description

A WasmEngine provides an environment to compile and execute WebAssembly modules.

Definition at line 16 of file WebAssembly.hpp.

Constructor & Destructor Documentation

◆ WasmEngine() [1/3]

m::WasmEngine::WasmEngine ( )
default

◆ ~WasmEngine()

virtual m::WasmEngine::~WasmEngine ( )
inlinevirtual

Definition at line 116 of file WebAssembly.hpp.

◆ WasmEngine() [2/3]

m::WasmEngine::WasmEngine ( const WasmEngine )
delete

◆ WasmEngine() [3/3]

m::WasmEngine::WasmEngine ( WasmEngine &&  )
default

Member Function Documentation

◆ compile()

virtual void m::WasmEngine::compile ( const MatchBase plan) const
pure virtual

Compiles the already computed physical covering represented by plan using this WasmEngine.

◆ Create_Wasm_Context_For_ID()

static WasmContext & m::WasmEngine::Create_Wasm_Context_For_ID ( unsigned  id,
const MatchBase plan,
WasmContext::config_t  configuration = WasmContext::config_t(0x0),
std::size_t  size = WASM_MAX_MEMORY 
)
inlinestatic

Creates a new WasmContext for ID id with size bytes of virtual address space.

Definition at line 71 of file WebAssembly.hpp.

References contexts_, and M_insist.

◆ Dispose_Wasm_Context() [1/2]

static void m::WasmEngine::Dispose_Wasm_Context ( const WasmContext ctx)
inlinestatic

Disposes the WasmContext ctx.

Definition at line 103 of file WebAssembly.hpp.

References Dispose_Wasm_Context(), and m::WasmEngine::WasmContext::id.

Referenced by Dispose_Wasm_Context().

◆ Dispose_Wasm_Context() [2/2]

static void m::WasmEngine::Dispose_Wasm_Context ( unsigned  id)
inlinestatic

Disposes the WasmContext with ID id.

Definition at line 96 of file WebAssembly.hpp.

References contexts_, and M_insist.

◆ Ensure_Wasm_Context_For_ID()

static std::pair< std::reference_wrapper< WasmContext >, bool > m::WasmEngine::Ensure_Wasm_Context_For_ID ( unsigned  id,
const MatchBase plan,
WasmContext::config_t  configuration = WasmContext::config_t(0x0),
std::size_t  size = WASM_MAX_MEMORY 
)
inlinestatic

If none exists, creates a new WasmContext for ID id with size bytes of virtual address space.

Definition at line 84 of file WebAssembly.hpp.

References contexts_.

◆ execute()

virtual void m::WasmEngine::execute ( const MatchBase plan)
pure virtual

Executes the already computed physical covering represented by plan using this WasmEngine.

◆ Get_Wasm_Context_By_ID()

static WasmContext & m::WasmEngine::Get_Wasm_Context_By_ID ( unsigned  id)
inlinestatic

◆ Has_Wasm_Context()

static bool m::WasmEngine::Has_Wasm_Context ( unsigned  id)
inlinestatic

Tests if the WasmContext with ID id exists.

Definition at line 113 of file WebAssembly.hpp.

References contexts_.

Referenced by m::wasm::Module::Memory().

Field Documentation

◆ contexts_

std::unordered_map<unsigned, std::unique_ptr<WasmContext> > m::WasmEngine::contexts_
inlinestaticprivate

◆ WASM_ALIGNMENT

constexpr std::size_t m::WasmEngine::WASM_ALIGNMENT = 8
staticconstexpr

The alignment that is suitable for all built-in types.

Definition at line 23 of file WebAssembly.hpp.

◆ WASM_MAX_MEMORY

constexpr std::size_t m::WasmEngine::WASM_MAX_MEMORY = (1UL << 32) - (1UL << 16)
staticconstexpr

The maximum memory of a WebAssembly module: 2^32 - 2^16 bytes ≈ 4 GiB.

Definition at line 21 of file WebAssembly.hpp.

Referenced by m::wasm::Module::Memory(), m::wasm::Module::Module(), and m::WasmEngine::WasmContext::WasmContext().

◆ WASM_PAGE_SIZE

constexpr std::size_t m::WasmEngine::WASM_PAGE_SIZE = 1UL << 16
staticconstexpr

the size of a WebAssembly memory page, 64 KiB.

Definition at line 19 of file WebAssembly.hpp.

Referenced by m::wasm::Module::Module().


The documentation for this struct was generated from the following file: