fix: 修复复用 VM IC 缓存未清除问题

This commit is contained in:
爱特每羊队
2026-06-07 19:22:25 +08:00
parent 19f016e866
commit 3fce4a9663
3 changed files with 56 additions and 3 deletions
+18
View File
@@ -864,9 +864,27 @@ impl Vm {
self.regs = [JsValue::undefined(); 256];
self.frames.clear();
self.for_in_iters.clear();
self.clear_ic_caches();
self.dispatch()
}
fn clear_ic_caches(&mut self) {
let mut i = 0;
while i < self.bytecode.len() {
let op = opcode::opcode(self.bytecode[i]);
if op.has_ic_ext_words() {
if i + 3 < self.bytecode.len() {
self.bytecode[i + 1] = 0;
self.bytecode[i + 2] = 0;
self.bytecode[i + 3] = 0;
}
i += 4;
} else {
i += 1;
}
}
}
pub fn run(&mut self, module: &CompiledModule) -> Result<JsValue, String> {
self.constants = self.convert_constants(module);
self.sub_modules = module.sub_modules.clone();