feat: 添加全局 VM 池与 RAII 泄漏保护

This commit is contained in:
爱特每羊队
2026-06-05 22:25:22 +08:00
parent ba46a3e60b
commit 2d3ced1a7b
4 changed files with 218 additions and 9 deletions
+11
View File
@@ -43,6 +43,17 @@ impl Vm {
}
}
pub fn reset(&mut self) {
self.regs = [JsValue::undefined(); 256];
self.pc = 0;
self.bytecode.clear();
self.constants.clear();
self.frames.clear();
self.string_table.clear();
self.string_reverse.clear();
self.epoch.reset();
}
pub fn intern(&mut self, s: &str) -> JsValue {
if let Some(&idx) = self.string_table.get(s) {
return JsValue::string(idx, hash16(s));