diff --git a/README.md b/README.md index 044e1ccd..318d0176 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,13 @@ ## Core Model in One Screen -**No IR layers — source IS the IR.** The program counter is a kvspace path string; call-stack depth equals path depth: +**No IR layers — source IS the IR.** The program counter is a kvspace path string; call-stack depth is the frame number in that path: ``` -PC = "/vthread/tid/[0,0]/[0,0]/[1,0]" the program counter is a KV path -fetch = kv.Get(PC) instruction fetch is one KV read -call = create subtree; return = clean it crash? restart and resume from PC +PC = "/vthread/tid/[1]/[3,0]" vthread tid, frame 1, instruction 3 +fetch = GetBatch(frame/, ["[3,0]"]) take opcode from the frame dir (extindex → /lib) +call = create frame [d+1]; return = DelTree crash? restart and resume from PC +goto/br = rewrite the irseq in the same frame if/while do not create frames ``` Every instruction occupies a 2-D coordinate `[s0, s1]`: `[s0,0]` is always the opcode, `[s0,-j]` read params, `[s0,+j]` write params. diff --git a/README_CN.md b/README_CN.md index 3e86e3d1..c1fbc91a 100644 --- a/README_CN.md +++ b/README_CN.md @@ -22,12 +22,13 @@ ## 核心模型:一屏看懂 -**不分 IR 层,源码即 IR。** 程序计数器是 kvspace 路径字符串,调用栈深度 = 路径深度: +**不分 IR 层,源码即 IR。** 程序计数器是 kvspace 路径字符串,调用栈深度是路径里的帧号: ``` -PC = "/vthread/tid/[0,0]/[0,0]/[1,0]" 程序计数器是 KV 路径 -指令 = kv.Get(PC) 取指是一次 KV 读 -调用 = 创建子树;返回 = 清理子树 崩溃后按 PC 重启继续 +PC = "/vthread/tid/[1]/[3,0]" vthread tid、第 1 帧、第 3 条指令 +取指 = GetBatch(帧目录/, ["[3,0]"]) 从帧目录取 opcode(extindex → /lib) +调用 = 创建 [d+1] 帧;返回 = DelTree 崩溃后按 PC 重启继续 +goto/br = 只改同一帧的 irseq if/while 不建帧 ``` 每条指令占据二维坐标 `[s0, s1]`:`[s0,0]` 恒为操作码,`[s0,-j]` 读参,`[s0,+j]` 写参。 diff --git a/layout/src/code.rs b/layout/src/code.rs index 5dc128c7..10f3caad 100644 --- a/layout/src/code.rs +++ b/layout/src/code.rs @@ -4,12 +4,14 @@ //! /lib/·/[0,0] 编译后签名(kind=rwfunc) //! /lib/·/ 命名参数→slot 指针(kind=char, isptr=1) //! /lib/·/[i,j] 编译后指令(kind=rwir),i 从 1 开始 -//! /lib/·/