feat: 生成器基础支持(YIELD 帧快照挂起/恢复 + GeneratorPrototype next/return/throw)

- 新增 YIELD/SUSPEND_BODY opcode;function* 识别与 yield emit
- GeneratorState 全量快照 VM 执行上下文(regs/pc/bytecode/spill/save/try/cell 栈段/迭代器)
- 调用时参数初始化(默认值/解构副作用与异常在 g() 时刻生效)
- %GeneratorPrototype%/%GeneratorFunction.prototype% 内建对象与 next/return/throw
- session GC trace 生成器状态 JsValues;闭包捕获分析补 yield/赋值目标扫描
This commit is contained in:
2026-08-09 18:02:08 +08:00
parent cd1bc206a5
commit 783e89e4cb
26 changed files with 1265 additions and 107 deletions
+6 -1
View File
@@ -189,7 +189,7 @@ define_opcodes! {
PROFILE_BRANCH = 0x6B => "PROFILE_BRANCH",
PROFILE_CALL = 0x6C => "PROFILE_CALL",
// ── 并行 — 占位符 (0x70-0x7F) ──
// ── 并行 — 占位符 (0x70-0x75) ──
FORK = 0x70 => "FORK",
JOIN = 0x71 => "JOIN",
GET_PRIVATE = 0x72 => "GET_PRIVATE",
@@ -197,6 +197,11 @@ define_opcodes! {
INIT_PRIVATE = 0x74 => "INIT_PRIVATE",
PRIVATE_BRAND_IN = 0x75 => "PRIVATE_BRAND_IN",
// ── 生成器 (0x76-0x77) ──
YIELD = 0x76 => "YIELD", // rd=被让出的值(结果经 reg 0 交付,见 contract.rs)
// 生成器 body 起点标记:调用时参数初始化完成后挂起于此,首次 next() 从这继续。
SUSPEND_BODY = 0x77 => "SUSPEND_BODY",
// ── 位运算 (0x80-0x8F) ──
BIT_AND = 0x80 => "BIT_AND",
BIT_OR = 0x81 => "BIT_OR",