feat: 添加全局 VM 池与 RAII 泄漏保护
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user