一起来读源码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

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