feat(jit): fib!

This commit is contained in:
2025-05-19 19:29:25 +08:00
parent 6d26716412
commit 9e172bf013
10 changed files with 363 additions and 166 deletions

View File

@@ -11,7 +11,7 @@ use super::public as p;
use crate::bytecode::OpCodes;
use crate::error::*;
use crate::vm::{Env, VM};
use crate::vm::{LetEnv, VM};
mod attrset;
mod func;
@@ -157,7 +157,11 @@ impl<'jit, 'vm> Value<'jit, 'vm> {
pub fn typename(&self) -> &'static str {
use Value::*;
match self {
Const(_) => unreachable!(),
Const(self::Const::Int(_)) => "int",
Const(self::Const::Float(_)) => "float",
Const(self::Const::Bool(_)) => "bool",
Const(self::Const::String(_)) => "string",
Const(self::Const::Null) => "null",
Thunk(_) => "thunk",
ThunkRef(_) => "thunk",
AttrSet(_) => "set",
@@ -481,7 +485,7 @@ pub struct Thunk<'jit, 'vm> {
#[derive(Debug, IsVariant, Unwrap, Clone)]
pub enum _Thunk<'jit, 'vm> {
Code(&'vm OpCodes, OnceCell<Env<'jit, 'vm>>),
Code(&'vm OpCodes, OnceCell<LetEnv<'jit, 'vm>>),
SuspendedFrom(*const Thunk<'jit, 'vm>),
Value(Value<'jit, 'vm>),
}
@@ -493,7 +497,7 @@ impl<'jit, 'vm> Thunk<'jit, 'vm> {
}
}
pub fn capture(&self, env: Env<'jit, 'vm>) {
pub fn capture(&self, env: LetEnv<'jit, 'vm>) {
if let _Thunk::Code(_, envcell) = &*self.thunk.borrow() {
envcell.get_or_init(|| env);
}