diff --git a/compiler/load/src/file.rs b/compiler/load/src/file.rs index 4ac1f371e1..ed14abcc95 100644 --- a/compiler/load/src/file.rs +++ b/compiler/load/src/file.rs @@ -20,6 +20,7 @@ use roc_module::symbol::{ }; use roc_mono::ir::{ CapturedSymbols, EntryPoint, ExternalSpecializations, PartialProc, Proc, ProcLayout, Procs, + UpdateModeIds, }; use roc_mono::layout::{Layout, LayoutCache, LayoutProblem}; use roc_parse::ast::{self, StrLiteral, TypeAnnotation}; @@ -835,6 +836,7 @@ enum Msg<'a> { external_specializations_requested: BumpMap, procedures: MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>, problems: Vec, + update_mode_ids: UpdateModeIds, module_timing: ModuleTiming, subs: Subs, }, @@ -3922,6 +3924,7 @@ fn make_specializations<'a>( ) -> Msg<'a> { let make_specializations_start = SystemTime::now(); let mut mono_problems = Vec::new(); + let mut update_mode_ids = UpdateModeIds::new(); // do the thing let mut mono_env = roc_mono::ir::Env { arena, @@ -3930,7 +3933,7 @@ fn make_specializations<'a>( home, ident_ids: &mut ident_ids, ptr_bytes, - update_mode_counter: 0, + update_mode_ids: &mut update_mode_ids, // call_specialization_counter=0 is reserved call_specialization_counter: 1, }; @@ -3973,6 +3976,7 @@ fn make_specializations<'a>( layout_cache, procedures, problems: mono_problems, + update_mode_ids, subs, external_specializations_requested, module_timing, @@ -4016,6 +4020,7 @@ fn build_pending_specializations<'a>( }; let mut mono_problems = std::vec::Vec::new(); + let mut update_mode_ids = UpdateModeIds::new(); let mut subs = solved_subs.into_inner(); let mut mono_env = roc_mono::ir::Env { arena, @@ -4024,7 +4029,7 @@ fn build_pending_specializations<'a>( home, ident_ids: &mut ident_ids, ptr_bytes, - update_mode_counter: 0, + update_mode_ids: &mut update_mode_ids, // call_specialization_counter=0 is reserved call_specialization_counter: 1, }; diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index d4956d4ba9..dabc5b5c05 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -988,7 +988,7 @@ pub struct Env<'a, 'i> { pub home: ModuleId, pub ident_ids: &'i mut IdentIds, pub ptr_bytes: u32, - pub update_mode_counter: u64, + pub update_mode_ids: &'i mut UpdateModeIds, pub call_specialization_counter: u64, } @@ -1000,13 +1000,7 @@ impl<'a, 'i> Env<'a, 'i> { } pub fn next_update_mode_id(&mut self) -> UpdateModeId { - let id = UpdateModeId { - id: self.update_mode_counter, - }; - - self.update_mode_counter += 1; - - id + self.update_mode_ids.next_id() } pub fn next_call_specialization_id(&mut self) -> CallSpecId { @@ -1302,6 +1296,23 @@ impl UpdateModeId { } } +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct UpdateModeIds { + next: u64, +} + +impl UpdateModeIds { + pub const fn new() -> Self { + Self { next: 0 } + } + + fn next_id(&mut self) -> UpdateModeId { + let id = UpdateModeId { id: self.next }; + self.next += 1; + id + } +} + #[derive(Clone, Debug, PartialEq)] pub enum CallType<'a> { ByName { @@ -1390,12 +1401,14 @@ pub enum Expr<'a> { Reuse { symbol: Symbol, update_tag_id: bool, + // update_mode: UpdateModeId, // normal Tag fields tag_layout: UnionLayout<'a>, tag_name: TagName, tag_id: TagIdIntType, arguments: &'a [Symbol], }, + // Reset { symbol: Symbol, update_mode: UpdateModeId, }, Reset(Symbol), RuntimeErrorFunction(&'a str), diff --git a/reporting/tests/test_reporting.rs b/reporting/tests/test_reporting.rs index 735861ebb3..5b16a871c2 100644 --- a/reporting/tests/test_reporting.rs +++ b/reporting/tests/test_reporting.rs @@ -102,7 +102,7 @@ mod test_reporting { home, ident_ids: &mut ident_ids, ptr_bytes, - update_mode_counter: 0, + update_mode_ids: 0, // call_specialization_counter=0 is reserved call_specialization_counter: 1, };