fix: 将 VM 步数上限改为 KernelConfig 可配置项
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user