一起來讀源碼7-eos vm

摘要:

 

詳情:

allocator.hpp

提供了以下內存分配器:

1.邊界內存分配器

2.連續內存分配器

3.jit分配器

4.自增內存分配器

5.棧分配器

6.wasm分配器

 

backend.hpp

定義類:

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);

 

base_visitor.hpp

visitor類

 

bitcode_writer.hpp

二進制中間碼寫入器

 

config.hpp

全局定義了一些變量

EOS_VM_ALIGN_MEMORY_OPS:內存對齊選項

EOS_VM_SOFTFLOAT: 軟浮點

EOS_VM_FULL_DEBUG: 調試

 

constants.hpp

定義常量:

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) //最大頁數量

 

debug_visitor.hpp

調試訪問器

 

disassembly_visitor.hpp

拆解訪問器

 

error_codes_def.hpp

錯誤碼類別:

parser_errors:解析錯誤

memory_errors:內存錯誤

system_errors:系統錯誤

auxiliary_errors:輔助錯誤

 

error_codes_pp.hpp

錯誤碼

 

error_codes.hpp

錯誤碼

 

exceptions.hpp

異常類

 

execution_context.hpp

執行上下文

 

guarded_ptr.hpp

host_function.hpp

interpret_visitor.hpp

leb128.hpp

memory_dump.hpp

opcodes_def.hpp

opcode.hpp

outcome.hpp

parser.hpp

sections.hpp

signals.hpp

softfloat.hpp

stack_elem.hpp

types.hpp

utils.hpp

validation.hpp

variant.hpp

vector.hpp

wasm_stack.hpp

watchdog.hpp

x86_64.hpp

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章