Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::vm::module Struct Reference

#include <types.hpp>

Collaboration diagram for sysio::vm::module:

Public Member Functions

void finalize ()
 
uint32_t get_imported_functions_size () const
 
uint32_t get_functions_size () const
 
uint32_t get_functions_total () const
 
opcodeget_function_pc (uint32_t fidx) const
 
auto & get_opcode (uint32_t pc) const
 
uint32_t get_function_locals_size (uint32_t index) const
 
auto & get_function_type (uint32_t index) const
 
uint32_t get_exported_function (const std::string_view str)
 
void normalize_types ()
 
void finalize ()
 
uint32_t get_imported_functions_size () const
 
uint32_t get_functions_size () const
 
uint32_t get_functions_total () const
 
opcodeget_function_pc (uint32_t fidx) const
 
auto & get_opcode (uint32_t pc) const
 
uint32_t get_function_locals_size (uint32_t index) const
 
auto & get_function_type (uint32_t index) const
 
uint32_t get_exported_function (const std::string_view str)
 
void normalize_types ()
 

Public Attributes

growable_allocator allocator = { constants::initial_module_size }
 
uint32_t start = std::numeric_limits<uint32_t>::max()
 
guarded_vector< func_typetypes = { allocator, 0 }
 
guarded_vector< import_entryimports = { allocator, 0 }
 
guarded_vector< uint32_tfunctions = { allocator, 0 }
 
guarded_vector< table_typetables = { allocator, 0 }
 
guarded_vector< memory_typememories = { allocator, 0 }
 
guarded_vector< global_variableglobals = { allocator, 0 }
 
guarded_vector< export_entryexports = { allocator, 0 }
 
guarded_vector< elem_segmentelements = { allocator, 0 }
 
guarded_vector< function_bodycode = { allocator, 0 }
 
guarded_vector< data_segmentdata = { allocator, 0 }
 
name_sectionnames = nullptr
 
guarded_vector< uint32_timport_functions = { allocator, 0 }
 
guarded_vector< uint32_ttype_aliases = { allocator, 0 }
 
guarded_vector< uint32_tfast_functions = { allocator, 0 }
 
uint64_t maximum_stack = 0
 
const char * error = nullptr
 

Detailed Description

Definition at line 166 of file types.hpp.

Member Function Documentation

◆ finalize() [1/2]

void sysio::vm::module::finalize ( )
inline

Definition at line 193 of file types.hpp.

193 {
196 }
uint32_t get_imported_functions_size() const
Definition types.hpp:197
guarded_vector< uint32_t > import_functions
Definition types.hpp:184
growable_allocator allocator
Definition types.hpp:167
Here is the call graph for this function:

◆ finalize() [2/2]

void sysio::vm::module::finalize ( )
inline

Definition at line 193 of file types.hpp.

Here is the call graph for this function:

◆ get_exported_function() [1/2]

uint32_t sysio::vm::module::get_exported_function ( const std::string_view str)
inline

Definition at line 227 of file types.hpp.

227 {
228 uint32_t index = std::numeric_limits<uint32_t>::max();
229 for (uint32_t i = 0; i < exports.size(); i++) {
230 if (exports[i].kind == external_kind::Function && exports[i].field_str.size() == str.size() &&
231 memcmp((const char*)str.data(), (const char*)exports[i].field_str.raw(), exports[i].field_str.size()) ==
232 0) {
233 index = exports[i].index;
234 break;
235 }
236 }
237 return index;
238 }
return str
Definition CLI11.hpp:1359
unsigned int uint32_t
Definition stdint.h:126
guarded_vector< export_entry > exports
Definition types.hpp:175
Here is the caller graph for this function:

◆ get_exported_function() [2/2]

uint32_t sysio::vm::module::get_exported_function ( const std::string_view str)
inline

Definition at line 227 of file types.hpp.

227 {
228 uint32_t index = std::numeric_limits<uint32_t>::max();
229 for (uint32_t i = 0; i < exports.size(); i++) {
230 if (exports[i].kind == external_kind::Function && exports[i].field_str.size() == str.size() &&
231 memcmp((const char*)str.data(), (const char*)exports[i].field_str.raw(), exports[i].field_str.size()) ==
232 0) {
233 index = exports[i].index;
234 break;
235 }
236 }
237 return index;
238 }

◆ get_function_locals_size() [1/2]

uint32_t sysio::vm::module::get_function_locals_size ( uint32_t index) const
inline

Definition at line 216 of file types.hpp.

216 {
217 SYS_VM_ASSERT(index >= get_imported_functions_size(), wasm_interpreter_exception, "imported functions do not have locals");
218 return code[index - get_imported_functions_size()].locals.size();
219 }
#define SYS_VM_ASSERT(expr, exc_type, msg)
Definition exceptions.hpp:8
Here is the call graph for this function:

◆ get_function_locals_size() [2/2]

uint32_t sysio::vm::module::get_function_locals_size ( uint32_t index) const
inline

Definition at line 216 of file types.hpp.

216 {
217 SYS_VM_ASSERT(index >= get_imported_functions_size(), wasm_interpreter_exception, "imported functions do not have locals");
218 return code[index - get_imported_functions_size()].locals.size();
219 }
Here is the call graph for this function:

◆ get_function_pc() [1/2]

opcode * sysio::vm::module::get_function_pc ( uint32_t fidx) const
inline

Definition at line 207 of file types.hpp.

207 {
208 SYS_VM_ASSERT( fidx >= get_imported_functions_size(), wasm_interpreter_exception, "trying to get the PC of an imported function" );
209 return code[fidx-get_imported_functions_size()].code;
210 }
Here is the call graph for this function:

◆ get_function_pc() [2/2]

opcode * sysio::vm::module::get_function_pc ( uint32_t fidx) const
inline

Definition at line 207 of file types.hpp.

207 {
208 SYS_VM_ASSERT( fidx >= get_imported_functions_size(), wasm_interpreter_exception, "trying to get the PC of an imported function" );
209 return code[fidx-get_imported_functions_size()].code;
210 }
Here is the call graph for this function:

◆ get_function_type() [1/2]

auto & sysio::vm::module::get_function_type ( uint32_t index) const
inline

Definition at line 221 of file types.hpp.

221 {
222 if (index < get_imported_functions_size())
223 return types[imports[index].type.func_t];
225 }
guarded_vector< uint32_t > functions
Definition types.hpp:171
guarded_vector< import_entry > imports
Definition types.hpp:170
guarded_vector< func_type > types
Definition types.hpp:169
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_function_type() [2/2]

auto & sysio::vm::module::get_function_type ( uint32_t index) const
inline

Definition at line 221 of file types.hpp.

221 {
222 if (index < get_imported_functions_size())
223 return types[imports[index].type.func_t];
225 }
Here is the call graph for this function:

◆ get_functions_size() [1/2]

uint32_t sysio::vm::module::get_functions_size ( ) const
inline

Definition at line 205 of file types.hpp.

205{ return functions.size(); }
Here is the caller graph for this function:

◆ get_functions_size() [2/2]

uint32_t sysio::vm::module::get_functions_size ( ) const
inline

Definition at line 205 of file types.hpp.

205{ return functions.size(); }

◆ get_functions_total() [1/2]

uint32_t sysio::vm::module::get_functions_total ( ) const
inline

Definition at line 206 of file types.hpp.

uint32_t get_functions_size() const
Definition types.hpp:205
Here is the call graph for this function:

◆ get_functions_total() [2/2]

uint32_t sysio::vm::module::get_functions_total ( ) const
inline

Definition at line 206 of file types.hpp.

Here is the call graph for this function:

◆ get_imported_functions_size() [1/2]

uint32_t sysio::vm::module::get_imported_functions_size ( ) const
inline

Definition at line 197 of file types.hpp.

197 {
198 uint32_t number_of_imports = 0;
199 for (uint32_t i = 0; i < imports.size(); i++) {
200 if (imports[i].kind == external_kind::Function)
201 number_of_imports++;
202 }
203 return number_of_imports;
204 }
Here is the caller graph for this function:

◆ get_imported_functions_size() [2/2]

uint32_t sysio::vm::module::get_imported_functions_size ( ) const
inline

Definition at line 197 of file types.hpp.

197 {
198 uint32_t number_of_imports = 0;
199 for (uint32_t i = 0; i < imports.size(); i++) {
200 if (imports[i].kind == external_kind::Function)
201 number_of_imports++;
202 }
203 return number_of_imports;
204 }

◆ get_opcode() [1/2]

auto & sysio::vm::module::get_opcode ( uint32_t pc) const
inline

Definition at line 212 of file types.hpp.

212 {
213 return ((opcode*)&code[0].code[0])[pc];
214 }
variant< > opcode
Definition opcodes.hpp:79

◆ get_opcode() [2/2]

auto & sysio::vm::module::get_opcode ( uint32_t pc) const
inline

Definition at line 212 of file types.hpp.

212 {
213 return ((opcode*)&code[0].code[0])[pc];
214 }

◆ normalize_types() [1/2]

void sysio::vm::module::normalize_types ( )
inline

Definition at line 240 of file types.hpp.

240 {
241 type_aliases.resize(types.size());
242 for (uint32_t i = 0; i < types.size(); ++i) {
243 uint32_t j = 0;
244 for (; j < i; ++j) {
245 if (types[j] == types[i]) {
246 break;
247 }
248 }
249 type_aliases[i] = j;
250 }
251
252 uint32_t imported_functions_size = get_imported_functions_size();
253 fast_functions.resize(functions.size() + imported_functions_size);
254 for (uint32_t i = 0; i < imported_functions_size; ++i) {
255 fast_functions[i] = type_aliases[imports[i].type.func_t];
256 }
257 for (uint32_t i = 0; i < functions.size(); ++i) {
258 fast_functions[i + imported_functions_size] = type_aliases[functions[i]];
259 }
260 }
guarded_vector< uint32_t > type_aliases
Definition types.hpp:185
guarded_vector< uint32_t > fast_functions
Definition types.hpp:186
uint16_t j
Here is the call graph for this function:
Here is the caller graph for this function:

◆ normalize_types() [2/2]

void sysio::vm::module::normalize_types ( )
inline

Definition at line 240 of file types.hpp.

240 {
241 type_aliases.resize(types.size());
242 for (uint32_t i = 0; i < types.size(); ++i) {
243 uint32_t j = 0;
244 for (; j < i; ++j) {
245 if (types[j] == types[i]) {
246 break;
247 }
248 }
249 type_aliases[i] = j;
250 }
251
252 uint32_t imported_functions_size = get_imported_functions_size();
253 fast_functions.resize(functions.size() + imported_functions_size);
254 for (uint32_t i = 0; i < imported_functions_size; ++i) {
255 fast_functions[i] = type_aliases[imports[i].type.func_t];
256 }
257 for (uint32_t i = 0; i < functions.size(); ++i) {
258 fast_functions[i + imported_functions_size] = type_aliases[functions[i]];
259 }
260 }
Here is the call graph for this function:

Member Data Documentation

◆ allocator

growable_allocator sysio::vm::module::allocator = { constants::initial_module_size }

Definition at line 167 of file types.hpp.

167{ constants::initial_module_size };

◆ code

guarded_vector< function_body > sysio::vm::module::code = { allocator, 0 }

Definition at line 177 of file types.hpp.

177{ allocator, 0 };

◆ data

guarded_vector< data_segment > sysio::vm::module::data = { allocator, 0 }

Definition at line 178 of file types.hpp.

178{ allocator, 0 };

◆ elements

guarded_vector< elem_segment > sysio::vm::module::elements = { allocator, 0 }

Definition at line 176 of file types.hpp.

176{ allocator, 0 };

◆ error

const char * sysio::vm::module::error = nullptr

Definition at line 191 of file types.hpp.

◆ exports

guarded_vector< export_entry > sysio::vm::module::exports = { allocator, 0 }

Definition at line 175 of file types.hpp.

175{ allocator, 0 };

◆ fast_functions

guarded_vector< uint32_t > sysio::vm::module::fast_functions = { allocator, 0 }

Definition at line 186 of file types.hpp.

186{ allocator, 0 };

◆ functions

guarded_vector< uint32_t > sysio::vm::module::functions = { allocator, 0 }

Definition at line 171 of file types.hpp.

171{ allocator, 0 };

◆ globals

guarded_vector< global_variable > sysio::vm::module::globals = { allocator, 0 }

Definition at line 174 of file types.hpp.

174{ allocator, 0 };

◆ import_functions

guarded_vector< uint32_t > sysio::vm::module::import_functions = { allocator, 0 }

Definition at line 184 of file types.hpp.

184{ allocator, 0 };

◆ imports

guarded_vector< import_entry > sysio::vm::module::imports = { allocator, 0 }

Definition at line 170 of file types.hpp.

170{ allocator, 0 };

◆ maximum_stack

uint64_t sysio::vm::module::maximum_stack = 0

Definition at line 187 of file types.hpp.

◆ memories

guarded_vector< memory_type > sysio::vm::module::memories = { allocator, 0 }

Definition at line 173 of file types.hpp.

173{ allocator, 0 };

◆ names

name_section * sysio::vm::module::names = nullptr

Definition at line 181 of file types.hpp.

◆ start

uint32_t sysio::vm::module::start = std::numeric_limits<uint32_t>::max()

Definition at line 168 of file types.hpp.

◆ tables

guarded_vector< table_type > sysio::vm::module::tables = { allocator, 0 }

Definition at line 172 of file types.hpp.

172{ allocator, 0 };

◆ type_aliases

guarded_vector< uint32_t > sysio::vm::module::type_aliases = { allocator, 0 }

Definition at line 185 of file types.hpp.

185{ allocator, 0 };

◆ types

guarded_vector< func_type > sysio::vm::module::types = { allocator, 0 }

Definition at line 169 of file types.hpp.

169{ allocator, 0 };

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