refactor vm

This commit is contained in:
2026-04-19 17:23:51 +08:00
parent ca7f7a5ec8
commit e527d31450
14 changed files with 1504 additions and 906 deletions
+51
View File
@@ -0,0 +1,51 @@
use crate::{BytecodeReader, StepResult};
impl<'gc> crate::Vm<'gc> {
#[inline(always)]
pub(crate) fn op_jump_if_false(
&mut self,
reader: &mut BytecodeReader<'_>,
mc: &gc_arena::Mutation<'gc>,
) -> StepResult<'gc> {
let offset = reader.read_i32();
if let Some(step) = self.try_force_resolved(0, reader.inst_start_pc(), mc) {
return step;
}
let cond = self.pop_stack();
if cond.as_inline::<bool>() == Some(false) {
reader.set_pc(((reader.pc() as isize) + (offset as isize)) as usize);
}
StepResult::Continue
}
#[inline(always)]
pub(crate) fn op_jump_if_true(
&mut self,
reader: &mut BytecodeReader<'_>,
mc: &gc_arena::Mutation<'gc>,
) -> StepResult<'gc> {
let offset = reader.read_i32();
if let Some(step) = self.try_force_resolved(0, reader.inst_start_pc(), mc) {
return step;
}
let cond = self.pop_stack();
if cond.as_inline::<bool>() == Some(true) {
reader.set_pc(((reader.pc() as isize) + (offset as isize)) as usize);
}
StepResult::Continue
}
#[inline(always)]
pub(crate) fn op_jump(&mut self, reader: &mut BytecodeReader<'_>) -> StepResult<'gc> {
let offset = reader.read_i32();
reader.set_pc(((reader.pc() as isize) + (offset as isize)) as usize);
StepResult::Continue
}
#[inline(always)]
pub(crate) fn op_assert(&mut self, reader: &mut BytecodeReader<'_>) -> StepResult<'gc> {
let _raw_idx = reader.read_u32();
let _span_id = reader.read_u32();
todo!("implement Assert (force TOS)");
}
}