diff --git a/cli/src/repl/eval.rs b/cli/src/repl/eval.rs index 89fd30e74f..ef6dfec3a4 100644 --- a/cli/src/repl/eval.rs +++ b/cli/src/repl/eval.rs @@ -6,6 +6,7 @@ use roc_gen_llvm::{run_jit_function, run_jit_function_dynamic_type}; use roc_module::ident::{Lowercase, TagName}; use roc_module::operator::CalledVia; use roc_module::symbol::{Interns, ModuleId, Symbol}; +use roc_mono::ir::TopLevelFunctionLayout; use roc_mono::layout::{union_sorted_tags_help, Builtin, Layout, UnionLayout, UnionVariant}; use roc_parse::ast::{AssignedField, Expr, StrLiteral}; use roc_region::all::{Located, Region}; @@ -37,7 +38,7 @@ pub unsafe fn jit_to_ast<'a>( arena: &'a Bump, lib: Library, main_fn_name: &str, - layout: &Layout<'a>, + layout: TopLevelFunctionLayout<'a>, content: &Content, interns: &Interns, home: ModuleId, @@ -53,11 +54,14 @@ pub unsafe fn jit_to_ast<'a>( }; match layout { - Layout::FunctionPointer(&[], result) => { + TopLevelFunctionLayout { + arguments: [], + result, + } => { // this is a thunk - jit_to_ast_help(&env, lib, main_fn_name, result, content) + jit_to_ast_help(&env, lib, main_fn_name, &result, content) } - _ => jit_to_ast_help(&env, lib, main_fn_name, layout, content), + _ => Err(ToAstProblem::FunctionLayout), } } diff --git a/cli/src/repl/gen.rs b/cli/src/repl/gen.rs index 699d244908..797fdba999 100644 --- a/cli/src/repl/gen.rs +++ b/cli/src/repl/gen.rs @@ -226,7 +226,7 @@ pub fn gen_and_eval<'a>( &arena, lib, main_fn_name, - &arena.alloc(main_fn_layout).full(), + main_fn_layout, &content, &env.interns, home, diff --git a/compiler/gen_llvm/src/llvm/build.rs b/compiler/gen_llvm/src/llvm/build.rs index d2beab5002..6b65b7d985 100644 --- a/compiler/gen_llvm/src/llvm/build.rs +++ b/compiler/gen_llvm/src/llvm/build.rs @@ -118,7 +118,7 @@ impl<'ctx> Iterator for FunctionIterator<'ctx> { #[derive(Default, Debug, Clone, PartialEq)] pub struct Scope<'a, 'ctx> { symbols: ImMap, BasicValueEnum<'ctx>)>, - pub top_level_thunks: ImMap, FunctionValue<'ctx>)>, + pub top_level_thunks: ImMap, FunctionValue<'ctx>)>, join_points: ImMap, &'a [PointerValue<'ctx>])>, } @@ -136,7 +136,7 @@ impl<'a, 'ctx> Scope<'a, 'ctx> { function_value: FunctionValue<'ctx>, ) { self.top_level_thunks - .insert(symbol, (layout.full(), function_value)); + .insert(symbol, (*layout, function_value)); } fn remove(&mut self, symbol: &Symbol) { self.symbols.remove(symbol); diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index 3138184873..ff8a92d886 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -2624,10 +2624,6 @@ impl<'a> TopLevelFunctionLayout<'a> { }, } } - - pub fn full(&'a self) -> Layout<'a> { - Layout::FunctionPointer(self.arguments, &self.result) - } } fn specialize_naked_symbol<'a>( @@ -6788,7 +6784,7 @@ fn call_specialized_proc<'a>( arguments: field_symbols, }; - build_call(env, call, assigned, function_layout.full(), hole) + build_call(env, call, assigned, function_layout.result, hole) } } } else {