stage0 新增内存复制指令 重构vm交互
This commit is contained in:
1 parent
0b8f649818
commit
40cffa9cb5
22 files changed
+626
-158
No files matched your search
@@ -87,32 +87,4 @@ SPL_FN u64 vm_timestamp(u64 kind) {
|
||||
#define SPL_VM_EMBED_IMPLIMENTATION
|
||||
#include "spl_vm_embed.h"
|
||||
|
||||
/* 配置层外部函数处理器(native 端):把 nested VM 未解析的 native 按名分发到
|
||||
* 编译器生成的 `ct_*` 函数(表由 ir2c 生成,见 stage2/ir2c.spl)。 */
|
||||
extern void *spl_ct_lookup(const char *name);
|
||||
|
||||
typedef spl_vm_val_t (*spl_native_ct_fn_t)(void *, spl_vm_val_t, spl_vm_val_t, spl_vm_val_t);
|
||||
|
||||
SPL_FN spl_vm_val_t spl_native_foreign(spl_vm_t *vm, const spl_vm_call_t *call, void *user) {
|
||||
void *fn;
|
||||
spl_vm_val_t a0 = 0, a1 = 0;
|
||||
(void)vm;
|
||||
if (!call)
|
||||
return 0;
|
||||
fn = spl_ct_lookup(call->name);
|
||||
if (!fn)
|
||||
return 0;
|
||||
if (call->nargs > 0)
|
||||
a0 = call->args[0];
|
||||
if (call->nargs > 1)
|
||||
a1 = call->args[1];
|
||||
/* ct_* 统一形状:返回 u64,参数 (ctx, u64, u64);多余参数被忽略。 */
|
||||
return ((spl_native_ct_fn_t)fn)(user, a0, a1, 0);
|
||||
}
|
||||
|
||||
SPL_FN void vm_set_foreign(void *p, unsigned long long handler, void *ctx) {
|
||||
(void)handler;
|
||||
spl_vm_set_foreign((spl_vm_t *)p, spl_native_foreign, ctx);
|
||||
}
|
||||
|
||||
#endif /* __SPL_RT_H__ */
|
||||
Reference in new issue
Block a user