From b5d4acbcb9421ce13ae729e8415dbabc2403dcef Mon Sep 17 00:00:00 2001 From: AmuroEita <1071307515@qq.com> Date: Sat, 5 Sep 2026 00:00:34 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20if/while=20=E6=91=8A=E6=88=90?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E5=86=85=20goto/br=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E5=BB=BA=20scope=20=E5=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + README_CN.md | 1 + layout/src/code.rs | 283 ++++++++++---------- layout/src/keytree.rs | 30 ++- layout/src/lower.rs | 35 ++- layout/tests/issue116.rs | 468 +++++++++++++++++++++++++++++++++ layout/tests/pipeline_test.rs | 53 +++- runtime/src/keytree.c | 20 +- runtime/src/kvcpu.c | 143 +++------- runtime/src/runtime_internal.h | 2 +- runtime/src/rwir.c | 82 +----- tutorial/issue116_exp.py | 382 +++++++++++++++++++++++++++ 12 files changed, 1165 insertions(+), 335 deletions(-) create mode 100644 layout/tests/issue116.rs create mode 100644 tutorial/issue116_exp.py diff --git a/README.md b/README.md index 044e1ccd..7fe7cb55 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ 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 +goto/br = rewrite 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..edc2626e 100644 --- a/README_CN.md +++ b/README_CN.md @@ -28,6 +28,7 @@ PC = "/vthread/tid/[0,0]/[0,0]/[1,0]" 程序计数器是 KV 路径 指令 = kv.Get(PC) 取指是一次 KV 读 调用 = 创建子树;返回 = 清理子树 崩溃后按 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/·/