Skip to content

runtime: 执行循环热路径免 malloc + vthread 状态写入收敛 - #312

Merged
miaobyte merged 1 commit into
masterfrom
feat/issue-309-runtime-hotpath
Sep 12, 2026
Merged

runtime: 执行循环热路径免 malloc + vthread 状态写入收敛#312
miaobyte merged 1 commit into
masterfrom
feat/issue-309-runtime-hotpath

Conversation

@miaobyte

Copy link
Copy Markdown
Contributor

变更

routine-c 每指令热路径去掉多余分配与回读。

  • keytreekvlangKeytreeStackBuf / kvlangKeytreeFrameRootLenFrameNum 直接定位帧坐标、免 strbuf 构造。
  • kvspace:短 key 走栈缓冲(免每操作一次 malloc);新增 kvlangKvSetChar 直写 char/utf8 body,跳过「TLV 编码→KvSet 再解 head」往返,供 PC 推进热路径用。
  • kvcpu:执行循环缓存 frame_root/深度/funcdir,仅当帧变(前缀比较)才重算;jump_to 复用帧根;免指令后回读。
  • vthreadkvlangVthreadAdvance(状态门,每步只回读 1 个 ‥status key,保证外部置 paused/error 下一步即见)+ kvlangVthreadStatusGet
  • kvlangFrame_tframe_root/status_known/fb_pc;rwir_func/decode/myrwircaps 配套签名收敛。

10 文件 +299/-94。CI(shm+fs 跑 tutorial)验证不回归。

Closes #309

🤖 Generated with Claude Code

- keytree: 新增 kvlangKeytreeStackBuf/FrameRootLen;FrameNum 免 strbuf 构造
- kvspace: 短 key 走栈缓冲;新增 kvlangKvSetChar 直写 char/utf8 body
  (跳过 TLV 编码→KvSet 往返),供 PC 推进热路径
- kvcpu: 执行循环缓存 frame_root/深度/funcdir,前缀比较判帧变;
  jump_to/Advance 复用帧根;免指令后回读
- vthread: kvlangVthreadAdvance(状态门,每步只回读 1 个 ‥status key)
  + kvlangVthreadStatusGet
- frame_t 增 frame_root/status_known/fb_pc;rwir_func/decode/myrwircaps
  配套签名收敛

Closes #309

Co-Authored-By: Claude Code <noreply@anthropic.com>
@miaobyte
miaobyte merged commit e4e4fc3 into master Sep 12, 2026
4 checks passed
@miaobyte
miaobyte deleted the feat/issue-309-runtime-hotpath branch September 12, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2-runtime: 执行循环热路径免 malloc + vthread 状态写入收敛

1 participant