fix: 将 VM 步数上限改为 KernelConfig 可配置项

This commit is contained in:
爱特每羊队
2026-06-08 21:46:08 +08:00
parent 43c7151c54
commit 2e09beaf65
3 changed files with 43 additions and 3 deletions
+4 -3
View File
@@ -556,11 +556,12 @@ impl Vm {
fn dispatch(&mut self) -> Result<JsValue, String> {
let mut steps: u64 = 0;
const MAX_STEPS: u64 = 100_000_000;
loop {
steps += 1;
if steps > MAX_STEPS {
return Err(format!("VM step limit exceeded at pc={}", self.pc));
if let Some(max_steps) = self.kernel.config.max_steps {
if steps > max_steps {
return Err(format!("VM step limit exceeded at pc={}", self.pc));
}
}
if self.pc >= self.bytecode.len() {
return Err("program counter out of bounds".into());