mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Data Fields | Private Member Functions | Private Attributes | Static Private Attributes | Friends
m::wasm::Module Struct Referencefinal

#include <WasmDSL.hpp>

Collaboration diagram for m::wasm::Module:
[legend]

Public Member Functions

::wasm::Block * set_active_block (::wasm::Block *block)
 Sets the new active ::wasm::Block and returns the previously active ::wasm::Block.
 
::wasm::Function * set_active_function (::wasm::Function *fn)
 Sets the new active ::wasm::Function and returns the previously active ::wasm::Function.
 
void emit_return ()
 An unsafe, i.e.
 
template<typename T , std::size_t L>
void emit_return (PrimitiveExpr< T, L > expr)
 An unsafe, i.e.
 
template<typename T , std::size_t L>
void emit_return (Expr< T, L > expr)
 An unsafe, i.e.
 
void emit_break (std::size_t level=1)
 Emit an unconditional break, breaking level levels.
 
void emit_break (PrimitiveExpr< bool, 1 > cond, std::size_t level=1)
 Emit a conditional break, breaking if cond is true and breaking level levels.
 
void emit_continue (std::size_t level=1)
 Emit an unconditional continue, continuing level levels above.
 
void emit_continue (PrimitiveExpr< bool, 1 > cond, std::size_t level=1)
 Emit an conditional continue, continuing level levels above if cond evaluates to true and the original continue condition evaluates to true.
 
template<typename T , std::size_t L>
PrimitiveExpr< T, Lemit_select (PrimitiveExpr< bool, 1 > cond, PrimitiveExpr< T, L > tru, PrimitiveExpr< T, L > fals)
 
template<typename T , std::size_t L>
Expr< T, Lemit_select (PrimitiveExpr< bool, 1 > cond, Expr< T, L > tru, Expr< T, L > fals)
 
PrimitiveExpr< T, Lemit_select (PrimitiveExpr< bool, L > cond, PrimitiveExpr< T, L > tru, PrimitiveExpr< T, L > fals)
 
Expr< T, Lemit_select (PrimitiveExpr< bool, L > cond, Expr< T, L > tru, Expr< T, L > fals)
 
template<typename T , std::size_t L, std::size_t M>
requires (L > 1)
 and (L *sizeof(T)<=16) and(M > 0) and(M<
 Selects lanes of first and second in byte granularity depending on the indices specified by indices.
 
sizeof (T)> emit_shuffle_bytes(PrimitiveExpr< T
 
template<typename T , std::size_t L, std::size_t M>
requires (L > 1)
 and (L *sizeof(T)<=16) and(M > 0) and(is_pow_2(M)) and(M *sizeof(T)<
 Selects lanes of first and second in lane granularity depending on the indices specified by indices.
 
emit_shuffle_lanes (PrimitiveExpr< T, L > first, PrimitiveExpr< T, L > second, const std::array< uint8_t, M > &indices)
 
template<typename T , std::size_t L, std::size_t M>
requires (L > 1)
 and (L *sizeof(T)<=16) and(M > 0) and(M<
 Selects lanes of first and second in byte granularity depending on the indices specified by indices.
 
sizeof (T)> emit_shuffle_bytes(Expr< T
 
template<typename T , std::size_t L, std::size_t M>
requires (L > 1)
 and (L *sizeof(T)<=16) and(M > 0) and(is_pow_2(M)) and(M *sizeof(T)<
 Selects lanes of first and second in lane granularity depending on the indices specified by indices.
 
emit_shuffle_lanes (Expr< T, L > first, Expr< T, L > second, const std::array< uint8_t, M > &indices)
 
void emit_global (::wasm::Name name, bool is_mutable, Us... inits)
 
void emit_global (const std::array<::wasm::Name, 1 > &names, bool is_mutable, Us... inits)
 
template<dsl_primitive T, std::size_t L = 1, std::size_t N, dsl_primitive... Us>
requires requires (Us... us) { { make_literal<T, L>(us...) } -> std::same_as<std::array<::wasm::Literal, N>>; }
void emit_global (const std::array<::wasm::Name, N > &names, bool is_mutable, Us... inits)
 
template<dsl_pointer_to_primitive T, std::size_t L = 1>
void emit_global (::wasm::Name name, bool is_mutable, uint32_t init)
 
template<typename T , std::size_t L = 1>
requires (L * sizeof(T) <= 16)
PrimitiveExpr< T, Lget_global (const char *name)
 
void emit_import (const char *extern_name, const char *intern_name=nullptr)
 
void emit_function_import (const char *name)
 
void emit_function_export (const char *name)
 Add function name as export.
 
template<typename ReturnType , typename... ParamTypes, std::size_t... ParamLs>
requires std::is_void_v<ReturnType>
void emit_call (const char *fn, PrimitiveExpr< ParamTypes, ParamLs >... args)
 
template<typename ReturnType , std::size_t ReturnL = 1, typename... ParamTypes, std::size_t... ParamLs>
requires dsl_primitive<ReturnType>
or dsl_pointer_to_primitive< ReturnType > PrimitiveExpr< ReturnType, ReturnLemit_call (const char *fn, PrimitiveExpr< ParamTypes, ParamLs >... args)
 
template<std::size_t L>
void emit_insist (PrimitiveExpr< bool, L > cond, const char *filename, unsigned line, const char *msg)
 
template<>
void emit_insist (PrimitiveExpr< bool, 1 > cond, const char *filename, unsigned line, const char *msg)
 
void emit_throw (exception::exception_t type, const char *filename, unsigned line, const char *msg)
 
const std::tuple< const char *, unsigned, const char * > & get_message (std::size_t idx) const
 
template<class C , typename... Args>
C & add_garbage_collected_data (void *handle, Args... args)
 Adds and returns an instance of.
 
::wasm::ModuleRunner::ExternalInterfaceget_mock_interface (::wasm::GlobalValueSet imports={})
 
::wasm::ModuleRunner instantiate (::wasm::GlobalValueSet imports={})
 Create an instance of this module.
 
void set_feature (::wasm::FeatureSet feature, bool value)
 
std::pair< uint8_t *, std::size_t > binary ()
 Returns the binary representation of module_ in a freshly allocated memory.
 
template<std::size_t L = 1>
requires (L > 0)
 and (L<=16) LocalBit< L > allocate_bit()
 
void push_branch_targets (::wasm::Name brk, ::wasm::Name continu)
 
void push_branch_targets (::wasm::Name brk, ::wasm::Name continu, PrimitiveExpr< bool, 1 > condition)
 
branch_target_t pop_branch_targets ()
 
const branch_target_tcurrent_branch_targets () const
 
void dump (std::ostream &out) const
 
void dump () const
 
void dump_all (std::ostream &out)
 
void dump_all ()
 

Static Public Member Functions

static void Init ()
 
static void Dispose ()
 
static ModuleGet ()
 
static unsigned ID ()
 Returns the ID of the current module.
 
static std::string Unique_Block_Name (std::string prefix="block")
 Returns a unique block name in the current module.
 
static std::string Unique_Function_Name (std::string prefix="function")
 Returns a unique function name in the current module.
 
static std::string Unique_Global_Name (std::string prefix="global")
 Returns a unique global name in the current module.
 
static std::string Unique_If_Name (std::string prefix="if")
 Returns a unique if name in the current module.
 
static std::string Unique_Loop_Name (std::string prefix="loop")
 Returns a unique loop name in the current module.
 
::wasm::Builder & Builder ()
 Returns the expression builder of the current module.
 
::wasm::Block & Block ()
 Returns the currently active block.
 
::wasm::Function & Function ()
 Returns the currently active function.
 
static memory::AddressSpaceMemory ()
 Returns the virtual address space.
 
static AllocatorAllocator ()
 Returns the allocator.
 
static bool Validate (bool verbose=true, bool global=true)
 Validates that the module is well-formed.
 
static void Optimize (int optimization_level)
 Optimizes the module with the optimization level set to level.
 

Data Fields

template<typename T , std::size_t L>
requires (PrimitiveExpr<int8_t, L> e)
 and { e.template to<int_t<sizeof(T)>, L>()
 Add function name with type T as import.
 
M L first
 
M L PrimitiveExpr< T, Lsecond
 
M L PrimitiveExpr< T, L > const std::array< uint8_t, M > & indices
 
M L Expr< T, Lsecond
 
M L Expr< T, L > const std::array< uint8_t, M > & indices
 

Private Member Functions

 Module ()
 
 Module (const Module &)=delete
 
void create_local_bitmap_stack ()
 
void create_local_bitvector_stack ()
 
void dispose_local_bitmap_stack ()
 
void dispose_local_bitvector_stack ()
 

Private Attributes

unsigned id_
 

‍the unique ID for this Module


 
unsigned next_block_id_ = 0
 

‍counter to make block names unique


 
unsigned next_function_id_ = 0
 

‍counter to make function names unique


 
unsigned next_global_id_ = 0
 

‍counter to make global variable names unique


 
unsigned next_if_id_ = 0
 

‍counter to make if names unique


 
unsigned next_loop_id_ = 0
 

‍counter to make loop names unique


 
::wasm::Module module_
 

‍the Binaryen Wasm module


 
::wasm::Builder builder_
 

‍the Binaryen expression builder for the module_


 
::wasm::Block * active_block_ = nullptr
 

‍the currently active Binaryen block


 
::wasm::Function * active_function_ = nullptr
 

‍the currently active Binaryen function


 
::wasm::Memory * memory_ = nullptr
 

‍the main memory of the module


 
std::unique_ptr< std::pair< memory::AddressSpace, memory::Memory > > vm_
 

‍the virtual address space and its backed memory; only set if no WasmContext was created


 
std::unique_ptr< Allocatorallocator_
 

‍the allocator


 
std::vector< branch_target_tbranch_target_stack_
 

‍stack of Binaryen branch targets


 
std::vector< std::tuple< const char *, unsigned, const char * > > messages_
 

‍filename, line, and an optional message for each emitted insist or exception throw


 
std::unique_ptr<::wasm::ModuleRunner::ExternalInterfaceinterface_
 

‍this module's interface, if any


 
std::vector< std::vector< LocalBitmap * > > local_bitmaps_stack_
 

‍the per-function stacks of local bitmaps; used for local scalar boolean variables and NULL bits


 
std::vector< std::vector< LocalBitvector * > > local_bitvectors_stack_
 

‍the per-function stacks of local bitvectors; used for local vectorial boolean variables and NULL bits


 
std::unordered_map< void *, std::unique_ptr< GarbageCollectedData > > garbage_collected_data_
 

‍mapping from handles to garbage collected data


 

Static Private Attributes

static std::atomic_uint NEXT_MODULE_ID_ = 0
 

‍counter to make block names unique


 
static thread_local std::unique_ptr< Modulethe_module_
 

Friends

struct Block
 
struct BlockUser
 
template<typename >
struct Function
 
template<typename , std::size_t >
struct PrimitiveExpr
 

‍Constructs an empty PrimitiveExpr, for which operator bool() returns false.


 
template<typename , VariableKind , bool , std::size_t >
class detail::variable_storage
 
template<std::size_t >
struct LocalBit
 
struct Allocator
 
template<typename >
struct invoke_v8
 
std::ostream & operator<< (std::ostream &out, const Module &M)
 

Detailed Description

Definition at line 643 of file WasmDSL.hpp.

Constructor & Destructor Documentation

◆ Module() [1/2]

Module::Module ( )
private

◆ Module() [2/2]

m::wasm::Module::Module ( const Module )
privatedelete

Member Function Documentation

◆ add_garbage_collected_data()

template<class C , typename... Args>
C & m::wasm::Module::add_garbage_collected_data ( void *  handle,
Args...  args 
)
inline

Adds and returns an instance of.

Template Parameters
C,whichwill be created by calling its ctor with an GarbageCollectedData&&instance and the forwarded \p args, tothisModule`s garbage collection using the unique caller handle handle.

Definition at line 916 of file WasmDSL.hpp.

References args.

Referenced by m::wasm::like(), m::wasm::like_contains(), m::wasm::strncmp(), and m::wasm::strncpy().

◆ Allocator()

static Allocator & m::wasm::Module::Allocator ( )
static

Returns the allocator.

◆ and() [1/5]

template<typename T , std::size_t L, std::size_t M>
requires (L > 1)
m::wasm::Module::and ( L *sizeof(T)<=  16)

Selects lanes of first and second in lane granularity depending on the indices specified by indices.

Indices i in the range [0, L) select the i-th lane of first, indices i in the range [L, 2 * L) select the i-L-th lane of second, indices outside of these ranges result in undefined values.

◆ and() [2/5]

template<typename T , std::size_t L, std::size_t M>
requires (L > 1)
m::wasm::Module::and ( L *sizeof(T)<=  16)

Selects lanes of first and second in lane granularity depending on the indices specified by indices.

Indices i in the range [0, L) select the i-th lane of first, indices i in the range [L, 2 * L) select the i-L-th lane of second, indices outside of these ranges result in undefined values.

◆ and() [3/5]

template<typename T , std::size_t L, std::size_t M>
requires (L > 1)
m::wasm::Module::and ( L *sizeof(T)<=  16)

Selects lanes of first and second in byte granularity depending on the indices specified by indices.

Indices i in the range [0, L * sizeof(T)) select the i-th lane of first, indices i in the range [L * sizeof(T), 2 * L * sizeof(T)) select the i-(L * sizeof(T))-th lane of second, indices outside of these ranges result in undefined values.

References m::wasm::L.

◆ and() [4/5]

template<typename T , std::size_t L, std::size_t M>
requires (L > 1)
m::wasm::Module::and ( L *sizeof(T)<=  16)

Selects lanes of first and second in byte granularity depending on the indices specified by indices.

Indices i in the range [0, L * sizeof(T)) select the i-th lane of first, indices i in the range [L * sizeof(T), 2 * L * sizeof(T)) select the i-(L * sizeof(T))-th lane of second, indices outside of these ranges result in undefined values.

◆ and() [5/5]

template<std::size_t L = 1>
requires (L > 0)
m::wasm::Module::and ( L<=  16)

References m::wasm::L.

◆ binary()

std::pair< uint8_t *, std::size_t > Module::binary ( )

Returns the binary representation of module_ in a freshly allocated memory.

The caller must dispose of this memory.

Definition at line 385 of file WasmDSL.cpp.

References binary(), and module_.

Referenced by binary(), m::wasm::detail::create_js_debug_script(), and m::wasm::detail::instantiate().

◆ Block()

::wasm::Block & m::wasm::Module::Block ( )
inlinestatic

Returns the currently active block.

Definition at line 742 of file WasmDSL.hpp.

References M_notnull.

◆ Builder()

::wasm::Builder & m::wasm::Module::Builder ( )
inlinestatic

Returns the expression builder of the current module.

Definition at line 739 of file WasmDSL.hpp.

Referenced by m::wasm::If::~If().

◆ create_local_bitmap_stack()

void m::wasm::Module::create_local_bitmap_stack ( )
inlineprivate

Definition at line 6606 of file WasmDSL.hpp.

◆ create_local_bitvector_stack()

void m::wasm::Module::create_local_bitvector_stack ( )
inlineprivate

Definition at line 6611 of file WasmDSL.hpp.

◆ current_branch_targets()

const branch_target_t & m::wasm::Module::current_branch_targets ( ) const
inline

Definition at line 961 of file WasmDSL.hpp.

◆ Dispose()

static void m::wasm::Module::Dispose ( )
inlinestatic

Definition at line 710 of file WasmDSL.hpp.

References M_insist.

◆ dispose_local_bitmap_stack()

void m::wasm::Module::dispose_local_bitmap_stack ( )
inlineprivate

Definition at line 6616 of file WasmDSL.hpp.

References M_insist.

◆ dispose_local_bitvector_stack()

void m::wasm::Module::dispose_local_bitvector_stack ( )
inlineprivate

Definition at line 6626 of file WasmDSL.hpp.

References m::wasm::bitmask(), and M_insist.

◆ dump() [1/2]

void m::wasm::Module::dump ( ) const
inline

Definition at line 991 of file WasmDSL.hpp.

References dump().

Referenced by dump().

◆ dump() [2/2]

void m::wasm::Module::dump ( std::ostream &  out) const
inline

Definition at line 990 of file WasmDSL.hpp.

◆ dump_all() [1/2]

void m::wasm::Module::dump_all ( )
inline

Definition at line 994 of file WasmDSL.hpp.

References dump_all().

Referenced by dump_all().

◆ dump_all() [2/2]

void m::wasm::Module::dump_all ( std::ostream &  out)
inline

Definition at line 993 of file WasmDSL.hpp.

◆ emit_break() [1/2]

void m::wasm::Module::emit_break ( PrimitiveExpr< bool, 1 >  cond,
std::size_t  level = 1 
)
inline

Emit a conditional break, breaking if cond is true and breaking level levels.

Definition at line 6759 of file WasmDSL.hpp.

References M_insist.

◆ emit_break() [2/2]

void m::wasm::Module::emit_break ( std::size_t  level = 1)
inline

Emit an unconditional break, breaking level levels.

Definition at line 6750 of file WasmDSL.hpp.

References M_insist.

◆ emit_call() [1/2]

template<typename ReturnType , typename... ParamTypes, std::size_t... ParamLs>
requires std::is_void_v<ReturnType>
void m::wasm::Module::emit_call ( const char *  fn,
PrimitiveExpr< ParamTypes, ParamLs >...  args 
)
inline

◆ emit_call() [2/2]

template<typename ReturnType , std::size_t ReturnL, typename... ParamTypes, std::size_t... ParamLs>
requires dsl_primitive<ReturnType>
or dsl_pointer_to_primitive< ReturnType > PrimitiveExpr< ReturnType, ReturnL > m::wasm::Module::emit_call ( const char *  fn,
PrimitiveExpr< ParamTypes, ParamLs >...  args 
)
inline

Definition at line 6725 of file WasmDSL.hpp.

◆ emit_continue() [1/2]

void Module::emit_continue ( PrimitiveExpr< bool, 1 >  cond,
std::size_t  level = 1 
)

Emit an conditional continue, continuing level levels above if cond evaluates to true and the original continue condition evaluates to true.

Definition at line 476 of file WasmDSL.cpp.

References branch_target_stack_, emit_continue(), IF, and M_insist.

◆ emit_continue() [2/2]

void Module::emit_continue ( std::size_t  level = 1)

Emit an unconditional continue, continuing level levels above.

Definition at line 453 of file WasmDSL.cpp.

References active_block_, branch_target_stack_, m::wasm::BREAK(), builder_, ELSE, Get(), IF, M_insist, and module_.

Referenced by emit_continue().

◆ emit_function_export()

void m::wasm::Module::emit_function_export ( const char *  name)
inline

Add function name as export.

Definition at line 886 of file WasmDSL.hpp.

◆ emit_function_import()

void m::wasm::Module::emit_function_import ( const char *  name)
inline

Definition at line 879 of file WasmDSL.hpp.

Referenced by m::wasm::detail::create_env().

◆ emit_global() [1/4]

template<dsl_pointer_to_primitive T, std::size_t L = 1>
void m::wasm::Module::emit_global ( ::wasm::Name  name,
bool  is_mutable,
uint32_t  init 
)
inline

Definition at line 849 of file WasmDSL.hpp.

References m::init().

◆ emit_global() [2/4]

void m::wasm::Module::emit_global ( ::wasm::Name  name,
bool  is_mutable,
Us...  inits 
)
inline

Definition at line 824 of file WasmDSL.hpp.

◆ emit_global() [3/4]

void m::wasm::Module::emit_global ( const std::array<::wasm::Name, 1 > &  names,
bool  is_mutable,
Us...  inits 
)
inline

Definition at line 833 of file WasmDSL.hpp.

◆ emit_global() [4/4]

template<dsl_primitive T, std::size_t L = 1, std::size_t N, dsl_primitive... Us>
requires requires (Us... us) { { make_literal<T, L>(us...) } -> std::same_as<std::array<::wasm::Literal, N>>; }
void m::wasm::Module::emit_global ( const std::array<::wasm::Name, N > &  names,
bool  is_mutable,
Us...  inits 
)
inline

Definition at line 838 of file WasmDSL.hpp.

◆ emit_import()

void m::wasm::Module::emit_import ( const char *  extern_name,
const char *  intern_name = nullptr 
)
inline

Definition at line 865 of file WasmDSL.hpp.

References M_CONSTEXPR_COND, M_notnull, m::T(), and m::wasm::value.

Referenced by m::wasm::detail::create_env().

◆ emit_insist() [1/2]

template<>
void Module::emit_insist ( PrimitiveExpr< bool, 1 >  cond,
const char *  filename,
unsigned  line,
const char *  msg 
)

Definition at line 410 of file WasmDSL.cpp.

References FUNCTION, IF, M_insist, messages_, and PARAMETER.

◆ emit_insist() [2/2]

template<std::size_t L>
void Module::emit_insist ( PrimitiveExpr< bool, L cond,
const char *  filename,
unsigned  line,
const char *  msg 
)

Definition at line 397 of file WasmDSL.cpp.

References emit_insist().

Referenced by emit_insist().

◆ emit_return() [1/3]

void m::wasm::Module::emit_return ( )
inline

An unsafe, i.e.

statically-**un**typed, version of Function::emit_return().

Definition at line 6732 of file WasmDSL.hpp.

◆ emit_return() [2/3]

template<typename T , std::size_t L>
void m::wasm::Module::emit_return ( Expr< T, L expr)
inline

An unsafe, i.e.

statically-**un**typed, version of Function::emit_return(T&&).

Definition at line 6744 of file WasmDSL.hpp.

References m::wasm::value.

◆ emit_return() [3/3]

template<typename T , std::size_t L>
void m::wasm::Module::emit_return ( PrimitiveExpr< T, L expr)
inline

An unsafe, i.e.

statically-**un**typed, version of Function::emit_return(T&&).

Definition at line 6738 of file WasmDSL.hpp.

References m::wasm::value.

◆ emit_select() [1/4]

template<typename T , std::size_t L>
Expr< T, L > m::wasm::Module::emit_select ( PrimitiveExpr< bool, 1 >  cond,
Expr< T, L tru,
Expr< T, L fals 
)

Definition at line 6800 of file WasmDSL.hpp.

◆ emit_select() [2/4]

template<typename T , std::size_t L>
PrimitiveExpr< T, L > m::wasm::Module::emit_select ( PrimitiveExpr< bool, 1 >  cond,
PrimitiveExpr< T, L tru,
PrimitiveExpr< T, L fals 
)

Definition at line 6768 of file WasmDSL.hpp.

References m::wasm::L, m::wasm::referenced_bits(), m::T(), and m::wasm::vectors().

◆ emit_select() [3/4]

Expr< T, L > m::wasm::Module::emit_select ( PrimitiveExpr< bool, L cond,
Expr< T, L tru,
Expr< T, L fals 
)

Definition at line 6859 of file WasmDSL.hpp.

◆ emit_select() [4/4]

PrimitiveExpr< T, L > m::wasm::Module::emit_select ( PrimitiveExpr< bool, L cond,
PrimitiveExpr< T, L tru,
PrimitiveExpr< T, L fals 
)

◆ emit_shuffle_lanes() [1/2]

M m::wasm::Module::emit_shuffle_lanes ( Expr< T, L first,
Expr< T, L second,
const std::array< uint8_t, M > &  indices 
)

Definition at line 6957 of file WasmDSL.hpp.

References m::wasm::indices.

◆ emit_shuffle_lanes() [2/2]

M m::wasm::Module::emit_shuffle_lanes ( PrimitiveExpr< T, L first,
PrimitiveExpr< T, L second,
const std::array< uint8_t, M > &  indices 
)

◆ emit_throw()

void Module::emit_throw ( exception::exception_t  type,
const char *  filename,
unsigned  line,
const char *  msg 
)

Definition at line 441 of file WasmDSL.cpp.

References active_block_, args, builder_, and messages_.

◆ Function()

::wasm::Function & m::wasm::Module::Function ( )
inlinestatic

Returns the currently active function.

Definition at line 745 of file WasmDSL.hpp.

References M_notnull.

◆ Get()

static Module & m::wasm::Module::Get ( )
inlinestatic

◆ get_global()

template<typename T , std::size_t L>
requires (L * sizeof(T) <= 16)
PrimitiveExpr< T, L > m::wasm::Module::get_global ( const char *  name)
inline

Definition at line 6709 of file WasmDSL.hpp.

Referenced by get_base_address(), and get_num_rows().

◆ get_message()

const std::tuple< const char *, unsigned, const char * > & m::wasm::Module::get_message ( std::size_t  idx) const
inline

◆ get_mock_interface()

wasm::ModuleRunner::ExternalInterface * Module::get_mock_interface ( ::wasm::GlobalValueSet  imports = {})

Definition at line 360 of file WasmDSL.cpp.

References interface_, and Memory().

◆ ID()

static unsigned m::wasm::Module::ID ( )
inlinestatic

◆ Init()

static void m::wasm::Module::Init ( )
inlinestatic

Definition at line 706 of file WasmDSL.hpp.

References M_insist.

◆ instantiate()

::wasm::ModuleRunner m::wasm::Module::instantiate ( ::wasm::GlobalValueSet  imports = {})
inline

Create an instance of this module.

Can be used for interpretation and debugging.

Definition at line 928 of file WasmDSL.hpp.

◆ Memory()

memory::AddressSpace & Module::Memory ( )
static

◆ Optimize()

void Module::Optimize ( int  optimization_level)
static

Optimizes the module with the optimization level set to level.

Definition at line 375 of file WasmDSL.cpp.

References Get(), and module_.

◆ pop_branch_targets()

branch_target_t m::wasm::Module::pop_branch_targets ( )
inline

Definition at line 955 of file WasmDSL.hpp.

◆ push_branch_targets() [1/2]

void m::wasm::Module::push_branch_targets ( ::wasm::Name  brk,
::wasm::Name  continu 
)
inline

Definition at line 949 of file WasmDSL.hpp.

◆ push_branch_targets() [2/2]

void m::wasm::Module::push_branch_targets ( ::wasm::Name  brk,
::wasm::Name  continu,
PrimitiveExpr< bool, 1 >  condition 
)
inline

Definition at line 6973 of file WasmDSL.hpp.

◆ set_active_block()

::wasm::Block * m::wasm::Module::set_active_block ( ::wasm::Block *  block)
inline

Sets the new active ::wasm::Block and returns the previously active ::wasm::Block.

Definition at line 760 of file WasmDSL.hpp.

◆ set_active_function()

::wasm::Function * m::wasm::Module::set_active_function ( ::wasm::Function *  fn)
inline

Sets the new active ::wasm::Function and returns the previously active ::wasm::Function.

Definition at line 762 of file WasmDSL.hpp.

◆ set_feature()

void m::wasm::Module::set_feature ( ::wasm::FeatureSet  feature,
bool  value 
)
inline

Definition at line 933 of file WasmDSL.hpp.

References m::wasm::value.

◆ sizeof() [1/2]

M m::wasm::Module::sizeof ( T  )

◆ sizeof() [2/2]

M m::wasm::Module::sizeof ( T  )

◆ Unique_Block_Name()

static std::string m::wasm::Module::Unique_Block_Name ( std::string  prefix = "block")
inlinestatic

Returns a unique block name in the current module.

Definition at line 724 of file WasmDSL.hpp.

References m::wasm::unique().

◆ Unique_Function_Name()

static std::string m::wasm::Module::Unique_Function_Name ( std::string  prefix = "function")
inlinestatic

Returns a unique function name in the current module.

Definition at line 726 of file WasmDSL.hpp.

References m::wasm::unique().

◆ Unique_Global_Name()

static std::string m::wasm::Module::Unique_Global_Name ( std::string  prefix = "global")
inlinestatic

Returns a unique global name in the current module.

Definition at line 730 of file WasmDSL.hpp.

References m::wasm::unique().

◆ Unique_If_Name()

static std::string m::wasm::Module::Unique_If_Name ( std::string  prefix = "if")
inlinestatic

Returns a unique if name in the current module.

Definition at line 734 of file WasmDSL.hpp.

References m::wasm::unique().

◆ Unique_Loop_Name()

static std::string m::wasm::Module::Unique_Loop_Name ( std::string  prefix = "loop")
inlinestatic

Returns a unique loop name in the current module.

Definition at line 736 of file WasmDSL.hpp.

References m::wasm::unique().

◆ Validate()

bool Module::Validate ( bool  verbose = true,
bool  global = true 
)
static

Validates that the module is well-formed.

Definition at line 367 of file WasmDSL.cpp.

References Get(), and module_.

Friends And Related Function Documentation

◆ Allocator

Allocator & Module::Allocator
friend

Definition at line 652 of file WasmDSL.hpp.

Referenced by m::wasm::Buffer< IsGlobal >::Buffer(), m::wasm::ChainedHashTable< IsGlobal >::clear(), m::wasm::Buffer< IsGlobal >::consume(), m::wasm::ChainedHashTable< IsGlobal >::create_predication_dummy(), m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::create_predication_dummy(), m::wasm::ChainedHashTable< IsGlobal >::dummy_entry(), m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::dummy_entry(), m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::emplace(), m::wasm::ChainedHashTable< IsGlobal >::emplace_without_rehashing(), index_scan_codegen_compilation(), index_scan_codegen_hybrid(), index_scan_codegen_interpretation(), m::wasm::like(), m::wasm::like_contains(), m::wasm::like_prefix(), m::wasm::like_suffix(), m::wasm::ExprCompiler::operator()(), m::wasm::buffer_swap_proxy_t< IsGlobal >::operator()(), m::wasm::ChainedHashTable< IsGlobal >::rehash(), m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::rehash(), m::wasm::Buffer< IsGlobal >::setup(), m::wasm::ChainedHashTable< IsGlobal >::setup(), m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::setup(), m::wasm::Buffer< IsGlobal >::teardown(), m::wasm::ChainedHashTable< IsGlobal >::teardown(), m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::teardown(), m::wasm::ChainedHashTable< IsGlobal >::try_emplace(), m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::try_emplace(), m::wasm::Buffer< IsGlobal >::~Buffer(), m::wasm::ChainedHashTable< IsGlobal >::~ChainedHashTable(), and m::wasm::OpenAddressingHashTable< IsGlobal, ValueInPlace >::~OpenAddressingHashTable().

◆ Block

friend struct Block
friend

Definition at line 646 of file WasmDSL.hpp.

Referenced by m::wasm::If::~If().

◆ BlockUser

friend struct BlockUser
friend

Definition at line 647 of file WasmDSL.hpp.

◆ detail::variable_storage

template<typename , VariableKind , bool , std::size_t >
friend class detail::variable_storage
friend

Definition at line 650 of file WasmDSL.hpp.

◆ Function

template<typename >
friend struct Function
friend

Definition at line 648 of file WasmDSL.hpp.

◆ invoke_v8

template<typename >
friend struct invoke_v8
friend

Definition at line 653 of file WasmDSL.hpp.

◆ LocalBit

template<std::size_t >
friend struct LocalBit
friend

Definition at line 651 of file WasmDSL.hpp.

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const Module M 
)
friend

Definition at line 965 of file WasmDSL.hpp.

◆ PrimitiveExpr

template<typename , std::size_t >
friend struct PrimitiveExpr
friend

‍Constructs an empty PrimitiveExpr, for which operator bool() returns false.

Definition at line 649 of file WasmDSL.hpp.

Field Documentation

◆ active_block_

::wasm::Block* m::wasm::Module::active_block_ = nullptr
private

‍the currently active Binaryen block

Definition at line 676 of file WasmDSL.hpp.

Referenced by emit_continue(), and emit_throw().

◆ active_function_

::wasm::Function* m::wasm::Module::active_function_ = nullptr
private

‍the currently active Binaryen function

Definition at line 678 of file WasmDSL.hpp.

◆ allocator_

std::unique_ptr<Allocator> m::wasm::Module::allocator_
private

‍the allocator

Definition at line 684 of file WasmDSL.hpp.

◆ and

template<typename T , std::size_t L>
requires (PrimitiveExpr<int8_t, L> e)
m::wasm::Module::and { e.template to<int_t<sizeof(T)>, L>()

Add function name with type T as import.

Definition at line 785 of file WasmDSL.hpp.

◆ branch_target_stack_

std::vector<branch_target_t> m::wasm::Module::branch_target_stack_
private

‍stack of Binaryen branch targets

Definition at line 686 of file WasmDSL.hpp.

Referenced by emit_continue().

◆ builder_

::wasm::Builder m::wasm::Module::builder_
private

‍the Binaryen expression builder for the module_

Definition at line 674 of file WasmDSL.hpp.

Referenced by emit_continue(), emit_throw(), and Module().

◆ first

M L m::wasm::Module::first

Definition at line 798 of file WasmDSL.hpp.

◆ garbage_collected_data_

std::unordered_map<void*, std::unique_ptr<GarbageCollectedData> > m::wasm::Module::garbage_collected_data_
private

‍mapping from handles to garbage collected data

Definition at line 696 of file WasmDSL.hpp.

◆ id_

unsigned m::wasm::Module::id_
private

‍the unique ID for this Module

Definition at line 660 of file WasmDSL.hpp.

Referenced by Module().

◆ indices [1/2]

M L PrimitiveExpr<T, L> const std::array<uint8_t, M>& m::wasm::Module::indices

Definition at line 799 of file WasmDSL.hpp.

◆ indices [2/2]

M L Expr<T, L> const std::array<uint8_t, M>& m::wasm::Module::indices

Definition at line 813 of file WasmDSL.hpp.

◆ interface_

std::unique_ptr<::wasm::ModuleRunner::ExternalInterface> m::wasm::Module::interface_
private

‍this module's interface, if any

Definition at line 690 of file WasmDSL.hpp.

Referenced by get_mock_interface().

◆ local_bitmaps_stack_

std::vector<std::vector<LocalBitmap*> > m::wasm::Module::local_bitmaps_stack_
private

‍the per-function stacks of local bitmaps; used for local scalar boolean variables and NULL bits

Definition at line 692 of file WasmDSL.hpp.

◆ local_bitvectors_stack_

std::vector<std::vector<LocalBitvector*> > m::wasm::Module::local_bitvectors_stack_
private

‍the per-function stacks of local bitvectors; used for local vectorial boolean variables and NULL bits

Definition at line 694 of file WasmDSL.hpp.

◆ memory_

::wasm::Memory* m::wasm::Module::memory_ = nullptr
private

‍the main memory of the module

Definition at line 680 of file WasmDSL.hpp.

Referenced by Module().

◆ messages_

std::vector<std::tuple<const char*, unsigned, const char*> > m::wasm::Module::messages_
private

‍filename, line, and an optional message for each emitted insist or exception throw

Definition at line 688 of file WasmDSL.hpp.

Referenced by emit_insist(), and emit_throw().

◆ module_

::wasm::Module m::wasm::Module::module_
private

‍the Binaryen Wasm module

Definition at line 672 of file WasmDSL.hpp.

Referenced by binary(), emit_continue(), Module(), Optimize(), and Validate().

◆ next_block_id_

unsigned m::wasm::Module::next_block_id_ = 0
private

‍counter to make block names unique

Definition at line 662 of file WasmDSL.hpp.

◆ next_function_id_

unsigned m::wasm::Module::next_function_id_ = 0
private

‍counter to make function names unique

Definition at line 664 of file WasmDSL.hpp.

◆ next_global_id_

unsigned m::wasm::Module::next_global_id_ = 0
private

‍counter to make global variable names unique

Definition at line 666 of file WasmDSL.hpp.

◆ next_if_id_

unsigned m::wasm::Module::next_if_id_ = 0
private

‍counter to make if names unique

Definition at line 668 of file WasmDSL.hpp.

◆ next_loop_id_

unsigned m::wasm::Module::next_loop_id_ = 0
private

‍counter to make loop names unique

Definition at line 670 of file WasmDSL.hpp.

◆ NEXT_MODULE_ID_

std::atomic_uint m::wasm::Module::NEXT_MODULE_ID_ = 0
inlinestaticprivate

‍counter to make block names unique

Definition at line 657 of file WasmDSL.hpp.

◆ second [1/2]

M L PrimitiveExpr<T, L> m::wasm::Module::second

Definition at line 798 of file WasmDSL.hpp.

◆ second [2/2]

M L Expr<T, L> m::wasm::Module::second

Definition at line 813 of file WasmDSL.hpp.

◆ the_module_

thread_local std::unique_ptr< Module > Module::the_module_
staticprivate

Definition at line 700 of file WasmDSL.hpp.

◆ vm_

std::unique_ptr<std::pair<memory::AddressSpace, memory::Memory> > m::wasm::Module::vm_
private

‍the virtual address space and its backed memory; only set if no WasmContext was created

Definition at line 682 of file WasmDSL.hpp.

Referenced by Memory().


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