This commit is contained in:
J.Teeuwissen 2023-04-05 19:31:03 +02:00
parent fc9f04b716
commit ed947b773d
No known key found for this signature in database
GPG key ID: DB5F7A1ED8D478AD
10 changed files with 2331 additions and 4951 deletions

View file

@ -1248,12 +1248,6 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
let (tag_ptr, layout) = load_symbol_and_layout(scope, symbol);
let tag_ptr = tag_ptr.into_pointer_value();
// reset is only generated for union values
let union_layout = match layout_interner.get(layout) {
Layout::Union(ul) => ul,
_ => unreachable!(),
};
let ctx = env.context;
let not_unique_block = ctx.append_basic_block(parent, "else_decref");
let cont_block = ctx.append_basic_block(parent, "cont");

View file

@ -30,7 +30,7 @@ use roc_module::symbol::{
IdentIds, IdentIdsByModule, Interns, ModuleId, ModuleIds, PQModuleName, PackageModuleIds,
PackageQualified, Symbol,
};
use roc_mono::fl_reuse;
use roc_mono::inc_dec;
use roc_mono::ir::{
CapturedSymbols, ExternalSpecializations, GlueLayouts, LambdaSetId, PartialProc, Proc,
ProcLayout, Procs, ProcsBase, UpdateModeIds,
@ -39,7 +39,7 @@ use roc_mono::layout::LayoutInterner;
use roc_mono::layout::{
GlobalLayoutInterner, LambdaName, Layout, LayoutCache, LayoutProblem, Niche, STLayoutInterner,
};
use roc_mono::perceus;
use roc_mono::reset_reuse;
use roc_packaging::cache::RocCacheDir;
use roc_parse::ast::{
self, CommentOrNewline, Defs, ExtractSpaces, Spaced, StrLiteral, TypeAnnotation,
@ -3096,44 +3096,15 @@ fn update<'a>(
let ident_ids = state.constrained_ident_ids.get_mut(&module_id).unwrap();
// Proc::insert_reset_reuse_operations(
// arena,
// &mut layout_interner,
// module_id,
// ident_ids,
// &mut update_mode_ids,
// &mut state.procedures,
// );
// debug_print_ir!(state, &layout_interner, ROC_PRINT_IR_AFTER_RESET_REUSE);
// let host_exposed_procs = bumpalo::collections::Vec::from_iter_in(
// state.exposed_to_host.top_level_values.keys().copied(),
// arena,
// );
// Proc::insert_refcount_operations(
// arena,
// &layout_interner,
// module_id,
// ident_ids,
// &mut update_mode_ids,
// &mut state.procedures,
// &host_exposed_procs,
// );
perceus::insert_refcount_operations(
inc_dec::insert_inc_dec_operations(
arena,
&layout_interner,
module_id,
ident_ids,
&mut update_mode_ids,
&mut state.procedures,
);
debug_print_ir!(state, &layout_interner, ROC_PRINT_IR_AFTER_REFCOUNT);
fl_reuse::insert_reset_reuse_operations(
reset_reuse::insert_reset_reuse_operations(
arena,
&mut layout_interner,
module_id,

View file

@ -285,21 +285,6 @@ impl<'a> ParamMap<'a> {
.into_bump_slice()
}
fn init_borrow_args_always_owned(
arena: &'a Bump,
ps: &'a [(InLayout<'a>, Symbol)],
) -> &'a [Param<'a>] {
Vec::from_iter_in(
ps.iter().map(|(layout, symbol)| Param {
ownership: Ownership::Owned,
layout: *layout,
symbol: *symbol,
}),
arena,
)
.into_bump_slice()
}
fn visit_proc(
&mut self,
arena: &'a Bump,
@ -325,26 +310,6 @@ impl<'a> ParamMap<'a> {
self.visit_stmt(arena, interner, proc.name.name(), &proc.body);
}
fn visit_proc_always_owned(
&mut self,
arena: &'a Bump,
interner: &STLayoutInterner<'a>,
proc: &Proc<'a>,
key: (Symbol, ProcLayout<'a>),
) {
let index: usize = self.get_param_offset(interner, key.0, key.1).into();
for (i, param) in Self::init_borrow_args_always_owned(arena, proc.args)
.iter()
.copied()
.enumerate()
{
self.declarations[index + i] = param;
}
self.visit_stmt(arena, interner, proc.name.name(), &proc.body);
}
fn visit_stmt(
&mut self,
arena: &'a Bump,

View file

@ -575,44 +575,6 @@ pub fn refcount_resetref_proc_body<'a>(
rc_ptr_stmt
}
// Check if refcounting is implemented yet. In the long term, this will be deleted.
// In the short term, it helps us to skip refcounting and let it leak, so we can make
// progress incrementally. Kept in sync with generate_procs using assertions.
pub fn is_rc_implemented_yet<'a, I>(interner: &I, layout: InLayout<'a>) -> bool
where
I: LayoutInterner<'a>,
{
use UnionLayout::*;
match interner.get(layout) {
Layout::Builtin(Builtin::List(elem_layout)) => is_rc_implemented_yet(interner, elem_layout),
Layout::Builtin(_) => true,
Layout::Struct { field_layouts, .. } => field_layouts
.iter()
.all(|l| is_rc_implemented_yet(interner, *l)),
Layout::Union(union_layout) => match union_layout {
NonRecursive(tags) => tags
.iter()
.all(|fields| fields.iter().all(|l| is_rc_implemented_yet(interner, *l))),
Recursive(tags) => tags
.iter()
.all(|fields| fields.iter().all(|l| is_rc_implemented_yet(interner, *l))),
NonNullableUnwrapped(fields) => {
fields.iter().all(|l| is_rc_implemented_yet(interner, *l))
}
NullableWrapped { other_tags, .. } => other_tags
.iter()
.all(|fields| fields.iter().all(|l| is_rc_implemented_yet(interner, *l))),
NullableUnwrapped { other_fields, .. } => other_fields
.iter()
.all(|l| is_rc_implemented_yet(interner, *l)),
},
Layout::LambdaSet(lambda_set) => is_rc_implemented_yet(interner, lambda_set.representation),
Layout::RecursivePointer(_) => true,
Layout::Boxed(_) => true,
}
}
fn rc_return_stmt<'a>(
root: &CodeGenHelp<'a>,
ident_ids: &mut IdentIds,

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,7 @@ use crate::ir::literal::{make_num_literal, IntOrFloatValue};
use crate::layout::{
self, Builtin, ClosureCallOptions, ClosureRepresentation, EnumDispatch, InLayout, LambdaName,
LambdaSet, Layout, LayoutCache, LayoutInterner, LayoutProblem, Niche, RawFunctionLayout,
STLayoutInterner, TLLayoutInterner, TagIdIntType, UnionLayout, WrappedVariant,
TLLayoutInterner, TagIdIntType, UnionLayout, WrappedVariant,
};
use bumpalo::collections::{CollectIn, Vec};
use bumpalo::Bump;
@ -408,50 +408,6 @@ impl<'a> Proc<'a> {
String::from_utf8(w).unwrap()
}
pub fn insert_refcount_operations<'i>(
arena: &'a Bump,
layout_interner: &'i STLayoutInterner<'a>,
home: ModuleId,
ident_ids: &'i mut IdentIds,
update_mode_ids: &'i mut UpdateModeIds,
procs: &mut MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>,
host_exposed_procs: &[Symbol],
) {
let borrow_params =
crate::borrow::infer_borrow(arena, layout_interner, procs, host_exposed_procs);
crate::inc_dec::visit_procs(
arena,
layout_interner,
home,
ident_ids,
update_mode_ids,
arena.alloc(borrow_params),
procs,
);
}
pub fn insert_reset_reuse_operations<'i>(
arena: &'a Bump,
layout_interner: &'i mut STLayoutInterner<'a>,
home: ModuleId,
ident_ids: &'i mut IdentIds,
update_mode_ids: &'i mut UpdateModeIds,
procs: &mut MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>,
) {
for proc in procs.values_mut() {
let new_proc = crate::reset_reuse::insert_reset_reuse(
arena,
layout_interner,
home,
ident_ids,
update_mode_ids,
proc.clone(),
);
*proc = new_proc;
}
}
fn make_tail_recursive(&mut self, env: &mut Env<'a, '_>) {
let mut args = Vec::with_capacity_in(self.args.len(), env.arena);
let mut proc_args = Vec::with_capacity_in(self.args.len(), env.arena);

View file

@ -11,13 +11,11 @@
pub mod borrow;
pub mod code_gen_help;
pub mod fl_reuse;
pub mod inc_dec;
pub mod ir;
pub mod layout;
pub mod layout_soa;
pub mod low_level;
pub mod perceus;
pub mod reset_reuse;
pub mod tail_recursion;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff