feat: add experimental tailcall vm backend
This commit is contained in:
@@ -12,6 +12,7 @@ pub(crate) struct BytecodeReader<'a> {
|
||||
}
|
||||
|
||||
impl<'a> BytecodeReader<'a> {
|
||||
#[cfg_attr(feature = "tailcall", allow(dead_code))]
|
||||
pub(crate) fn new(bytecode: &'a [u8], pc: usize) -> Self {
|
||||
Self {
|
||||
bytecode,
|
||||
@@ -20,6 +21,16 @@ impl<'a> BytecodeReader<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg_attr(not(feature = "tailcall"), allow(dead_code))]
|
||||
pub(crate) fn from_after_op(bytecode: &'a [u8], inst_start_pc: usize) -> Self {
|
||||
Self {
|
||||
bytecode,
|
||||
pc: inst_start_pc + 1,
|
||||
inst_start_pc,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg_attr(debug_assertions, track_caller)]
|
||||
fn read_array<const N: usize>(&mut self) -> [u8; N] {
|
||||
@@ -31,6 +42,7 @@ impl<'a> BytecodeReader<'a> {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[cfg_attr(feature = "tailcall", allow(dead_code))]
|
||||
pub(crate) fn read_op(&mut self) -> fix_codegen::Op {
|
||||
use fix_codegen::Op;
|
||||
self.inst_start_pc = self.pc;
|
||||
@@ -105,16 +117,17 @@ impl<'a> BytecodeReader<'a> {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(crate) fn read_attr_key_data<C: crate::VmContext>(&mut self, ctx: &C) -> crate::AttrKeyData {
|
||||
pub(crate) fn read_attr_key_data<C: crate::VmContext>(
|
||||
&mut self,
|
||||
ctx: &C,
|
||||
) -> crate::AttrKeyData {
|
||||
use fix_codegen::AttrKeyType;
|
||||
let tag = self.read_u8();
|
||||
let ty = AttrKeyType::try_from_primitive(tag)
|
||||
.unwrap_or_else(|err| panic!("unknown key tag: {:#04x}", err.number));
|
||||
match ty {
|
||||
AttrKeyType::Static => crate::AttrKeyData::Static(self.read_string_id()),
|
||||
AttrKeyType::Dynamic => {
|
||||
crate::AttrKeyData::Dynamic(self.read_operand_data(ctx))
|
||||
}
|
||||
AttrKeyType::Dynamic => crate::AttrKeyData::Dynamic(self.read_operand_data(ctx)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user