feat: lookup at downgrade time
works, but leaks memory
This commit is contained in:
@@ -199,7 +199,7 @@ impl<'gc> JITContext<'gc> {
|
||||
|
||||
pub fn compile_seq(
|
||||
&self,
|
||||
opcodes: impl ExactSizeIterator<Item = OpCode> + DoubleEndedIterator,
|
||||
mut opcodes: impl ExactSizeIterator<Item = OpCode>,
|
||||
vm: &'gc VM<'gc>,
|
||||
) -> Result<JITFunc<'gc>> {
|
||||
let mut stack = Stack::<_, STACK_SIZE>::new();
|
||||
@@ -211,7 +211,7 @@ impl<'gc> JITContext<'gc> {
|
||||
let entry = self.context.append_basic_block(func_, "entry");
|
||||
self.builder.position_at_end(entry);
|
||||
let len = opcodes.len();
|
||||
self.build_expr(&mut opcodes.rev(), vm, env, mc, &mut stack, func_, len)?;
|
||||
self.build_expr(&mut opcodes, vm, env, mc, &mut stack, func_, len)?;
|
||||
|
||||
assert_eq!(stack.len(), 1);
|
||||
let value = stack.pop();
|
||||
@@ -437,6 +437,47 @@ impl<'gc> JITContext<'gc> {
|
||||
_ => todo!("BinOp::{:?} not implemented in JIT", op),
|
||||
}
|
||||
}
|
||||
OpCode::Arg { level } => stack.push(
|
||||
self.builder
|
||||
.build_direct_call(
|
||||
self.helpers.arg,
|
||||
&[
|
||||
self.helpers
|
||||
.ptr_int_type
|
||||
.const_int(level as u64, false)
|
||||
.into(),
|
||||
env.into(),
|
||||
],
|
||||
"call_arg",
|
||||
)
|
||||
.unwrap()
|
||||
.try_as_basic_value()
|
||||
.left()
|
||||
.unwrap(),
|
||||
)?,
|
||||
OpCode::LookUpLet { level, idx } => stack.push(
|
||||
self.builder
|
||||
.build_direct_call(
|
||||
self.helpers.lookup_let,
|
||||
&[
|
||||
self.helpers
|
||||
.ptr_int_type
|
||||
.const_int(level as u64, false)
|
||||
.into(),
|
||||
self.helpers
|
||||
.ptr_int_type
|
||||
.const_int(idx as u64, false)
|
||||
.into(),
|
||||
env.into(),
|
||||
],
|
||||
"call_lookup_let",
|
||||
)
|
||||
.unwrap()
|
||||
.try_as_basic_value()
|
||||
.left()
|
||||
.unwrap(),
|
||||
)?,
|
||||
|
||||
OpCode::LookUp { sym } => stack.push(
|
||||
self.builder
|
||||
.build_direct_call(
|
||||
|
||||
Reference in New Issue
Block a user