perf: 不可变常量改 OnceLock 一次性缓存,删 Constant 死变体并移出 GC 根

This commit is contained in:
爱特每羊队
2026-06-25 14:32:49 +08:00
parent 1ef8349208
commit 06f769c4e0
9 changed files with 115 additions and 192 deletions
+1 -6
View File
@@ -10,8 +10,6 @@ pub enum Constant {
Boolean(bool),
Null,
Undefined,
BytecodeFunc(u32),
RegExp(String, String),
}
pub struct CompiledModule {
@@ -92,10 +90,7 @@ impl fmt::Display for CompiledModule {
writeln!(f, "; n_registers = {}", self.n_registers)?;
writeln!(f, "; constants:")?;
for (i, c) in self.constants.iter().enumerate() {
match c {
Constant::BytecodeFunc(idx) => writeln!(f, "; [{i}] = BytecodeFunc(sub_module[{idx}])")?,
other => writeln!(f, "; [{i}] = {other:?}")?,
}
writeln!(f, "; [{i}] = {c:?}")?;
}
writeln!(f)?;
for (offset, &instr) in self.bytecode.iter().enumerate() {