From 581c33307027e80516d9529c796354f499d89bd8 Mon Sep 17 00:00:00 2001 From: imxyy_soope_ Date: Mon, 20 Apr 2026 15:28:51 +0800 Subject: [PATCH] minor changes --- fix-vm/src/dispatch_tailcall.rs | 3 +-- fix-vm/src/lib.rs | 11 +++++------ fix-vm/src/value.rs | 1 + 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/fix-vm/src/dispatch_tailcall.rs b/fix-vm/src/dispatch_tailcall.rs index 7a16f6c..1e0c817 100644 --- a/fix-vm/src/dispatch_tailcall.rs +++ b/fix-vm/src/dispatch_tailcall.rs @@ -288,8 +288,7 @@ pub(crate) fn run_tailcall<'gc, C: VmContext>( bc: &[u8], pc: u32, ) -> TailResult { - const FUEL: u32 = 1024; let table = &DispatchTable::<'gc, C>::NEW; let op = bc[pc as usize] as usize; - table.0[op](vm, mc, ctx, bc, table, pc, FUEL) + table.0[op](vm, mc, ctx, bc, table, pc, Vm::DEFAULT_FUEL_AMOUNT) } diff --git a/fix-vm/src/lib.rs b/fix-vm/src/lib.rs index 4bd4f8a..ea62019 100644 --- a/fix-vm/src/lib.rs +++ b/fix-vm/src/lib.rs @@ -143,6 +143,7 @@ pub struct Vm<'gc> { pub(crate) stack: Vec>, pub(crate) call_stack: Vec>, pub(crate) call_depth: usize, + #[allow(dead_code)] #[collect(require_static)] pub(crate) error_context: Vec, @@ -332,10 +333,7 @@ impl<'gc> Vm<'gc> { reader: &mut BytecodeReader<'_>, mc: &Mutation<'gc>, ) -> Option { - let val = self.peek_stack(depth); - let Some(thunk) = val.as_gc::() else { - return None; - }; + let thunk = self.peek_stack(depth).as_gc::()?; let mut state = thunk.borrow_mut(mc); match *state { ThunkState::Pending { ip, env, with_env } => { @@ -425,6 +423,8 @@ impl Vm<'_> { } impl<'gc> Vm<'gc> { + const DEFAULT_FUEL_AMOUNT: u32 = 1024; + #[inline(always)] fn dispatch_batch( &mut self, @@ -461,10 +461,9 @@ impl<'gc> Vm<'gc> { mc: &Mutation<'gc>, ) -> Action { use fix_codegen::Op::*; - const DEFAULT_FUEL_AMOUNT: usize = 1024; let mut reader = BytecodeReader::new(bytecode, pc); - let mut fuel = DEFAULT_FUEL_AMOUNT; + let mut fuel = Self::DEFAULT_FUEL_AMOUNT; loop { if fuel == 0 { diff --git a/fix-vm/src/value.rs b/fix-vm/src/value.rs index 9c42197..141be58 100644 --- a/fix-vm/src/value.rs +++ b/fix-vm/src/value.rs @@ -28,6 +28,7 @@ mod private { pub unsafe trait Storable: private::Cealed { const TAG: (bool, u8); } +#[allow(private_bounds)] pub trait InlineStorable: Storable + RawStore {} pub trait GcStorable: Storable {}