mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Revert "Store layouts in a layout-buffer for expects"
This reverts commit bba6e36a18
.
This commit is contained in:
parent
bba6e36a18
commit
897b69b072
8 changed files with 30 additions and 67 deletions
|
@ -2222,7 +2222,7 @@ macro_rules! debug_print_ir {
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! debug_check_ir {
|
macro_rules! debug_check_ir {
|
||||||
($state:expr, $arena:expr, $interner:expr, $layout_buffers:expr, $flag:path) => {
|
($state:expr, $arena:expr, $interner:expr, $flag:path) => {
|
||||||
dbg_do!($flag, {
|
dbg_do!($flag, {
|
||||||
use roc_mono::debug::{check_procs, format_problems};
|
use roc_mono::debug::{check_procs, format_problems};
|
||||||
|
|
||||||
|
@ -2233,7 +2233,7 @@ macro_rules! debug_check_ir {
|
||||||
|
|
||||||
let procedures = &$state.procedures;
|
let procedures = &$state.procedures;
|
||||||
|
|
||||||
let problems = check_procs($arena, $interner, $layout_buffers, procedures);
|
let problems = check_procs($arena, $interner, procedures);
|
||||||
if !problems.is_empty() {
|
if !problems.is_empty() {
|
||||||
let formatted = format_problems(&interns, $interner, problems);
|
let formatted = format_problems(&interns, $interner, problems);
|
||||||
eprintln!("IR PROBLEMS FOUND:\n{formatted}");
|
eprintln!("IR PROBLEMS FOUND:\n{formatted}");
|
||||||
|
@ -2958,18 +2958,10 @@ fn update<'a>(
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.expect("outstanding references to global layout interener, but we just drained all layout caches");
|
.expect("outstanding references to global layout interener, but we just drained all layout caches");
|
||||||
|
|
||||||
let layout_buffers = &state.module_cache.layout_buffers;
|
|
||||||
|
|
||||||
log!("specializations complete from {:?}", module_id);
|
log!("specializations complete from {:?}", module_id);
|
||||||
|
|
||||||
debug_print_ir!(state, &layout_interner, ROC_PRINT_IR_AFTER_SPECIALIZATION);
|
debug_print_ir!(state, &layout_interner, ROC_PRINT_IR_AFTER_SPECIALIZATION);
|
||||||
debug_check_ir!(
|
debug_check_ir!(state, arena, &layout_interner, ROC_CHECK_MONO_IR);
|
||||||
state,
|
|
||||||
arena,
|
|
||||||
&layout_interner,
|
|
||||||
layout_buffers,
|
|
||||||
ROC_CHECK_MONO_IR
|
|
||||||
);
|
|
||||||
|
|
||||||
let ident_ids = state.constrained_ident_ids.get_mut(&module_id).unwrap();
|
let ident_ids = state.constrained_ident_ids.get_mut(&module_id).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use roc_collections::{MutMap, VecMap, VecSet};
|
use roc_collections::{MutMap, VecMap, VecSet};
|
||||||
use roc_module::symbol::{ModuleId, Symbol};
|
use roc_module::symbol::Symbol;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ir::{
|
ir::{
|
||||||
|
@ -10,7 +10,6 @@ use crate::{
|
||||||
ModifyRc, Param, Proc, ProcLayout, Stmt,
|
ModifyRc, Param, Proc, ProcLayout, Stmt,
|
||||||
},
|
},
|
||||||
layout::{Builtin, Layout, STLayoutInterner, TagIdIntType, UnionLayout},
|
layout::{Builtin, Layout, STLayoutInterner, TagIdIntType, UnionLayout},
|
||||||
LayoutBuffer,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub enum UseKind {
|
pub enum UseKind {
|
||||||
|
@ -133,7 +132,6 @@ impl<'a> Problems<'a> {
|
||||||
pub fn check_procs<'a>(
|
pub fn check_procs<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
interner: &'a STLayoutInterner<'a>,
|
interner: &'a STLayoutInterner<'a>,
|
||||||
layout_buffers: &VecMap<ModuleId, LayoutBuffer<'a>>,
|
|
||||||
procs: &'a Procs<'a>,
|
procs: &'a Procs<'a>,
|
||||||
) -> Problems<'a> {
|
) -> Problems<'a> {
|
||||||
let mut problems = Default::default();
|
let mut problems = Default::default();
|
||||||
|
@ -151,7 +149,6 @@ pub fn check_procs<'a>(
|
||||||
venv: Default::default(),
|
venv: Default::default(),
|
||||||
joinpoints: Default::default(),
|
joinpoints: Default::default(),
|
||||||
line: 0,
|
line: 0,
|
||||||
layout_buffers,
|
|
||||||
};
|
};
|
||||||
ctx.check_proc(proc);
|
ctx.check_proc(proc);
|
||||||
}
|
}
|
||||||
|
@ -169,7 +166,6 @@ struct Ctx<'a, 'r> {
|
||||||
proc: &'a Proc<'a>,
|
proc: &'a Proc<'a>,
|
||||||
proc_layout: ProcLayout<'a>,
|
proc_layout: ProcLayout<'a>,
|
||||||
procs: &'r Procs<'a>,
|
procs: &'r Procs<'a>,
|
||||||
layout_buffers: &'r VecMap<ModuleId, LayoutBuffer<'a>>,
|
|
||||||
call_spec_ids: CallSpecIds,
|
call_spec_ids: CallSpecIds,
|
||||||
ret_layout: Layout<'a>,
|
ret_layout: Layout<'a>,
|
||||||
venv: VEnv<'a>,
|
venv: VEnv<'a>,
|
||||||
|
@ -328,10 +324,8 @@ impl<'a, 'r> Ctx<'a, 'r> {
|
||||||
Layout::Builtin(Builtin::Bool),
|
Layout::Builtin(Builtin::Bool),
|
||||||
UseKind::ExpectCond,
|
UseKind::ExpectCond,
|
||||||
);
|
);
|
||||||
let layout_buffer = self.layout_buffers.get(&condition.module_id()).unwrap();
|
|
||||||
let layouts = layout_buffer.iter_slice(layouts);
|
|
||||||
for (sym, lay) in lookups.iter().zip(layouts) {
|
for (sym, lay) in lookups.iter().zip(layouts) {
|
||||||
self.check_sym_layout(*sym, lay, UseKind::ExpectLookup);
|
self.check_sym_layout(*sym, *lay, UseKind::ExpectLookup);
|
||||||
}
|
}
|
||||||
self.check_stmt(remainder);
|
self.check_stmt(remainder);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1207,7 +1207,7 @@ impl<'a, 'i> Context<'a, 'i> {
|
||||||
condition: *condition,
|
condition: *condition,
|
||||||
region: *region,
|
region: *region,
|
||||||
lookups,
|
lookups,
|
||||||
layouts: *layouts,
|
layouts,
|
||||||
remainder: b,
|
remainder: b,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1231,7 +1231,7 @@ impl<'a, 'i> Context<'a, 'i> {
|
||||||
condition: *condition,
|
condition: *condition,
|
||||||
region: *region,
|
region: *region,
|
||||||
lookups,
|
lookups,
|
||||||
layouts: *layouts,
|
layouts,
|
||||||
remainder: b,
|
remainder: b,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ use roc_can::abilities::SpecializationId;
|
||||||
use roc_can::expr::{AnnotatedMark, ClosureData, ExpectLookup, IntValue};
|
use roc_can::expr::{AnnotatedMark, ClosureData, ExpectLookup, IntValue};
|
||||||
use roc_can::module::ExposedByModule;
|
use roc_can::module::ExposedByModule;
|
||||||
use roc_collections::all::{default_hasher, BumpMap, BumpMapDefault, MutMap};
|
use roc_collections::all::{default_hasher, BumpMap, BumpMapDefault, MutMap};
|
||||||
use roc_collections::soa::Slice;
|
|
||||||
use roc_collections::VecMap;
|
use roc_collections::VecMap;
|
||||||
use roc_debug_flags::dbg_do;
|
use roc_debug_flags::dbg_do;
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
|
@ -1625,7 +1624,7 @@ pub enum Stmt<'a> {
|
||||||
condition: Symbol,
|
condition: Symbol,
|
||||||
region: Region,
|
region: Region,
|
||||||
lookups: &'a [Symbol],
|
lookups: &'a [Symbol],
|
||||||
layouts: Slice<Layout<'a>>,
|
layouts: &'a [Layout<'a>],
|
||||||
/// what happens after the expect
|
/// what happens after the expect
|
||||||
remainder: &'a Stmt<'a>,
|
remainder: &'a Stmt<'a>,
|
||||||
},
|
},
|
||||||
|
@ -1633,7 +1632,7 @@ pub enum Stmt<'a> {
|
||||||
condition: Symbol,
|
condition: Symbol,
|
||||||
region: Region,
|
region: Region,
|
||||||
lookups: &'a [Symbol],
|
lookups: &'a [Symbol],
|
||||||
layouts: Slice<Layout<'a>>,
|
layouts: &'a [Layout<'a>],
|
||||||
/// what happens after the expect
|
/// what happens after the expect
|
||||||
remainder: &'a Stmt<'a>,
|
remainder: &'a Stmt<'a>,
|
||||||
},
|
},
|
||||||
|
@ -6599,14 +6598,11 @@ pub fn from_can<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let layouts_slice = env.layout_buffer.reserve(layouts.len());
|
|
||||||
env.layout_buffer.set_reserved(layouts_slice, layouts);
|
|
||||||
|
|
||||||
let mut stmt = Stmt::Expect {
|
let mut stmt = Stmt::Expect {
|
||||||
condition: cond_symbol,
|
condition: cond_symbol,
|
||||||
region: loc_condition.region,
|
region: loc_condition.region,
|
||||||
lookups: lookups.into_bump_slice(),
|
lookups: lookups.into_bump_slice(),
|
||||||
layouts: layouts_slice,
|
layouts: layouts.into_bump_slice(),
|
||||||
remainder: env.arena.alloc(rest),
|
remainder: env.arena.alloc(rest),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6658,14 +6654,11 @@ pub fn from_can<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let layouts_slice = env.layout_buffer.reserve(layouts.len());
|
|
||||||
env.layout_buffer.set_reserved(layouts_slice, layouts);
|
|
||||||
|
|
||||||
let mut stmt = Stmt::ExpectFx {
|
let mut stmt = Stmt::ExpectFx {
|
||||||
condition: cond_symbol,
|
condition: cond_symbol,
|
||||||
region: loc_condition.region,
|
region: loc_condition.region,
|
||||||
lookups: lookups.into_bump_slice(),
|
lookups: lookups.into_bump_slice(),
|
||||||
layouts: layouts_slice,
|
layouts: layouts.into_bump_slice(),
|
||||||
remainder: env.arena.alloc(rest),
|
remainder: env.arena.alloc(rest),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7106,7 +7099,7 @@ fn substitute_in_stmt_help<'a>(
|
||||||
condition: substitute(subs, *condition).unwrap_or(*condition),
|
condition: substitute(subs, *condition).unwrap_or(*condition),
|
||||||
region: *region,
|
region: *region,
|
||||||
lookups: new_lookups.into_bump_slice(),
|
lookups: new_lookups.into_bump_slice(),
|
||||||
layouts: *layouts,
|
layouts,
|
||||||
remainder: new_remainder,
|
remainder: new_remainder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7132,7 +7125,7 @@ fn substitute_in_stmt_help<'a>(
|
||||||
condition: substitute(subs, *condition).unwrap_or(*condition),
|
condition: substitute(subs, *condition).unwrap_or(*condition),
|
||||||
region: *region,
|
region: *region,
|
||||||
lookups: new_lookups.into_bump_slice(),
|
lookups: new_lookups.into_bump_slice(),
|
||||||
layouts: *layouts,
|
layouts,
|
||||||
remainder: new_remainder,
|
remainder: new_remainder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,19 +11,14 @@ impl<'a> LayoutBuffer<'a> {
|
||||||
Slice::extend_new(&mut self.0, std::iter::repeat(Layout::VOID).take(size))
|
Slice::extend_new(&mut self.0, std::iter::repeat(Layout::VOID).take(size))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_reserved<I>(&mut self, slice: Slice<Layout<'a>>, layouts: I)
|
pub fn set_reserved(
|
||||||
where
|
&mut self,
|
||||||
I: IntoIterator<Item = Layout<'a>>,
|
slice: Slice<Layout<'a>>,
|
||||||
I::IntoIter: ExactSizeIterator,
|
layouts: impl ExactSizeIterator<Item = Layout<'a>>,
|
||||||
{
|
) {
|
||||||
let layouts = layouts.into_iter();
|
|
||||||
debug_assert_eq!(layouts.len(), slice.len());
|
debug_assert_eq!(layouts.len(), slice.len());
|
||||||
for (index, layout) in slice.indices().zip(layouts) {
|
for (index, layout) in slice.indices().zip(layouts) {
|
||||||
self.0[index] = layout;
|
self.0[index] = layout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter_slice(&self, slice: Slice<Layout<'a>>) -> impl Iterator<Item = Layout<'a>> + '_ {
|
|
||||||
self.0[slice.indices()].iter().copied()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,7 @@ fn function_s<'a, 'i>(
|
||||||
condition: *condition,
|
condition: *condition,
|
||||||
region: *region,
|
region: *region,
|
||||||
lookups,
|
lookups,
|
||||||
layouts: *layouts,
|
layouts,
|
||||||
remainder: new_continuation,
|
remainder: new_continuation,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ fn function_s<'a, 'i>(
|
||||||
condition: *condition,
|
condition: *condition,
|
||||||
region: *region,
|
region: *region,
|
||||||
lookups,
|
lookups,
|
||||||
layouts: *layouts,
|
layouts,
|
||||||
remainder: new_continuation,
|
remainder: new_continuation,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ fn function_d_main<'a, 'i>(
|
||||||
condition: *condition,
|
condition: *condition,
|
||||||
region: *region,
|
region: *region,
|
||||||
lookups,
|
lookups,
|
||||||
layouts: *layouts,
|
layouts,
|
||||||
remainder: b,
|
remainder: b,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -464,7 +464,7 @@ fn function_d_main<'a, 'i>(
|
||||||
condition: *condition,
|
condition: *condition,
|
||||||
region: *region,
|
region: *region,
|
||||||
lookups,
|
lookups,
|
||||||
layouts: *layouts,
|
layouts,
|
||||||
remainder: b,
|
remainder: b,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -485,7 +485,7 @@ fn function_d_main<'a, 'i>(
|
||||||
condition: *condition,
|
condition: *condition,
|
||||||
region: *region,
|
region: *region,
|
||||||
lookups,
|
lookups,
|
||||||
layouts: *layouts,
|
layouts,
|
||||||
remainder: b,
|
remainder: b,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -497,7 +497,7 @@ fn function_d_main<'a, 'i>(
|
||||||
condition: *condition,
|
condition: *condition,
|
||||||
region: *region,
|
region: *region,
|
||||||
lookups,
|
lookups,
|
||||||
layouts: *layouts,
|
layouts,
|
||||||
remainder: b,
|
remainder: b,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -669,7 +669,7 @@ fn function_r<'a, 'i>(env: &mut Env<'a, 'i>, stmt: &'a Stmt<'a>) -> &'a Stmt<'a>
|
||||||
condition: *condition,
|
condition: *condition,
|
||||||
region: *region,
|
region: *region,
|
||||||
lookups,
|
lookups,
|
||||||
layouts: *layouts,
|
layouts,
|
||||||
remainder: b,
|
remainder: b,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -689,7 +689,7 @@ fn function_r<'a, 'i>(env: &mut Env<'a, 'i>, stmt: &'a Stmt<'a>) -> &'a Stmt<'a>
|
||||||
condition: *condition,
|
condition: *condition,
|
||||||
region: *region,
|
region: *region,
|
||||||
lookups,
|
lookups,
|
||||||
layouts: *layouts,
|
layouts,
|
||||||
remainder: b,
|
remainder: b,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,7 @@ fn insert_jumps<'a>(
|
||||||
condition: *condition,
|
condition: *condition,
|
||||||
region: *region,
|
region: *region,
|
||||||
lookups,
|
lookups,
|
||||||
layouts: *layouts,
|
layouts,
|
||||||
remainder: cont,
|
remainder: cont,
|
||||||
})),
|
})),
|
||||||
None => None,
|
None => None,
|
||||||
|
@ -291,7 +291,7 @@ fn insert_jumps<'a>(
|
||||||
condition: *condition,
|
condition: *condition,
|
||||||
region: *region,
|
region: *region,
|
||||||
lookups,
|
lookups,
|
||||||
layouts: *layouts,
|
layouts,
|
||||||
remainder: cont,
|
remainder: cont,
|
||||||
})),
|
})),
|
||||||
None => None,
|
None => None,
|
||||||
|
|
|
@ -15,18 +15,15 @@ const EXPANDED_STACK_SIZE: usize = 8 * 1024 * 1024;
|
||||||
|
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use roc_collections::all::MutMap;
|
use roc_collections::all::MutMap;
|
||||||
use roc_collections::VecMap;
|
|
||||||
use roc_load::ExecutionMode;
|
use roc_load::ExecutionMode;
|
||||||
use roc_load::LoadConfig;
|
use roc_load::LoadConfig;
|
||||||
use roc_load::LoadMonomorphizedError;
|
use roc_load::LoadMonomorphizedError;
|
||||||
use roc_load::Threading;
|
use roc_load::Threading;
|
||||||
use roc_module::symbol::Interns;
|
use roc_module::symbol::Interns;
|
||||||
use roc_module::symbol::ModuleId;
|
|
||||||
use roc_module::symbol::Symbol;
|
use roc_module::symbol::Symbol;
|
||||||
use roc_mono::ir::Proc;
|
use roc_mono::ir::Proc;
|
||||||
use roc_mono::ir::ProcLayout;
|
use roc_mono::ir::ProcLayout;
|
||||||
use roc_mono::layout::STLayoutInterner;
|
use roc_mono::layout::STLayoutInterner;
|
||||||
use roc_mono::LayoutBuffer;
|
|
||||||
use test_mono_macros::*;
|
use test_mono_macros::*;
|
||||||
|
|
||||||
const TARGET_INFO: roc_target::TargetInfo = roc_target::TargetInfo::default_x86_64();
|
const TARGET_INFO: roc_target::TargetInfo = roc_target::TargetInfo::default_x86_64();
|
||||||
|
@ -140,7 +137,6 @@ fn compiles_to_ir(test_name: &str, src: &str, mode: &str, no_check: bool) {
|
||||||
exposed_to_host,
|
exposed_to_host,
|
||||||
layout_interner,
|
layout_interner,
|
||||||
interns,
|
interns,
|
||||||
layout_buffers,
|
|
||||||
..
|
..
|
||||||
} = loaded;
|
} = loaded;
|
||||||
|
|
||||||
|
@ -156,13 +152,7 @@ fn compiles_to_ir(test_name: &str, src: &str, mode: &str, no_check: bool) {
|
||||||
let main_fn_symbol = exposed_to_host.values.keys().copied().next();
|
let main_fn_symbol = exposed_to_host.values.keys().copied().next();
|
||||||
|
|
||||||
if !no_check {
|
if !no_check {
|
||||||
check_procedures(
|
check_procedures(arena, &interns, &layout_interner, &procedures);
|
||||||
arena,
|
|
||||||
&interns,
|
|
||||||
&layout_interner,
|
|
||||||
&layout_buffers,
|
|
||||||
&procedures,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
verify_procedures(test_name, layout_interner, procedures, main_fn_symbol);
|
verify_procedures(test_name, layout_interner, procedures, main_fn_symbol);
|
||||||
|
@ -172,11 +162,10 @@ fn check_procedures<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
interns: &Interns,
|
interns: &Interns,
|
||||||
interner: &STLayoutInterner<'a>,
|
interner: &STLayoutInterner<'a>,
|
||||||
layout_buffers: &VecMap<ModuleId, LayoutBuffer<'a>>,
|
|
||||||
procedures: &MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>,
|
procedures: &MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>,
|
||||||
) {
|
) {
|
||||||
use roc_mono::debug::{check_procs, format_problems};
|
use roc_mono::debug::{check_procs, format_problems};
|
||||||
let problems = check_procs(arena, interner, layout_buffers, procedures);
|
let problems = check_procs(arena, interner, procedures);
|
||||||
if problems.is_empty() {
|
if problems.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue