feat: less gc (WIP)

This commit is contained in:
2025-06-02 14:18:59 +08:00
parent d3442e87e7
commit 51f8df9cca
11 changed files with 125 additions and 179 deletions

View File

@@ -11,7 +11,7 @@ pub struct Env<'gc, K: Hash + Eq + Collect<'gc>, V: Collect<'gc>> {
let_: Gc<'gc, LetEnv<'gc, V>>,
with: Gc<'gc, With<'gc, K, V>>,
args: Vec<V>,
gc_alloced: Vec<Gc<'gc, V>>,
jit_store: Vec<Box<V>>,
last: Option<Gc<'gc, Env<'gc, K, V>>>,
}
@@ -60,7 +60,7 @@ impl<'gc, K: Hash + Eq + Clone + Collect<'gc>, V: Clone + Collect<'gc>> Env<'gc,
},
),
args: Vec::new(),
gc_alloced: Vec::new(),
jit_store: Vec::new(),
last: None,
},
)
@@ -92,7 +92,7 @@ impl<'gc, K: Hash + Eq + Clone + Collect<'gc>, V: Clone + Collect<'gc>> Env<'gc,
let_: self.let_,
with: self.with,
last: Some(self),
gc_alloced: Vec::new(),
jit_store: Vec::new(),
args
},
)
@@ -110,7 +110,7 @@ impl<'gc, K: Hash + Eq + Clone + Collect<'gc>, V: Clone + Collect<'gc>> Env<'gc,
let_: self.let_.enter_let(map, mc),
with: self.with,
args: self.args.clone(),
gc_alloced: Vec::new(),
jit_store: Vec::new(),
last: Some(self),
},
)
@@ -128,17 +128,21 @@ impl<'gc, K: Hash + Eq + Clone + Collect<'gc>, V: Clone + Collect<'gc>> Env<'gc,
let_: self.let_,
with: self.with.enter(map, mc),
args: self.args.clone(),
gc_alloced: Vec::new(),
jit_store: Vec::new(),
last: Some(self),
},
)
}
#[inline]
pub fn alloc_gc(&mut self, val: V, mc: &Mutation<'gc>) -> &'gc V {
let gc = Gc::new(mc, val);
self.gc_alloced.push(gc);
gc.as_ref()
pub fn jit_store(&'gc mut self, val: V) -> &'gc V {
self.jit_store.push(Box::new(val));
&self.jit_store[self.jit_store.len() - 1]
}
#[inline]
pub fn jit_stored(&self) -> usize {
self.jit_store.len()
}
pub fn leave(&self) -> Gc<'gc, Self> {