Skip to content

Commit

Permalink
don't capture from outside join point for the dev backend
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed Jun 21, 2023
1 parent b848128 commit 5fa7910
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions crates/compiler/mono/src/tail_recursion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ fn trmc_candidates_help<'a>(
#[derive(Clone)]
pub(crate) struct TrmcEnv<'a> {
hole_symbol: Symbol,
initial_ptr_symbol: Symbol,
head_symbol: Symbol,
joinpoint_id: JoinPointId,
return_layout: InLayout<'a>,
ptr_return_layout: InLayout<'a>,
Expand Down Expand Up @@ -659,6 +659,7 @@ impl<'a> TrmcEnv<'a> {
// the root of the recursive structure that we'll be building
let initial_ptr_symbol = env.named_unique_symbol("initial");
jump_arguments.push(initial_ptr_symbol);
jump_arguments.push(initial_ptr_symbol);

let null_symbol = env.named_unique_symbol("null");
let let_null = |next| Stmt::Let(null_symbol, Expr::NullPointer, return_layout, next);
Expand All @@ -680,14 +681,15 @@ impl<'a> TrmcEnv<'a> {

let joinpoint_id = JoinPointId(env.named_unique_symbol("trmc"));
let hole_symbol = env.named_unique_symbol("hole");
let head_symbol = env.named_unique_symbol("head");

let jump_stmt = Stmt::Jump(joinpoint_id, jump_arguments.into_bump_slice());

let trmc_calls = trmc_calls.iter().map(|s| (*s, None)).collect();

let mut this = Self {
hole_symbol,
initial_ptr_symbol,
head_symbol,
joinpoint_id,
return_layout,
ptr_return_layout,
Expand All @@ -701,6 +703,13 @@ impl<'a> TrmcEnv<'a> {
};
joinpoint_parameters.push(param);

let param = Param {
symbol: head_symbol,
ownership: Ownership::Owned,
layout: ptr_return_layout,
};
joinpoint_parameters.push(param);

let joinpoint = Stmt::Join {
id: joinpoint_id,
parameters: joinpoint_parameters.into_bump_slice(),
Expand Down Expand Up @@ -834,6 +843,7 @@ impl<'a> TrmcEnv<'a> {
let mut jump_arguments =
Vec::from_iter_in(call.arguments.iter().copied(), env.arena);
jump_arguments.push(new_hole_symbol);
jump_arguments.push(self.head_symbol);

let jump =
Stmt::Jump(self.joinpoint_id, jump_arguments.into_bump_slice());
Expand Down Expand Up @@ -963,7 +973,7 @@ impl<'a> TrmcEnv<'a> {
op: LowLevel::PtrLoad,
update_mode: UpdateModeId::BACKEND_DUMMY,
},
arguments: &*arena.alloc([self.initial_ptr_symbol]),
arguments: &*arena.alloc([self.head_symbol]),
};

let ptr_load = |next| Stmt::Let(final_symbol, Expr::Call(call), layout, next);
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/test_gen/src/gen_primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ fn linked_list_sum_int() {
}

#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn linked_list_map() {
assert_evals_to!(
indoc!(
Expand Down

0 comments on commit 5fa7910

Please sign in to comment.