摘要:
詳情:
提供了以下內存分配器:
1.邊界內存分配器
2.連續內存分配器
3.jit分配器
4.自增內存分配器
5.棧分配器
6.wasm分配器
定義類:
jit:jit類
backend:後臺類
//後臺初始化
inline backend& initialize(Host* host=nullptr);
//曲線調用
template <typename... Args>
inline bool call_indirect( Host* host, uint32_t func_index, Args... args );
//調用
template <typename... Args>
inline bool call( Host* host, uint32_t func_index, Args... args );
//調用
template <typename... Args>
inline bool call( Host* host, const std::string_view& mod, const std::string_view& func, Args... args );
//調用
template <typename... Args>
inline auto call_with_return(Host* host, const std::string_view& mod, const std::string_view& func, Args... args);
//跑時間
template <typename Watchdog, typename F>
void timed_run(Watchdog&& wd, F&& f);
//執行所有watchdog任務
template <typename Watchdog>
inline void execute_all(Watchdog&& wd, Host* host = nullptr);
//讀wasm文件
static std::vector<uint8_t> read_wasm(const std::string& fname);
visitor類
二進制中間碼寫入器
全局定義了一些變量
EOS_VM_ALIGN_MEMORY_OPS:內存對齊選項
EOS_VM_SOFTFLOAT: 軟浮點
EOS_VM_FULL_DEBUG: 調試
定義常量:
magic = 0x6D736100 //魔幻數字
version = 0x1 //版本
magic_size = sizeof(uint32_t) //魔幻數字類型大小
version_size = sizeof(uint32_t) //版本類型大小
id_size = sizeof(uint8_t) //id大小
varuint32_size = 5
max_nested_structures = 1024 //網絡結構體尺寸
max_call_depth = 250 //調用深度
max_stack_size = 8*1024 //棧尺寸
initial_module_size = 1*1024*1024 //初始化module尺寸
max_memory = 4ull << 31 //最大內存
max_useable_memory = (33 * 1024 * 1024) //最大可用內存,33mb
page_size = 64ull * 1024 //頁尺寸64kb
max_pages = (max_useable_memory/page_size) //最大頁數量
調試訪問器
拆解訪問器
錯誤碼類別:
parser_errors:解析錯誤
memory_errors:內存錯誤
system_errors:系統錯誤
auxiliary_errors:輔助錯誤
錯誤碼
錯誤碼
異常類
執行上下文