minor changes

This commit is contained in:
2026-04-10 21:25:32 +08:00
parent b1b886229b
commit d90fd8d681
2 changed files with 10 additions and 10 deletions
+9 -7
View File
@@ -422,12 +422,10 @@ impl<C: VmContext> Vm<C> {
self.fuel -= 1;
let byte = self.ctx.bytecode()[self.pc];
if likely_stable::unlikely(!(0..Op::Illegal as u8).contains(&byte)) {
if !likely_stable::likely((0..Op::Illegal as u8).contains(&byte)) {
panic!("unknown opcode: {byte:#04x}")
}
let op = unsafe {
std::mem::transmute::<u8, Op>(byte)
};
let op = unsafe { std::mem::transmute::<u8, Op>(byte) };
// let Ok(op) = Op::try_from_primitive(self.ctx.bytecode()[self.pc])
// .map_err(|err| panic!("unknown opcode: {:#04x}", err.number));
self.pc += 1;
@@ -1105,7 +1103,7 @@ impl<C: VmContext> Vm<C> {
return self.handle_return();
}
Illegal => unreachable!()
Illegal => unreachable!(),
}
Action::Continue
@@ -1294,13 +1292,13 @@ impl<C: VmContext> Vm<C> {
#[inline]
fn force_tos(&mut self) -> Action {
loop {
let (run, target_depth) = self.arena.mutate_root(|_mc, root| {
let (run, target_depth) = self.arena.mutate_root(|mc, root| {
let thunk = root.stack.tos_mut().expect("stack underflow");
let Some(thunk_state) = thunk.as_gc::<Thunk>() else {
return (false, 0);
};
match *thunk_state.borrow() {
let ret = match *thunk_state.borrow() {
ThunkState::Pending { ip, env, with_env } => {
root.frames
.push(CallFrame {
@@ -1320,7 +1318,11 @@ impl<C: VmContext> Vm<C> {
(false, 0)
}
ThunkState::Blackhole => todo!("force_tos"),
};
if ret.0 {
*thunk_state.borrow_mut(mc) = ThunkState::Blackhole;
}
ret
});
if likely_stable::likely(!run) {
return Action::Continue;