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 gc_arena::{Gc, Mutation};
use crate::{BytecodeReader, StepResult, Value};
impl<'gc> crate::Vm<'gc> {
#[inline(always)]
pub(crate) fn op_push_smi(&mut self, reader: &mut BytecodeReader<'_>) -> StepResult<'gc> {
let val = reader.read_i32();
self.push_stack(Value::new_inline(val));
StepResult::Continue
}
#[inline(always)]
pub(crate) fn op_push_bigint(&mut self, reader: &mut BytecodeReader<'_>, mc: &Mutation<'gc>) -> StepResult<'gc> {
let val = reader.read_i64();
self.push_stack(Value::new_gc(Gc::new(mc, val)));
StepResult::Continue
}
#[inline(always)]
pub(crate) fn op_push_float(&mut self, reader: &mut BytecodeReader<'_>) -> StepResult<'gc> {
let val = reader.read_f64();
self.push_stack(Value::new_float(val));
StepResult::Continue
}
#[inline(always)]
pub(crate) fn op_push_string(&mut self, reader: &mut BytecodeReader<'_>) -> StepResult<'gc> {
let sid = reader.read_string_id();
self.push_stack(Value::new_inline(sid));
StepResult::Continue
}
#[inline(always)]
pub(crate) fn op_push_null(&mut self) -> StepResult<'gc> {
self.push_stack(Value::new_inline(crate::Null));
StepResult::Continue
}
#[inline(always)]
pub(crate) fn op_push_true(&mut self) -> StepResult<'gc> {
self.push_stack(Value::new_inline(true));
StepResult::Continue
}
#[inline(always)]
pub(crate) fn op_push_false(&mut self) -> StepResult<'gc> {
self.push_stack(Value::new_inline(false));
StepResult::Continue
}
}