fix: 子模块全局扁平化根治逃逸闭包上下文错位

This commit is contained in:
2026-08-07 10:49:15 +08:00
parent 98b07687f0
commit fd94ff6931
10 changed files with 137 additions and 62 deletions
+5
View File
@@ -64,6 +64,9 @@ pub struct CompiledModule {
pub needs_home_object: bool,
pub upvalue_captures: Vec<UpvalueCapture>,
pub cells_needed: u8,
/// 全局扁平模块 id:编译末端 flatten 阶段分配(顶层 0,子模块 DFS 递增)。
/// `CREATE_CLOSURE` 的 imm16 在 flatten 后即此 id,运行时以它为平表下标。
pub flat_id: u32,
}
impl CompiledModule {
@@ -85,6 +88,7 @@ impl CompiledModule {
needs_home_object: false,
upvalue_captures: Vec::new(),
cells_needed: 0,
flat_id: 0,
}
}
}
@@ -113,6 +117,7 @@ impl Clone for CompiledModule {
needs_home_object: self.needs_home_object,
upvalue_captures: self.upvalue_captures.clone(),
cells_needed: self.cells_needed,
flat_id: self.flat_id,
}
}
}