From 1709b3269a9d2d4634b5da713512ad6f68bba461 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 3 May 2023 05:07:20 -0400 Subject: [PATCH 01/13] author some comments --- components/dada-brew/src/brew.rs | 3 ++- components/dada-brew/src/brewery.rs | 21 +++++++++++++++++---- components/dada-brew/src/cursor.rs | 17 +++++++++++++++-- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/components/dada-brew/src/brew.rs b/components/dada-brew/src/brew.rs index 65ff3624..840bb2f9 100644 --- a/components/dada-brew/src/brew.rs +++ b/components/dada-brew/src/brew.rs @@ -14,6 +14,7 @@ use crate::{ cursor::Cursor, }; +/// Convert a [`validated::Tree`] to [BIR](`bir::Bir`). #[salsa::tracked] pub fn brew(db: &dyn crate::Db, validated_tree: validated::Tree) -> bir::Bir { let function = validated_tree.function(db); @@ -34,7 +35,7 @@ pub fn brew(db: &dyn crate::Db, validated_tree: validated::Tree) -> bir::Bir { ); let num_parameters = validated_tree.data(db).num_parameters; - // Compile the root expression and -- assuming it doesn't diverse -- + // Compile the root expression and -- assuming it doesn't diverge -- // return the resulting value. let root_expr = validated_tree.data(db).root_expr; let root_expr_origin = validated_tree.origins(db)[root_expr]; diff --git a/components/dada-brew/src/brewery.rs b/components/dada-brew/src/brewery.rs index 0379da63..4f69a88f 100644 --- a/components/dada-brew/src/brewery.rs +++ b/components/dada-brew/src/brewery.rs @@ -11,6 +11,14 @@ use dada_ir::{ origin_table::{HasOriginIn, PushOriginIn}, }; +/// The "brewery" stores an "under construction" BIR, +/// along with the validated tree we are building it from. +/// New basic blocks, statements, etc can be allocated with the +/// `add` method. The contents of a basic block etc can be accessed +/// and mutated by indexing into the brewery (e.g., `&mut brewery[bb]`) +/// +/// The brewery does not track the current location +/// in the IR; a [`Cursor`](`crate::cursor::Cursor`) is used for that. pub struct Brewery<'me> { db: &'me dyn crate::Db, input_file: InputFile, @@ -87,11 +95,16 @@ impl<'me> Brewery<'me> { &self.validated_tree_data.tables } - /// Create a "sub-brewery" that has the same output - /// tables but independent loop contexts and other - /// scoped information. + /// Create a "sub-brewery" that clones the current state + /// and which shares the same output tables/origins as the + /// original. /// - /// The temporary stack is also independent; the assumption + /// This is used to brew loops. The idea is that the loop + /// can mutate owned fields like `loop_contexts` without affecting + /// the outer brewery. An alternative would be to "pop" the changes + /// to `loop_contexts`. + /// + /// The subbrewery contains a fresh temporary stack; the assumption /// is that the subbrewery will be used to brew complete /// expressions and hence the stack will just extend /// the parent's stack. diff --git a/components/dada-brew/src/cursor.rs b/components/dada-brew/src/cursor.rs index 22d51ba3..d82a6d8e 100644 --- a/components/dada-brew/src/cursor.rs +++ b/components/dada-brew/src/cursor.rs @@ -6,11 +6,14 @@ use dada_ir::code::{ use crate::brewery::Brewery; +/// Tracks the current basic block that we are appending statements to. pub(crate) struct Cursor { - /// The block that we started from; may or may not be "complete". + /// The block that we started from; may or may not be "complete" + /// (i.e., may not yet have a terminator assigned to it). start_block: bir::BasicBlock, - /// The basic block we are currently appending to. + /// The basic block we are currently appending to; could be the + /// same as `start_block`. /// /// If `None`, we are in a section of dead code. end_block: Option, @@ -26,6 +29,7 @@ pub(crate) struct TemporaryScope { } impl Cursor { + /// Creates a new cursor with a dummy starting block. pub(crate) fn new(brewery: &mut Brewery<'_>, origin: ExprOrigin) -> Self { let block = brewery.dummy_block(origin); Cursor { @@ -34,11 +38,14 @@ impl Cursor { } } + /// Invoked at the end of the method, returns the start block. pub(crate) fn complete(self) -> bir::BasicBlock { assert!(self.in_dead_code()); self.start_block } + /// Creates a new cursor that shares the same start block but is now appending + /// to `end_block`. pub(crate) fn with_end_block(&self, end_block: bir::BasicBlock) -> Cursor { Cursor { start_block: self.start_block, @@ -46,16 +53,21 @@ impl Cursor { } } + /// Test if this cursor is contained in dead code. pub(crate) fn in_dead_code(&self) -> bool { self.end_block.is_none() } + /// Creates a temporary scope marker that tracks the current number of temporaries; + /// the return value should later be given to `pop_temporary_scope`. pub(crate) fn push_temporary_scope(&self, brewery: &mut Brewery<'_>) -> TemporaryScope { TemporaryScope { mark: brewery.temporary_stack_len(), } } + /// Pops all temporaries pushed since `scope` was created from the stack and inserts + /// "clear variable" instructions. pub(crate) fn pop_temporary_scope(&mut self, brewery: &mut Brewery<'_>, scope: TemporaryScope) { while brewery.temporary_stack_len() > scope.mark { let temporary = brewery.pop_temporary(); @@ -70,6 +82,7 @@ impl Cursor { } } + /// Pushes clear instructions for each of the given variables. pub(crate) fn pop_declared_variables( &mut self, brewery: &mut Brewery<'_>, From 0fb271a7ef41875119cdd4e9d0d872b48ef07fe2 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 3 May 2023 05:11:09 -0400 Subject: [PATCH 02/13] rename cursor to scope --- components/dada-brew/src/brew.rs | 6 +++--- components/dada-brew/src/lib.rs | 2 +- components/dada-brew/src/{cursor.rs => scope.rs} | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) rename components/dada-brew/src/{cursor.rs => scope.rs} (99%) diff --git a/components/dada-brew/src/brew.rs b/components/dada-brew/src/brew.rs index 840bb2f9..5f9a0342 100644 --- a/components/dada-brew/src/brew.rs +++ b/components/dada-brew/src/brew.rs @@ -11,7 +11,7 @@ use salsa::DebugWithDb; use crate::{ brewery::{Brewery, LoopContext}, - cursor::Cursor, + scope::Scope, }; /// Convert a [`validated::Tree`] to [BIR](`bir::Bir`). @@ -39,7 +39,7 @@ pub fn brew(db: &dyn crate::Db, validated_tree: validated::Tree) -> bir::Bir { // return the resulting value. let root_expr = validated_tree.data(db).root_expr; let root_expr_origin = validated_tree.origins(db)[root_expr]; - let mut cursor = Cursor::new(brewery, root_expr_origin); + let mut cursor = Scope::new(brewery, root_expr_origin); if let Some(place) = cursor.brew_expr_to_temporary(brewery, root_expr) { cursor.terminate_and_diverge( brewery, @@ -67,7 +67,7 @@ pub fn brew(db: &dyn crate::Db, validated_tree: validated::Tree) -> bir::Bir { bir } -impl Cursor { +impl Scope { #[tracing::instrument(level = "debug", skip_all)] pub(crate) fn brew_expr_for_side_effects( &mut self, diff --git a/components/dada-brew/src/lib.rs b/components/dada-brew/src/lib.rs index f16931fd..82d31a3d 100644 --- a/components/dada-brew/src/lib.rs +++ b/components/dada-brew/src/lib.rs @@ -23,5 +23,5 @@ impl Db for T where mod brew; mod brewery; -mod cursor; pub mod prelude; +mod scope; diff --git a/components/dada-brew/src/cursor.rs b/components/dada-brew/src/scope.rs similarity index 99% rename from components/dada-brew/src/cursor.rs rename to components/dada-brew/src/scope.rs index d82a6d8e..20b23caa 100644 --- a/components/dada-brew/src/cursor.rs +++ b/components/dada-brew/src/scope.rs @@ -7,7 +7,7 @@ use dada_ir::code::{ use crate::brewery::Brewery; /// Tracks the current basic block that we are appending statements to. -pub(crate) struct Cursor { +pub(crate) struct Scope { /// The block that we started from; may or may not be "complete" /// (i.e., may not yet have a terminator assigned to it). start_block: bir::BasicBlock, @@ -28,11 +28,11 @@ pub(crate) struct TemporaryScope { mark: usize, } -impl Cursor { +impl Scope { /// Creates a new cursor with a dummy starting block. pub(crate) fn new(brewery: &mut Brewery<'_>, origin: ExprOrigin) -> Self { let block = brewery.dummy_block(origin); - Cursor { + Scope { start_block: block, end_block: Some(block), } @@ -46,8 +46,8 @@ impl Cursor { /// Creates a new cursor that shares the same start block but is now appending /// to `end_block`. - pub(crate) fn with_end_block(&self, end_block: bir::BasicBlock) -> Cursor { - Cursor { + pub(crate) fn with_end_block(&self, end_block: bir::BasicBlock) -> Scope { + Scope { start_block: self.start_block, end_block: Some(end_block), } From ea74c77120c6eca03d7620c0aa10a24474896d85 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 3 May 2023 06:11:42 -0400 Subject: [PATCH 03/13] refactor scopes in codegen --- components/dada-brew/src/brew.rs | 77 +++++------- components/dada-brew/src/brewery.rs | 92 -------------- components/dada-brew/src/scope.rs | 187 +++++++++++++++++++++++----- 3 files changed, 185 insertions(+), 171 deletions(-) diff --git a/components/dada-brew/src/brew.rs b/components/dada-brew/src/brew.rs index 5f9a0342..991c6f85 100644 --- a/components/dada-brew/src/brew.rs +++ b/components/dada-brew/src/brew.rs @@ -1,17 +1,14 @@ use dada_id::prelude::*; -use dada_ir::{ - code::{ - bir::{self, BirData}, - validated::{self, ExprOrigin}, - }, - storage::Atomic, +use dada_ir::code::{ + bir::{self, BirData}, + validated::{self, ExprOrigin}, }; use dada_parse::prelude::*; use salsa::DebugWithDb; use crate::{ - brewery::{Brewery, LoopContext}, - scope::Scope, + brewery::Brewery, + scope::{LoopContext, Scope, ScopeCause}, }; /// Convert a [`validated::Tree`] to [BIR](`bir::Bir`). @@ -39,7 +36,7 @@ pub fn brew(db: &dyn crate::Db, validated_tree: validated::Tree) -> bir::Bir { // return the resulting value. let root_expr = validated_tree.data(db).root_expr; let root_expr_origin = validated_tree.origins(db)[root_expr]; - let mut cursor = Scope::new(brewery, root_expr_origin); + let mut cursor = Scope::root(brewery, root_expr_origin); if let Some(place) = cursor.brew_expr_to_temporary(brewery, root_expr) { cursor.terminate_and_diverge( brewery, @@ -67,7 +64,7 @@ pub fn brew(db: &dyn crate::Db, validated_tree: validated::Tree) -> bir::Bir { bir } -impl Scope { +impl Scope<'_> { #[tracing::instrument(level = "debug", skip_all)] pub(crate) fn brew_expr_for_side_effects( &mut self, @@ -76,23 +73,25 @@ impl Scope { ) { tracing::debug!("expr = {:?}", expr.data(brewery.validated_tables())); let origin = brewery.origin(expr); - let temporary_scope = self.push_temporary_scope(brewery); + let temporary_marker = self.mark_variables(); match expr.data(brewery.validated_tables()) { validated::ExprData::Break { from_expr, with_value, } => { self.push_breakpoint_start(brewery, origin); - let loop_context = brewery.loop_context(*from_expr); + let (loop_context, variables) = self.loop_context(*from_expr); self.brew_expr_and_assign_to(brewery, loop_context.loop_value, *with_value); self.push_breakpoint_end(brewery, Some(loop_context.loop_value), origin); + self.push_clear_variables(brewery, &variables, origin); self.terminate_and_goto(brewery, loop_context.break_block, origin); } validated::ExprData::Continue(from_expr) => { self.push_breakpoint_start(brewery, origin); - let loop_context = brewery.loop_context(*from_expr); + let (loop_context, variables) = self.loop_context(*from_expr); self.push_breakpoint_end(brewery, None::, origin); + self.push_clear_variables(brewery, &variables, origin); self.terminate_and_goto(brewery, loop_context.continue_block, origin); } @@ -124,8 +123,9 @@ impl Scope { validated::ExprData::Declare(vars, subexpr) => { self.push_breakpoint_start(brewery, origin); + let variables_marker = self.push_declared_variables(vars, brewery); self.brew_expr_for_side_effects(brewery, *subexpr); - self.pop_declared_variables(brewery, vars, origin); + self.clear_variables_since_marker(variables_marker, brewery, origin); self.push_breakpoint_end(brewery, None::, origin); } @@ -152,7 +152,7 @@ impl Scope { let _ = self.brew_expr_to_temporary(brewery, expr); } } - self.pop_temporary_scope(brewery, temporary_scope); + self.clear_variables_since_marker(temporary_marker, brewery, origin); } /// Compiles expr into a temporary `t` and returns `Some(t)`. @@ -164,7 +164,7 @@ impl Scope { ) -> Option { let origin = brewery.origin(expr); // Spill into a temporary - let temp_place = add_temporary_place(brewery, origin); + let temp_place = self.add_temporary(brewery, origin); self.brew_expr_and_assign_to(brewery, temp_place, expr); Some(brewery.place_from_target_place(temp_place)) } @@ -180,7 +180,7 @@ impl Scope { expr: validated::Expr, ) { let origin = brewery.origin(expr); - let temporary_scope = self.push_temporary_scope(brewery); + let temporary_marker = self.mark_variables(); match expr.data(brewery.validated_tables()) { validated::ExprData::Await(future) => { self.push_breakpoint_start(brewery, origin); @@ -212,11 +212,12 @@ impl Scope { ); self.push_breakpoint_end(brewery, Some(target), origin); // "cusp" of an if is after it completes - let mut if_true_cursor = self.with_end_block(if_true_block); + let mut if_true_cursor = self.subscope(Some(if_true_block), ScopeCause::Branch); if_true_cursor.brew_expr_and_assign_to(brewery, target, *if_true); if_true_cursor.terminate_and_goto(brewery, join_block, origin); - let mut if_false_cursor = self.with_end_block(if_false_block); + let mut if_false_cursor = + self.subscope(Some(if_false_block), ScopeCause::Branch); if_false_cursor.brew_expr_and_assign_to(brewery, target, *if_false); if_false_cursor.terminate_and_goto(brewery, join_block, origin); } @@ -232,19 +233,18 @@ impl Scope { ); self.push_breakpoint_end(brewery, Some(target), origin); // "cusp" of a loop is after it breaks - let body_brewery = &mut brewery.subbrewery(); - body_brewery.push_loop_context( - expr, - LoopContext { + let mut body_cursor = self.subscope( + Some(body_block), + ScopeCause::Loop(LoopContext { continue_block: body_block, break_block, loop_value: target, - }, + expr, + }), ); - let mut body_cursor = self.with_end_block(body_block); - body_cursor.brew_expr_for_side_effects(body_brewery, *body); + body_cursor.brew_expr_for_side_effects(brewery, *body); body_cursor.terminate_and_diverge( - body_brewery, + brewery, bir::TerminatorData::Goto(body_block), origin, ); @@ -463,8 +463,9 @@ impl Scope { validated::ExprData::Declare(vars, subexpr) => { self.push_breakpoint_start(brewery, origin); + let variables_marker = self.push_declared_variables(vars, brewery); self.brew_expr_and_assign_to(brewery, target, *subexpr); - self.pop_declared_variables(brewery, vars, origin); + self.clear_variables_since_marker(variables_marker, brewery, origin); self.push_breakpoint_end(brewery, None::, origin); } @@ -475,7 +476,7 @@ impl Scope { self.brew_expr_for_side_effects(brewery, expr); } }; - self.pop_temporary_scope(brewery, temporary_scope); + self.clear_variables_since_marker(temporary_marker, brewery, origin); } /// Brews a place to a bir place, returning a vector of the @@ -551,21 +552,3 @@ impl Scope { brewery.add(bir::TargetPlaceData::LocalVariable(bir_var), origin) } } - -fn add_temporary(brewery: &mut Brewery, origin: ExprOrigin) -> bir::LocalVariable { - let temporary = brewery.add( - bir::LocalVariableData { - name: None, - atomic: Atomic::No, - }, - validated::LocalVariableOrigin::Temporary(origin.into()), - ); - tracing::debug!("created temporary: temp{{{:?}}}", u32::from(temporary)); - brewery.push_temporary(temporary); - temporary -} - -fn add_temporary_place(brewery: &mut Brewery, origin: ExprOrigin) -> bir::TargetPlace { - let temporary_var = add_temporary(brewery, origin); - brewery.add(bir::TargetPlaceData::LocalVariable(temporary_var), origin) -} diff --git a/components/dada-brew/src/brewery.rs b/components/dada-brew/src/brewery.rs index 4f69a88f..b38044d5 100644 --- a/components/dada-brew/src/brewery.rs +++ b/components/dada-brew/src/brewery.rs @@ -20,38 +20,14 @@ use dada_ir::{ /// The brewery does not track the current location /// in the IR; a [`Cursor`](`crate::cursor::Cursor`) is used for that. pub struct Brewery<'me> { - db: &'me dyn crate::Db, input_file: InputFile, pub(crate) breakpoints: &'me [syntax::Expr], validated_tree_data: &'me validated::TreeData, validated_origins: &'me validated::Origins, tables: &'me mut bir::Tables, origins: &'me mut bir::Origins, - loop_contexts: Map, variables: Rc>, dummy_terminator: bir::Terminator, - - /// The "temporary stack". This is used to track temporaries that - /// were created during the brewing process and clear them out - /// so that we don't artificially extend the lifetime of objects - /// during interpretation. - /// - /// The basic strategy is as follows: - /// - /// * Upon starting to brew an expression, we record the length of this - /// stack. - /// * During the brewing process, any new temporary is pushed onto this - /// stack. - /// * When we've finished brewing an expression, we can pop off any temporaries - /// pushed during that time and clear their values to nil. - temporaries: Vec, -} - -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Hash)] -pub struct LoopContext { - pub continue_block: bir::BasicBlock, - pub break_block: bir::BasicBlock, - pub loop_value: bir::TargetPlace, } impl<'me> Brewery<'me> { @@ -73,17 +49,14 @@ impl<'me> Brewery<'me> { *validated_tree_data.root_expr.origin_in(validated_origins), ); Self { - db, input_file, breakpoints, validated_tree_data, validated_origins, tables, origins, - loop_contexts: Default::default(), variables, dummy_terminator, - temporaries: vec![], } } @@ -95,35 +68,6 @@ impl<'me> Brewery<'me> { &self.validated_tree_data.tables } - /// Create a "sub-brewery" that clones the current state - /// and which shares the same output tables/origins as the - /// original. - /// - /// This is used to brew loops. The idea is that the loop - /// can mutate owned fields like `loop_contexts` without affecting - /// the outer brewery. An alternative would be to "pop" the changes - /// to `loop_contexts`. - /// - /// The subbrewery contains a fresh temporary stack; the assumption - /// is that the subbrewery will be used to brew complete - /// expressions and hence the stack will just extend - /// the parent's stack. - pub fn subbrewery(&mut self) -> Brewery<'_> { - Brewery { - db: self.db, - input_file: self.input_file, - breakpoints: self.breakpoints, - validated_tree_data: self.validated_tree_data, - validated_origins: self.validated_origins, - tables: self.tables, - origins: self.origins, - loop_contexts: self.loop_contexts.clone(), - variables: self.variables.clone(), - dummy_terminator: self.dummy_terminator, - temporaries: vec![], - } - } - pub fn input_file(&self) -> InputFile { self.input_file } @@ -175,48 +119,12 @@ impl<'me> Brewery<'me> { } } - /// Find the loop context for a given loop expression. - /// - /// Panics if that loop context has not been pushed. - pub fn loop_context(&self, loop_expr: validated::Expr) -> LoopContext { - self.loop_contexts[&loop_expr] - } - - /// Push a new loop context into the brewery; typically this is done in a "subbrewery". - pub fn push_loop_context(&mut self, loop_expr: validated::Expr, loop_context: LoopContext) { - let old_value = self.loop_contexts.insert(loop_expr, loop_context); - assert!(old_value.is_none()); - } - /// Find the loop context for a given loop expression. /// /// Panics if that loop context has not been pushed. pub fn variable(&self, var: validated::LocalVariable) -> bir::LocalVariable { self.variables[&var] } - - /// Number of temporaries on the "temporary stack". - /// - /// See the comments on the `temporaries` field for more information. - pub fn temporary_stack_len(&self) -> usize { - self.temporaries.len() - } - - /// Push a temporary onto the "temporary stack". - /// - /// See the comments on the `temporaries` field for more information. - pub fn push_temporary(&mut self, lv: bir::LocalVariable) { - tracing::debug!("pushing temporary: {:?}", lv); - self.temporaries.push(lv); - } - - /// Pop a temporary from the "temporary stack". - /// - /// See the comments on the `temporaries` field for more information. - #[track_caller] - pub fn pop_temporary(&mut self) -> bir::LocalVariable { - self.temporaries.pop().unwrap() - } } fn map_variables( diff --git a/components/dada-brew/src/scope.rs b/components/dada-brew/src/scope.rs index 20b23caa..40675e26 100644 --- a/components/dada-brew/src/scope.rs +++ b/components/dada-brew/src/scope.rs @@ -1,13 +1,16 @@ use dada_id::prelude::*; -use dada_ir::code::{ - bir, syntax, - validated::{self, ExprOrigin}, +use dada_ir::{ + code::{ + bir, syntax, + validated::{self, ExprOrigin}, + }, + storage::Atomic, }; use crate::brewery::Brewery; /// Tracks the current basic block that we are appending statements to. -pub(crate) struct Scope { +pub(crate) struct Scope<'s> { /// The block that we started from; may or may not be "complete" /// (i.e., may not yet have a terminator assigned to it). start_block: bir::BasicBlock, @@ -17,6 +20,39 @@ pub(crate) struct Scope { /// /// If `None`, we are in a section of dead code. end_block: Option, + + /// Reason for introducing this scope + cause: ScopeCause, + + /// Previous scope in the chain + previous: Option<&'s Scope<'s>>, + + /// Variables that have been introduced in this scope, + /// whether temporaries or user declared. These variables + /// need to be popped before the scope is complete. + /// + /// See `push_variable_marker` and `pop_variables`. + variables: Vec, +} + +/// Reason for introducing a new scope +pub(crate) enum ScopeCause { + /// Root scope + Root, + + /// An internal branch (e.g., if-then-else, new block) + Branch, + + /// Loop introduced that might be target of a break + Loop(LoopContext), +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Hash)] +pub struct LoopContext { + pub expr: validated::Expr, + pub continue_block: bir::BasicBlock, + pub break_block: bir::BasicBlock, + pub loop_value: bir::TargetPlace, } /// Created when we start brewing an expression or other thing that @@ -24,32 +60,44 @@ pub(crate) struct Scope { /// are cleared out. /// /// See the `temporaries` field of [`Brewery`] for more information. -pub(crate) struct TemporaryScope { +pub(crate) struct VariableMarker { mark: usize, } -impl Scope { +impl Scope<'_> { /// Creates a new cursor with a dummy starting block. - pub(crate) fn new(brewery: &mut Brewery<'_>, origin: ExprOrigin) -> Self { + pub(crate) fn root(brewery: &mut Brewery<'_>, origin: ExprOrigin) -> Self { let block = brewery.dummy_block(origin); Scope { start_block: block, end_block: Some(block), + cause: ScopeCause::Root, + previous: None, + variables: vec![], } } /// Invoked at the end of the method, returns the start block. pub(crate) fn complete(self) -> bir::BasicBlock { assert!(self.in_dead_code()); + assert!(matches!(self.cause, ScopeCause::Root)); self.start_block } - /// Creates a new cursor that shares the same start block but is now appending - /// to `end_block`. - pub(crate) fn with_end_block(&self, end_block: bir::BasicBlock) -> Scope { + /// Creates a subscope with the given `cause` that shares the same start block but is now appending + /// to `end_block`. It is your reponsibility to connect `end_block` (or some successor of it) back to + /// `self.end_block` in this subscope. + pub(crate) fn subscope<'s>( + &'s self, + end_block: Option, + cause: ScopeCause, + ) -> Scope<'s> { Scope { start_block: self.start_block, - end_block: Some(end_block), + end_block: end_block, + cause, + previous: Some(self), + variables: vec![], } } @@ -58,43 +106,118 @@ impl Scope { self.end_block.is_none() } - /// Creates a temporary scope marker that tracks the current number of temporaries; - /// the return value should later be given to `pop_temporary_scope`. - pub(crate) fn push_temporary_scope(&self, brewery: &mut Brewery<'_>) -> TemporaryScope { - TemporaryScope { - mark: brewery.temporary_stack_len(), + /// Iterate up the causal chain from all parent scopes + fn scopes(&self) -> impl Iterator { + let mut s = Some(self); + std::iter::from_fn(move || match s { + Some(s1) => { + s = s1.previous; + Some(s1) + } + None => None, + }) + } + + /// Find and return loop context for a given loop expression, + /// along with a list of variables whose values must be cleared + /// before breaking or continuing from that loop. + /// + /// Panics if that loop context has not been pushed. + #[track_caller] + pub fn loop_context( + &self, + loop_expr: validated::Expr, + ) -> (LoopContext, Vec) { + let mut variables = vec![]; + + for s in self.scopes() { + variables.extend(s.variables.iter()); + match &s.cause { + ScopeCause::Loop(c) if c.expr == loop_expr => { + return (*c, variables); + } + _ => {} + } + } + + panic!("malformed IR: loop expr {loop_expr:?} not in scope") + } + + /// Create a temporary variable and push it into this scope; it will be cleared + /// when the surrounding `clear_variables_since_marker` is invoked. + pub fn add_temporary(&mut self, brewery: &mut Brewery, origin: ExprOrigin) -> bir::TargetPlace { + let temporary = brewery.add( + bir::LocalVariableData { + name: None, + atomic: Atomic::No, + }, + validated::LocalVariableOrigin::Temporary(origin.into()), + ); + tracing::debug!("created temporary: temp{{{:?}}}", u32::from(temporary)); + self.variables.push(temporary); + brewery.add(bir::TargetPlaceData::LocalVariable(temporary), origin) + } + + /// Pushes user-declared variables into scope. Returns a new [`VariableMarker`][] + /// that should be freed by a call to [`Self::pop_variables_since_marker`][] + /// to clear the declared variables. + pub(crate) fn push_declared_variables( + &mut self, + vars: &[validated::LocalVariable], + brewery: &mut Brewery<'_>, + ) -> VariableMarker { + let marker = self.mark_variables(); + for &v in vars { + self.variables.push(brewery.variable(v)); + } + marker + } + + /// Record the set of declared variables; must be paired + /// with a call to `pop_variables_since_marker` + /// that will clear all variables (temporary or declared) + /// pushed since the marker was created. + pub(crate) fn mark_variables(&self) -> VariableMarker { + VariableMarker { + mark: self.variables.len(), } } - /// Pops all temporaries pushed since `scope` was created from the stack and inserts - /// "clear variable" instructions. - pub(crate) fn pop_temporary_scope(&mut self, brewery: &mut Brewery<'_>, scope: TemporaryScope) { - while brewery.temporary_stack_len() > scope.mark { - let temporary = brewery.pop_temporary(); - let origin = match brewery.bir_origin(temporary) { + /// Clears all variables (temporary or declared) pushed + /// since the marker was created. Clears of temporaries + /// will be given an origin based on the expression that they + /// were synthesized from; clears of local variables use `origin`. + pub(crate) fn clear_variables_since_marker( + &mut self, + marker: VariableMarker, + brewery: &mut Brewery<'_>, + origin: ExprOrigin, + ) { + assert!(marker.mark <= self.variables.len()); + while self.variables.len() > marker.mark { + let var = self.variables.pop().unwrap(); + let clear_origin = match brewery.bir_origin(var) { validated::LocalVariableOrigin::Temporary(expr) => ExprOrigin::synthesized(expr), validated::LocalVariableOrigin::LocalVariable(_) - | validated::LocalVariableOrigin::Parameter(_) => { - panic!("BIR temporaries should not originate from locals or parameters") - } + | validated::LocalVariableOrigin::Parameter(_) => origin, }; - self.push_clear_variable(brewery, temporary, origin); + self.push_clear_variable(brewery, var, clear_origin); } } - /// Pushes clear instructions for each of the given variables. - pub(crate) fn pop_declared_variables( + /// Push clear statements for `variables` onto the current block. + pub(crate) fn push_clear_variables( &mut self, brewery: &mut Brewery<'_>, - vars: &[validated::LocalVariable], + variables: &[bir::LocalVariable], origin: ExprOrigin, ) { - for var in vars { - let bir_var = brewery.variable(*var); - self.push_clear_variable(brewery, bir_var, origin); + for &variable in variables { + self.push_clear_variable(brewery, variable, origin); } } + /// Push a clear statement for `variable` onto the current block. fn push_clear_variable( &mut self, brewery: &mut Brewery<'_>, From f3882013a10165776721ab480c8555d1cf2e4046 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 3 May 2023 06:19:01 -0400 Subject: [PATCH 04/13] assert that all variables are cleared --- components/dada-brew/src/brew.rs | 2 ++ components/dada-brew/src/scope.rs | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/components/dada-brew/src/brew.rs b/components/dada-brew/src/brew.rs index 991c6f85..856aa6e6 100644 --- a/components/dada-brew/src/brew.rs +++ b/components/dada-brew/src/brew.rs @@ -37,6 +37,7 @@ pub fn brew(db: &dyn crate::Db, validated_tree: validated::Tree) -> bir::Bir { let root_expr = validated_tree.data(db).root_expr; let root_expr_origin = validated_tree.origins(db)[root_expr]; let mut cursor = Scope::root(brewery, root_expr_origin); + let marker = cursor.mark_variables(); if let Some(place) = cursor.brew_expr_to_temporary(brewery, root_expr) { cursor.terminate_and_diverge( brewery, @@ -44,6 +45,7 @@ pub fn brew(db: &dyn crate::Db, validated_tree: validated::Tree) -> bir::Bir { root_expr_origin, ); } + cursor.clear_variables_since_marker(marker, brewery, root_expr_origin); let start_basic_block = cursor.complete(); let bir = bir::Bir::new( diff --git a/components/dada-brew/src/scope.rs b/components/dada-brew/src/scope.rs index 40675e26..611ff88e 100644 --- a/components/dada-brew/src/scope.rs +++ b/components/dada-brew/src/scope.rs @@ -10,6 +10,7 @@ use dada_ir::{ use crate::brewery::Brewery; /// Tracks the current basic block that we are appending statements to. +#[derive(Debug)] pub(crate) struct Scope<'s> { /// The block that we started from; may or may not be "complete" /// (i.e., may not yet have a terminator assigned to it). @@ -36,6 +37,7 @@ pub(crate) struct Scope<'s> { } /// Reason for introducing a new scope +#[derive(Debug)] pub(crate) enum ScopeCause { /// Root scope Root, @@ -393,6 +395,15 @@ impl Scope<'_> { } } +impl Drop for Scope<'_> { + fn drop(&mut self) { + assert!( + self.variables.is_empty(), + "scope {self:?} was popped with variables not yet cleared" + ); + } +} + pub(crate) trait AnyPlace { fn into_place(self, brewery: &mut Brewery<'_>) -> bir::Place; } From 9c5cbc0bd047a6f50523e9a53ee3b86cc5145ea9 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 16 Aug 2023 12:05:04 +0300 Subject: [PATCH 05/13] track PC for permissions, include in errors --- components/dada-execute/src/machine.rs | 9 +- components/dada-execute/src/machine/op.rs | 8 +- components/dada-execute/src/step.rs | 36 +++++-- components/dada-execute/src/step/apply_op.rs | 98 ++++++++++--------- .../dada-execute/src/step/apply_unary.rs | 6 +- components/dada-execute/src/step/call.rs | 17 ++-- .../dada-execute/src/step/concatenate.rs | 4 +- components/dada-execute/src/step/give.rs | 4 +- .../dada-execute/src/step/into_shared.rs | 8 +- components/dada-execute/src/step/intrinsic.rs | 9 +- components/dada-execute/src/step/lease.rs | 4 +- components/dada-execute/src/step/share.rs | 4 +- components/dada-execute/src/step/tenant.rs | 1 + components/dada-execute/src/step/traversal.rs | 2 +- 14 files changed, 131 insertions(+), 79 deletions(-) diff --git a/components/dada-execute/src/machine.rs b/components/dada-execute/src/machine.rs index 4a319622..9dd20344 100644 --- a/components/dada-execute/src/machine.rs +++ b/components/dada-execute/src/machine.rs @@ -329,6 +329,9 @@ impl PermissionData { /// place (memory location) `p` to some object `o`. #[derive(Clone, Debug, PartialEq, Eq)] pub struct ValidPermissionData { + /// When the permission was granted. + pub pc: ProgramCounter, + /// A *joint* permission indicates whether this particular /// place permits other permissions to `o`. /// @@ -362,8 +365,9 @@ pub struct ValidPermissionData { impl ValidPermissionData { /// The data for a new "uniquely owned" permission. - pub fn my() -> Self { + pub fn my(pc: ProgramCounter) -> Self { ValidPermissionData { + pc, joint: Joint::No, leased: Leased::No, tenants: vec![], @@ -372,8 +376,9 @@ impl ValidPermissionData { } /// The data for a new "jointly owned" permission. Used for literals. - pub fn our() -> Self { + pub fn our(pc: ProgramCounter) -> Self { ValidPermissionData { + pc, joint: Joint::Yes, leased: Leased::No, tenants: vec![], diff --git a/components/dada-execute/src/machine/op.rs b/components/dada-execute/src/machine/op.rs index df8c3cb6..fd34b37b 100644 --- a/components/dada-execute/src/machine/op.rs +++ b/components/dada-execute/src/machine/op.rs @@ -291,14 +291,14 @@ impl std::ops::IndexMut for Machine { #[extension_trait::extension_trait] pub(crate) impl MachineOpExtMut for &mut dyn MachineOp { - fn my_value(&mut self, data: impl Into) -> Value { - let permission = self.new_permission(ValidPermissionData::my()); + fn my_value(&mut self, pc: ProgramCounter, data: impl Into) -> Value { + let permission = self.new_permission(ValidPermissionData::my(pc)); let object = self.new_object(data.into()); Value { object, permission } } - fn our_value(&mut self, data: impl Into) -> Value { - let permission = self.new_permission(ValidPermissionData::our()); + fn our_value(&mut self, pc: ProgramCounter, data: impl Into) -> Value { + let permission = self.new_permission(ValidPermissionData::our(pc)); let object = self.new_object(data.into()); Value { object, permission } } diff --git a/components/dada-execute/src/step.rs b/components/dada-execute/src/step.rs index 3881465a..044054e0 100644 --- a/components/dada-execute/src/step.rs +++ b/components/dada-execute/src/step.rs @@ -390,7 +390,9 @@ impl<'me> Stepper<'me> { "calling frame should be at a terminator" ); - let TerminatorData::Assign(top_place, _, top_basic_block) = &top_table[top_basic_block_data.terminator] else { + let TerminatorData::Assign(top_place, _, top_basic_block) = + &top_table[top_basic_block_data.terminator] + else { unreachable!("calling frame should be at an assign terminator") }; @@ -433,33 +435,47 @@ impl<'me> Stepper<'me> { match expr.data(table) { bir::ExprData::BooleanLiteral(v) => Ok(Value { object: self.machine.new_object(ObjectData::Bool(*v)), - permission: self.machine.new_permission(ValidPermissionData::our()), + permission: self + .machine + .new_permission(ValidPermissionData::our(self.machine.pc())), }), bir::ExprData::IntegerLiteral(v) => Ok(Value { object: self.machine.new_object(ObjectData::Int(*v)), - permission: self.machine.new_permission(ValidPermissionData::our()), + permission: self + .machine + .new_permission(ValidPermissionData::our(self.machine.pc())), }), bir::ExprData::UnsignedIntegerLiteral(v) => Ok(Value { object: self.machine.new_object(ObjectData::UnsignedInt(*v)), - permission: self.machine.new_permission(ValidPermissionData::our()), + permission: self + .machine + .new_permission(ValidPermissionData::our(self.machine.pc())), }), bir::ExprData::SignedIntegerLiteral(v) => Ok(Value { object: self.machine.new_object(ObjectData::SignedInt(*v)), - permission: self.machine.new_permission(ValidPermissionData::our()), + permission: self + .machine + .new_permission(ValidPermissionData::our(self.machine.pc())), }), bir::ExprData::FloatLiteral(v) => Ok(Value { object: self.machine.new_object(ObjectData::Float(v.0)), - permission: self.machine.new_permission(ValidPermissionData::our()), + permission: self + .machine + .new_permission(ValidPermissionData::our(self.machine.pc())), }), bir::ExprData::StringLiteral(v) => Ok(Value { object: self .machine .new_object(ObjectData::String(v.as_str(self.db).to_string())), - permission: self.machine.new_permission(ValidPermissionData::our()), + permission: self + .machine + .new_permission(ValidPermissionData::our(self.machine.pc())), }), bir::ExprData::Unit => Ok(Value { object: self.machine.new_object(ObjectData::Unit(())), - permission: self.machine.new_permission(ValidPermissionData::our()), + permission: self + .machine + .new_permission(ValidPermissionData::our(self.machine.pc())), }), bir::ExprData::IntoShared(place) => self.into_shared_place(table, *place), bir::ExprData::Lease(place) => self.lease_place(table, *place), @@ -472,7 +488,9 @@ impl<'me> Stepper<'me> { .collect::, _>>()?; Ok(Value { object: self.machine.new_object(ObjectData::Tuple(Tuple { fields })), - permission: self.machine.new_permission(ValidPermissionData::my()), + permission: self + .machine + .new_permission(ValidPermissionData::my(self.machine.pc())), }) } bir::ExprData::Concatenate(places) => self.concatenate(table, places), diff --git a/components/dada-execute/src/step/apply_op.rs b/components/dada-execute/src/step/apply_op.rs index d597cfbf..e593263c 100644 --- a/components/dada-execute/src/step/apply_op.rs +++ b/components/dada-execute/src/step/apply_op.rs @@ -40,58 +40,66 @@ impl Stepper<'_> { }; match (&self.machine[lhs], &self.machine[rhs]) { (&ObjectData::Bool(lhs), &ObjectData::Bool(rhs)) => match op { - Op::EqualEqual => Ok(self.machine.our_value(lhs == rhs)), - Op::GreaterEqual => Ok(self.machine.our_value(lhs >= rhs)), - Op::LessEqual => Ok(self.machine.our_value(lhs <= rhs)), + Op::EqualEqual => Ok(self.machine.our_value(self.machine.pc(), lhs == rhs)), + Op::GreaterEqual => Ok(self.machine.our_value(self.machine.pc(), lhs >= rhs)), + Op::LessEqual => Ok(self.machine.our_value(self.machine.pc(), lhs <= rhs)), _ => op_error(), }, (&ObjectData::UnsignedInt(lhs), &ObjectData::UnsignedInt(rhs)) | (&ObjectData::UnsignedInt(lhs), &ObjectData::Int(rhs)) | (&ObjectData::Int(lhs), &ObjectData::UnsignedInt(rhs)) => match op { - Op::EqualEqual => Ok(self.machine.our_value(lhs == rhs)), - Op::GreaterEqual => Ok(self.machine.our_value(lhs >= rhs)), - Op::LessEqual => Ok(self.machine.our_value(lhs <= rhs)), + Op::EqualEqual => Ok(self.machine.our_value(self.machine.pc(), lhs == rhs)), + Op::GreaterEqual => Ok(self.machine.our_value(self.machine.pc(), lhs >= rhs)), + Op::LessEqual => Ok(self.machine.our_value(self.machine.pc(), lhs <= rhs)), Op::Plus => match lhs.checked_add(rhs) { - Some(value) => Ok(self.machine.our_value(value)), + Some(value) => Ok(self.machine.our_value(self.machine.pc(), value)), None => overflow_error(), }, Op::Minus => match lhs.checked_sub(rhs) { - Some(value) => Ok(self.machine.our_value(value)), + Some(value) => Ok(self.machine.our_value(self.machine.pc(), value)), None => overflow_error(), }, Op::Times => match lhs.checked_mul(rhs) { - Some(value) => Ok(self.machine.our_value(value)), + Some(value) => Ok(self.machine.our_value(self.machine.pc(), value)), None => overflow_error(), }, Op::DividedBy => match lhs.checked_div(rhs) { - Some(value) => Ok(self.machine.our_value(value)), + Some(value) => Ok(self.machine.our_value(self.machine.pc(), value)), None => div_zero_error(), }, - Op::LessThan => Ok(self.machine.our_value(lhs < rhs)), - Op::GreaterThan => Ok(self.machine.our_value(lhs > rhs)), + Op::LessThan => Ok(self.machine.our_value(self.machine.pc(), lhs < rhs)), + Op::GreaterThan => Ok(self.machine.our_value(self.machine.pc(), lhs > rhs)), }, (&ObjectData::Int(lhs), &ObjectData::Int(rhs)) => match op { - Op::EqualEqual => Ok(self.machine.our_value(lhs == rhs)), - Op::GreaterEqual => Ok(self.machine.our_value(lhs >= rhs)), - Op::LessEqual => Ok(self.machine.our_value(lhs <= rhs)), + Op::EqualEqual => Ok(self.machine.our_value(self.machine.pc(), lhs == rhs)), + Op::GreaterEqual => Ok(self.machine.our_value(self.machine.pc(), lhs >= rhs)), + Op::LessEqual => Ok(self.machine.our_value(self.machine.pc(), lhs <= rhs)), Op::Plus => match lhs.checked_add(rhs) { - Some(value) => Ok(self.machine.our_value(ObjectData::Int(value))), + Some(value) => Ok(self + .machine + .our_value(self.machine.pc(), ObjectData::Int(value))), None => overflow_error(), }, Op::Minus => match lhs.checked_sub(rhs) { - Some(value) => Ok(self.machine.our_value(ObjectData::Int(value))), + Some(value) => Ok(self + .machine + .our_value(self.machine.pc(), ObjectData::Int(value))), None => overflow_error(), }, Op::Times => match lhs.checked_mul(rhs) { - Some(value) => Ok(self.machine.our_value(ObjectData::Int(value))), + Some(value) => Ok(self + .machine + .our_value(self.machine.pc(), ObjectData::Int(value))), None => overflow_error(), }, Op::DividedBy => match lhs.checked_div(rhs) { - Some(value) => Ok(self.machine.our_value(ObjectData::Int(value))), + Some(value) => Ok(self + .machine + .our_value(self.machine.pc(), ObjectData::Int(value))), None => div_zero_error(), }, - Op::LessThan => Ok(self.machine.our_value(lhs < rhs)), - Op::GreaterThan => Ok(self.machine.our_value(lhs > rhs)), + Op::LessThan => Ok(self.machine.our_value(self.machine.pc(), lhs < rhs)), + Op::GreaterThan => Ok(self.machine.our_value(self.machine.pc(), lhs > rhs)), }, (&ObjectData::SignedInt(lhs), &ObjectData::SignedInt(rhs)) => { self.apply_signed_int(expr, op, lhs, rhs) @@ -105,35 +113,35 @@ impl Stepper<'_> { Err(_) => overflow_error(), }, (&ObjectData::Float(lhs), &ObjectData::Float(rhs)) => match op { - Op::EqualEqual => Ok(self.machine.our_value(lhs == rhs)), - Op::GreaterEqual => Ok(self.machine.our_value(lhs >= rhs)), - Op::LessEqual => Ok(self.machine.our_value(lhs <= rhs)), - Op::Plus => Ok(self.machine.our_value(lhs + rhs)), - Op::Minus => Ok(self.machine.our_value(lhs - rhs)), - Op::Times => Ok(self.machine.our_value(lhs * rhs)), - Op::DividedBy => Ok(self.machine.our_value(lhs / rhs)), - Op::LessThan => Ok(self.machine.our_value(lhs < rhs)), - Op::GreaterThan => Ok(self.machine.our_value(lhs > rhs)), + Op::EqualEqual => Ok(self.machine.our_value(self.machine.pc(), lhs == rhs)), + Op::GreaterEqual => Ok(self.machine.our_value(self.machine.pc(), lhs >= rhs)), + Op::LessEqual => Ok(self.machine.our_value(self.machine.pc(), lhs <= rhs)), + Op::Plus => Ok(self.machine.our_value(self.machine.pc(), lhs + rhs)), + Op::Minus => Ok(self.machine.our_value(self.machine.pc(), lhs - rhs)), + Op::Times => Ok(self.machine.our_value(self.machine.pc(), lhs * rhs)), + Op::DividedBy => Ok(self.machine.our_value(self.machine.pc(), lhs / rhs)), + Op::LessThan => Ok(self.machine.our_value(self.machine.pc(), lhs < rhs)), + Op::GreaterThan => Ok(self.machine.our_value(self.machine.pc(), lhs > rhs)), }, (ObjectData::String(lhs), ObjectData::String(rhs)) => match op { Op::EqualEqual => { let val = lhs == rhs; - Ok(self.machine.our_value(val)) + Ok(self.machine.our_value(self.machine.pc(), val)) } Op::GreaterEqual => { let val = lhs >= rhs; - Ok(self.machine.our_value(val)) + Ok(self.machine.our_value(self.machine.pc(), val)) } Op::LessEqual => { let val = lhs <= rhs; - Ok(self.machine.our_value(val)) + Ok(self.machine.our_value(self.machine.pc(), val)) } _ => op_error(), }, (&ObjectData::Unit(()), &ObjectData::Unit(())) => match op { - Op::EqualEqual => Ok(self.machine.our_value(true)), - Op::GreaterEqual => Ok(self.machine.our_value(lhs >= rhs)), - Op::LessEqual => Ok(self.machine.our_value(lhs <= rhs)), + Op::EqualEqual => Ok(self.machine.our_value(self.machine.pc(), true)), + Op::GreaterEqual => Ok(self.machine.our_value(self.machine.pc(), lhs >= rhs)), + Op::LessEqual => Ok(self.machine.our_value(self.machine.pc(), lhs <= rhs)), _ => op_error(), }, _ => op_error(), @@ -156,23 +164,23 @@ impl Stepper<'_> { Err(error!(span, "overflow").eyre(self.db)) }; match op { - Op::EqualEqual => Ok(self.machine.our_value(lhs == rhs)), - Op::GreaterEqual => Ok(self.machine.our_value(lhs >= rhs)), - Op::LessEqual => Ok(self.machine.our_value(lhs <= rhs)), + Op::EqualEqual => Ok(self.machine.our_value(self.machine.pc(), lhs == rhs)), + Op::GreaterEqual => Ok(self.machine.our_value(self.machine.pc(), lhs >= rhs)), + Op::LessEqual => Ok(self.machine.our_value(self.machine.pc(), lhs <= rhs)), Op::Plus => match lhs.checked_add(rhs) { - Some(value) => Ok(self.machine.our_value(value)), + Some(value) => Ok(self.machine.our_value(self.machine.pc(), value)), None => overflow_error(), }, Op::Minus => match lhs.checked_sub(rhs) { - Some(value) => Ok(self.machine.our_value(value)), + Some(value) => Ok(self.machine.our_value(self.machine.pc(), value)), None => overflow_error(), }, Op::Times => match lhs.checked_mul(rhs) { - Some(value) => Ok(self.machine.our_value(value)), + Some(value) => Ok(self.machine.our_value(self.machine.pc(), value)), None => overflow_error(), }, Op::DividedBy => match lhs.checked_div(rhs) { - Some(value) => Ok(self.machine.our_value(value)), + Some(value) => Ok(self.machine.our_value(self.machine.pc(), value)), None => { if rhs != -1 { div_zero_error() @@ -182,8 +190,8 @@ impl Stepper<'_> { } } }, - Op::LessThan => Ok(self.machine.our_value(lhs < rhs)), - Op::GreaterThan => Ok(self.machine.our_value(lhs > rhs)), + Op::LessThan => Ok(self.machine.our_value(self.machine.pc(), lhs < rhs)), + Op::GreaterThan => Ok(self.machine.our_value(self.machine.pc(), lhs > rhs)), } } } diff --git a/components/dada-execute/src/step/apply_unary.rs b/components/dada-execute/src/step/apply_unary.rs index dfd4da54..b8d73a0f 100644 --- a/components/dada-execute/src/step/apply_unary.rs +++ b/components/dada-execute/src/step/apply_unary.rs @@ -29,9 +29,11 @@ impl Stepper<'_> { .eyre(self.db)) }; match (op, &self.machine[rhs]) { - (Op::Minus, &ObjectData::SignedInt(rhs)) => Ok(self.machine.our_value(-rhs)), + (Op::Minus, &ObjectData::SignedInt(rhs)) => { + Ok(self.machine.our_value(self.machine.pc(), -rhs)) + } (Op::Minus, &ObjectData::Int(rhs)) => match i64::try_from(rhs) { - Ok(rhs) => Ok(self.machine.our_value(-rhs)), + Ok(rhs) => Ok(self.machine.our_value(self.machine.pc(), -rhs)), Err(_) => { let span = self.span_from_bir(expr); Err(error!(span, "overflow").eyre(self.db)) diff --git a/components/dada-execute/src/step/call.rs b/components/dada-execute/src/step/call.rs index aff92fcd..6436d15d 100644 --- a/components/dada-execute/src/step/call.rs +++ b/components/dada-execute/src/step/call.rs @@ -47,7 +47,9 @@ impl Stepper<'_> { class: c, fields: arguments, }; - Ok(CallResult::Returned(self.machine.my_value(instance))) + Ok(CallResult::Returned( + self.machine.my_value(self.machine.pc(), instance), + )) } &ObjectData::Function(function) => { let signature = function.signature(self.db); @@ -60,11 +62,14 @@ impl Stepper<'_> { if function.effect(self.db).permits_await() { // If the function can await, then it must be an async function. // Now that we have validated the arguments, return a thunk. - let thunk = self.machine.my_value(ThunkFn { - function, - arguments, - expected_return_ty, - }); + let thunk = self.machine.my_value( + self.machine.pc(), + ThunkFn { + function, + arguments, + expected_return_ty, + }, + ); Ok(CallResult::Returned(thunk)) } else { // This is not an async function, so push it onto the stack diff --git a/components/dada-execute/src/step/concatenate.rs b/components/dada-execute/src/step/concatenate.rs index 2598b26a..24d4d5ae 100644 --- a/components/dada-execute/src/step/concatenate.rs +++ b/components/dada-execute/src/step/concatenate.rs @@ -21,7 +21,9 @@ impl Stepper<'_> { Ok(Value { object: self.machine.new_object(ObjectData::String(string)), - permission: self.machine.new_permission(ValidPermissionData::our()), + permission: self + .machine + .new_permission(ValidPermissionData::our(self.machine.pc())), }) } } diff --git a/components/dada-execute/src/step/give.rs b/components/dada-execute/src/step/give.rs index 93bf84ac..e8815a26 100644 --- a/components/dada-execute/src/step/give.rs +++ b/components/dada-execute/src/step/give.rs @@ -74,7 +74,9 @@ impl Stepper<'_> { // create a new one to return. let object = self.take_object(object_traversal)?; - let permission = self.machine.new_permission(ValidPermissionData::my()); + let permission = self + .machine + .new_permission(ValidPermissionData::my(self.machine.pc())); Ok(Value { object, permission }) } } diff --git a/components/dada-execute/src/step/into_shared.rs b/components/dada-execute/src/step/into_shared.rs index eca7c048..5d159046 100644 --- a/components/dada-execute/src/step/into_shared.rs +++ b/components/dada-execute/src/step/into_shared.rs @@ -113,7 +113,9 @@ impl Stepper<'_> { // ``` (Leased::No, Joint::No) => { let object = self.take_object(traversal)?; - let permission = self.machine.new_permission(ValidPermissionData::our()); + let permission = self + .machine + .new_permission(ValidPermissionData::our(self.machine.pc())); Ok(Value { object, permission }) } @@ -151,7 +153,9 @@ impl Stepper<'_> { // state, because there may be extant references to the data that it owned. // * `our [String]` is therefore very different from `Rc>`. (Leased::No, Joint::Yes) => { - let permission = self.machine.new_permission(ValidPermissionData::our()); + let permission = self + .machine + .new_permission(ValidPermissionData::our(self.machine.pc())); Ok(Value { object: traversal.object, permission, diff --git a/components/dada-execute/src/step/intrinsic.rs b/components/dada-execute/src/step/intrinsic.rs index b89a704d..68c1443f 100644 --- a/components/dada-execute/src/step/intrinsic.rs +++ b/components/dada-execute/src/step/intrinsic.rs @@ -48,9 +48,10 @@ impl Stepper<'_> { } fn intrinsic_print(&mut self, values: Vec) -> eyre::Result { - Ok(self - .machine - .my_value(RustThunk::new("print", values, Intrinsic::Print))) + Ok(self.machine.my_value( + self.machine.pc(), + RustThunk::new("print", values, Intrinsic::Print), + )) } #[tracing::instrument(level = "Debug", skip(self, await_pc))] @@ -75,6 +76,6 @@ impl Stepper<'_> { error!(span_now, "error printing `{:?}`", message_str).eyre(self.db) })?; - Ok(self.machine.our_value(())) + Ok(self.machine.our_value(await_pc, ())) } } diff --git a/components/dada-execute/src/step/lease.rs b/components/dada-execute/src/step/lease.rs index 12af67f2..5d62d239 100644 --- a/components/dada-execute/src/step/lease.rs +++ b/components/dada-execute/src/step/lease.rs @@ -98,7 +98,9 @@ impl Stepper<'_> { accumulated_permissions.joint, accumulated_permissions.leased, ) { - let permission = self.machine.new_permission(ValidPermissionData::our()); + let permission = self + .machine + .new_permission(ValidPermissionData::our(self.machine.pc())); return Ok(Value { object, permission }); } diff --git a/components/dada-execute/src/step/share.rs b/components/dada-execute/src/step/share.rs index 331b6137..c4dab903 100644 --- a/components/dada-execute/src/step/share.rs +++ b/components/dada-execute/src/step/share.rs @@ -90,7 +90,9 @@ impl Stepper<'_> { accumulated_permissions.joint, accumulated_permissions.leased, ) { - let permission = self.machine.new_permission(ValidPermissionData::our()); + let permission = self + .machine + .new_permission(ValidPermissionData::our(self.machine.pc())); return Ok(Value { object, permission }); } diff --git a/components/dada-execute/src/step/tenant.rs b/components/dada-execute/src/step/tenant.rs index 0f545e92..7ab51820 100644 --- a/components/dada-execute/src/step/tenant.rs +++ b/components/dada-execute/src/step/tenant.rs @@ -19,6 +19,7 @@ impl Stepper<'_> { leased: Leased::Yes, easements: vec![], tenants: vec![], + pc: self.machine.pc(), }); let (lessor, easements_on) = traversed.split_last().unwrap(); diff --git a/components/dada-execute/src/step/traversal.rs b/components/dada-execute/src/step/traversal.rs index fedcfe01..e6e17a2b 100644 --- a/components/dada-execute/src/step/traversal.rs +++ b/components/dada-execute/src/step/traversal.rs @@ -254,7 +254,7 @@ impl Stepper<'_> { } fn traverse_to_constant(&mut self, object_data: ObjectData) -> PlaceTraversal { - let object = self.machine.our_value(object_data); + let object = self.machine.our_value(self.machine.pc(), object_data); let permissions = AccumulatedPermissions { traversed: vec![], leased: Leased::No, From de37b3e683984a6b1651030995db706c372b0389 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sat, 19 Aug 2023 17:07:17 +0300 Subject: [PATCH 06/13] convert StatementData to struct with fields --- components/dada-brew/src/scope.rs | 27 +++++++++++++++++++++++---- components/dada-execute/src/step.rs | 10 +++++----- components/dada-ir/src/code/bir.rs | 24 ++++++++++++++++++------ 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/components/dada-brew/src/scope.rs b/components/dada-brew/src/scope.rs index 611ff88e..fcada905 100644 --- a/components/dada-brew/src/scope.rs +++ b/components/dada-brew/src/scope.rs @@ -226,7 +226,12 @@ impl Scope<'_> { variable: bir::LocalVariable, origin: ExprOrigin, ) { - let statement = brewery.add(bir::StatementData::Clear(variable), origin); + let statement = brewery.add( + bir::StatementData { + action: bir::ActionData::Clear(variable), + }, + origin, + ); self.push_statement(brewery, statement) } @@ -281,7 +286,12 @@ impl Scope<'_> { ) { if self.end_block.is_some() { let value = brewery.add(value, origin); - let statement = brewery.add(bir::StatementData::AssignExpr(target, value), origin); + let statement = brewery.add( + bir::StatementData { + action: bir::ActionData::AssignExpr(target, value), + }, + origin, + ); self.push_statement(brewery, statement); } } @@ -311,7 +321,9 @@ impl Scope<'_> { if let Some(breakpoint_index) = brewery.expr_is_breakpoint(origin.syntax_expr) { let input_file = brewery.input_file(); let statement = brewery.add( - bir::StatementData::BreakpointStart(input_file, breakpoint_index), + bir::StatementData { + action: bir::ActionData::BreakpointStart(input_file, breakpoint_index), + }, origin, ); self.push_statement(brewery, statement); @@ -360,7 +372,14 @@ impl Scope<'_> { if let Some(breakpoint_index) = brewery.expr_is_breakpoint(origin.syntax_expr) { let input_file = brewery.input_file(); let statement = brewery.add( - bir::StatementData::BreakpointEnd(input_file, breakpoint_index, expr, place), + bir::StatementData { + action: bir::ActionData::BreakpointEnd( + input_file, + breakpoint_index, + expr, + place, + ), + }, origin, ); self.push_statement(brewery, statement); diff --git a/components/dada-execute/src/step.rs b/components/dada-execute/src/step.rs index 044054e0..29efa8ca 100644 --- a/components/dada-execute/src/step.rs +++ b/components/dada-execute/src/step.rs @@ -176,8 +176,8 @@ impl<'me> Stepper<'me> { statement.data(table).debug(&bir.in_ir_db(self.db)) ); - match statement.data(table) { - bir::StatementData::AssignExpr(place, expr) => { + match &statement.data(table).action { + bir::ActionData::AssignExpr(place, expr) => { // Subtle: The way this is setup, permissions for the target are not // canceled until the write occurs. Consider something like this: // @@ -191,12 +191,12 @@ impl<'me> Stepper<'me> { let value = self.eval_expr(table, *expr)?; self.assign_value_to_place(table, *place, value)?; } - bir::StatementData::Clear(lv) => { + bir::ActionData::Clear(lv) => { let permission = self.machine.expired_permission(None); let object = self.machine.unit_object(); *self.machine.local_mut(*lv) = Value { object, permission }; } - bir::StatementData::BreakpointStart(input_file, index) => { + bir::ActionData::BreakpointStart(input_file, index) => { let kernel = self.kernel.take().unwrap(); let result = kernel.breakpoint_start(self.db, *input_file, *index, &mut || { HeapGraph::new(self.db, self.machine, None) @@ -204,7 +204,7 @@ impl<'me> Stepper<'me> { self.kernel = Some(kernel); result? } - bir::StatementData::BreakpointEnd(input_file, index, expr, in_flight_place) => { + bir::ActionData::BreakpointEnd(input_file, index, expr, in_flight_place) => { let span = self.span_from_syntax_expr(*expr); let kernel = self.kernel.take().unwrap(); let result = kernel.breakpoint_end(self.db, *input_file, *index, span, &mut || { diff --git a/components/dada-ir/src/code/bir.rs b/components/dada-ir/src/code/bir.rs index 68a8d450..a7198b7b 100644 --- a/components/dada-ir/src/code/bir.rs +++ b/components/dada-ir/src/code/bir.rs @@ -256,7 +256,19 @@ impl DebugWithDb> for Statement { } #[derive(PartialEq, Eq, Clone, Hash, Debug)] -pub enum StatementData { +pub struct StatementData { + pub action: ActionData, +} + +impl DebugWithDb> for StatementData { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Bir>) -> std::fmt::Result { + let StatementData { action } = self; + action.fmt(f, db) + } +} + +#[derive(PartialEq, Eq, Clone, Hash, Debug)] +pub enum ActionData { /// Assign the result of evaluating an expression to a place. /// This is the preferred form of assignment, and covers /// cases like `a := b` as well as `a := 22`. In these case, either @@ -293,24 +305,24 @@ pub enum StatementData { BreakpointEnd(InputFile, usize, syntax::Expr, Option), } -impl DebugWithDb> for StatementData { +impl DebugWithDb> for ActionData { fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Bir>) -> std::fmt::Result { match self { - StatementData::AssignExpr(place, expr) => f + ActionData::AssignExpr(place, expr) => f .debug_tuple("AssignExpr") .field(&place.debug(db)) .field(&expr.debug(db)) .finish(), - StatementData::Clear(lv) => f.debug_tuple("Clear").field(&lv.debug(db)).finish(), + ActionData::Clear(lv) => f.debug_tuple("Clear").field(&lv.debug(db)).finish(), - StatementData::BreakpointStart(input_file, index) => f + ActionData::BreakpointStart(input_file, index) => f .debug_tuple("BreakpoingStart") .field(&input_file.debug(db.db())) .field(index) .finish(), - StatementData::BreakpointEnd(input_file, index, e, p) => f + ActionData::BreakpointEnd(input_file, index, e, p) => f .debug_tuple("BreakpointEnd") .field(&input_file.debug(db.db())) .field(index) From 341f5d2ec836f46da5051ac358fe8a066affd321 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sat, 19 Aug 2023 17:18:25 +0300 Subject: [PATCH 07/13] add no-op action --- components/dada-execute/src/step.rs | 4 ++++ components/dada-ir/src/code/bir.rs | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/components/dada-execute/src/step.rs b/components/dada-execute/src/step.rs index 29efa8ca..b9e812c1 100644 --- a/components/dada-execute/src/step.rs +++ b/components/dada-execute/src/step.rs @@ -177,6 +177,10 @@ impl<'me> Stepper<'me> { ); match &statement.data(table).action { + bir::ActionData::Noop => { + // nothing happens! + } + bir::ActionData::AssignExpr(place, expr) => { // Subtle: The way this is setup, permissions for the target are not // canceled until the write occurs. Consider something like this: diff --git a/components/dada-ir/src/code/bir.rs b/components/dada-ir/src/code/bir.rs index a7198b7b..a4ffbe5f 100644 --- a/components/dada-ir/src/code/bir.rs +++ b/components/dada-ir/src/code/bir.rs @@ -269,6 +269,9 @@ impl DebugWithDb> for StatementData { #[derive(PartialEq, Eq, Clone, Hash, Debug)] pub enum ActionData { + /// No action. Created during construction. + Noop, + /// Assign the result of evaluating an expression to a place. /// This is the preferred form of assignment, and covers /// cases like `a := b` as well as `a := 22`. In these case, either @@ -308,6 +311,8 @@ pub enum ActionData { impl DebugWithDb> for ActionData { fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Bir>) -> std::fmt::Result { match self { + ActionData::Noop => f.debug_tuple("Noop").finish(), + ActionData::AssignExpr(place, expr) => f .debug_tuple("AssignExpr") .field(&place.debug(db)) From d763f7ed5c0b3c693d11a5dcf4148e4639e9f61e Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sat, 19 Aug 2023 18:09:51 +0300 Subject: [PATCH 08/13] convert to an open-ended control-flow graph --- components/dada-brew/src/brewery.rs | 22 +- components/dada-brew/src/scope.rs | 81 +- components/dada-execute/src/machine.rs | 42 +- components/dada-execute/src/machine/op.rs | 3 +- components/dada-execute/src/step.rs | 105 ++- components/dada-execute/src/step/call.rs | 22 +- components/dada-id/src/lib.rs | 3 +- components/dada-ir/src/code/bir.rs | 196 +++-- .../cursor-position/HeapGraph-0.bir.ref | 480 +++++------ .../cursor-position/HeapGraph-1.bir.ref | 518 ++++++------ .../cursor-position/HeapGraph-2.bir.ref | 518 ++++++------ .../cursor-position/HeapGraph-3.bir.ref | 518 ++++++------ dada_tests/heap-graph/dag/HeapGraph-0.bir.ref | 348 ++++---- .../leased-point/HeapGraph-0.bir.ref | 286 +++---- .../heap-graph/line-end/HeapGraph-0.bir.ref | 90 +-- .../heap-graph/line-end/HeapGraph-1.bir.ref | 90 +-- .../heap-graph/line-start/HeapGraph-0.bir.ref | 326 ++++---- .../heap-graph/line-start/HeapGraph-1.bir.ref | 286 +++---- .../mid-increment/HeapGraph-0.bir.ref | 414 +++++----- .../nested-functions/HeapGraph-0.bir.ref | 744 +++++++++--------- .../nested-points/HeapGraph-0.bir.ref | 286 +++---- .../nested-points/HeapGraph-1.bir.ref | 286 +++---- .../nested-points/HeapGraph-2.bir.ref | 326 ++++---- .../heap-graph/past-end/HeapGraph-0.bir.ref | 170 ++-- .../heap-graph/rust-thunk/HeapGraph-0.bir.ref | 208 ++--- .../heap-graph/tutorial-1/HeapGraph-0.bir.ref | 368 ++++----- .../heap-graph/tutorial-1/HeapGraph-1.bir.ref | 328 ++++---- .../heap-graph/tutorial-1/HeapGraph-2.bir.ref | 332 ++++---- .../heap-graph/tutorial-1/HeapGraph-3.bir.ref | 328 ++++---- .../heap-graph/tutorial-1/HeapGraph-4.bir.ref | 370 ++++----- .../tutorial-give-10/HeapGraph-0.bir.ref | 204 ++--- .../tutorial-give-10/HeapGraph-1.bir.ref | 204 ++--- .../tutorial-lease-10/HeapGraph-0.bir.ref | 422 +++++----- .../tutorial-lease-10/HeapGraph-1.bir.ref | 422 +++++----- .../tutorial-lease-20/HeapGraph-0.bir.ref | 436 +++++----- .../tutorial-share-10/HeapGraph-0.bir.ref | 258 +++--- .../tutorial-share-20/HeapGraph-0.bir.ref | 246 +++--- .../tutorial-share-30/HeapGraph-0.bir.ref | 232 +++--- 38 files changed, 5251 insertions(+), 5267 deletions(-) diff --git a/components/dada-brew/src/brewery.rs b/components/dada-brew/src/brewery.rs index b38044d5..60233a62 100644 --- a/components/dada-brew/src/brewery.rs +++ b/components/dada-brew/src/brewery.rs @@ -4,7 +4,8 @@ use dada_collections::Map; use dada_id::prelude::*; use dada_ir::{ code::{ - bir, syntax, + bir::{self, StatementData}, + syntax, validated::{self, ExprOrigin}, }, input_file::InputFile, @@ -27,7 +28,7 @@ pub struct Brewery<'me> { tables: &'me mut bir::Tables, origins: &'me mut bir::Origins, variables: Rc>, - dummy_terminator: bir::Terminator, + pub(crate) dummy_terminator: bir::ControlPoint, } impl<'me> Brewery<'me> { @@ -45,7 +46,7 @@ impl<'me> Brewery<'me> { let dummy_terminator = add( tables, origins, - bir::TerminatorData::Panic, + bir::ControlPointData::Terminator(bir::TerminatorData::Panic), *validated_tree_data.root_expr.origin_in(validated_origins), ); Self { @@ -86,15 +87,14 @@ impl<'me> Brewery<'me> { of.origin_in(self.origins).clone() } - /// Returns a new basic block with no statements and a "panic" terminator. - /// This is meant to be used by `cursor`, which should ensure the terminator - /// is overwritten. - pub fn dummy_block(&mut self, origin: ExprOrigin) -> bir::BasicBlock { + /// Creates a new "no-op" statement that will start up a new basic block. + /// The "next" statement will be the dummy terminator. + pub fn dummy_block(&mut self, origin: ExprOrigin) -> bir::ControlPoint { self.add( - bir::BasicBlockData { - statements: vec![], - terminator: self.dummy_terminator, - }, + bir::ControlPointData::Statement(StatementData { + action: bir::ActionData::Noop, + next: self.dummy_terminator, + }), origin, ) } diff --git a/components/dada-brew/src/scope.rs b/components/dada-brew/src/scope.rs index fcada905..a3203f85 100644 --- a/components/dada-brew/src/scope.rs +++ b/components/dada-brew/src/scope.rs @@ -1,7 +1,8 @@ use dada_id::prelude::*; use dada_ir::{ code::{ - bir, syntax, + bir::{self, ControlPoint}, + syntax, validated::{self, ExprOrigin}, }, storage::Atomic, @@ -14,13 +15,13 @@ use crate::brewery::Brewery; pub(crate) struct Scope<'s> { /// The block that we started from; may or may not be "complete" /// (i.e., may not yet have a terminator assigned to it). - start_block: bir::BasicBlock, + start_block: bir::ControlPoint, /// The basic block we are currently appending to; could be the /// same as `start_block`. /// /// If `None`, we are in a section of dead code. - end_block: Option, + end_block: Option, /// Reason for introducing this scope cause: ScopeCause, @@ -52,8 +53,8 @@ pub(crate) enum ScopeCause { #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Hash)] pub struct LoopContext { pub expr: validated::Expr, - pub continue_block: bir::BasicBlock, - pub break_block: bir::BasicBlock, + pub continue_block: bir::ControlPoint, + pub break_block: bir::ControlPoint, pub loop_value: bir::TargetPlace, } @@ -80,7 +81,7 @@ impl Scope<'_> { } /// Invoked at the end of the method, returns the start block. - pub(crate) fn complete(self) -> bir::BasicBlock { + pub(crate) fn complete(self) -> bir::ControlPoint { assert!(self.in_dead_code()); assert!(matches!(self.cause, ScopeCause::Root)); self.start_block @@ -91,7 +92,7 @@ impl Scope<'_> { /// `self.end_block` in this subscope. pub(crate) fn subscope<'s>( &'s self, - end_block: Option, + end_block: Option, cause: ScopeCause, ) -> Scope<'s> { Scope { @@ -226,18 +227,26 @@ impl Scope<'_> { variable: bir::LocalVariable, origin: ExprOrigin, ) { - let statement = brewery.add( + self.push_statement( + brewery, bir::StatementData { action: bir::ActionData::Clear(variable), + next: brewery.dummy_terminator, }, origin, - ); - self.push_statement(brewery, statement) + ) } - pub(crate) fn push_statement(&mut self, brewery: &mut Brewery<'_>, statement: bir::Statement) { - if let Some(end_block) = self.end_block { - brewery[end_block].statements.push(statement); + pub(crate) fn push_statement( + &mut self, + brewery: &mut Brewery<'_>, + statement: bir::StatementData, + origin: ExprOrigin, + ) { + if self.end_block.is_some() { + let statement = brewery.add(bir::ControlPointData::Statement(statement), origin); + self.set_next_field_of_end_block(brewery, statement); + self.end_block = Some(statement); } } @@ -246,16 +255,31 @@ impl Scope<'_> { brewery: &mut Brewery<'_>, terminator_data: bir::TerminatorData, origin: ExprOrigin, - next_block: Option, + next_block: Option, ) { - if let Some(end_block) = self.end_block { - let terminator = brewery.add(terminator_data, origin); - brewery[end_block].terminator = terminator; - brewery[end_block].statements.shrink_to_fit(); + if self.end_block.is_some() { + let terminator = + brewery.add(bir::ControlPointData::Terminator(terminator_data), origin); + self.set_next_field_of_end_block(brewery, terminator); self.end_block = next_block; } } + fn set_next_field_of_end_block(&mut self, brewery: &mut Brewery<'_>, next: ControlPoint) { + if let Some(end_block) = self.end_block { + let dummy_terminator = brewery.dummy_terminator; + match &mut brewery[end_block] { + bir::ControlPointData::Statement(data) => { + assert_eq!(data.next, dummy_terminator); + data.next = next; + } + bir::ControlPointData::Terminator(_) => { + panic!("end block can never be a terminator") + } + } + } + } + pub(crate) fn terminate_and_diverge( &mut self, brewery: &mut Brewery<'_>, @@ -268,9 +292,9 @@ impl Scope<'_> { pub(crate) fn terminate_and_continue( &mut self, brewery: &mut Brewery<'_>, - terminator_data: impl FnOnce(bir::BasicBlock) -> bir::TerminatorData, + terminator_data: impl FnOnce(bir::ControlPoint) -> bir::TerminatorData, origin: ExprOrigin, - ) -> bir::BasicBlock { + ) -> bir::ControlPoint { let next_block = brewery.dummy_block(origin); let terminator_data = terminator_data(next_block); self.terminate(brewery, terminator_data, origin, Some(next_block)); @@ -286,13 +310,14 @@ impl Scope<'_> { ) { if self.end_block.is_some() { let value = brewery.add(value, origin); - let statement = brewery.add( + self.push_statement( + brewery, bir::StatementData { action: bir::ActionData::AssignExpr(target, value), + next: brewery.dummy_terminator, }, origin, ); - self.push_statement(brewery, statement); } } @@ -320,13 +345,14 @@ impl Scope<'_> { if !origin.synthesized && self.end_block.is_some() { if let Some(breakpoint_index) = brewery.expr_is_breakpoint(origin.syntax_expr) { let input_file = brewery.input_file(); - let statement = brewery.add( + self.push_statement( + brewery, bir::StatementData { action: bir::ActionData::BreakpointStart(input_file, breakpoint_index), + next: brewery.dummy_terminator, }, origin, ); - self.push_statement(brewery, statement); } } } @@ -371,7 +397,8 @@ impl Scope<'_> { if !origin.synthesized && self.end_block.is_some() { if let Some(breakpoint_index) = brewery.expr_is_breakpoint(origin.syntax_expr) { let input_file = brewery.input_file(); - let statement = brewery.add( + self.push_statement( + brewery, bir::StatementData { action: bir::ActionData::BreakpointEnd( input_file, @@ -379,10 +406,10 @@ impl Scope<'_> { expr, place, ), + next: brewery.dummy_terminator, }, origin, ); - self.push_statement(brewery, statement); } } } @@ -390,7 +417,7 @@ impl Scope<'_> { pub(crate) fn terminate_and_goto( &mut self, brewery: &mut Brewery<'_>, - target: bir::BasicBlock, + target: bir::ControlPoint, origin: ExprOrigin, ) { self.terminate_and_diverge(brewery, bir::TerminatorData::Goto(target), origin); diff --git a/components/dada-execute/src/machine.rs b/components/dada-execute/src/machine.rs index 9dd20344..3b23bfcd 100644 --- a/components/dada-execute/src/machine.rs +++ b/components/dada-execute/src/machine.rs @@ -4,7 +4,7 @@ use dada_collections::IndexVec; use dada_id::id; use dada_ir::{ class::Class, - code::bir, + code::bir::{self, TerminatorData}, function::Function, intrinsic::Intrinsic, span::FileSpan, @@ -453,39 +453,26 @@ pub struct ProgramCounter { /// The BIR we are interpreting. pub bir: bir::Bir, - /// The current basic block. - pub basic_block: bir::BasicBlock, - - /// The index of the statement to execute next within the - /// basic block, or -- if equal to the number of statements -- indicates - /// we are about to execute the terminator. - pub statement: usize, + /// The control point we are about to execute. + pub control_point: bir::ControlPoint, } impl ProgramCounter { - pub fn move_to_block(self, basic_block: bir::BasicBlock) -> ProgramCounter { - Self::at_block(self.bir, basic_block) + pub fn move_to(self, control_point: bir::ControlPoint) -> ProgramCounter { + Self::at_block(self.bir, control_point) } - pub fn at_block(bir: bir::Bir, basic_block: bir::BasicBlock) -> ProgramCounter { - Self { - bir, - basic_block, - statement: 0, - } + pub fn at_block(bir: bir::Bir, control_point: bir::ControlPoint) -> ProgramCounter { + Self { bir, control_point } } /// True if this PC represents a `return` terminator. pub fn is_return(&self, db: &dyn crate::Db) -> bool { let bir_data = self.bir.data(db); - let basic_block_data = &bir_data.tables[self.basic_block]; - if self.statement < basic_block_data.statements.len() { - return false; + match &bir_data.tables[self.control_point] { + bir::ControlPointData::Terminator(TerminatorData::Return(_)) => true, + _ => false, } - - let data = &bir_data.tables[basic_block_data.terminator]; - - matches!(data, bir::TerminatorData::Return(_)) } pub fn span(&self, db: &dyn crate::Db) -> FileSpan { @@ -493,15 +480,8 @@ impl ProgramCounter { // it seems like we could create some helper functions, maybe on the // Bir type itself. - let bir_data = self.bir.data(db); - let basic_block_data = &bir_data.tables[self.basic_block]; let origins = self.bir.origins(db); - let syntax_expr = if self.statement < basic_block_data.statements.len() { - origins[basic_block_data.statements[self.statement]] - } else { - origins[basic_block_data.terminator] - }; - + let syntax_expr = origins[self.control_point]; self.bir.span_of(db, syntax_expr) } } diff --git a/components/dada-execute/src/machine/op.rs b/components/dada-execute/src/machine/op.rs index fd34b37b..adce1d50 100644 --- a/components/dada-execute/src/machine/op.rs +++ b/components/dada-execute/src/machine/op.rs @@ -106,8 +106,7 @@ impl MachineOp for Machine { self.stack.frames.push(Frame { pc: ProgramCounter { bir, - basic_block: bir_data.start_basic_block, - statement: 0, + control_point: bir_data.start_point, }, locals, expected_return_ty, diff --git a/components/dada-execute/src/step.rs b/components/dada-execute/src/step.rs index b9e812c1..d5d0291a 100644 --- a/components/dada-execute/src/step.rs +++ b/components/dada-execute/src/step.rs @@ -2,7 +2,7 @@ use dada_id::prelude::*; use dada_ir::{ class::Class, code::{ - bir::{self, TerminatorData, TerminatorExpr}, + bir::{self, ControlPoint, ControlPointData, TerminatorData, TerminatorExpr}, syntax, }, error, @@ -97,15 +97,6 @@ impl<'me> Stepper<'me> { let bir_data = pc.bir.data(self.db); let table = &bir_data.tables; - let basic_block_data = pc.basic_block.data(table); - - // The statement should either be the index of a statement or - // the terminator. - assert!( - pc.statement <= basic_block_data.statements.len(), - "statement index out of range" - ); - let pc_span = pc.span(self.db); let snippet = pc_span.snippet(self.db); if snippet.len() > 50 { @@ -118,27 +109,30 @@ impl<'me> Stepper<'me> { tracing::debug!("executing {:?}", snippet); } - if pc.statement < basic_block_data.statements.len() { - self.step_statement(table, pc.bir, basic_block_data.statements[pc.statement])?; - pc.statement += 1; - self.machine.set_pc(pc); - self.gc(&[]); - self.assert_invariants()?; - return Ok(ControlFlow::Next); - } + match &table[pc.control_point] { + bir::ControlPointData::Statement(statement_data) => { + pc = pc.move_to(self.step_statement(table, pc, statement_data)?); + self.machine.set_pc(pc); + self.gc(&[]); + self.assert_invariants()?; + return Ok(ControlFlow::Next); + } - let cf = self.step_terminator(table, pc, basic_block_data.terminator)?; - let temp; - self.gc(match &cf { - ControlFlow::Next => &[], - ControlFlow::Await(v) => &v.arguments[..], - ControlFlow::Done(_, v) => { - temp = [*v]; - &temp + bir::ControlPointData::Terminator(terminator_data) => { + let cf = self.step_terminator(table, pc, terminator_data)?; + let temp; + self.gc(match &cf { + ControlFlow::Next => &[], + ControlFlow::Await(v) => &v.arguments[..], + ControlFlow::Done(_, v) => { + temp = [*v]; + &temp + } + }); + self.assert_invariants()?; + Ok(cf) } - }); - self.assert_invariants()?; - Ok(cf) + } } /// After a `ControlFlow::Await` is returned, the caller is responsible for @@ -168,15 +162,18 @@ impl<'me> Stepper<'me> { fn step_statement( &mut self, table: &bir::Tables, - bir: bir::Bir, - statement: bir::Statement, - ) -> eyre::Result<()> { + pc: ProgramCounter, + statement_data: &bir::StatementData, + ) -> eyre::Result { + let ProgramCounter { bir, control_point } = pc; + tracing::debug!( - "statement = {:?}", - statement.data(table).debug(&bir.in_ir_db(self.db)) + "statement @ {:?} = {:?}", + control_point, + statement_data.debug(&bir.in_ir_db(self.db)) ); - match &statement.data(table).action { + match &statement_data.action { bir::ActionData::Noop => { // nothing happens! } @@ -220,7 +217,7 @@ impl<'me> Stepper<'me> { } } - Ok(()) + Ok(statement_data.next) } fn peek_place(&mut self, table: &bir::Tables, place: bir::Place) -> Option { @@ -273,28 +270,27 @@ impl<'me> Stepper<'me> { &mut self, table: &bir::Tables, pc: ProgramCounter, - terminator: bir::Terminator, + terminator_data: &bir::TerminatorData, ) -> eyre::Result { tracing::debug!( - "terminator = {:?}", - terminator.data(table).debug(&pc.bir.in_ir_db(self.db)) + "terminator at {:?} is {:?}", + pc.control_point, + terminator_data.debug(&pc.bir.in_ir_db(self.db)) ); - let terminator_data: &bir::TerminatorData = &table[terminator]; - match terminator_data { // FIXME: implement atomics TerminatorData::StartAtomic(b) | TerminatorData::EndAtomic(b) | TerminatorData::Goto(b) => { - self.machine.set_pc(pc.move_to_block(*b)); + self.machine.set_pc(pc.move_to(*b)); Ok(ControlFlow::Next) } TerminatorData::If(place, if_true, if_false) => { if self.eval_place_to_bool(table, *place)? { - self.machine.set_pc(pc.move_to_block(*if_true)); + self.machine.set_pc(pc.move_to(*if_true)); } else { - self.machine.set_pc(pc.move_to_block(*if_false)); + self.machine.set_pc(pc.move_to(*if_false)); } Ok(ControlFlow::Next) } @@ -307,10 +303,10 @@ impl<'me> Stepper<'me> { labels, }, next_block, - ) => match self.call(table, terminator, *function, arguments, labels)? { + ) => match self.call(table, pc, *function, arguments, labels)? { call::CallResult::Returned(return_value) => { self.assign_value_to_place(table, *destination, return_value)?; - self.machine.set_pc(pc.move_to_block(*next_block)); + self.machine.set_pc(pc.move_to(*next_block)); Ok(ControlFlow::Next) } call::CallResult::PushedNewFrame => Ok(ControlFlow::Next), @@ -359,11 +355,11 @@ impl<'me> Stepper<'me> { } } TerminatorData::Error => { - let span = self.span_from_bir(terminator); + let span = self.span_from_bir(pc.control_point); Err(error!(span, "compilation error encountered 😢").eyre(self.db)) } TerminatorData::Panic => { - let span = self.span_from_bir(terminator); + let span = self.span_from_bir(pc.control_point); Err(error!(span, "panic! omg! 😱").eyre(self.db)) } } @@ -387,15 +383,8 @@ impl<'me> Stepper<'me> { // Otherwise, this function was invoked from `top`. We have to store the return // value into the location where `top` expects it. let top_table = &top.pc.bir.data(self.db).tables; - let top_basic_block_data = &top_table[top.pc.basic_block]; - assert_eq!( - top.pc.statement, - top_basic_block_data.statements.len(), - "calling frame should be at a terminator" - ); - - let TerminatorData::Assign(top_place, _, top_basic_block) = - &top_table[top_basic_block_data.terminator] + let ControlPointData::Terminator(TerminatorData::Assign(top_place, _, top_basic_block)) = + &top_table[top.pc.control_point] else { unreachable!("calling frame should be at an assign terminator") }; @@ -410,7 +399,7 @@ impl<'me> Stepper<'me> { )); } - let new_pc = top.pc.move_to_block(*top_basic_block); + let new_pc = top.pc.move_to(*top_basic_block); self.assign_value_to_place(top_table, *top_place, value)?; self.machine.set_pc(new_pc); Ok(()) diff --git a/components/dada-execute/src/step/call.rs b/components/dada-execute/src/step/call.rs index 6436d15d..41cb0b66 100644 --- a/components/dada-execute/src/step/call.rs +++ b/components/dada-execute/src/step/call.rs @@ -1,16 +1,10 @@ use dada_brew::prelude::*; -use dada_ir::{ - code::{bir, syntax}, - error, - origin_table::HasOriginIn, - signature::InputTy, - word::Word, -}; +use dada_ir::{code::bir, error, signature::InputTy, word::Word}; use dada_validate::prelude::*; use crate::{ error::DiagnosticBuilderExt, - machine::{op::MachineOpExtMut, Instance, ObjectData, ThunkFn, Value}, + machine::{op::MachineOpExtMut, Instance, ObjectData, ProgramCounter, ThunkFn, Value}, step::intrinsic::IntrinsicDefinition, }; @@ -25,7 +19,7 @@ impl Stepper<'_> { pub(super) fn call( &mut self, table: &bir::Tables, - terminator: bir::Terminator, + pc: ProgramCounter, callee: bir::Place, argument_places: &[bir::Place], labels: &[Option], @@ -40,7 +34,7 @@ impl Stepper<'_> { match &self.machine[function_value.object] { &ObjectData::Class(c) => { let signature = c.signature(self.db); - self.match_labels(table, terminator, labels, &signature.inputs)?; + self.match_labels(table, pc, labels, &signature.inputs)?; let arguments = self.give_arguments(table, argument_places)?; self.check_signature(&arguments, signature)?; let instance = Instance { @@ -53,7 +47,7 @@ impl Stepper<'_> { } &ObjectData::Function(function) => { let signature = function.signature(self.db); - self.match_labels(table, terminator, labels, &signature.inputs)?; + self.match_labels(table, pc, labels, &signature.inputs)?; let arguments = self.give_arguments(table, argument_places)?; @@ -82,7 +76,7 @@ impl Stepper<'_> { } &ObjectData::Intrinsic(intrinsic) => { let definition = IntrinsicDefinition::for_intrinsic(self.db, intrinsic); - self.match_labels(table, callee, labels, &definition.argument_names)?; + self.match_labels(table, pc, labels, &definition.argument_names)?; let arguments = self.give_arguments(table, argument_places)?; let value = (definition.function)(self, arguments)?; Ok(CallResult::Returned(value)) @@ -113,7 +107,7 @@ impl Stepper<'_> { fn match_labels( &self, table: &bir::Tables, - call_terminator: impl HasOriginIn, + pc: ProgramCounter, actual_labels: &[Option], expected_names: &[impl ExpectedName], ) -> eyre::Result<()> { @@ -137,7 +131,7 @@ impl Stepper<'_> { if actual_labels.len() != expected_names.len() { return Err(error!( - self.span_from_bir(call_terminator), + self.span_from_bir(pc.control_point), "expected to find {} arguments, but found {}", expected_names.len(), actual_labels.len(), diff --git a/components/dada-id/src/lib.rs b/components/dada-id/src/lib.rs index 8e5baede..70f0b9fe 100644 --- a/components/dada-id/src/lib.rs +++ b/components/dada-id/src/lib.rs @@ -34,7 +34,8 @@ pub mod table_types { /// Declares a struct usable as an id within a table. #[macro_export] macro_rules! id { - ($v:vis struct $n:ident) => { + ($(#[$a:meta])* $v:vis struct $n:ident) => { + $(#[$a])* #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] $v struct $n(salsa::Id); diff --git a/components/dada-ir/src/code/bir.rs b/components/dada-ir/src/code/bir.rs index a4ffbe5f..2e7aeaff 100644 --- a/components/dada-ir/src/code/bir.rs +++ b/components/dada-ir/src/code/bir.rs @@ -1,6 +1,8 @@ //! The "bir" (pronounced "beer") is the "base ir" that we use //! for interpretation. +use std::collections::BTreeSet; + use crate::{ class::Class, code::validated::op::Op, @@ -30,7 +32,7 @@ pub struct Bir { /// Syntax tree from which this Bir was created. syntax_tree: syntax::Tree, - /// The BIR data + /// The BIR bir #[return_ref] data: BirData, @@ -83,20 +85,17 @@ pub struct BirData { /// First N local variables are the parameters. pub num_parameters: usize, - /// The starting block - pub start_basic_block: BasicBlock, + /// The starting point in the control flow + pub start_point: ControlPoint, } impl DebugWithDb> for BirData { fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Bir>) -> std::fmt::Result { let mut dbg = f.debug_struct("bir::Bir"); - dbg.field("start_basic_block", &self.start_basic_block); + dbg.field("start_point", &self.start_point); - for basic_block in self.all_basic_blocks() { - dbg.field( - &format!("{basic_block:?}"), - &basic_block.data(db.tables()).debug(db), - ); + for cp in self.control_points() { + dbg.field(&format!("{cp:?}"), &cp.data(&self.tables).debug(db)); } dbg.finish() @@ -104,11 +103,11 @@ impl DebugWithDb> for BirData { } impl BirData { - pub fn new(tables: Tables, num_parameters: usize, start_basic_block: BasicBlock) -> Self { + pub fn new(tables: Tables, num_parameters: usize, start_point: ControlPoint) -> Self { Self { tables, num_parameters, - start_basic_block, + start_point, } } @@ -128,24 +127,27 @@ impl BirData { LocalVariable::max_key(&self.tables) } - pub fn max_basic_block(&self) -> BasicBlock { - BasicBlock::max_key(&self.tables) - } + pub fn control_points(&self) -> BTreeSet { + let mut points = BTreeSet::new(); + let mut stack = vec![self.start_point]; - pub fn all_basic_blocks(&self) -> impl Iterator { - self.max_basic_block().iter() + while let Some(p) = stack.pop() { + if points.insert(p) { + stack.extend(p.successors(self)); + } + } + + points } } tables! { - /// Tables that store the data for expr in the AST. - /// You can use `tables[expr]` (etc) to access the data. + /// Tables that store the bir for expr in the AST. + /// You can use `tables[expr]` (etc) to access the bir. #[derive(Clone, Debug, PartialEq, Eq)] pub struct Tables { local_variables: alloc LocalVariable => LocalVariableData, - basic_blocks: alloc BasicBlock => BasicBlockData, - statements: alloc Statement => StatementData, - terminators: alloc Terminator => TerminatorData, + control_points: alloc ControlPoint => ControlPointData, exprs: alloc Expr => ExprData, places: alloc Place => PlaceData, target_places: alloc TargetPlace => TargetPlaceData, @@ -162,9 +164,7 @@ origin_table! { #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] pub struct Origins { local_variables: LocalVariable => validated::LocalVariableOrigin, - basic_blocks: BasicBlock => syntax::Expr, - statements: Statement => syntax::Expr, - terminator: Terminator => syntax::Expr, + control_points: ControlPoint => syntax::Expr, expr: Expr => syntax::Expr, place: Place => syntax::Expr, target_place: TargetPlace => syntax::Expr, @@ -172,98 +172,85 @@ origin_table! { } } -id!(pub struct LocalVariable); +id!( + /// A *control point* is a point in the control-flow graph; + /// it can be either a [`Statement`][] (which has a single successor) + /// or a [`Terminator`][] (which has a custom set of successors). + pub struct ControlPoint +); -impl DebugWithDb> for LocalVariable { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Bir>) -> std::fmt::Result { - let id = u32::from(*self); - let data = self.data(db.tables()); - let name = data.name.map(|n| n.as_str(db.db())).unwrap_or("temp"); - write!(f, "{name}{{{id}}}") +impl DebugWithDb> for ControlPoint { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>, _db: &InIrDb<'_, Bir>) -> std::fmt::Result { + write!(f, "ControlPoint({})", u32::from(*self)) } } -#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Hash, Debug)] -pub struct LocalVariableData { - /// Name given to this variable by the user. - /// If it is None, then this is a temporary - /// introduced by the compiler. - pub name: Option, - - pub atomic: Atomic, -} - -id!(pub struct BasicBlock); - -impl DebugWithDb for BasicBlock { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>, _db: &Db) -> std::fmt::Result { - std::fmt::Debug::fmt(self, f) +impl ControlPoint { + pub fn successors(&self, bir_data: &BirData) -> Vec { + match self.data(&bir_data.tables) { + ControlPointData::Statement(s) => vec![s.next], + ControlPointData::Terminator(t) => t.successors(), + } } } #[derive(PartialEq, Eq, Clone, Hash, Debug)] -pub struct BasicBlockData { - pub statements: Vec, - pub terminator: Terminator, +pub enum ControlPointData { + Statement(StatementData), + Terminator(TerminatorData), } -impl BasicBlockData { - /// Number of "elements" in this block, including the terminator. - pub fn elements(&self) -> usize { - self.statements.len() + 1 - } - - /// Get a particular "element" in this block (either a statement or a terminator). - pub fn element_at(&self, index: usize) -> BasicBlockElement { - if index < self.statements.len() { - BasicBlockElement::Statement(self.statements[index]) - } else { - BasicBlockElement::Terminator(self.terminator) +impl DebugWithDb> for ControlPointData { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Bir>) -> std::fmt::Result { + match self { + ControlPointData::Statement(s) => s.fmt(f, db), + ControlPointData::Terminator(t) => t.fmt(f, db), } } } -impl DebugWithDb> for BasicBlockData { +id!(pub struct LocalVariable); + +impl DebugWithDb> for LocalVariable { fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Bir>) -> std::fmt::Result { - f.debug_tuple("BasicBlockData") - .field(&self.statements.debug(db)) - .field(&self.terminator.debug(db)) - .finish() + let id = u32::from(*self); + let bir = self.data(db.tables()); + let name = bir.name.map(|n| n.as_str(db.db())).unwrap_or("temp"); + write!(f, "{name}{{{id}}}") } } -/// An "element" of a basic block is a statement or terminator. -/// -/// (In case you are curious, I made this term up, it's not standard.) -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum BasicBlockElement { - Statement(Statement), - Terminator(Terminator), -} - -id!(pub struct Statement); +#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Hash, Debug)] +pub struct LocalVariableData { + /// Name given to this variable by the user. + /// If it is None, then this is a temporary + /// introduced by the compiler. + pub name: Option, -impl DebugWithDb> for Statement { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Bir>) -> std::fmt::Result { - let origin = self.origin_in(db.origins(db.db())); - let result = f - .debug_tuple("") - .field(&self.data(db.tables()).debug(db)) - .field(&origin) - .finish(); - result - } + pub atomic: Atomic, } +/// A *statement* is a node in the control-flow graph that performs an action +/// and which always has exactly 1 successor; statements can either start basic blocks +/// or be in the mid-points. #[derive(PartialEq, Eq, Clone, Hash, Debug)] pub struct StatementData { + /// The action to be performed at this statement. pub action: ActionData, + + /// Next point in the control flow. During the "brewing" process, + /// this is initially set to a "dummy" terminator which is later overwritten + /// with the next statemenr or terminator. + pub next: ControlPoint, } impl DebugWithDb> for StatementData { fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Bir>) -> std::fmt::Result { - let StatementData { action } = self; - action.fmt(f, db) + let StatementData { action, next } = self; + f.debug_tuple("Statement") + .field(&action.debug(db)) + .field(&next.debug(db)) + .finish() } } @@ -338,26 +325,33 @@ impl DebugWithDb> for ActionData { } } -id!(pub struct Terminator); - -impl DebugWithDb> for Terminator { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Bir>) -> std::fmt::Result { - DebugWithDb::fmt(self.data(db.tables()), f, db) - } -} - #[derive(PartialEq, Eq, Clone, Hash, Debug)] pub enum TerminatorData { - Goto(BasicBlock), - If(Place, BasicBlock, BasicBlock), - StartAtomic(BasicBlock), - EndAtomic(BasicBlock), + Goto(ControlPoint), + If(Place, ControlPoint, ControlPoint), + StartAtomic(ControlPoint), + EndAtomic(ControlPoint), Return(Place), - Assign(TargetPlace, TerminatorExpr, BasicBlock), + Assign(TargetPlace, TerminatorExpr, ControlPoint), Error, Panic, } +impl TerminatorData { + pub fn successors(&self) -> Vec { + match *self { + TerminatorData::Goto(c) => vec![c], + TerminatorData::If(_, a, b) => vec![a, b], + TerminatorData::StartAtomic(a) => vec![a], + TerminatorData::EndAtomic(a) => vec![a], + TerminatorData::Return(_) => vec![], + TerminatorData::Assign(_, _, a) => vec![a], + TerminatorData::Error => vec![], + TerminatorData::Panic => vec![], + } + } +} + impl DebugWithDb> for TerminatorData { fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Bir>) -> std::fmt::Result { match self { diff --git a/dada_tests/heap-graph/cursor-position/HeapGraph-0.bir.ref b/dada_tests/heap-graph/cursor-position/HeapGraph-0.bir.ref index 72bf9edc..10b9b5c2 100644 --- a/dada_tests/heap-graph/cursor-position/HeapGraph-0.bir.ref +++ b/dada_tests/heap-graph/cursor-position/HeapGraph-0.bir.ref @@ -1,262 +1,262 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{4}, - Class(Id { value: 1 }).share, - ), - Expr(0), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{4}, + Class(Id { value: 1 }).share, + ), + ControlPoint(3), + ), + ControlPoint(3): Statement( + AssignExpr( + temp{5}, + 22, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{6}, + 44, + ), + ControlPoint(6), + ), + ControlPoint(5): Statement( + Noop, + ControlPoint(7), + ), + ControlPoint(6): Assign( + temp{3}, + Call( + temp{4}, + [ + temp{5}, + temp{6}, + ], + [ + None, + None, + ], + ), + ControlPoint(5), + ), + ControlPoint(7): Statement( + Clear( + temp{6}, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + Clear( + temp{5}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{4}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/cursor-position.dada", ), - ( - AssignExpr( - temp{5}, - 22, - ), - Expr(1), + 0, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + AssignExpr( + p{0}, + temp{3}.share, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/cursor-position.dada", ), - ( - AssignExpr( - temp{6}, - 44, - ), - Expr(2), + 0, + Expr(4), + Some( + p{0}, ), - ], - Assign( + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + Clear( temp{3}, - Call( - temp{4}, - [ - temp{5}, - temp{6}, - ], - [ - None, - None, - ], - ), - BasicBlock(1), ), + ControlPoint(14), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{6}, - ), - Expr(2), - ), - ( - Clear( - temp{5}, - ), - Expr(1), - ), - ( - Clear( - temp{4}, - ), - Expr(0), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/cursor-position.dada", - ), - 0, - ), - Expr(4), - ), - ( - AssignExpr( - p{0}, - temp{3}.share, - ), - Expr(4), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/cursor-position.dada", - ), - 0, - Expr(4), - Some( - p{0}, - ), - ), - Expr(4), - ), - ( - Clear( - temp{3}, - ), - Expr(3), - ), - ( - AssignExpr( - temp{8}, - Class(Id { value: 1 }).share, - ), - Expr(6), - ), - ( - AssignExpr( - temp{9}, - p{0}.share, - ), - Expr(7), - ), - ( - AssignExpr( - temp{10}, - 66, - ), - Expr(8), - ), - ], - Assign( + ControlPoint(14): Statement( + AssignExpr( + temp{8}, + Class(Id { value: 1 }).share, + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + AssignExpr( + temp{9}, + p{0}.share, + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + AssignExpr( + temp{10}, + 66, + ), + ControlPoint(18), + ), + ControlPoint(17): Statement( + Noop, + ControlPoint(19), + ), + ControlPoint(18): Assign( + temp{7}, + Call( + temp{8}, + [ + temp{9}, + temp{10}, + ], + [ + None, + None, + ], + ), + ControlPoint(17), + ), + ControlPoint(19): Statement( + Clear( + temp{10}, + ), + ControlPoint(20), + ), + ControlPoint(20): Statement( + Clear( + temp{9}, + ), + ControlPoint(21), + ), + ControlPoint(21): Statement( + Clear( + temp{8}, + ), + ControlPoint(22), + ), + ControlPoint(22): Statement( + AssignExpr( + q{1}, + temp{7}.share, + ), + ControlPoint(23), + ), + ControlPoint(23): Statement( + Clear( temp{7}, - Call( - temp{8}, - [ - temp{9}, - temp{10}, - ], - [ - None, - None, - ], - ), - BasicBlock(2), ), + ControlPoint(24), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{10}, - ), - Expr(8), - ), - ( - Clear( - temp{9}, - ), - Expr(7), - ), - ( - Clear( - temp{8}, - ), - Expr(6), - ), - ( - AssignExpr( - q{1}, - temp{7}.share, - ), - Expr(10), - ), - ( - Clear( - temp{7}, - ), - Expr(9), - ), - ( - AssignExpr( - temp{13}, - Print.share, - ), - Expr(12), - ), - ( - AssignExpr( - temp{15}, - "Hi", - ), - Expr(13), - ), - ( - AssignExpr( - temp{14}, - Concatenate(temp{15}), - ), - Expr(14), - ), - ( - Clear( - temp{15}, - ), - Expr(13), - ), - ], - Assign( + ControlPoint(24): Statement( + AssignExpr( + temp{13}, + Print.share, + ), + ControlPoint(25), + ), + ControlPoint(25): Statement( + AssignExpr( + temp{15}, + "Hi", + ), + ControlPoint(26), + ), + ControlPoint(26): Statement( + AssignExpr( + temp{14}, + Concatenate(temp{15}), + ), + ControlPoint(27), + ), + ControlPoint(27): Statement( + Clear( + temp{15}, + ), + ControlPoint(29), + ), + ControlPoint(28): Statement( + Noop, + ControlPoint(30), + ), + ControlPoint(29): Assign( + temp{12}, + Call( + temp{13}, + [ + temp{14}, + ], + [ + None, + ], + ), + ControlPoint(28), + ), + ControlPoint(30): Statement( + Clear( + temp{14}, + ), + ControlPoint(31), + ), + ControlPoint(31): Statement( + Clear( + temp{13}, + ), + ControlPoint(33), + ), + ControlPoint(32): Statement( + Noop, + ControlPoint(34), + ), + ControlPoint(33): Assign( + temp{11}, + Await( temp{12}, - Call( - temp{13}, - [ - temp{14}, - ], - [ - None, - ], - ), - BasicBlock(3), ), + ControlPoint(32), ), - BasicBlock(3): BasicBlockData( - [ - ( - Clear( - temp{14}, - ), - Expr(14), - ), - ( - Clear( - temp{13}, - ), - Expr(12), - ), - ], - Assign( + ControlPoint(34): Statement( + Clear( + temp{12}, + ), + ControlPoint(35), + ), + ControlPoint(35): Statement( + Clear( temp{11}, - Await( - temp{12}, - ), - BasicBlock(4), ), + ControlPoint(36), ), - BasicBlock(4): BasicBlockData( - [ - ( - Clear( - temp{12}, - ), - Expr(15), - ), - ( - Clear( - temp{11}, - ), - Expr(16), - ), - ( - AssignExpr( - temp{2}, - (), - ), - Expr(17), - ), - ], - Return( + ControlPoint(36): Statement( + AssignExpr( temp{2}, + (), ), + ControlPoint(37), + ), + ControlPoint(37): Return( + temp{2}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/cursor-position/HeapGraph-1.bir.ref b/dada_tests/heap-graph/cursor-position/HeapGraph-1.bir.ref index 68e59f8b..19d023a3 100644 --- a/dada_tests/heap-graph/cursor-position/HeapGraph-1.bir.ref +++ b/dada_tests/heap-graph/cursor-position/HeapGraph-1.bir.ref @@ -1,284 +1,284 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{4}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{5}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{6}, - 44, - ), - Expr(2), - ), - ], - Assign( + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{4}, + Class(Id { value: 1 }).share, + ), + ControlPoint(3), + ), + ControlPoint(3): Statement( + AssignExpr( + temp{5}, + 22, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{6}, + 44, + ), + ControlPoint(6), + ), + ControlPoint(5): Statement( + Noop, + ControlPoint(7), + ), + ControlPoint(6): Assign( + temp{3}, + Call( + temp{4}, + [ + temp{5}, + temp{6}, + ], + [ + None, + None, + ], + ), + ControlPoint(5), + ), + ControlPoint(7): Statement( + Clear( + temp{6}, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + Clear( + temp{5}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{4}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + AssignExpr( + p{0}, + temp{3}.share, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + Clear( temp{3}, - Call( - temp{4}, - [ - temp{5}, - temp{6}, - ], - [ - None, - None, - ], - ), - BasicBlock(1), ), + ControlPoint(12), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{6}, - ), - Expr(2), - ), - ( - Clear( - temp{5}, - ), - Expr(1), - ), - ( - Clear( - temp{4}, - ), - Expr(0), - ), - ( - AssignExpr( - p{0}, - temp{3}.share, - ), - Expr(4), - ), - ( - Clear( - temp{3}, - ), - Expr(3), - ), - ( - AssignExpr( - temp{8}, - Class(Id { value: 1 }).share, - ), - Expr(6), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/cursor-position.dada", - ), - 0, - ), - Expr(7), + ControlPoint(12): Statement( + AssignExpr( + temp{8}, + Class(Id { value: 1 }).share, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/cursor-position.dada", ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/cursor-position.dada", - ), - 0, - ), - Expr(7), + 0, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/cursor-position.dada", ), - ( - AssignExpr( - temp{9}, - p{0}.share, - ), - Expr(7), + 0, + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + AssignExpr( + temp{9}, + p{0}.share, + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/cursor-position.dada", ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/cursor-position.dada", - ), - 0, - Expr(7), - Some( - temp{9}, - ), - ), - Expr(7), + 0, + Expr(7), + Some( + temp{9}, ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/cursor-position.dada", - ), - 0, - Expr(7), - Some( - temp{9}, - ), - ), - Expr(7), + ), + ControlPoint(17), + ), + ControlPoint(17): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/cursor-position.dada", ), - ( - AssignExpr( - temp{10}, - 66, - ), - Expr(8), + 0, + Expr(7), + Some( + temp{9}, ), - ], - Assign( + ), + ControlPoint(18), + ), + ControlPoint(18): Statement( + AssignExpr( + temp{10}, + 66, + ), + ControlPoint(20), + ), + ControlPoint(19): Statement( + Noop, + ControlPoint(21), + ), + ControlPoint(20): Assign( + temp{7}, + Call( + temp{8}, + [ + temp{9}, + temp{10}, + ], + [ + None, + None, + ], + ), + ControlPoint(19), + ), + ControlPoint(21): Statement( + Clear( + temp{10}, + ), + ControlPoint(22), + ), + ControlPoint(22): Statement( + Clear( + temp{9}, + ), + ControlPoint(23), + ), + ControlPoint(23): Statement( + Clear( + temp{8}, + ), + ControlPoint(24), + ), + ControlPoint(24): Statement( + AssignExpr( + q{1}, + temp{7}.share, + ), + ControlPoint(25), + ), + ControlPoint(25): Statement( + Clear( temp{7}, - Call( - temp{8}, - [ - temp{9}, - temp{10}, - ], - [ - None, - None, - ], - ), - BasicBlock(2), ), + ControlPoint(26), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{10}, - ), - Expr(8), - ), - ( - Clear( - temp{9}, - ), - Expr(7), - ), - ( - Clear( - temp{8}, - ), - Expr(6), - ), - ( - AssignExpr( - q{1}, - temp{7}.share, - ), - Expr(10), - ), - ( - Clear( - temp{7}, - ), - Expr(9), - ), - ( - AssignExpr( - temp{13}, - Print.share, - ), - Expr(12), - ), - ( - AssignExpr( - temp{15}, - "Hi", - ), - Expr(13), - ), - ( - AssignExpr( - temp{14}, - Concatenate(temp{15}), - ), - Expr(14), - ), - ( - Clear( - temp{15}, - ), - Expr(13), - ), - ], - Assign( + ControlPoint(26): Statement( + AssignExpr( + temp{13}, + Print.share, + ), + ControlPoint(27), + ), + ControlPoint(27): Statement( + AssignExpr( + temp{15}, + "Hi", + ), + ControlPoint(28), + ), + ControlPoint(28): Statement( + AssignExpr( + temp{14}, + Concatenate(temp{15}), + ), + ControlPoint(29), + ), + ControlPoint(29): Statement( + Clear( + temp{15}, + ), + ControlPoint(31), + ), + ControlPoint(30): Statement( + Noop, + ControlPoint(32), + ), + ControlPoint(31): Assign( + temp{12}, + Call( + temp{13}, + [ + temp{14}, + ], + [ + None, + ], + ), + ControlPoint(30), + ), + ControlPoint(32): Statement( + Clear( + temp{14}, + ), + ControlPoint(33), + ), + ControlPoint(33): Statement( + Clear( + temp{13}, + ), + ControlPoint(35), + ), + ControlPoint(34): Statement( + Noop, + ControlPoint(36), + ), + ControlPoint(35): Assign( + temp{11}, + Await( temp{12}, - Call( - temp{13}, - [ - temp{14}, - ], - [ - None, - ], - ), - BasicBlock(3), ), + ControlPoint(34), ), - BasicBlock(3): BasicBlockData( - [ - ( - Clear( - temp{14}, - ), - Expr(14), - ), - ( - Clear( - temp{13}, - ), - Expr(12), - ), - ], - Assign( + ControlPoint(36): Statement( + Clear( + temp{12}, + ), + ControlPoint(37), + ), + ControlPoint(37): Statement( + Clear( temp{11}, - Await( - temp{12}, - ), - BasicBlock(4), ), + ControlPoint(38), ), - BasicBlock(4): BasicBlockData( - [ - ( - Clear( - temp{12}, - ), - Expr(15), - ), - ( - Clear( - temp{11}, - ), - Expr(16), - ), - ( - AssignExpr( - temp{2}, - (), - ), - Expr(17), - ), - ], - Return( + ControlPoint(38): Statement( + AssignExpr( temp{2}, + (), ), + ControlPoint(39), + ), + ControlPoint(39): Return( + temp{2}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/cursor-position/HeapGraph-2.bir.ref b/dada_tests/heap-graph/cursor-position/HeapGraph-2.bir.ref index 68e59f8b..19d023a3 100644 --- a/dada_tests/heap-graph/cursor-position/HeapGraph-2.bir.ref +++ b/dada_tests/heap-graph/cursor-position/HeapGraph-2.bir.ref @@ -1,284 +1,284 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{4}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{5}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{6}, - 44, - ), - Expr(2), - ), - ], - Assign( + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{4}, + Class(Id { value: 1 }).share, + ), + ControlPoint(3), + ), + ControlPoint(3): Statement( + AssignExpr( + temp{5}, + 22, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{6}, + 44, + ), + ControlPoint(6), + ), + ControlPoint(5): Statement( + Noop, + ControlPoint(7), + ), + ControlPoint(6): Assign( + temp{3}, + Call( + temp{4}, + [ + temp{5}, + temp{6}, + ], + [ + None, + None, + ], + ), + ControlPoint(5), + ), + ControlPoint(7): Statement( + Clear( + temp{6}, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + Clear( + temp{5}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{4}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + AssignExpr( + p{0}, + temp{3}.share, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + Clear( temp{3}, - Call( - temp{4}, - [ - temp{5}, - temp{6}, - ], - [ - None, - None, - ], - ), - BasicBlock(1), ), + ControlPoint(12), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{6}, - ), - Expr(2), - ), - ( - Clear( - temp{5}, - ), - Expr(1), - ), - ( - Clear( - temp{4}, - ), - Expr(0), - ), - ( - AssignExpr( - p{0}, - temp{3}.share, - ), - Expr(4), - ), - ( - Clear( - temp{3}, - ), - Expr(3), - ), - ( - AssignExpr( - temp{8}, - Class(Id { value: 1 }).share, - ), - Expr(6), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/cursor-position.dada", - ), - 0, - ), - Expr(7), + ControlPoint(12): Statement( + AssignExpr( + temp{8}, + Class(Id { value: 1 }).share, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/cursor-position.dada", ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/cursor-position.dada", - ), - 0, - ), - Expr(7), + 0, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/cursor-position.dada", ), - ( - AssignExpr( - temp{9}, - p{0}.share, - ), - Expr(7), + 0, + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + AssignExpr( + temp{9}, + p{0}.share, + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/cursor-position.dada", ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/cursor-position.dada", - ), - 0, - Expr(7), - Some( - temp{9}, - ), - ), - Expr(7), + 0, + Expr(7), + Some( + temp{9}, ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/cursor-position.dada", - ), - 0, - Expr(7), - Some( - temp{9}, - ), - ), - Expr(7), + ), + ControlPoint(17), + ), + ControlPoint(17): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/cursor-position.dada", ), - ( - AssignExpr( - temp{10}, - 66, - ), - Expr(8), + 0, + Expr(7), + Some( + temp{9}, ), - ], - Assign( + ), + ControlPoint(18), + ), + ControlPoint(18): Statement( + AssignExpr( + temp{10}, + 66, + ), + ControlPoint(20), + ), + ControlPoint(19): Statement( + Noop, + ControlPoint(21), + ), + ControlPoint(20): Assign( + temp{7}, + Call( + temp{8}, + [ + temp{9}, + temp{10}, + ], + [ + None, + None, + ], + ), + ControlPoint(19), + ), + ControlPoint(21): Statement( + Clear( + temp{10}, + ), + ControlPoint(22), + ), + ControlPoint(22): Statement( + Clear( + temp{9}, + ), + ControlPoint(23), + ), + ControlPoint(23): Statement( + Clear( + temp{8}, + ), + ControlPoint(24), + ), + ControlPoint(24): Statement( + AssignExpr( + q{1}, + temp{7}.share, + ), + ControlPoint(25), + ), + ControlPoint(25): Statement( + Clear( temp{7}, - Call( - temp{8}, - [ - temp{9}, - temp{10}, - ], - [ - None, - None, - ], - ), - BasicBlock(2), ), + ControlPoint(26), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{10}, - ), - Expr(8), - ), - ( - Clear( - temp{9}, - ), - Expr(7), - ), - ( - Clear( - temp{8}, - ), - Expr(6), - ), - ( - AssignExpr( - q{1}, - temp{7}.share, - ), - Expr(10), - ), - ( - Clear( - temp{7}, - ), - Expr(9), - ), - ( - AssignExpr( - temp{13}, - Print.share, - ), - Expr(12), - ), - ( - AssignExpr( - temp{15}, - "Hi", - ), - Expr(13), - ), - ( - AssignExpr( - temp{14}, - Concatenate(temp{15}), - ), - Expr(14), - ), - ( - Clear( - temp{15}, - ), - Expr(13), - ), - ], - Assign( + ControlPoint(26): Statement( + AssignExpr( + temp{13}, + Print.share, + ), + ControlPoint(27), + ), + ControlPoint(27): Statement( + AssignExpr( + temp{15}, + "Hi", + ), + ControlPoint(28), + ), + ControlPoint(28): Statement( + AssignExpr( + temp{14}, + Concatenate(temp{15}), + ), + ControlPoint(29), + ), + ControlPoint(29): Statement( + Clear( + temp{15}, + ), + ControlPoint(31), + ), + ControlPoint(30): Statement( + Noop, + ControlPoint(32), + ), + ControlPoint(31): Assign( + temp{12}, + Call( + temp{13}, + [ + temp{14}, + ], + [ + None, + ], + ), + ControlPoint(30), + ), + ControlPoint(32): Statement( + Clear( + temp{14}, + ), + ControlPoint(33), + ), + ControlPoint(33): Statement( + Clear( + temp{13}, + ), + ControlPoint(35), + ), + ControlPoint(34): Statement( + Noop, + ControlPoint(36), + ), + ControlPoint(35): Assign( + temp{11}, + Await( temp{12}, - Call( - temp{13}, - [ - temp{14}, - ], - [ - None, - ], - ), - BasicBlock(3), ), + ControlPoint(34), ), - BasicBlock(3): BasicBlockData( - [ - ( - Clear( - temp{14}, - ), - Expr(14), - ), - ( - Clear( - temp{13}, - ), - Expr(12), - ), - ], - Assign( + ControlPoint(36): Statement( + Clear( + temp{12}, + ), + ControlPoint(37), + ), + ControlPoint(37): Statement( + Clear( temp{11}, - Await( - temp{12}, - ), - BasicBlock(4), ), + ControlPoint(38), ), - BasicBlock(4): BasicBlockData( - [ - ( - Clear( - temp{12}, - ), - Expr(15), - ), - ( - Clear( - temp{11}, - ), - Expr(16), - ), - ( - AssignExpr( - temp{2}, - (), - ), - Expr(17), - ), - ], - Return( + ControlPoint(38): Statement( + AssignExpr( temp{2}, + (), ), + ControlPoint(39), + ), + ControlPoint(39): Return( + temp{2}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/cursor-position/HeapGraph-3.bir.ref b/dada_tests/heap-graph/cursor-position/HeapGraph-3.bir.ref index 68e59f8b..19d023a3 100644 --- a/dada_tests/heap-graph/cursor-position/HeapGraph-3.bir.ref +++ b/dada_tests/heap-graph/cursor-position/HeapGraph-3.bir.ref @@ -1,284 +1,284 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{4}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{5}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{6}, - 44, - ), - Expr(2), - ), - ], - Assign( + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{4}, + Class(Id { value: 1 }).share, + ), + ControlPoint(3), + ), + ControlPoint(3): Statement( + AssignExpr( + temp{5}, + 22, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{6}, + 44, + ), + ControlPoint(6), + ), + ControlPoint(5): Statement( + Noop, + ControlPoint(7), + ), + ControlPoint(6): Assign( + temp{3}, + Call( + temp{4}, + [ + temp{5}, + temp{6}, + ], + [ + None, + None, + ], + ), + ControlPoint(5), + ), + ControlPoint(7): Statement( + Clear( + temp{6}, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + Clear( + temp{5}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{4}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + AssignExpr( + p{0}, + temp{3}.share, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + Clear( temp{3}, - Call( - temp{4}, - [ - temp{5}, - temp{6}, - ], - [ - None, - None, - ], - ), - BasicBlock(1), ), + ControlPoint(12), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{6}, - ), - Expr(2), - ), - ( - Clear( - temp{5}, - ), - Expr(1), - ), - ( - Clear( - temp{4}, - ), - Expr(0), - ), - ( - AssignExpr( - p{0}, - temp{3}.share, - ), - Expr(4), - ), - ( - Clear( - temp{3}, - ), - Expr(3), - ), - ( - AssignExpr( - temp{8}, - Class(Id { value: 1 }).share, - ), - Expr(6), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/cursor-position.dada", - ), - 0, - ), - Expr(7), + ControlPoint(12): Statement( + AssignExpr( + temp{8}, + Class(Id { value: 1 }).share, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/cursor-position.dada", ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/cursor-position.dada", - ), - 0, - ), - Expr(7), + 0, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/cursor-position.dada", ), - ( - AssignExpr( - temp{9}, - p{0}.share, - ), - Expr(7), + 0, + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + AssignExpr( + temp{9}, + p{0}.share, + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/cursor-position.dada", ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/cursor-position.dada", - ), - 0, - Expr(7), - Some( - temp{9}, - ), - ), - Expr(7), + 0, + Expr(7), + Some( + temp{9}, ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/cursor-position.dada", - ), - 0, - Expr(7), - Some( - temp{9}, - ), - ), - Expr(7), + ), + ControlPoint(17), + ), + ControlPoint(17): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/cursor-position.dada", ), - ( - AssignExpr( - temp{10}, - 66, - ), - Expr(8), + 0, + Expr(7), + Some( + temp{9}, ), - ], - Assign( + ), + ControlPoint(18), + ), + ControlPoint(18): Statement( + AssignExpr( + temp{10}, + 66, + ), + ControlPoint(20), + ), + ControlPoint(19): Statement( + Noop, + ControlPoint(21), + ), + ControlPoint(20): Assign( + temp{7}, + Call( + temp{8}, + [ + temp{9}, + temp{10}, + ], + [ + None, + None, + ], + ), + ControlPoint(19), + ), + ControlPoint(21): Statement( + Clear( + temp{10}, + ), + ControlPoint(22), + ), + ControlPoint(22): Statement( + Clear( + temp{9}, + ), + ControlPoint(23), + ), + ControlPoint(23): Statement( + Clear( + temp{8}, + ), + ControlPoint(24), + ), + ControlPoint(24): Statement( + AssignExpr( + q{1}, + temp{7}.share, + ), + ControlPoint(25), + ), + ControlPoint(25): Statement( + Clear( temp{7}, - Call( - temp{8}, - [ - temp{9}, - temp{10}, - ], - [ - None, - None, - ], - ), - BasicBlock(2), ), + ControlPoint(26), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{10}, - ), - Expr(8), - ), - ( - Clear( - temp{9}, - ), - Expr(7), - ), - ( - Clear( - temp{8}, - ), - Expr(6), - ), - ( - AssignExpr( - q{1}, - temp{7}.share, - ), - Expr(10), - ), - ( - Clear( - temp{7}, - ), - Expr(9), - ), - ( - AssignExpr( - temp{13}, - Print.share, - ), - Expr(12), - ), - ( - AssignExpr( - temp{15}, - "Hi", - ), - Expr(13), - ), - ( - AssignExpr( - temp{14}, - Concatenate(temp{15}), - ), - Expr(14), - ), - ( - Clear( - temp{15}, - ), - Expr(13), - ), - ], - Assign( + ControlPoint(26): Statement( + AssignExpr( + temp{13}, + Print.share, + ), + ControlPoint(27), + ), + ControlPoint(27): Statement( + AssignExpr( + temp{15}, + "Hi", + ), + ControlPoint(28), + ), + ControlPoint(28): Statement( + AssignExpr( + temp{14}, + Concatenate(temp{15}), + ), + ControlPoint(29), + ), + ControlPoint(29): Statement( + Clear( + temp{15}, + ), + ControlPoint(31), + ), + ControlPoint(30): Statement( + Noop, + ControlPoint(32), + ), + ControlPoint(31): Assign( + temp{12}, + Call( + temp{13}, + [ + temp{14}, + ], + [ + None, + ], + ), + ControlPoint(30), + ), + ControlPoint(32): Statement( + Clear( + temp{14}, + ), + ControlPoint(33), + ), + ControlPoint(33): Statement( + Clear( + temp{13}, + ), + ControlPoint(35), + ), + ControlPoint(34): Statement( + Noop, + ControlPoint(36), + ), + ControlPoint(35): Assign( + temp{11}, + Await( temp{12}, - Call( - temp{13}, - [ - temp{14}, - ], - [ - None, - ], - ), - BasicBlock(3), ), + ControlPoint(34), ), - BasicBlock(3): BasicBlockData( - [ - ( - Clear( - temp{14}, - ), - Expr(14), - ), - ( - Clear( - temp{13}, - ), - Expr(12), - ), - ], - Assign( + ControlPoint(36): Statement( + Clear( + temp{12}, + ), + ControlPoint(37), + ), + ControlPoint(37): Statement( + Clear( temp{11}, - Await( - temp{12}, - ), - BasicBlock(4), ), + ControlPoint(38), ), - BasicBlock(4): BasicBlockData( - [ - ( - Clear( - temp{12}, - ), - Expr(15), - ), - ( - Clear( - temp{11}, - ), - Expr(16), - ), - ( - AssignExpr( - temp{2}, - (), - ), - Expr(17), - ), - ], - Return( + ControlPoint(38): Statement( + AssignExpr( temp{2}, + (), ), + ControlPoint(39), + ), + ControlPoint(39): Return( + temp{2}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/dag/HeapGraph-0.bir.ref b/dada_tests/heap-graph/dag/HeapGraph-0.bir.ref index 630321ca..52a2bbbc 100644 --- a/dada_tests/heap-graph/dag/HeapGraph-0.bir.ref +++ b/dada_tests/heap-graph/dag/HeapGraph-0.bir.ref @@ -1,192 +1,192 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{4}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{5}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{6}, - 44, - ), - Expr(2), - ), - ], - Assign( + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{4}, + Class(Id { value: 1 }).share, + ), + ControlPoint(3), + ), + ControlPoint(3): Statement( + AssignExpr( + temp{5}, + 22, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{6}, + 44, + ), + ControlPoint(6), + ), + ControlPoint(5): Statement( + Noop, + ControlPoint(7), + ), + ControlPoint(6): Assign( + temp{3}, + Call( + temp{4}, + [ + temp{5}, + temp{6}, + ], + [ + None, + None, + ], + ), + ControlPoint(5), + ), + ControlPoint(7): Statement( + Clear( + temp{6}, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + Clear( + temp{5}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{4}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + AssignExpr( + p{0}, + temp{3}.share, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + Clear( temp{3}, - Call( - temp{4}, - [ - temp{5}, - temp{6}, - ], - [ - None, - None, - ], - ), - BasicBlock(1), ), + ControlPoint(12), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{6}, - ), - Expr(2), - ), - ( - Clear( - temp{5}, - ), - Expr(1), - ), - ( - Clear( - temp{4}, - ), - Expr(0), - ), - ( - AssignExpr( - p{0}, - temp{3}.share, - ), - Expr(4), - ), - ( - Clear( - temp{3}, - ), - Expr(3), - ), - ( - AssignExpr( - temp{7}, - Class(Id { value: 1 }).share, - ), - Expr(6), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/dag.dada", - ), - 0, - ), - Expr(7), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/dag.dada", - ), - 0, - ), - Expr(7), - ), - ( - AssignExpr( - temp{8}, - p{0}.share, - ), - Expr(7), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/dag.dada", - ), - 0, - Expr(7), - Some( - temp{8}, - ), - ), - Expr(7), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/dag.dada", - ), - 0, - Expr(7), - Some( - temp{8}, - ), - ), - Expr(7), - ), - ( - AssignExpr( - temp{9}, - p{0}.share, - ), - Expr(8), + ControlPoint(12): Statement( + AssignExpr( + temp{7}, + Class(Id { value: 1 }).share, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/dag.dada", ), - ], - Assign( - q{1}, - Call( - temp{7}, - [ - temp{8}, - temp{9}, - ], - [ - None, - None, - ], + 0, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/dag.dada", ), - BasicBlock(2), + 0, + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + AssignExpr( + temp{8}, + p{0}.share, ), + ControlPoint(16), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{9}, - ), - Expr(8), + ControlPoint(16): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/dag.dada", ), - ( - Clear( - temp{8}, - ), - Expr(7), + 0, + Expr(7), + Some( + temp{8}, ), - ( - Clear( - temp{7}, - ), - Expr(6), + ), + ControlPoint(17), + ), + ControlPoint(17): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/dag.dada", ), - ( - AssignExpr( - temp{2}, - (), - ), - Expr(11), + 0, + Expr(7), + Some( + temp{8}, ), - ], - Return( + ), + ControlPoint(18), + ), + ControlPoint(18): Statement( + AssignExpr( + temp{9}, + p{0}.share, + ), + ControlPoint(20), + ), + ControlPoint(19): Statement( + Noop, + ControlPoint(21), + ), + ControlPoint(20): Assign( + q{1}, + Call( + temp{7}, + [ + temp{8}, + temp{9}, + ], + [ + None, + None, + ], + ), + ControlPoint(19), + ), + ControlPoint(21): Statement( + Clear( + temp{9}, + ), + ControlPoint(22), + ), + ControlPoint(22): Statement( + Clear( + temp{8}, + ), + ControlPoint(23), + ), + ControlPoint(23): Statement( + Clear( + temp{7}, + ), + ControlPoint(24), + ), + ControlPoint(24): Statement( + AssignExpr( temp{2}, + (), ), + ControlPoint(25), + ), + ControlPoint(25): Return( + temp{2}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/leased-point/HeapGraph-0.bir.ref b/dada_tests/heap-graph/leased-point/HeapGraph-0.bir.ref index 462d941e..f6c3e32c 100644 --- a/dada_tests/heap-graph/leased-point/HeapGraph-0.bir.ref +++ b/dada_tests/heap-graph/leased-point/HeapGraph-0.bir.ref @@ -1,157 +1,157 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{3}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{4}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{5}, - 44, - ), - Expr(2), - ), - ], - Assign( - p{0}, - Call( - temp{3}, - [ - temp{4}, - temp{5}, - ], - [ - None, - None, - ], - ), - BasicBlock(1), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{3}, + Class(Id { value: 1 }).share, ), + ControlPoint(3), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{5}, - ), - Expr(2), - ), - ( - Clear( - temp{4}, - ), - Expr(1), - ), - ( - Clear( - temp{3}, - ), - Expr(0), - ), - ( - AssignExpr( - temp{6}, - Class(Id { value: 1 }).share, - ), - Expr(5), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/leased-point.dada", - ), - 0, - ), - Expr(7), - ), - ( - AssignExpr( - temp{7}, - p{0}.lease, - ), - Expr(7), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/leased-point.dada", - ), - 0, - Expr(7), - Some( - temp{7}, - ), - ), - Expr(7), - ), - ( - AssignExpr( - temp{8}, - 66, - ), - Expr(8), - ), - ], - Assign( - q{1}, - Call( - temp{6}, - [ - temp{7}, - temp{8}, - ], - [ - None, - None, - ], - ), - BasicBlock(2), + ControlPoint(3): Statement( + AssignExpr( + temp{4}, + 22, ), + ControlPoint(4), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{8}, - ), - Expr(8), - ), - ( - Clear( - temp{7}, - ), - Expr(7), + ControlPoint(4): Statement( + AssignExpr( + temp{5}, + 44, + ), + ControlPoint(6), + ), + ControlPoint(5): Statement( + Noop, + ControlPoint(7), + ), + ControlPoint(6): Assign( + p{0}, + Call( + temp{3}, + [ + temp{4}, + temp{5}, + ], + [ + None, + None, + ], + ), + ControlPoint(5), + ), + ControlPoint(7): Statement( + Clear( + temp{5}, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + Clear( + temp{4}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{3}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + AssignExpr( + temp{6}, + Class(Id { value: 1 }).share, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/leased-point.dada", ), - ( - Clear( - temp{6}, - ), - Expr(5), + 0, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + AssignExpr( + temp{7}, + p{0}.lease, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/leased-point.dada", ), - ( - AssignExpr( - temp{2}, - (), - ), - Expr(11), + 0, + Expr(7), + Some( + temp{7}, ), - ], - Return( + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + AssignExpr( + temp{8}, + 66, + ), + ControlPoint(16), + ), + ControlPoint(15): Statement( + Noop, + ControlPoint(17), + ), + ControlPoint(16): Assign( + q{1}, + Call( + temp{6}, + [ + temp{7}, + temp{8}, + ], + [ + None, + None, + ], + ), + ControlPoint(15), + ), + ControlPoint(17): Statement( + Clear( + temp{8}, + ), + ControlPoint(18), + ), + ControlPoint(18): Statement( + Clear( + temp{7}, + ), + ControlPoint(19), + ), + ControlPoint(19): Statement( + Clear( + temp{6}, + ), + ControlPoint(20), + ), + ControlPoint(20): Statement( + AssignExpr( temp{2}, + (), ), + ControlPoint(21), + ), + ControlPoint(21): Return( + temp{2}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/line-end/HeapGraph-0.bir.ref b/dada_tests/heap-graph/line-end/HeapGraph-0.bir.ref index b684f75d..a0b5c36d 100644 --- a/dada_tests/heap-graph/line-end/HeapGraph-0.bir.ref +++ b/dada_tests/heap-graph/line-end/HeapGraph-0.bir.ref @@ -1,55 +1,55 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/line-end.dada", - ), - 0, - ), - Expr(0), - ), - ( - AssignExpr( - x{0}, - 22, - ), - Expr(0), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/line-end.dada", - ), - 0, - Expr(0), - Some( - x{0}, - ), - ), - Expr(0), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/line-end.dada", ), - ( - AssignExpr( - y{1}, - 44, - ), - Expr(2), + 0, + ), + ControlPoint(3), + ), + ControlPoint(3): Statement( + AssignExpr( + x{0}, + 22, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/line-end.dada", ), - ( - AssignExpr( - temp{2}, - (), - ), - Expr(4), + 0, + Expr(0), + Some( + x{0}, ), - ], - Return( + ), + ControlPoint(5), + ), + ControlPoint(5): Statement( + AssignExpr( + y{1}, + 44, + ), + ControlPoint(6), + ), + ControlPoint(6): Statement( + AssignExpr( temp{2}, + (), ), + ControlPoint(7), + ), + ControlPoint(7): Return( + temp{2}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/line-end/HeapGraph-1.bir.ref b/dada_tests/heap-graph/line-end/HeapGraph-1.bir.ref index f97e49f1..8802d18a 100644 --- a/dada_tests/heap-graph/line-end/HeapGraph-1.bir.ref +++ b/dada_tests/heap-graph/line-end/HeapGraph-1.bir.ref @@ -1,55 +1,55 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - x{0}, - 22, - ), - Expr(0), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/line-end.dada", - ), - 0, - ), - Expr(2), - ), - ( - AssignExpr( - y{1}, - 44, - ), - Expr(2), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + x{0}, + 22, + ), + ControlPoint(3), + ), + ControlPoint(3): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/line-end.dada", ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/line-end.dada", - ), - 0, - Expr(2), - Some( - y{1}, - ), - ), - Expr(2), + 0, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + y{1}, + 44, + ), + ControlPoint(5), + ), + ControlPoint(5): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/line-end.dada", ), - ( - AssignExpr( - temp{2}, - (), - ), - Expr(4), + 0, + Expr(2), + Some( + y{1}, ), - ], - Return( + ), + ControlPoint(6), + ), + ControlPoint(6): Statement( + AssignExpr( temp{2}, + (), ), + ControlPoint(7), + ), + ControlPoint(7): Return( + temp{2}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/line-start/HeapGraph-0.bir.ref b/dada_tests/heap-graph/line-start/HeapGraph-0.bir.ref index a80e7789..12f5341a 100644 --- a/dada_tests/heap-graph/line-start/HeapGraph-0.bir.ref +++ b/dada_tests/heap-graph/line-start/HeapGraph-0.bir.ref @@ -1,179 +1,179 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/line-start.dada", - ), - 0, - ), - Expr(0), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/line-start.dada", - ), - 0, - ), - Expr(0), - ), - ( - AssignExpr( - temp{3}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/line-start.dada", - ), - 0, - Expr(0), - Some( - temp{3}, - ), - ), - Expr(0), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/line-start.dada", - ), - 0, - Expr(0), - Some( - temp{3}, - ), - ), - Expr(0), - ), - ( - AssignExpr( - temp{4}, - 22, - ), - Expr(1), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/line-start.dada", ), - ( - AssignExpr( - temp{5}, - 44, - ), - Expr(2), + 0, + ), + ControlPoint(3), + ), + ControlPoint(3): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/line-start.dada", ), - ], - Assign( - p{0}, - Call( + 0, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{3}, + Class(Id { value: 1 }).share, + ), + ControlPoint(5), + ), + ControlPoint(5): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/line-start.dada", + ), + 0, + Expr(0), + Some( temp{3}, - [ - temp{4}, - temp{5}, - ], - [ - None, - None, - ], ), - BasicBlock(1), ), + ControlPoint(6), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{5}, - ), - Expr(2), - ), - ( - Clear( - temp{4}, - ), - Expr(1), - ), - ( - Clear( - temp{3}, - ), - Expr(0), - ), - ( - AssignExpr( - temp{6}, - Class(Id { value: 1 }).share, - ), - Expr(5), - ), - ( - AssignExpr( - temp{7}, - p{0}.share, - ), - Expr(6), - ), - ( - AssignExpr( - temp{8}, - 66, - ), - Expr(7), - ), - ], - Assign( - q{1}, - Call( - temp{6}, - [ - temp{7}, - temp{8}, - ], - [ - None, - None, - ], + ControlPoint(6): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/line-start.dada", + ), + 0, + Expr(0), + Some( + temp{3}, ), - BasicBlock(2), ), + ControlPoint(7), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{8}, - ), - Expr(7), - ), - ( - Clear( - temp{7}, - ), - Expr(6), - ), - ( - Clear( - temp{6}, - ), - Expr(5), - ), - ( - AssignExpr( - temp{2}, - (), - ), - Expr(10), - ), - ], - Return( + ControlPoint(7): Statement( + AssignExpr( + temp{4}, + 22, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + AssignExpr( + temp{5}, + 44, + ), + ControlPoint(10), + ), + ControlPoint(9): Statement( + Noop, + ControlPoint(11), + ), + ControlPoint(10): Assign( + p{0}, + Call( + temp{3}, + [ + temp{4}, + temp{5}, + ], + [ + None, + None, + ], + ), + ControlPoint(9), + ), + ControlPoint(11): Statement( + Clear( + temp{5}, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + Clear( + temp{4}, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + Clear( + temp{3}, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + AssignExpr( + temp{6}, + Class(Id { value: 1 }).share, + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + AssignExpr( + temp{7}, + p{0}.share, + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + AssignExpr( + temp{8}, + 66, + ), + ControlPoint(18), + ), + ControlPoint(17): Statement( + Noop, + ControlPoint(19), + ), + ControlPoint(18): Assign( + q{1}, + Call( + temp{6}, + [ + temp{7}, + temp{8}, + ], + [ + None, + None, + ], + ), + ControlPoint(17), + ), + ControlPoint(19): Statement( + Clear( + temp{8}, + ), + ControlPoint(20), + ), + ControlPoint(20): Statement( + Clear( + temp{7}, + ), + ControlPoint(21), + ), + ControlPoint(21): Statement( + Clear( + temp{6}, + ), + ControlPoint(22), + ), + ControlPoint(22): Statement( + AssignExpr( temp{2}, + (), ), + ControlPoint(23), + ), + ControlPoint(23): Return( + temp{2}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/line-start/HeapGraph-1.bir.ref b/dada_tests/heap-graph/line-start/HeapGraph-1.bir.ref index 13ad75a2..71916029 100644 --- a/dada_tests/heap-graph/line-start/HeapGraph-1.bir.ref +++ b/dada_tests/heap-graph/line-start/HeapGraph-1.bir.ref @@ -1,155 +1,155 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/line-start.dada", - ), - 0, - ), - Expr(4), - ), - ( - AssignExpr( - temp{3}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{4}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{5}, - 44, - ), - Expr(2), - ), - ], - Assign( - p{0}, - Call( - temp{3}, - [ - temp{4}, - temp{5}, - ], - [ - None, - None, - ], + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/line-start.dada", ), - BasicBlock(1), + 0, ), + ControlPoint(3), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{5}, - ), - Expr(2), - ), - ( - Clear( - temp{4}, - ), - Expr(1), - ), - ( - Clear( - temp{3}, - ), - Expr(0), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/line-start.dada", - ), - 0, - Expr(4), - None, - ), - Expr(4), - ), - ( - AssignExpr( - temp{6}, - Class(Id { value: 1 }).share, - ), - Expr(5), - ), - ( - AssignExpr( - temp{7}, - p{0}.share, - ), - Expr(6), - ), - ( - AssignExpr( - temp{8}, - 66, - ), - Expr(7), - ), - ], - Assign( - q{1}, - Call( - temp{6}, - [ - temp{7}, - temp{8}, - ], - [ - None, - None, - ], - ), - BasicBlock(2), + ControlPoint(3): Statement( + AssignExpr( + temp{3}, + Class(Id { value: 1 }).share, ), + ControlPoint(4), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{8}, - ), - Expr(7), - ), - ( - Clear( - temp{7}, - ), - Expr(6), - ), - ( - Clear( - temp{6}, - ), - Expr(5), - ), - ( - AssignExpr( - temp{2}, - (), - ), - Expr(10), - ), - ], - Return( + ControlPoint(4): Statement( + AssignExpr( + temp{4}, + 22, + ), + ControlPoint(5), + ), + ControlPoint(5): Statement( + AssignExpr( + temp{5}, + 44, + ), + ControlPoint(7), + ), + ControlPoint(6): Statement( + Noop, + ControlPoint(8), + ), + ControlPoint(7): Assign( + p{0}, + Call( + temp{3}, + [ + temp{4}, + temp{5}, + ], + [ + None, + None, + ], + ), + ControlPoint(6), + ), + ControlPoint(8): Statement( + Clear( + temp{5}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{4}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + Clear( + temp{3}, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/line-start.dada", + ), + 0, + Expr(4), + None, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + AssignExpr( + temp{6}, + Class(Id { value: 1 }).share, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + AssignExpr( + temp{7}, + p{0}.share, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + AssignExpr( + temp{8}, + 66, + ), + ControlPoint(16), + ), + ControlPoint(15): Statement( + Noop, + ControlPoint(17), + ), + ControlPoint(16): Assign( + q{1}, + Call( + temp{6}, + [ + temp{7}, + temp{8}, + ], + [ + None, + None, + ], + ), + ControlPoint(15), + ), + ControlPoint(17): Statement( + Clear( + temp{8}, + ), + ControlPoint(18), + ), + ControlPoint(18): Statement( + Clear( + temp{7}, + ), + ControlPoint(19), + ), + ControlPoint(19): Statement( + Clear( + temp{6}, + ), + ControlPoint(20), + ), + ControlPoint(20): Statement( + AssignExpr( temp{2}, + (), ), + ControlPoint(21), + ), + ControlPoint(21): Return( + temp{2}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/mid-increment/HeapGraph-0.bir.ref b/dada_tests/heap-graph/mid-increment/HeapGraph-0.bir.ref index 6b9b8f3e..be513877 100644 --- a/dada_tests/heap-graph/mid-increment/HeapGraph-0.bir.ref +++ b/dada_tests/heap-graph/mid-increment/HeapGraph-0.bir.ref @@ -1,223 +1,223 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{4}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{5}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{6}, - 44, - ), - Expr(2), - ), - ], - Assign( - p{0}, - Call( - temp{4}, - [ - temp{5}, - temp{6}, - ], - [ - None, - None, - ], - ), - BasicBlock(1), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{4}, + Class(Id { value: 1 }).share, ), + ControlPoint(3), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{6}, - ), - Expr(2), - ), - ( - Clear( - temp{5}, - ), - Expr(1), - ), - ( - Clear( - temp{4}, - ), - Expr(0), - ), - ( - AssignExpr( - q{1}, - p{0}.lease, - ), - Expr(6), - ), - ( - AssignExpr( - temp{8}, - q{1}.x.give, - ), - Expr(9), - ), - ( - AssignExpr( - temp{9}, - 1, - ), - Expr(10), - ), - ( - AssignExpr( - temp{2}, - temp{8} + temp{9}, - ), - Expr(11), - ), - ( - Clear( - temp{9}, - ), - Expr(10), - ), - ( - Clear( - temp{8}, - ), - Expr(9), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/mid-increment.dada", - ), - 0, - ), - Expr(9), - ), - ( - AssignExpr( - q{1}.x, - temp{2}.give, - ), - Expr(11), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/mid-increment.dada", - ), - 0, - Expr(11), - None, - ), - Expr(9), - ), - ( - AssignExpr( - temp{7}, - (), - ), - Expr(11), - ), - ( - Clear( - temp{7}, - ), - Expr(11), - ), - ( - AssignExpr( - temp{12}, - Print.share, - ), - Expr(12), - ), - ( - AssignExpr( - temp{13}, - q{1}.share, - ), - Expr(13), + ControlPoint(3): Statement( + AssignExpr( + temp{5}, + 22, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{6}, + 44, + ), + ControlPoint(6), + ), + ControlPoint(5): Statement( + Noop, + ControlPoint(7), + ), + ControlPoint(6): Assign( + p{0}, + Call( + temp{4}, + [ + temp{5}, + temp{6}, + ], + [ + None, + None, + ], + ), + ControlPoint(5), + ), + ControlPoint(7): Statement( + Clear( + temp{6}, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + Clear( + temp{5}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{4}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + AssignExpr( + q{1}, + p{0}.lease, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + AssignExpr( + temp{8}, + q{1}.x.give, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + AssignExpr( + temp{9}, + 1, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + AssignExpr( + temp{2}, + temp{8} + temp{9}, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + Clear( + temp{9}, + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + Clear( + temp{8}, + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/mid-increment.dada", ), - ], - Assign( + 0, + ), + ControlPoint(17), + ), + ControlPoint(17): Statement( + AssignExpr( + q{1}.x, + temp{2}.give, + ), + ControlPoint(18), + ), + ControlPoint(18): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/mid-increment.dada", + ), + 0, + Expr(11), + None, + ), + ControlPoint(19), + ), + ControlPoint(19): Statement( + AssignExpr( + temp{7}, + (), + ), + ControlPoint(20), + ), + ControlPoint(20): Statement( + Clear( + temp{7}, + ), + ControlPoint(21), + ), + ControlPoint(21): Statement( + AssignExpr( + temp{12}, + Print.share, + ), + ControlPoint(22), + ), + ControlPoint(22): Statement( + AssignExpr( + temp{13}, + q{1}.share, + ), + ControlPoint(24), + ), + ControlPoint(23): Statement( + Noop, + ControlPoint(25), + ), + ControlPoint(24): Assign( + temp{11}, + Call( + temp{12}, + [ + temp{13}, + ], + [ + None, + ], + ), + ControlPoint(23), + ), + ControlPoint(25): Statement( + Clear( + temp{13}, + ), + ControlPoint(26), + ), + ControlPoint(26): Statement( + Clear( + temp{12}, + ), + ControlPoint(28), + ), + ControlPoint(27): Statement( + Noop, + ControlPoint(29), + ), + ControlPoint(28): Assign( + temp{10}, + Await( temp{11}, - Call( - temp{12}, - [ - temp{13}, - ], - [ - None, - ], - ), - BasicBlock(2), ), + ControlPoint(27), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{13}, - ), - Expr(13), - ), - ( - Clear( - temp{12}, - ), - Expr(12), - ), - ], - Assign( + ControlPoint(29): Statement( + Clear( + temp{11}, + ), + ControlPoint(30), + ), + ControlPoint(30): Statement( + Clear( temp{10}, - Await( - temp{11}, - ), - BasicBlock(3), ), + ControlPoint(31), ), - BasicBlock(3): BasicBlockData( - [ - ( - Clear( - temp{11}, - ), - Expr(14), - ), - ( - Clear( - temp{10}, - ), - Expr(15), - ), - ( - AssignExpr( - temp{3}, - (), - ), - Expr(16), - ), - ], - Return( + ControlPoint(31): Statement( + AssignExpr( temp{3}, + (), ), + ControlPoint(32), + ), + ControlPoint(32): Return( + temp{3}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/nested-functions/HeapGraph-0.bir.ref b/dada_tests/heap-graph/nested-functions/HeapGraph-0.bir.ref index 535bd861..e75b448a 100644 --- a/dada_tests/heap-graph/nested-functions/HeapGraph-0.bir.ref +++ b/dada_tests/heap-graph/nested-functions/HeapGraph-0.bir.ref @@ -1,410 +1,410 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{2}, - "Fellow Dadaist", - ), - Expr(0), - ), - ( - AssignExpr( - name{0}, - Concatenate(temp{2}), - ), - Expr(1), - ), - ( - Clear( - temp{2}, - ), - Expr(0), - ), - ( - AssignExpr( - temp{5}, - helper.share, - ), - Expr(3), - ), - ], - Assign( + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{2}, + "Fellow Dadaist", + ), + ControlPoint(3), + ), + ControlPoint(3): Statement( + AssignExpr( + name{0}, + Concatenate(temp{2}), + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + Clear( + temp{2}, + ), + ControlPoint(5), + ), + ControlPoint(5): Statement( + AssignExpr( + temp{5}, + helper.share, + ), + ControlPoint(7), + ), + ControlPoint(6): Statement( + Noop, + ControlPoint(8), + ), + ControlPoint(7): Assign( + temp{4}, + Call( + temp{5}, + [], + [], + ), + ControlPoint(6), + ), + ControlPoint(8): Statement( + Clear( + temp{5}, + ), + ControlPoint(10), + ), + ControlPoint(9): Statement( + Noop, + ControlPoint(11), + ), + ControlPoint(10): Assign( + temp{3}, + Await( temp{4}, - Call( - temp{5}, - [], - [], - ), - BasicBlock(1), ), + ControlPoint(9), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{5}, - ), - Expr(3), - ), - ], - Assign( + ControlPoint(11): Statement( + Clear( + temp{4}, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + Clear( temp{3}, - Await( - temp{4}, - ), - BasicBlock(2), ), + ControlPoint(13), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{4}, - ), - Expr(4), - ), - ( - Clear( - temp{3}, - ), - Expr(5), - ), - ( - AssignExpr( - temp{8}, - Print.share, - ), - Expr(6), - ), - ( - AssignExpr( - temp{10}, - "Hello", - ), - Expr(7), - ), - ( - AssignExpr( - temp{9}, - Concatenate(temp{10}), - ), - Expr(8), - ), - ( - Clear( - temp{10}, - ), - Expr(7), - ), - ], - Assign( + ControlPoint(13): Statement( + AssignExpr( + temp{8}, + Print.share, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + AssignExpr( + temp{10}, + "Hello", + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + AssignExpr( + temp{9}, + Concatenate(temp{10}), + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + Clear( + temp{10}, + ), + ControlPoint(18), + ), + ControlPoint(17): Statement( + Noop, + ControlPoint(19), + ), + ControlPoint(18): Assign( + temp{7}, + Call( + temp{8}, + [ + temp{9}, + ], + [ + None, + ], + ), + ControlPoint(17), + ), + ControlPoint(19): Statement( + Clear( + temp{9}, + ), + ControlPoint(20), + ), + ControlPoint(20): Statement( + Clear( + temp{8}, + ), + ControlPoint(22), + ), + ControlPoint(21): Statement( + Noop, + ControlPoint(23), + ), + ControlPoint(22): Assign( + temp{6}, + Await( temp{7}, - Call( - temp{8}, - [ - temp{9}, - ], - [ - None, - ], - ), - BasicBlock(3), ), + ControlPoint(21), ), - BasicBlock(3): BasicBlockData( - [ - ( - Clear( - temp{9}, - ), - Expr(8), - ), - ( - Clear( - temp{8}, - ), - Expr(6), - ), - ], - Assign( + ControlPoint(23): Statement( + Clear( + temp{7}, + ), + ControlPoint(24), + ), + ControlPoint(24): Statement( + Clear( temp{6}, - Await( - temp{7}, - ), - BasicBlock(4), ), + ControlPoint(25), ), - BasicBlock(4): BasicBlockData( - [ - ( - Clear( - temp{7}, - ), - Expr(9), - ), - ( - Clear( - temp{6}, - ), - Expr(10), - ), - ( - AssignExpr( - temp{13}, - Print.share, - ), - Expr(11), - ), - ( - AssignExpr( - temp{14}, - name{0}.share, - ), - Expr(12), - ), - ], - Assign( + ControlPoint(25): Statement( + AssignExpr( + temp{13}, + Print.share, + ), + ControlPoint(26), + ), + ControlPoint(26): Statement( + AssignExpr( + temp{14}, + name{0}.share, + ), + ControlPoint(28), + ), + ControlPoint(27): Statement( + Noop, + ControlPoint(29), + ), + ControlPoint(28): Assign( + temp{12}, + Call( + temp{13}, + [ + temp{14}, + ], + [ + None, + ], + ), + ControlPoint(27), + ), + ControlPoint(29): Statement( + Clear( + temp{14}, + ), + ControlPoint(30), + ), + ControlPoint(30): Statement( + Clear( + temp{13}, + ), + ControlPoint(32), + ), + ControlPoint(31): Statement( + Noop, + ControlPoint(33), + ), + ControlPoint(32): Assign( + temp{11}, + Await( temp{12}, - Call( - temp{13}, - [ - temp{14}, - ], - [ - None, - ], - ), - BasicBlock(5), ), + ControlPoint(31), ), - BasicBlock(5): BasicBlockData( - [ - ( - Clear( - temp{14}, - ), - Expr(12), - ), - ( - Clear( - temp{13}, - ), - Expr(11), - ), - ], - Assign( + ControlPoint(33): Statement( + Clear( + temp{12}, + ), + ControlPoint(34), + ), + ControlPoint(34): Statement( + Clear( temp{11}, - Await( - temp{12}, - ), - BasicBlock(6), ), + ControlPoint(35), ), - BasicBlock(6): BasicBlockData( - [ - ( - Clear( - temp{12}, - ), - Expr(13), - ), - ( - Clear( - temp{11}, - ), - Expr(14), - ), - ( - AssignExpr( - temp{1}, - (), - ), - Expr(15), - ), - ], - Return( + ControlPoint(35): Statement( + AssignExpr( temp{1}, + (), ), + ControlPoint(36), + ), + ControlPoint(36): Return( + temp{1}, ), }, bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{3}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{4}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{5}, - 44, - ), - Expr(2), - ), - ], - Assign( - p{0}, - Call( - temp{3}, - [ - temp{4}, - temp{5}, - ], - [ - None, - None, - ], - ), - BasicBlock(1), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{3}, + Class(Id { value: 1 }).share, ), + ControlPoint(3), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{5}, - ), - Expr(2), - ), - ( - Clear( - temp{4}, - ), - Expr(1), - ), - ( - Clear( - temp{3}, - ), - Expr(0), - ), - ( - AssignExpr( - temp{6}, - Class(Id { value: 1 }).share, - ), - Expr(5), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/nested-functions.dada", - ), - 0, - ), - Expr(6), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/nested-functions.dada", - ), - 0, - ), - Expr(6), - ), - ( - AssignExpr( - temp{7}, - p{0}.share, - ), - Expr(6), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/nested-functions.dada", - ), - 0, - Expr(6), - Some( - temp{7}, - ), - ), - Expr(6), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/nested-functions.dada", - ), - 0, - Expr(6), - Some( - temp{7}, - ), - ), - Expr(6), - ), - ( - AssignExpr( - temp{8}, - 66, - ), - Expr(7), - ), - ], - Assign( - q{1}, - Call( - temp{6}, - [ - temp{7}, - temp{8}, - ], - [ - None, - None, - ], - ), - BasicBlock(2), + ControlPoint(3): Statement( + AssignExpr( + temp{4}, + 22, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{5}, + 44, ), + ControlPoint(6), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{8}, - ), - Expr(7), + ControlPoint(5): Statement( + Noop, + ControlPoint(7), + ), + ControlPoint(6): Assign( + p{0}, + Call( + temp{3}, + [ + temp{4}, + temp{5}, + ], + [ + None, + None, + ], + ), + ControlPoint(5), + ), + ControlPoint(7): Statement( + Clear( + temp{5}, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + Clear( + temp{4}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{3}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + AssignExpr( + temp{6}, + Class(Id { value: 1 }).share, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/nested-functions.dada", ), - ( - Clear( - temp{7}, - ), - Expr(6), + 0, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/nested-functions.dada", ), - ( - Clear( - temp{6}, - ), - Expr(5), + 0, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + AssignExpr( + temp{7}, + p{0}.share, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/nested-functions.dada", + ), + 0, + Expr(6), + Some( + temp{7}, ), - ( - AssignExpr( - temp{2}, - (), - ), - Expr(10), + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/nested-functions.dada", + ), + 0, + Expr(6), + Some( + temp{7}, ), - ], - Return( + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + AssignExpr( + temp{8}, + 66, + ), + ControlPoint(18), + ), + ControlPoint(17): Statement( + Noop, + ControlPoint(19), + ), + ControlPoint(18): Assign( + q{1}, + Call( + temp{6}, + [ + temp{7}, + temp{8}, + ], + [ + None, + None, + ], + ), + ControlPoint(17), + ), + ControlPoint(19): Statement( + Clear( + temp{8}, + ), + ControlPoint(20), + ), + ControlPoint(20): Statement( + Clear( + temp{7}, + ), + ControlPoint(21), + ), + ControlPoint(21): Statement( + Clear( + temp{6}, + ), + ControlPoint(22), + ), + ControlPoint(22): Statement( + AssignExpr( temp{2}, + (), ), + ControlPoint(23), + ), + ControlPoint(23): Return( + temp{2}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/nested-points/HeapGraph-0.bir.ref b/dada_tests/heap-graph/nested-points/HeapGraph-0.bir.ref index e9414f04..cfb4509b 100644 --- a/dada_tests/heap-graph/nested-points/HeapGraph-0.bir.ref +++ b/dada_tests/heap-graph/nested-points/HeapGraph-0.bir.ref @@ -1,157 +1,157 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{3}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/nested-points.dada", - ), - 0, - ), - Expr(1), - ), - ( - AssignExpr( - temp{4}, - 22, - ), - Expr(1), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/nested-points.dada", - ), - 0, - Expr(1), - Some( - temp{4}, - ), - ), - Expr(1), - ), - ( - AssignExpr( - temp{5}, - 44, - ), - Expr(2), - ), - ], - Assign( - p{0}, - Call( - temp{3}, - [ - temp{4}, - temp{5}, - ], - [ - None, - None, - ], - ), - BasicBlock(1), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{3}, + Class(Id { value: 1 }).share, ), + ControlPoint(3), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{5}, - ), - Expr(2), - ), - ( - Clear( - temp{4}, - ), - Expr(1), - ), - ( - Clear( - temp{3}, - ), - Expr(0), - ), - ( - AssignExpr( - temp{6}, - Class(Id { value: 1 }).share, - ), - Expr(5), - ), - ( - AssignExpr( - temp{7}, - p{0}.share, - ), - Expr(6), - ), - ( - AssignExpr( - temp{8}, - 66, - ), - Expr(7), + ControlPoint(3): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/nested-points.dada", ), - ], - Assign( - q{1}, - Call( - temp{6}, - [ - temp{7}, - temp{8}, - ], - [ - None, - None, - ], - ), - BasicBlock(2), + 0, ), + ControlPoint(4), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{8}, - ), - Expr(7), - ), - ( - Clear( - temp{7}, - ), - Expr(6), - ), - ( - Clear( - temp{6}, - ), - Expr(5), + ControlPoint(4): Statement( + AssignExpr( + temp{4}, + 22, + ), + ControlPoint(5), + ), + ControlPoint(5): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/nested-points.dada", ), - ( - AssignExpr( - temp{2}, - (), - ), - Expr(10), + 0, + Expr(1), + Some( + temp{4}, ), - ], - Return( + ), + ControlPoint(6), + ), + ControlPoint(6): Statement( + AssignExpr( + temp{5}, + 44, + ), + ControlPoint(8), + ), + ControlPoint(7): Statement( + Noop, + ControlPoint(9), + ), + ControlPoint(8): Assign( + p{0}, + Call( + temp{3}, + [ + temp{4}, + temp{5}, + ], + [ + None, + None, + ], + ), + ControlPoint(7), + ), + ControlPoint(9): Statement( + Clear( + temp{5}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + Clear( + temp{4}, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + Clear( + temp{3}, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + AssignExpr( + temp{6}, + Class(Id { value: 1 }).share, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + AssignExpr( + temp{7}, + p{0}.share, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + AssignExpr( + temp{8}, + 66, + ), + ControlPoint(16), + ), + ControlPoint(15): Statement( + Noop, + ControlPoint(17), + ), + ControlPoint(16): Assign( + q{1}, + Call( + temp{6}, + [ + temp{7}, + temp{8}, + ], + [ + None, + None, + ], + ), + ControlPoint(15), + ), + ControlPoint(17): Statement( + Clear( + temp{8}, + ), + ControlPoint(18), + ), + ControlPoint(18): Statement( + Clear( + temp{7}, + ), + ControlPoint(19), + ), + ControlPoint(19): Statement( + Clear( + temp{6}, + ), + ControlPoint(20), + ), + ControlPoint(20): Statement( + AssignExpr( temp{2}, + (), ), + ControlPoint(21), + ), + ControlPoint(21): Return( + temp{2}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/nested-points/HeapGraph-1.bir.ref b/dada_tests/heap-graph/nested-points/HeapGraph-1.bir.ref index e9414f04..cfb4509b 100644 --- a/dada_tests/heap-graph/nested-points/HeapGraph-1.bir.ref +++ b/dada_tests/heap-graph/nested-points/HeapGraph-1.bir.ref @@ -1,157 +1,157 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{3}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/nested-points.dada", - ), - 0, - ), - Expr(1), - ), - ( - AssignExpr( - temp{4}, - 22, - ), - Expr(1), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/nested-points.dada", - ), - 0, - Expr(1), - Some( - temp{4}, - ), - ), - Expr(1), - ), - ( - AssignExpr( - temp{5}, - 44, - ), - Expr(2), - ), - ], - Assign( - p{0}, - Call( - temp{3}, - [ - temp{4}, - temp{5}, - ], - [ - None, - None, - ], - ), - BasicBlock(1), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{3}, + Class(Id { value: 1 }).share, ), + ControlPoint(3), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{5}, - ), - Expr(2), - ), - ( - Clear( - temp{4}, - ), - Expr(1), - ), - ( - Clear( - temp{3}, - ), - Expr(0), - ), - ( - AssignExpr( - temp{6}, - Class(Id { value: 1 }).share, - ), - Expr(5), - ), - ( - AssignExpr( - temp{7}, - p{0}.share, - ), - Expr(6), - ), - ( - AssignExpr( - temp{8}, - 66, - ), - Expr(7), + ControlPoint(3): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/nested-points.dada", ), - ], - Assign( - q{1}, - Call( - temp{6}, - [ - temp{7}, - temp{8}, - ], - [ - None, - None, - ], - ), - BasicBlock(2), + 0, ), + ControlPoint(4), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{8}, - ), - Expr(7), - ), - ( - Clear( - temp{7}, - ), - Expr(6), - ), - ( - Clear( - temp{6}, - ), - Expr(5), + ControlPoint(4): Statement( + AssignExpr( + temp{4}, + 22, + ), + ControlPoint(5), + ), + ControlPoint(5): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/nested-points.dada", ), - ( - AssignExpr( - temp{2}, - (), - ), - Expr(10), + 0, + Expr(1), + Some( + temp{4}, ), - ], - Return( + ), + ControlPoint(6), + ), + ControlPoint(6): Statement( + AssignExpr( + temp{5}, + 44, + ), + ControlPoint(8), + ), + ControlPoint(7): Statement( + Noop, + ControlPoint(9), + ), + ControlPoint(8): Assign( + p{0}, + Call( + temp{3}, + [ + temp{4}, + temp{5}, + ], + [ + None, + None, + ], + ), + ControlPoint(7), + ), + ControlPoint(9): Statement( + Clear( + temp{5}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + Clear( + temp{4}, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + Clear( + temp{3}, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + AssignExpr( + temp{6}, + Class(Id { value: 1 }).share, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + AssignExpr( + temp{7}, + p{0}.share, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + AssignExpr( + temp{8}, + 66, + ), + ControlPoint(16), + ), + ControlPoint(15): Statement( + Noop, + ControlPoint(17), + ), + ControlPoint(16): Assign( + q{1}, + Call( + temp{6}, + [ + temp{7}, + temp{8}, + ], + [ + None, + None, + ], + ), + ControlPoint(15), + ), + ControlPoint(17): Statement( + Clear( + temp{8}, + ), + ControlPoint(18), + ), + ControlPoint(18): Statement( + Clear( + temp{7}, + ), + ControlPoint(19), + ), + ControlPoint(19): Statement( + Clear( + temp{6}, + ), + ControlPoint(20), + ), + ControlPoint(20): Statement( + AssignExpr( temp{2}, + (), ), + ControlPoint(21), + ), + ControlPoint(21): Return( + temp{2}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/nested-points/HeapGraph-2.bir.ref b/dada_tests/heap-graph/nested-points/HeapGraph-2.bir.ref index 50996fc7..98f11596 100644 --- a/dada_tests/heap-graph/nested-points/HeapGraph-2.bir.ref +++ b/dada_tests/heap-graph/nested-points/HeapGraph-2.bir.ref @@ -1,179 +1,179 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{3}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{4}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{5}, - 44, - ), - Expr(2), - ), - ], - Assign( - p{0}, - Call( - temp{3}, - [ - temp{4}, - temp{5}, - ], - [ - None, - None, - ], - ), - BasicBlock(1), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{3}, + Class(Id { value: 1 }).share, ), + ControlPoint(3), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{5}, - ), - Expr(2), - ), - ( - Clear( - temp{4}, - ), - Expr(1), - ), - ( - Clear( - temp{3}, - ), - Expr(0), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/nested-points.dada", - ), - 0, - ), - Expr(5), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/nested-points.dada", - ), - 0, - ), - Expr(5), - ), - ( - AssignExpr( - temp{6}, - Class(Id { value: 1 }).share, - ), - Expr(5), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/nested-points.dada", - ), - 0, - Expr(5), - Some( - temp{6}, - ), - ), - Expr(5), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/nested-points.dada", - ), - 0, - Expr(5), - Some( - temp{6}, - ), - ), - Expr(5), - ), - ( - AssignExpr( - temp{7}, - p{0}.share, - ), - Expr(6), + ControlPoint(3): Statement( + AssignExpr( + temp{4}, + 22, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{5}, + 44, + ), + ControlPoint(6), + ), + ControlPoint(5): Statement( + Noop, + ControlPoint(7), + ), + ControlPoint(6): Assign( + p{0}, + Call( + temp{3}, + [ + temp{4}, + temp{5}, + ], + [ + None, + None, + ], + ), + ControlPoint(5), + ), + ControlPoint(7): Statement( + Clear( + temp{5}, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + Clear( + temp{4}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{3}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/nested-points.dada", ), - ( - AssignExpr( - temp{8}, - 66, - ), - Expr(7), + 0, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/nested-points.dada", ), - ], - Assign( - q{1}, - Call( + 0, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + AssignExpr( + temp{6}, + Class(Id { value: 1 }).share, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/nested-points.dada", + ), + 0, + Expr(5), + Some( temp{6}, - [ - temp{7}, - temp{8}, - ], - [ - None, - None, - ], ), - BasicBlock(2), ), + ControlPoint(14), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{8}, - ), - Expr(7), - ), - ( - Clear( - temp{7}, - ), - Expr(6), - ), - ( - Clear( - temp{6}, - ), - Expr(5), - ), - ( - AssignExpr( - temp{2}, - (), - ), - Expr(10), + ControlPoint(14): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/nested-points.dada", + ), + 0, + Expr(5), + Some( + temp{6}, ), - ], - Return( + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + AssignExpr( + temp{7}, + p{0}.share, + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + AssignExpr( + temp{8}, + 66, + ), + ControlPoint(18), + ), + ControlPoint(17): Statement( + Noop, + ControlPoint(19), + ), + ControlPoint(18): Assign( + q{1}, + Call( + temp{6}, + [ + temp{7}, + temp{8}, + ], + [ + None, + None, + ], + ), + ControlPoint(17), + ), + ControlPoint(19): Statement( + Clear( + temp{8}, + ), + ControlPoint(20), + ), + ControlPoint(20): Statement( + Clear( + temp{7}, + ), + ControlPoint(21), + ), + ControlPoint(21): Statement( + Clear( + temp{6}, + ), + ControlPoint(22), + ), + ControlPoint(22): Statement( + AssignExpr( temp{2}, + (), ), + ControlPoint(23), + ), + ControlPoint(23): Return( + temp{2}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/past-end/HeapGraph-0.bir.ref b/dada_tests/heap-graph/past-end/HeapGraph-0.bir.ref index 30ae3aa2..c3f264d5 100644 --- a/dada_tests/heap-graph/past-end/HeapGraph-0.bir.ref +++ b/dada_tests/heap-graph/past-end/HeapGraph-0.bir.ref @@ -1,98 +1,98 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{3}, - Print.share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{5}, - "I have forced myself to contradict myself\nin order to avoid conforming to my own taste.\n -- Marcel Duchamp", - ), - Expr(1), - ), - ( - AssignExpr( - temp{4}, - Concatenate(temp{5}), - ), - Expr(2), - ), - ( - Clear( - temp{5}, - ), - Expr(1), - ), - ], - Assign( + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{3}, + Print.share, + ), + ControlPoint(3), + ), + ControlPoint(3): Statement( + AssignExpr( + temp{5}, + "I have forced myself to contradict myself\nin order to avoid conforming to my own taste.\n -- Marcel Duchamp", + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{4}, + Concatenate(temp{5}), + ), + ControlPoint(5), + ), + ControlPoint(5): Statement( + Clear( + temp{5}, + ), + ControlPoint(7), + ), + ControlPoint(6): Statement( + Noop, + ControlPoint(8), + ), + ControlPoint(7): Assign( + temp{2}, + Call( + temp{3}, + [ + temp{4}, + ], + [ + None, + ], + ), + ControlPoint(6), + ), + ControlPoint(8): Statement( + Clear( + temp{4}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{3}, + ), + ControlPoint(11), + ), + ControlPoint(10): Statement( + Noop, + ControlPoint(12), + ), + ControlPoint(11): Assign( + temp{1}, + Await( temp{2}, - Call( - temp{3}, - [ - temp{4}, - ], - [ - None, - ], - ), - BasicBlock(1), ), + ControlPoint(10), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{4}, - ), - Expr(2), - ), - ( - Clear( - temp{3}, - ), - Expr(0), - ), - ], - Assign( + ControlPoint(12): Statement( + Clear( + temp{2}, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + Clear( temp{1}, - Await( - temp{2}, - ), - BasicBlock(2), ), + ControlPoint(14), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{2}, - ), - Expr(3), - ), - ( - Clear( - temp{1}, - ), - Expr(4), - ), - ( - AssignExpr( - temp{0}, - (), - ), - Expr(5), - ), - ], - Return( + ControlPoint(14): Statement( + AssignExpr( temp{0}, + (), ), + ControlPoint(15), + ), + ControlPoint(15): Return( + temp{0}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/rust-thunk/HeapGraph-0.bir.ref b/dada_tests/heap-graph/rust-thunk/HeapGraph-0.bir.ref index a7919508..e25222a0 100644 --- a/dada_tests/heap-graph/rust-thunk/HeapGraph-0.bir.ref +++ b/dada_tests/heap-graph/rust-thunk/HeapGraph-0.bir.ref @@ -1,120 +1,120 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/rust-thunk.dada", - ), - 0, - ), - Expr(3), - ), - ( - AssignExpr( - temp{3}, - Print.share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{5}, - "foo", - ), - Expr(1), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/rust-thunk.dada", ), - ( - AssignExpr( - temp{4}, - Concatenate(temp{5}), - ), - Expr(2), + 0, + ), + ControlPoint(3), + ), + ControlPoint(3): Statement( + AssignExpr( + temp{3}, + Print.share, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{5}, + "foo", + ), + ControlPoint(5), + ), + ControlPoint(5): Statement( + AssignExpr( + temp{4}, + Concatenate(temp{5}), + ), + ControlPoint(6), + ), + ControlPoint(6): Statement( + Clear( + temp{5}, + ), + ControlPoint(8), + ), + ControlPoint(7): Statement( + Noop, + ControlPoint(9), + ), + ControlPoint(8): Assign( + temp{2}, + Call( + temp{3}, + [ + temp{4}, + ], + [ + None, + ], + ), + ControlPoint(7), + ), + ControlPoint(9): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/rust-thunk.dada", ), - ( - Clear( - temp{5}, - ), - Expr(1), + 0, + Expr(3), + Some( + temp{2}, ), - ], - Assign( + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + Clear( + temp{4}, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + Clear( + temp{3}, + ), + ControlPoint(13), + ), + ControlPoint(12): Statement( + Noop, + ControlPoint(14), + ), + ControlPoint(13): Assign( + temp{1}, + Await( temp{2}, - Call( - temp{3}, - [ - temp{4}, - ], - [ - None, - ], - ), - BasicBlock(1), ), + ControlPoint(12), ), - BasicBlock(1): BasicBlockData( - [ - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/rust-thunk.dada", - ), - 0, - Expr(3), - Some( - temp{2}, - ), - ), - Expr(3), - ), - ( - Clear( - temp{4}, - ), - Expr(2), - ), - ( - Clear( - temp{3}, - ), - Expr(0), - ), - ], - Assign( + ControlPoint(14): Statement( + Clear( + temp{2}, + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + Clear( temp{1}, - Await( - temp{2}, - ), - BasicBlock(2), ), + ControlPoint(16), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{2}, - ), - Expr(3), - ), - ( - Clear( - temp{1}, - ), - Expr(4), - ), - ( - AssignExpr( - temp{0}, - (), - ), - Expr(5), - ), - ], - Return( + ControlPoint(16): Statement( + AssignExpr( temp{0}, + (), ), + ControlPoint(17), + ), + ControlPoint(17): Return( + temp{0}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/tutorial-1/HeapGraph-0.bir.ref b/dada_tests/heap-graph/tutorial-1/HeapGraph-0.bir.ref index 8252dfcc..0d0dd3be 100644 --- a/dada_tests/heap-graph/tutorial-1/HeapGraph-0.bir.ref +++ b/dada_tests/heap-graph/tutorial-1/HeapGraph-0.bir.ref @@ -1,204 +1,204 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/tutorial-1.dada", - ), - 0, - ), - Expr(0), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/tutorial-1.dada", - ), - 0, - ), - Expr(0), - ), - ( - AssignExpr( - temp{2}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/tutorial-1.dada", - ), - 0, - Expr(0), - Some( - temp{2}, - ), - ), - Expr(0), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/tutorial-1.dada", - ), - 0, - Expr(0), - Some( - temp{2}, - ), - ), - Expr(0), - ), - ( - AssignExpr( - temp{3}, - 22, - ), - Expr(1), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/tutorial-1.dada", ), - ( - AssignExpr( - temp{4}, - 44, - ), - Expr(2), + 0, + ), + ControlPoint(3), + ), + ControlPoint(3): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/tutorial-1.dada", ), - ], - Assign( - p{0}, - Call( + 0, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{2}, + Class(Id { value: 1 }).share, + ), + ControlPoint(5), + ), + ControlPoint(5): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/tutorial-1.dada", + ), + 0, + Expr(0), + Some( temp{2}, - [ - temp{3}, - temp{4}, - ], - [ - Some( - "x", - ), - Some( - "y", - ), - ], ), - BasicBlock(1), ), + ControlPoint(6), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{4}, - ), - Expr(2), - ), - ( - Clear( - temp{3}, - ), - Expr(1), - ), - ( - Clear( - temp{2}, - ), - Expr(0), - ), - ( - AssignExpr( - temp{7}, - Print.share, - ), - Expr(5), - ), - ( - AssignExpr( - temp{9}, - "The point is FIXME", - ), - Expr(6), - ), - ( - AssignExpr( - temp{8}, - Concatenate(temp{9}), - ), - Expr(7), - ), - ( - Clear( - temp{9}, - ), - Expr(6), + ControlPoint(6): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/tutorial-1.dada", + ), + 0, + Expr(0), + Some( + temp{2}, ), - ], - Assign( + ), + ControlPoint(7), + ), + ControlPoint(7): Statement( + AssignExpr( + temp{3}, + 22, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + AssignExpr( + temp{4}, + 44, + ), + ControlPoint(10), + ), + ControlPoint(9): Statement( + Noop, + ControlPoint(11), + ), + ControlPoint(10): Assign( + p{0}, + Call( + temp{2}, + [ + temp{3}, + temp{4}, + ], + [ + Some( + "x", + ), + Some( + "y", + ), + ], + ), + ControlPoint(9), + ), + ControlPoint(11): Statement( + Clear( + temp{4}, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + Clear( + temp{3}, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + Clear( + temp{2}, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + AssignExpr( + temp{7}, + Print.share, + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + AssignExpr( + temp{9}, + "The point is FIXME", + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + AssignExpr( + temp{8}, + Concatenate(temp{9}), + ), + ControlPoint(17), + ), + ControlPoint(17): Statement( + Clear( + temp{9}, + ), + ControlPoint(19), + ), + ControlPoint(18): Statement( + Noop, + ControlPoint(20), + ), + ControlPoint(19): Assign( + temp{6}, + Call( + temp{7}, + [ + temp{8}, + ], + [ + None, + ], + ), + ControlPoint(18), + ), + ControlPoint(20): Statement( + Clear( + temp{8}, + ), + ControlPoint(21), + ), + ControlPoint(21): Statement( + Clear( + temp{7}, + ), + ControlPoint(23), + ), + ControlPoint(22): Statement( + Noop, + ControlPoint(24), + ), + ControlPoint(23): Assign( + temp{5}, + Await( temp{6}, - Call( - temp{7}, - [ - temp{8}, - ], - [ - None, - ], - ), - BasicBlock(2), ), + ControlPoint(22), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{8}, - ), - Expr(7), - ), - ( - Clear( - temp{7}, - ), - Expr(5), - ), - ], - Assign( + ControlPoint(24): Statement( + Clear( + temp{6}, + ), + ControlPoint(25), + ), + ControlPoint(25): Statement( + Clear( temp{5}, - Await( - temp{6}, - ), - BasicBlock(3), ), + ControlPoint(26), ), - BasicBlock(3): BasicBlockData( - [ - ( - Clear( - temp{6}, - ), - Expr(8), - ), - ( - Clear( - temp{5}, - ), - Expr(9), - ), - ( - AssignExpr( - temp{1}, - (), - ), - Expr(10), - ), - ], - Return( + ControlPoint(26): Statement( + AssignExpr( temp{1}, + (), ), + ControlPoint(27), + ), + ControlPoint(27): Return( + temp{1}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/tutorial-1/HeapGraph-1.bir.ref b/dada_tests/heap-graph/tutorial-1/HeapGraph-1.bir.ref index 11f840ca..8bdf932c 100644 --- a/dada_tests/heap-graph/tutorial-1/HeapGraph-1.bir.ref +++ b/dada_tests/heap-graph/tutorial-1/HeapGraph-1.bir.ref @@ -1,182 +1,182 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{2}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/tutorial-1.dada", - ), - 0, - ), - Expr(1), - ), - ( - AssignExpr( - temp{3}, - 22, - ), - Expr(1), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/tutorial-1.dada", - ), - 0, - Expr(1), - Some( - temp{3}, - ), - ), - Expr(1), - ), - ( - AssignExpr( - temp{4}, - 44, - ), - Expr(2), - ), - ], - Assign( - p{0}, - Call( - temp{2}, - [ - temp{3}, - temp{4}, - ], - [ - Some( - "x", - ), - Some( - "y", - ), - ], - ), - BasicBlock(1), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{2}, + Class(Id { value: 1 }).share, ), + ControlPoint(3), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{4}, - ), - Expr(2), - ), - ( - Clear( - temp{3}, - ), - Expr(1), - ), - ( - Clear( - temp{2}, - ), - Expr(0), - ), - ( - AssignExpr( - temp{7}, - Print.share, - ), - Expr(5), - ), - ( - AssignExpr( - temp{9}, - "The point is FIXME", - ), - Expr(6), + ControlPoint(3): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/tutorial-1.dada", ), - ( - AssignExpr( - temp{8}, - Concatenate(temp{9}), - ), - Expr(7), + 0, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{3}, + 22, + ), + ControlPoint(5), + ), + ControlPoint(5): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/tutorial-1.dada", ), - ( - Clear( - temp{9}, - ), - Expr(6), + 0, + Expr(1), + Some( + temp{3}, ), - ], - Assign( + ), + ControlPoint(6), + ), + ControlPoint(6): Statement( + AssignExpr( + temp{4}, + 44, + ), + ControlPoint(8), + ), + ControlPoint(7): Statement( + Noop, + ControlPoint(9), + ), + ControlPoint(8): Assign( + p{0}, + Call( + temp{2}, + [ + temp{3}, + temp{4}, + ], + [ + Some( + "x", + ), + Some( + "y", + ), + ], + ), + ControlPoint(7), + ), + ControlPoint(9): Statement( + Clear( + temp{4}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + Clear( + temp{3}, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + Clear( + temp{2}, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + AssignExpr( + temp{7}, + Print.share, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + AssignExpr( + temp{9}, + "The point is FIXME", + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + AssignExpr( + temp{8}, + Concatenate(temp{9}), + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + Clear( + temp{9}, + ), + ControlPoint(17), + ), + ControlPoint(16): Statement( + Noop, + ControlPoint(18), + ), + ControlPoint(17): Assign( + temp{6}, + Call( + temp{7}, + [ + temp{8}, + ], + [ + None, + ], + ), + ControlPoint(16), + ), + ControlPoint(18): Statement( + Clear( + temp{8}, + ), + ControlPoint(19), + ), + ControlPoint(19): Statement( + Clear( + temp{7}, + ), + ControlPoint(21), + ), + ControlPoint(20): Statement( + Noop, + ControlPoint(22), + ), + ControlPoint(21): Assign( + temp{5}, + Await( temp{6}, - Call( - temp{7}, - [ - temp{8}, - ], - [ - None, - ], - ), - BasicBlock(2), ), + ControlPoint(20), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{8}, - ), - Expr(7), - ), - ( - Clear( - temp{7}, - ), - Expr(5), - ), - ], - Assign( + ControlPoint(22): Statement( + Clear( + temp{6}, + ), + ControlPoint(23), + ), + ControlPoint(23): Statement( + Clear( temp{5}, - Await( - temp{6}, - ), - BasicBlock(3), ), + ControlPoint(24), ), - BasicBlock(3): BasicBlockData( - [ - ( - Clear( - temp{6}, - ), - Expr(8), - ), - ( - Clear( - temp{5}, - ), - Expr(9), - ), - ( - AssignExpr( - temp{1}, - (), - ), - Expr(10), - ), - ], - Return( + ControlPoint(24): Statement( + AssignExpr( temp{1}, + (), ), + ControlPoint(25), + ), + ControlPoint(25): Return( + temp{1}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/tutorial-1/HeapGraph-2.bir.ref b/dada_tests/heap-graph/tutorial-1/HeapGraph-2.bir.ref index 638cd9af..a1c0627b 100644 --- a/dada_tests/heap-graph/tutorial-1/HeapGraph-2.bir.ref +++ b/dada_tests/heap-graph/tutorial-1/HeapGraph-2.bir.ref @@ -1,182 +1,182 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/tutorial-1.dada", - ), - 0, - ), - Expr(3), - ), - ( - AssignExpr( - temp{2}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{3}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{4}, - 44, - ), - Expr(2), - ), - ], - Assign( - p{0}, - Call( - temp{2}, - [ - temp{3}, - temp{4}, - ], - [ - Some( - "x", - ), - Some( - "y", - ), - ], - ), - BasicBlock(1), - ), - ), - BasicBlock(1): BasicBlockData( - [ - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/tutorial-1.dada", - ), - 0, - Expr(3), - Some( - p{0}, - ), - ), - Expr(3), - ), - ( - Clear( - temp{4}, - ), - Expr(2), - ), - ( - Clear( - temp{3}, - ), - Expr(1), - ), - ( - Clear( - temp{2}, - ), - Expr(0), - ), - ( - AssignExpr( - temp{7}, - Print.share, - ), - Expr(5), - ), - ( - AssignExpr( - temp{9}, - "The point is FIXME", - ), - Expr(6), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/tutorial-1.dada", ), - ( - AssignExpr( - temp{8}, - Concatenate(temp{9}), - ), - Expr(7), + 0, + ), + ControlPoint(3), + ), + ControlPoint(3): Statement( + AssignExpr( + temp{2}, + Class(Id { value: 1 }).share, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{3}, + 22, + ), + ControlPoint(5), + ), + ControlPoint(5): Statement( + AssignExpr( + temp{4}, + 44, + ), + ControlPoint(7), + ), + ControlPoint(6): Statement( + Noop, + ControlPoint(8), + ), + ControlPoint(7): Assign( + p{0}, + Call( + temp{2}, + [ + temp{3}, + temp{4}, + ], + [ + Some( + "x", + ), + Some( + "y", + ), + ], + ), + ControlPoint(6), + ), + ControlPoint(8): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/tutorial-1.dada", ), - ( - Clear( - temp{9}, - ), - Expr(6), + 0, + Expr(3), + Some( + p{0}, ), - ], - Assign( + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{4}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + Clear( + temp{3}, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + Clear( + temp{2}, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + AssignExpr( + temp{7}, + Print.share, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + AssignExpr( + temp{9}, + "The point is FIXME", + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + AssignExpr( + temp{8}, + Concatenate(temp{9}), + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + Clear( + temp{9}, + ), + ControlPoint(17), + ), + ControlPoint(16): Statement( + Noop, + ControlPoint(18), + ), + ControlPoint(17): Assign( + temp{6}, + Call( + temp{7}, + [ + temp{8}, + ], + [ + None, + ], + ), + ControlPoint(16), + ), + ControlPoint(18): Statement( + Clear( + temp{8}, + ), + ControlPoint(19), + ), + ControlPoint(19): Statement( + Clear( + temp{7}, + ), + ControlPoint(21), + ), + ControlPoint(20): Statement( + Noop, + ControlPoint(22), + ), + ControlPoint(21): Assign( + temp{5}, + Await( temp{6}, - Call( - temp{7}, - [ - temp{8}, - ], - [ - None, - ], - ), - BasicBlock(2), ), + ControlPoint(20), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{8}, - ), - Expr(7), - ), - ( - Clear( - temp{7}, - ), - Expr(5), - ), - ], - Assign( + ControlPoint(22): Statement( + Clear( + temp{6}, + ), + ControlPoint(23), + ), + ControlPoint(23): Statement( + Clear( temp{5}, - Await( - temp{6}, - ), - BasicBlock(3), ), + ControlPoint(24), ), - BasicBlock(3): BasicBlockData( - [ - ( - Clear( - temp{6}, - ), - Expr(8), - ), - ( - Clear( - temp{5}, - ), - Expr(9), - ), - ( - AssignExpr( - temp{1}, - (), - ), - Expr(10), - ), - ], - Return( + ControlPoint(24): Statement( + AssignExpr( temp{1}, + (), ), + ControlPoint(25), + ), + ControlPoint(25): Return( + temp{1}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/tutorial-1/HeapGraph-3.bir.ref b/dada_tests/heap-graph/tutorial-1/HeapGraph-3.bir.ref index d55410ff..f54f239c 100644 --- a/dada_tests/heap-graph/tutorial-1/HeapGraph-3.bir.ref +++ b/dada_tests/heap-graph/tutorial-1/HeapGraph-3.bir.ref @@ -1,180 +1,180 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/tutorial-1.dada", - ), - 0, - ), - Expr(4), - ), - ( - AssignExpr( - temp{2}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{3}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{4}, - 44, - ), - Expr(2), - ), - ], - Assign( - p{0}, - Call( - temp{2}, - [ - temp{3}, - temp{4}, - ], - [ - Some( - "x", - ), - Some( - "y", - ), - ], + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/tutorial-1.dada", ), - BasicBlock(1), + 0, ), + ControlPoint(3), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{4}, - ), - Expr(2), - ), - ( - Clear( - temp{3}, - ), - Expr(1), - ), - ( - Clear( - temp{2}, - ), - Expr(0), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/tutorial-1.dada", - ), - 0, - Expr(4), - None, - ), - Expr(4), - ), - ( - AssignExpr( - temp{7}, - Print.share, - ), - Expr(5), - ), - ( - AssignExpr( - temp{9}, - "The point is FIXME", - ), - Expr(6), - ), - ( - AssignExpr( - temp{8}, - Concatenate(temp{9}), - ), - Expr(7), - ), - ( - Clear( - temp{9}, - ), - Expr(6), - ), - ], - Assign( + ControlPoint(3): Statement( + AssignExpr( + temp{2}, + Class(Id { value: 1 }).share, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{3}, + 22, + ), + ControlPoint(5), + ), + ControlPoint(5): Statement( + AssignExpr( + temp{4}, + 44, + ), + ControlPoint(7), + ), + ControlPoint(6): Statement( + Noop, + ControlPoint(8), + ), + ControlPoint(7): Assign( + p{0}, + Call( + temp{2}, + [ + temp{3}, + temp{4}, + ], + [ + Some( + "x", + ), + Some( + "y", + ), + ], + ), + ControlPoint(6), + ), + ControlPoint(8): Statement( + Clear( + temp{4}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{3}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + Clear( + temp{2}, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/tutorial-1.dada", + ), + 0, + Expr(4), + None, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + AssignExpr( + temp{7}, + Print.share, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + AssignExpr( + temp{9}, + "The point is FIXME", + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + AssignExpr( + temp{8}, + Concatenate(temp{9}), + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + Clear( + temp{9}, + ), + ControlPoint(17), + ), + ControlPoint(16): Statement( + Noop, + ControlPoint(18), + ), + ControlPoint(17): Assign( + temp{6}, + Call( + temp{7}, + [ + temp{8}, + ], + [ + None, + ], + ), + ControlPoint(16), + ), + ControlPoint(18): Statement( + Clear( + temp{8}, + ), + ControlPoint(19), + ), + ControlPoint(19): Statement( + Clear( + temp{7}, + ), + ControlPoint(21), + ), + ControlPoint(20): Statement( + Noop, + ControlPoint(22), + ), + ControlPoint(21): Assign( + temp{5}, + Await( temp{6}, - Call( - temp{7}, - [ - temp{8}, - ], - [ - None, - ], - ), - BasicBlock(2), ), + ControlPoint(20), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{8}, - ), - Expr(7), - ), - ( - Clear( - temp{7}, - ), - Expr(5), - ), - ], - Assign( + ControlPoint(22): Statement( + Clear( + temp{6}, + ), + ControlPoint(23), + ), + ControlPoint(23): Statement( + Clear( temp{5}, - Await( - temp{6}, - ), - BasicBlock(3), ), + ControlPoint(24), ), - BasicBlock(3): BasicBlockData( - [ - ( - Clear( - temp{6}, - ), - Expr(8), - ), - ( - Clear( - temp{5}, - ), - Expr(9), - ), - ( - AssignExpr( - temp{1}, - (), - ), - Expr(10), - ), - ], - Return( + ControlPoint(24): Statement( + AssignExpr( temp{1}, + (), ), + ControlPoint(25), + ), + ControlPoint(25): Return( + temp{1}, ), }, ] \ No newline at end of file diff --git a/dada_tests/heap-graph/tutorial-1/HeapGraph-4.bir.ref b/dada_tests/heap-graph/tutorial-1/HeapGraph-4.bir.ref index eb4aac6c..4f846874 100644 --- a/dada_tests/heap-graph/tutorial-1/HeapGraph-4.bir.ref +++ b/dada_tests/heap-graph/tutorial-1/HeapGraph-4.bir.ref @@ -1,204 +1,204 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{2}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{3}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{4}, - 44, - ), - Expr(2), - ), - ], - Assign( - p{0}, - Call( - temp{2}, - [ - temp{3}, - temp{4}, - ], - [ - Some( - "x", - ), - Some( - "y", - ), - ], - ), - BasicBlock(1), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{2}, + Class(Id { value: 1 }).share, ), + ControlPoint(3), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{4}, - ), - Expr(2), - ), - ( - Clear( - temp{3}, - ), - Expr(1), - ), - ( - Clear( - temp{2}, - ), - Expr(0), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/tutorial-1.dada", - ), - 0, - ), - Expr(5), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/heap-graph/tutorial-1.dada", - ), - 0, - ), - Expr(5), - ), - ( - AssignExpr( - temp{7}, - Print.share, - ), - Expr(5), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/tutorial-1.dada", - ), - 0, - Expr(5), - Some( - temp{7}, - ), - ), - Expr(5), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/heap-graph/tutorial-1.dada", - ), - 0, - Expr(5), - Some( - temp{7}, - ), - ), - Expr(5), - ), - ( - AssignExpr( - temp{9}, - "The point is FIXME", - ), - Expr(6), - ), - ( - AssignExpr( - temp{8}, - Concatenate(temp{9}), - ), - Expr(7), + ControlPoint(3): Statement( + AssignExpr( + temp{3}, + 22, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{4}, + 44, + ), + ControlPoint(6), + ), + ControlPoint(5): Statement( + Noop, + ControlPoint(7), + ), + ControlPoint(6): Assign( + p{0}, + Call( + temp{2}, + [ + temp{3}, + temp{4}, + ], + [ + Some( + "x", + ), + Some( + "y", + ), + ], + ), + ControlPoint(5), + ), + ControlPoint(7): Statement( + Clear( + temp{4}, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + Clear( + temp{3}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{2}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/tutorial-1.dada", ), - ( - Clear( - temp{9}, - ), - Expr(6), + 0, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/heap-graph/tutorial-1.dada", ), - ], - Assign( - temp{6}, - Call( + 0, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + AssignExpr( + temp{7}, + Print.share, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/tutorial-1.dada", + ), + 0, + Expr(5), + Some( temp{7}, - [ - temp{8}, - ], - [ - None, - ], ), - BasicBlock(2), ), + ControlPoint(14), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{8}, - ), - Expr(7), - ), - ( - Clear( - temp{7}, - ), - Expr(5), + ControlPoint(14): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/heap-graph/tutorial-1.dada", + ), + 0, + Expr(5), + Some( + temp{7}, ), - ], - Assign( + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + AssignExpr( + temp{9}, + "The point is FIXME", + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + AssignExpr( + temp{8}, + Concatenate(temp{9}), + ), + ControlPoint(17), + ), + ControlPoint(17): Statement( + Clear( + temp{9}, + ), + ControlPoint(19), + ), + ControlPoint(18): Statement( + Noop, + ControlPoint(20), + ), + ControlPoint(19): Assign( + temp{6}, + Call( + temp{7}, + [ + temp{8}, + ], + [ + None, + ], + ), + ControlPoint(18), + ), + ControlPoint(20): Statement( + Clear( + temp{8}, + ), + ControlPoint(21), + ), + ControlPoint(21): Statement( + Clear( + temp{7}, + ), + ControlPoint(23), + ), + ControlPoint(22): Statement( + Noop, + ControlPoint(24), + ), + ControlPoint(23): Assign( + temp{5}, + Await( + temp{6}, + ), + ControlPoint(22), + ), + ControlPoint(24): Statement( + Clear( + temp{6}, + ), + ControlPoint(25), + ), + ControlPoint(25): Statement( + Clear( temp{5}, - Await( - temp{6}, - ), - BasicBlock(3), ), + ControlPoint(26), ), - BasicBlock(3): BasicBlockData( - [ - ( - Clear( - temp{6}, - ), - Expr(8), - ), - ( - Clear( - temp{5}, - ), - Expr(9), - ), - ( - AssignExpr( - temp{1}, - (), - ), - Expr(10), - ), - ], - Return( + ControlPoint(26): Statement( + AssignExpr( temp{1}, + (), ), + ControlPoint(27), + ), + ControlPoint(27): Return( + temp{1}, ), }, ] \ No newline at end of file diff --git a/dada_tests/permissions/dyn_tutorial/tutorial-give-10/HeapGraph-0.bir.ref b/dada_tests/permissions/dyn_tutorial/tutorial-give-10/HeapGraph-0.bir.ref index 10a07f47..5940bec9 100644 --- a/dada_tests/permissions/dyn_tutorial/tutorial-give-10/HeapGraph-0.bir.ref +++ b/dada_tests/permissions/dyn_tutorial/tutorial-give-10/HeapGraph-0.bir.ref @@ -1,115 +1,115 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - BreakpoingStart( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-give-10.dada", - ), - 0, - ), - Expr(4), - ), - ( - AssignExpr( - temp{4}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{5}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{6}, - 44, - ), - Expr(2), - ), - ], - Assign( - p{0}, - Call( - temp{4}, - [ - temp{5}, - temp{6}, - ], - [ - Some( - "x", - ), - Some( - "y", - ), - ], + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-give-10.dada", ), - BasicBlock(1), + 0, ), + ControlPoint(3), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{6}, - ), - Expr(2), - ), - ( - Clear( - temp{5}, - ), - Expr(1), - ), - ( - Clear( - temp{4}, - ), - Expr(0), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-give-10.dada", - ), - 0, - Expr(4), - None, - ), - Expr(4), - ), - ( - AssignExpr( - q{1}, - p{0}.share, - ), - Expr(5), - ), - ( - AssignExpr( - x{2}, - p{0}.x.share, + ControlPoint(3): Statement( + AssignExpr( + temp{4}, + Class(Id { value: 1 }).share, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{5}, + 22, + ), + ControlPoint(5), + ), + ControlPoint(5): Statement( + AssignExpr( + temp{6}, + 44, + ), + ControlPoint(7), + ), + ControlPoint(6): Statement( + Noop, + ControlPoint(8), + ), + ControlPoint(7): Assign( + p{0}, + Call( + temp{4}, + [ + temp{5}, + temp{6}, + ], + [ + Some( + "x", ), - Expr(8), - ), - ( - AssignExpr( - temp{3}, - (), + Some( + "y", ), - Expr(10), + ], + ), + ControlPoint(6), + ), + ControlPoint(8): Statement( + Clear( + temp{6}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{5}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + Clear( + temp{4}, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-give-10.dada", ), - ], - Return( + 0, + Expr(4), + None, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + AssignExpr( + q{1}, + p{0}.share, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + AssignExpr( + x{2}, + p{0}.x.share, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + AssignExpr( temp{3}, + (), ), + ControlPoint(15), + ), + ControlPoint(15): Return( + temp{3}, ), }, ] \ No newline at end of file diff --git a/dada_tests/permissions/dyn_tutorial/tutorial-give-10/HeapGraph-1.bir.ref b/dada_tests/permissions/dyn_tutorial/tutorial-give-10/HeapGraph-1.bir.ref index 54ab0cb7..6d0716ba 100644 --- a/dada_tests/permissions/dyn_tutorial/tutorial-give-10/HeapGraph-1.bir.ref +++ b/dada_tests/permissions/dyn_tutorial/tutorial-give-10/HeapGraph-1.bir.ref @@ -1,115 +1,115 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{4}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{5}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{6}, - 44, - ), - Expr(2), - ), - ], - Assign( - p{0}, - Call( - temp{4}, - [ - temp{5}, - temp{6}, - ], - [ - Some( - "x", - ), - Some( - "y", - ), - ], - ), - BasicBlock(1), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{4}, + Class(Id { value: 1 }).share, ), + ControlPoint(3), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{6}, - ), - Expr(2), - ), - ( - Clear( - temp{5}, - ), - Expr(1), - ), - ( - Clear( - temp{4}, - ), - Expr(0), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-give-10.dada", - ), - 0, - ), - Expr(6), - ), - ( - AssignExpr( - q{1}, - p{0}.share, - ), - Expr(5), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-give-10.dada", - ), - 0, - Expr(6), - None, + ControlPoint(3): Statement( + AssignExpr( + temp{5}, + 22, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{6}, + 44, + ), + ControlPoint(6), + ), + ControlPoint(5): Statement( + Noop, + ControlPoint(7), + ), + ControlPoint(6): Assign( + p{0}, + Call( + temp{4}, + [ + temp{5}, + temp{6}, + ], + [ + Some( + "x", ), - Expr(6), - ), - ( - AssignExpr( - x{2}, - p{0}.x.share, + Some( + "y", ), - Expr(8), + ], + ), + ControlPoint(5), + ), + ControlPoint(7): Statement( + Clear( + temp{6}, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + Clear( + temp{5}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{4}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-give-10.dada", ), - ( - AssignExpr( - temp{3}, - (), - ), - Expr(10), + 0, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + AssignExpr( + q{1}, + p{0}.share, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-give-10.dada", ), - ], - Return( + 0, + Expr(6), + None, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + AssignExpr( + x{2}, + p{0}.x.share, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + AssignExpr( temp{3}, + (), ), + ControlPoint(15), + ), + ControlPoint(15): Return( + temp{3}, ), }, ] \ No newline at end of file diff --git a/dada_tests/permissions/dyn_tutorial/tutorial-lease-10/HeapGraph-0.bir.ref b/dada_tests/permissions/dyn_tutorial/tutorial-lease-10/HeapGraph-0.bir.ref index 474fd6e7..491d1030 100644 --- a/dada_tests/permissions/dyn_tutorial/tutorial-lease-10/HeapGraph-0.bir.ref +++ b/dada_tests/permissions/dyn_tutorial/tutorial-lease-10/HeapGraph-0.bir.ref @@ -1,229 +1,229 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{4}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{5}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{6}, - 44, - ), - Expr(2), - ), - ], - Assign( - p{0}, - Call( - temp{4}, - [ - temp{5}, - temp{6}, - ], - [ - Some( - "x", - ), - Some( - "y", - ), - ], - ), - BasicBlock(1), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{4}, + Class(Id { value: 1 }).share, ), + ControlPoint(3), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{6}, - ), - Expr(2), - ), - ( - Clear( - temp{5}, - ), - Expr(1), - ), - ( - Clear( - temp{4}, - ), - Expr(0), - ), - ( - AssignExpr( - q{1}, - p{0}.lease, - ), - Expr(6), - ), - ( - AssignExpr( - temp{8}, - q{1}.x.give, - ), - Expr(9), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-lease-10.dada", - ), - 0, - ), - Expr(10), - ), - ( - AssignExpr( - temp{9}, - 1, - ), - Expr(10), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-lease-10.dada", - ), - 0, - Expr(10), - Some( - temp{9}, - ), - ), - Expr(10), - ), - ( - AssignExpr( - temp{2}, - temp{8} + temp{9}, - ), - Expr(11), - ), - ( - Clear( - temp{9}, - ), - Expr(10), - ), - ( - Clear( - temp{8}, - ), - Expr(9), - ), - ( - AssignExpr( - q{1}.x, - temp{2}.give, - ), - Expr(11), - ), - ( - AssignExpr( - temp{7}, - (), - ), - Expr(11), - ), - ( - Clear( - temp{7}, - ), - Expr(11), + ControlPoint(3): Statement( + AssignExpr( + temp{5}, + 22, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{6}, + 44, + ), + ControlPoint(6), + ), + ControlPoint(5): Statement( + Noop, + ControlPoint(7), + ), + ControlPoint(6): Assign( + p{0}, + Call( + temp{4}, + [ + temp{5}, + temp{6}, + ], + [ + Some( + "x", + ), + Some( + "y", + ), + ], + ), + ControlPoint(5), + ), + ControlPoint(7): Statement( + Clear( + temp{6}, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + Clear( + temp{5}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{4}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + AssignExpr( + q{1}, + p{0}.lease, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + AssignExpr( + temp{8}, + q{1}.x.give, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-lease-10.dada", ), - ( - AssignExpr( - temp{12}, - Print.share, - ), - Expr(12), + 0, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + AssignExpr( + temp{9}, + 1, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-lease-10.dada", ), - ( - AssignExpr( - temp{13}, - p{0}.x.share, - ), - Expr(14), + 0, + Expr(10), + Some( + temp{9}, ), - ], - Assign( + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + AssignExpr( + temp{2}, + temp{8} + temp{9}, + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + Clear( + temp{9}, + ), + ControlPoint(17), + ), + ControlPoint(17): Statement( + Clear( + temp{8}, + ), + ControlPoint(18), + ), + ControlPoint(18): Statement( + AssignExpr( + q{1}.x, + temp{2}.give, + ), + ControlPoint(19), + ), + ControlPoint(19): Statement( + AssignExpr( + temp{7}, + (), + ), + ControlPoint(20), + ), + ControlPoint(20): Statement( + Clear( + temp{7}, + ), + ControlPoint(21), + ), + ControlPoint(21): Statement( + AssignExpr( + temp{12}, + Print.share, + ), + ControlPoint(22), + ), + ControlPoint(22): Statement( + AssignExpr( + temp{13}, + p{0}.x.share, + ), + ControlPoint(24), + ), + ControlPoint(23): Statement( + Noop, + ControlPoint(25), + ), + ControlPoint(24): Assign( + temp{11}, + Call( + temp{12}, + [ + temp{13}, + ], + [ + None, + ], + ), + ControlPoint(23), + ), + ControlPoint(25): Statement( + Clear( + temp{13}, + ), + ControlPoint(26), + ), + ControlPoint(26): Statement( + Clear( + temp{12}, + ), + ControlPoint(28), + ), + ControlPoint(27): Statement( + Noop, + ControlPoint(29), + ), + ControlPoint(28): Assign( + temp{10}, + Await( temp{11}, - Call( - temp{12}, - [ - temp{13}, - ], - [ - None, - ], - ), - BasicBlock(2), ), + ControlPoint(27), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{13}, - ), - Expr(14), - ), - ( - Clear( - temp{12}, - ), - Expr(12), - ), - ], - Assign( + ControlPoint(29): Statement( + Clear( + temp{11}, + ), + ControlPoint(30), + ), + ControlPoint(30): Statement( + Clear( temp{10}, - Await( - temp{11}, - ), - BasicBlock(3), ), + ControlPoint(31), ), - BasicBlock(3): BasicBlockData( - [ - ( - Clear( - temp{11}, - ), - Expr(15), - ), - ( - Clear( - temp{10}, - ), - Expr(16), - ), - ( - AssignExpr( - temp{3}, - (), - ), - Expr(17), - ), - ], - Return( + ControlPoint(31): Statement( + AssignExpr( temp{3}, + (), ), + ControlPoint(32), + ), + ControlPoint(32): Return( + temp{3}, ), }, ] \ No newline at end of file diff --git a/dada_tests/permissions/dyn_tutorial/tutorial-lease-10/HeapGraph-1.bir.ref b/dada_tests/permissions/dyn_tutorial/tutorial-lease-10/HeapGraph-1.bir.ref index 59d0a521..957c5d54 100644 --- a/dada_tests/permissions/dyn_tutorial/tutorial-lease-10/HeapGraph-1.bir.ref +++ b/dada_tests/permissions/dyn_tutorial/tutorial-lease-10/HeapGraph-1.bir.ref @@ -1,227 +1,227 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{4}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{5}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{6}, - 44, - ), - Expr(2), - ), - ], - Assign( - p{0}, - Call( - temp{4}, - [ - temp{5}, - temp{6}, - ], - [ - Some( - "x", - ), - Some( - "y", - ), - ], - ), - BasicBlock(1), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{4}, + Class(Id { value: 1 }).share, ), + ControlPoint(3), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{6}, - ), - Expr(2), - ), - ( - Clear( - temp{5}, - ), - Expr(1), - ), - ( - Clear( - temp{4}, - ), - Expr(0), - ), - ( - AssignExpr( - q{1}, - p{0}.lease, - ), - Expr(6), - ), - ( - AssignExpr( - temp{8}, - q{1}.x.give, - ), - Expr(9), - ), - ( - AssignExpr( - temp{9}, - 1, - ), - Expr(10), - ), - ( - AssignExpr( - temp{2}, - temp{8} + temp{9}, - ), - Expr(11), - ), - ( - Clear( - temp{9}, - ), - Expr(10), - ), - ( - Clear( - temp{8}, - ), - Expr(9), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-lease-10.dada", - ), - 0, - ), - Expr(11), - ), - ( - AssignExpr( - q{1}.x, - temp{2}.give, - ), - Expr(11), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-lease-10.dada", - ), - 0, - Expr(11), - None, - ), - Expr(11), - ), - ( - AssignExpr( - temp{7}, - (), - ), - Expr(11), - ), - ( - Clear( - temp{7}, - ), - Expr(11), - ), - ( - AssignExpr( - temp{12}, - Print.share, - ), - Expr(12), - ), - ( - AssignExpr( - temp{13}, - p{0}.x.share, - ), - Expr(14), + ControlPoint(3): Statement( + AssignExpr( + temp{5}, + 22, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{6}, + 44, + ), + ControlPoint(6), + ), + ControlPoint(5): Statement( + Noop, + ControlPoint(7), + ), + ControlPoint(6): Assign( + p{0}, + Call( + temp{4}, + [ + temp{5}, + temp{6}, + ], + [ + Some( + "x", + ), + Some( + "y", + ), + ], + ), + ControlPoint(5), + ), + ControlPoint(7): Statement( + Clear( + temp{6}, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + Clear( + temp{5}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{4}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + AssignExpr( + q{1}, + p{0}.lease, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + AssignExpr( + temp{8}, + q{1}.x.give, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + AssignExpr( + temp{9}, + 1, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + AssignExpr( + temp{2}, + temp{8} + temp{9}, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + Clear( + temp{9}, + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + Clear( + temp{8}, + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-lease-10.dada", ), - ], - Assign( + 0, + ), + ControlPoint(17), + ), + ControlPoint(17): Statement( + AssignExpr( + q{1}.x, + temp{2}.give, + ), + ControlPoint(18), + ), + ControlPoint(18): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-lease-10.dada", + ), + 0, + Expr(11), + None, + ), + ControlPoint(19), + ), + ControlPoint(19): Statement( + AssignExpr( + temp{7}, + (), + ), + ControlPoint(20), + ), + ControlPoint(20): Statement( + Clear( + temp{7}, + ), + ControlPoint(21), + ), + ControlPoint(21): Statement( + AssignExpr( + temp{12}, + Print.share, + ), + ControlPoint(22), + ), + ControlPoint(22): Statement( + AssignExpr( + temp{13}, + p{0}.x.share, + ), + ControlPoint(24), + ), + ControlPoint(23): Statement( + Noop, + ControlPoint(25), + ), + ControlPoint(24): Assign( + temp{11}, + Call( + temp{12}, + [ + temp{13}, + ], + [ + None, + ], + ), + ControlPoint(23), + ), + ControlPoint(25): Statement( + Clear( + temp{13}, + ), + ControlPoint(26), + ), + ControlPoint(26): Statement( + Clear( + temp{12}, + ), + ControlPoint(28), + ), + ControlPoint(27): Statement( + Noop, + ControlPoint(29), + ), + ControlPoint(28): Assign( + temp{10}, + Await( temp{11}, - Call( - temp{12}, - [ - temp{13}, - ], - [ - None, - ], - ), - BasicBlock(2), ), + ControlPoint(27), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{13}, - ), - Expr(14), - ), - ( - Clear( - temp{12}, - ), - Expr(12), - ), - ], - Assign( + ControlPoint(29): Statement( + Clear( + temp{11}, + ), + ControlPoint(30), + ), + ControlPoint(30): Statement( + Clear( temp{10}, - Await( - temp{11}, - ), - BasicBlock(3), ), + ControlPoint(31), ), - BasicBlock(3): BasicBlockData( - [ - ( - Clear( - temp{11}, - ), - Expr(15), - ), - ( - Clear( - temp{10}, - ), - Expr(16), - ), - ( - AssignExpr( - temp{3}, - (), - ), - Expr(17), - ), - ], - Return( + ControlPoint(31): Statement( + AssignExpr( temp{3}, + (), ), + ControlPoint(32), + ), + ControlPoint(32): Return( + temp{3}, ), }, ] \ No newline at end of file diff --git a/dada_tests/permissions/dyn_tutorial/tutorial-lease-20/HeapGraph-0.bir.ref b/dada_tests/permissions/dyn_tutorial/tutorial-lease-20/HeapGraph-0.bir.ref index ee3dd3ff..e34f24ec 100644 --- a/dada_tests/permissions/dyn_tutorial/tutorial-lease-20/HeapGraph-0.bir.ref +++ b/dada_tests/permissions/dyn_tutorial/tutorial-lease-20/HeapGraph-0.bir.ref @@ -1,234 +1,234 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{5}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{6}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{7}, - 44, - ), - Expr(2), - ), - ], - Assign( - p{0}, - Call( - temp{5}, - [ - temp{6}, - temp{7}, - ], - [ - Some( - "x", - ), - Some( - "y", - ), - ], - ), - BasicBlock(1), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{5}, + Class(Id { value: 1 }).share, ), + ControlPoint(3), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{7}, - ), - Expr(2), - ), - ( - Clear( - temp{6}, - ), - Expr(1), - ), - ( - Clear( - temp{5}, - ), - Expr(0), - ), - ( - AssignExpr( - q{1}, - p{0}.lease, - ), - Expr(6), - ), - ( - AssignExpr( - r{2}, - q{1}.lease, - ), - Expr(9), - ), - ( - AssignExpr( - temp{9}, - r{2}.x.give, - ), - Expr(12), - ), - ( - AssignExpr( - temp{10}, - 1, - ), - Expr(13), - ), - ( - AssignExpr( - temp{3}, - temp{9} + temp{10}, - ), - Expr(14), - ), - ( - Clear( - temp{10}, - ), - Expr(13), - ), - ( - Clear( - temp{9}, - ), - Expr(12), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-lease-20.dada", - ), - 0, - ), - Expr(14), - ), - ( - AssignExpr( - r{2}.x, - temp{3}.give, - ), - Expr(14), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-lease-20.dada", - ), - 0, - Expr(14), - None, - ), - Expr(14), - ), - ( - AssignExpr( - temp{8}, - (), - ), - Expr(14), - ), - ( - Clear( - temp{8}, - ), - Expr(14), - ), - ( - AssignExpr( - temp{13}, - Print.share, - ), - Expr(15), - ), - ( - AssignExpr( - temp{14}, - p{0}.x.share, - ), - Expr(17), + ControlPoint(3): Statement( + AssignExpr( + temp{6}, + 22, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{7}, + 44, + ), + ControlPoint(6), + ), + ControlPoint(5): Statement( + Noop, + ControlPoint(7), + ), + ControlPoint(6): Assign( + p{0}, + Call( + temp{5}, + [ + temp{6}, + temp{7}, + ], + [ + Some( + "x", + ), + Some( + "y", + ), + ], + ), + ControlPoint(5), + ), + ControlPoint(7): Statement( + Clear( + temp{7}, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + Clear( + temp{6}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{5}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + AssignExpr( + q{1}, + p{0}.lease, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + AssignExpr( + r{2}, + q{1}.lease, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + AssignExpr( + temp{9}, + r{2}.x.give, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + AssignExpr( + temp{10}, + 1, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + AssignExpr( + temp{3}, + temp{9} + temp{10}, + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + Clear( + temp{10}, + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + Clear( + temp{9}, + ), + ControlPoint(17), + ), + ControlPoint(17): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-lease-20.dada", ), - ], - Assign( + 0, + ), + ControlPoint(18), + ), + ControlPoint(18): Statement( + AssignExpr( + r{2}.x, + temp{3}.give, + ), + ControlPoint(19), + ), + ControlPoint(19): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-lease-20.dada", + ), + 0, + Expr(14), + None, + ), + ControlPoint(20), + ), + ControlPoint(20): Statement( + AssignExpr( + temp{8}, + (), + ), + ControlPoint(21), + ), + ControlPoint(21): Statement( + Clear( + temp{8}, + ), + ControlPoint(22), + ), + ControlPoint(22): Statement( + AssignExpr( + temp{13}, + Print.share, + ), + ControlPoint(23), + ), + ControlPoint(23): Statement( + AssignExpr( + temp{14}, + p{0}.x.share, + ), + ControlPoint(25), + ), + ControlPoint(24): Statement( + Noop, + ControlPoint(26), + ), + ControlPoint(25): Assign( + temp{12}, + Call( + temp{13}, + [ + temp{14}, + ], + [ + None, + ], + ), + ControlPoint(24), + ), + ControlPoint(26): Statement( + Clear( + temp{14}, + ), + ControlPoint(27), + ), + ControlPoint(27): Statement( + Clear( + temp{13}, + ), + ControlPoint(29), + ), + ControlPoint(28): Statement( + Noop, + ControlPoint(30), + ), + ControlPoint(29): Assign( + temp{11}, + Await( temp{12}, - Call( - temp{13}, - [ - temp{14}, - ], - [ - None, - ], - ), - BasicBlock(2), ), + ControlPoint(28), ), - BasicBlock(2): BasicBlockData( - [ - ( - Clear( - temp{14}, - ), - Expr(17), - ), - ( - Clear( - temp{13}, - ), - Expr(15), - ), - ], - Assign( + ControlPoint(30): Statement( + Clear( + temp{12}, + ), + ControlPoint(31), + ), + ControlPoint(31): Statement( + Clear( temp{11}, - Await( - temp{12}, - ), - BasicBlock(3), ), + ControlPoint(32), ), - BasicBlock(3): BasicBlockData( - [ - ( - Clear( - temp{12}, - ), - Expr(18), - ), - ( - Clear( - temp{11}, - ), - Expr(19), - ), - ( - AssignExpr( - temp{4}, - (), - ), - Expr(20), - ), - ], - Return( + ControlPoint(32): Statement( + AssignExpr( temp{4}, + (), ), + ControlPoint(33), + ), + ControlPoint(33): Return( + temp{4}, ), }, ] \ No newline at end of file diff --git a/dada_tests/permissions/dyn_tutorial/tutorial-share-10/HeapGraph-0.bir.ref b/dada_tests/permissions/dyn_tutorial/tutorial-share-10/HeapGraph-0.bir.ref index 4edb3558..cf11ad21 100644 --- a/dada_tests/permissions/dyn_tutorial/tutorial-share-10/HeapGraph-0.bir.ref +++ b/dada_tests/permissions/dyn_tutorial/tutorial-share-10/HeapGraph-0.bir.ref @@ -1,142 +1,142 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{7}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{8}, - 22, + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{7}, + Class(Id { value: 1 }).share, + ), + ControlPoint(3), + ), + ControlPoint(3): Statement( + AssignExpr( + temp{8}, + 22, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{9}, + 44, + ), + ControlPoint(6), + ), + ControlPoint(5): Statement( + Noop, + ControlPoint(7), + ), + ControlPoint(6): Assign( + temp{6}, + Call( + temp{7}, + [ + temp{8}, + temp{9}, + ], + [ + Some( + "x", ), - Expr(1), - ), - ( - AssignExpr( - temp{9}, - 44, + Some( + "y", ), - Expr(2), - ), - ], - Assign( + ], + ), + ControlPoint(5), + ), + ControlPoint(7): Statement( + Clear( + temp{9}, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + Clear( + temp{8}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{7}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + AssignExpr( + p{0}, + temp{6}.share, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + Clear( temp{6}, - Call( - temp{7}, - [ - temp{8}, - temp{9}, - ], - [ - Some( - "x", - ), - Some( - "y", - ), - ], - ), - BasicBlock(1), ), + ControlPoint(12), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{9}, - ), - Expr(2), - ), - ( - Clear( - temp{8}, - ), - Expr(1), - ), - ( - Clear( - temp{7}, - ), - Expr(0), - ), - ( - AssignExpr( - p{0}, - temp{6}.share, - ), - Expr(4), + ControlPoint(12): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-share-10.dada", ), - ( - Clear( - temp{6}, - ), - Expr(3), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-share-10.dada", - ), - 0, - ), - Expr(7), - ), - ( - AssignExpr( - q{1}, - p{0}.share, - ), - Expr(6), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-share-10.dada", - ), - 0, - Expr(7), - None, - ), - Expr(7), - ), - ( - AssignExpr( - x{2}, - p{0}.x.share, - ), - Expr(9), - ), - ( - AssignExpr( - x{3}, - q{1}.x.share, - ), - Expr(12), - ), - ( - AssignExpr( - x{4}, - p{0}.x.share, - ), - Expr(15), - ), - ( - AssignExpr( - temp{5}, - (), - ), - Expr(17), - ), - ], - Return( + 0, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + AssignExpr( + q{1}, + p{0}.share, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-share-10.dada", + ), + 0, + Expr(7), + None, + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + AssignExpr( + x{2}, + p{0}.x.share, + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + AssignExpr( + x{3}, + q{1}.x.share, + ), + ControlPoint(17), + ), + ControlPoint(17): Statement( + AssignExpr( + x{4}, + p{0}.x.share, + ), + ControlPoint(18), + ), + ControlPoint(18): Statement( + AssignExpr( temp{5}, + (), ), + ControlPoint(19), + ), + ControlPoint(19): Return( + temp{5}, ), }, ] \ No newline at end of file diff --git a/dada_tests/permissions/dyn_tutorial/tutorial-share-20/HeapGraph-0.bir.ref b/dada_tests/permissions/dyn_tutorial/tutorial-share-20/HeapGraph-0.bir.ref index 3399c8f6..149a1c7f 100644 --- a/dada_tests/permissions/dyn_tutorial/tutorial-share-20/HeapGraph-0.bir.ref +++ b/dada_tests/permissions/dyn_tutorial/tutorial-share-20/HeapGraph-0.bir.ref @@ -1,137 +1,137 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - BreakpoingStart( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-share-20.dada", - ), - 0, - ), - Expr(15), - ), - ( - AssignExpr( - temp{6}, - Class(Id { value: 1 }).share, - ), - Expr(0), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-share-20.dada", ), - ( - AssignExpr( - temp{7}, - 22, + 0, + ), + ControlPoint(3), + ), + ControlPoint(3): Statement( + AssignExpr( + temp{6}, + Class(Id { value: 1 }).share, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{7}, + 22, + ), + ControlPoint(5), + ), + ControlPoint(5): Statement( + AssignExpr( + temp{8}, + 44, + ), + ControlPoint(7), + ), + ControlPoint(6): Statement( + Noop, + ControlPoint(8), + ), + ControlPoint(7): Assign( + temp{5}, + Call( + temp{6}, + [ + temp{7}, + temp{8}, + ], + [ + Some( + "x", ), - Expr(1), - ), - ( - AssignExpr( - temp{8}, - 44, + Some( + "y", ), - Expr(2), - ), - ], - Assign( + ], + ), + ControlPoint(6), + ), + ControlPoint(8): Statement( + Clear( + temp{8}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{7}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + Clear( + temp{6}, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + AssignExpr( + p{0}, + temp{5}.share, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + Clear( temp{5}, - Call( - temp{6}, - [ - temp{7}, - temp{8}, - ], - [ - Some( - "x", - ), - Some( - "y", - ), - ], - ), - BasicBlock(1), ), + ControlPoint(13), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{8}, - ), - Expr(2), - ), - ( - Clear( - temp{7}, - ), - Expr(1), - ), - ( - Clear( - temp{6}, - ), - Expr(0), - ), - ( - AssignExpr( - p{0}, - temp{5}.share, - ), - Expr(4), - ), - ( - Clear( - temp{5}, - ), - Expr(3), - ), - ( - AssignExpr( - q{1}, - p{0}.share, - ), - Expr(7), - ), - ( - AssignExpr( - r{2}, - q{1}.share, - ), - Expr(10), - ), - ( - AssignExpr( - s{3}, - r{2}.share, - ), - Expr(13), - ), - ( - AssignExpr( - temp{4}, - (), - ), - Expr(15), + ControlPoint(13): Statement( + AssignExpr( + q{1}, + p{0}.share, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + AssignExpr( + r{2}, + q{1}.share, + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + AssignExpr( + s{3}, + r{2}.share, + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + AssignExpr( + temp{4}, + (), + ), + ControlPoint(17), + ), + ControlPoint(17): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-share-20.dada", ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-share-20.dada", - ), - 0, - Expr(15), - Some( - temp{4}, - ), - ), - Expr(15), + 0, + Expr(15), + Some( + temp{4}, ), - ], - Return( - temp{4}, ), + ControlPoint(18), + ), + ControlPoint(18): Return( + temp{4}, ), }, ] \ No newline at end of file diff --git a/dada_tests/permissions/dyn_tutorial/tutorial-share-30/HeapGraph-0.bir.ref b/dada_tests/permissions/dyn_tutorial/tutorial-share-30/HeapGraph-0.bir.ref index 0445148a..1dc2d580 100644 --- a/dada_tests/permissions/dyn_tutorial/tutorial-share-30/HeapGraph-0.bir.ref +++ b/dada_tests/permissions/dyn_tutorial/tutorial-share-30/HeapGraph-0.bir.ref @@ -1,130 +1,130 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - BreakpoingStart( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-share-30.dada", - ), - 0, - ), - Expr(11), - ), - ( - AssignExpr( - temp{5}, - Class(Id { value: 1 }).share, - ), - Expr(0), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-share-30.dada", ), - ( - AssignExpr( - temp{6}, - 22, + 0, + ), + ControlPoint(3), + ), + ControlPoint(3): Statement( + AssignExpr( + temp{5}, + Class(Id { value: 1 }).share, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{6}, + 22, + ), + ControlPoint(5), + ), + ControlPoint(5): Statement( + AssignExpr( + temp{7}, + 44, + ), + ControlPoint(7), + ), + ControlPoint(6): Statement( + Noop, + ControlPoint(8), + ), + ControlPoint(7): Assign( + temp{4}, + Call( + temp{5}, + [ + temp{6}, + temp{7}, + ], + [ + Some( + "x", ), - Expr(1), - ), - ( - AssignExpr( - temp{7}, - 44, + Some( + "y", ), - Expr(2), - ), - ], - Assign( + ], + ), + ControlPoint(6), + ), + ControlPoint(8): Statement( + Clear( + temp{7}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{6}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + Clear( + temp{5}, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + AssignExpr( + p{0}, + temp{4}.share, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + Clear( temp{4}, - Call( - temp{5}, - [ - temp{6}, - temp{7}, - ], - [ - Some( - "x", - ), - Some( - "y", - ), - ], - ), - BasicBlock(1), ), + ControlPoint(13), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{7}, - ), - Expr(2), - ), - ( - Clear( - temp{6}, - ), - Expr(1), - ), - ( - Clear( - temp{5}, - ), - Expr(0), - ), - ( - AssignExpr( - p{0}, - temp{4}.share, - ), - Expr(4), - ), - ( - Clear( - temp{4}, - ), - Expr(3), - ), - ( - AssignExpr( - q{1}, - p{0}.give, - ), - Expr(7), - ), - ( - AssignExpr( - r{2}, - q{1}.share, - ), - Expr(9), - ), - ( - AssignExpr( - temp{3}, - (), - ), - Expr(11), + ControlPoint(13): Statement( + AssignExpr( + q{1}, + p{0}.give, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + AssignExpr( + r{2}, + q{1}.share, + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + AssignExpr( + temp{3}, + (), + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-share-30.dada", ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-share-30.dada", - ), - 0, - Expr(11), - Some( - temp{3}, - ), - ), - Expr(11), + 0, + Expr(11), + Some( + temp{3}, ), - ], - Return( - temp{3}, ), + ControlPoint(17), + ), + ControlPoint(17): Return( + temp{3}, ), }, ] \ No newline at end of file From 0f5b6d063aaf67933924eb2c18c6ef03b06b7c48 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sat, 28 Oct 2023 06:11:49 -0400 Subject: [PATCH 09/13] update BIR ref (why is this checked in?) --- .../tutorial-lease-30/HeapGraph-0.bir.ref | 330 +++++++++--------- 1 file changed, 165 insertions(+), 165 deletions(-) diff --git a/dada_tests/permissions/dyn_tutorial/tutorial-lease-30/HeapGraph-0.bir.ref b/dada_tests/permissions/dyn_tutorial/tutorial-lease-30/HeapGraph-0.bir.ref index 08ed4ee6..df3918da 100644 --- a/dada_tests/permissions/dyn_tutorial/tutorial-lease-30/HeapGraph-0.bir.ref +++ b/dada_tests/permissions/dyn_tutorial/tutorial-lease-30/HeapGraph-0.bir.ref @@ -1,175 +1,175 @@ [ bir::Bir { - start_basic_block: BasicBlock(0), - BasicBlock(0): BasicBlockData( - [ - ( - AssignExpr( - temp{6}, - Class(Id { value: 1 }).share, - ), - Expr(0), - ), - ( - AssignExpr( - temp{7}, - 22, - ), - Expr(1), - ), - ( - AssignExpr( - temp{8}, - 44, - ), - Expr(2), - ), - ], - Assign( - p{0}, - Call( - temp{6}, - [ - temp{7}, - temp{8}, - ], - [ - Some( - "x", - ), - Some( - "y", - ), - ], - ), - BasicBlock(1), + start_point: ControlPoint(1), + ControlPoint(1): Statement( + Noop, + ControlPoint(2), + ), + ControlPoint(2): Statement( + AssignExpr( + temp{6}, + Class(Id { value: 1 }).share, ), + ControlPoint(3), ), - BasicBlock(1): BasicBlockData( - [ - ( - Clear( - temp{8}, - ), - Expr(2), - ), - ( - Clear( - temp{7}, - ), - Expr(1), - ), - ( - Clear( - temp{6}, - ), - Expr(0), - ), - ( - AssignExpr( - q{1}, - p{0}.lease, - ), - Expr(6), - ), - ( - AssignExpr( - temp{10}, - q{1}.x.give, - ), - Expr(9), - ), - ( - AssignExpr( - temp{11}, - 1, - ), - Expr(10), - ), - ( - AssignExpr( - temp{2}, - temp{10} + temp{11}, - ), - Expr(11), - ), - ( - Clear( - temp{11}, - ), - Expr(10), - ), - ( - Clear( - temp{10}, - ), - Expr(9), - ), - ( - AssignExpr( - q{1}.x, - temp{2}.give, - ), - Expr(11), - ), - ( - AssignExpr( - temp{9}, - (), - ), - Expr(11), - ), - ( - Clear( - temp{9}, - ), - Expr(11), - ), - ( - BreakpoingStart( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-lease-30.dada", - ), - 0, - ), - Expr(14), - ), - ( - AssignExpr( - x{3}, - p{0}.x.share, - ), - Expr(13), - ), - ( - BreakpointEnd( - SourceFile( - "dada_tests/permissions/dyn_tutorial/tutorial-lease-30.dada", - ), - 0, - Expr(14), - None, - ), - Expr(14), - ), - ( - AssignExpr( - x{4}, - q{1}.x.share, - ), - Expr(16), - ), - ( - AssignExpr( - temp{5}, - (), - ), - Expr(18), + ControlPoint(3): Statement( + AssignExpr( + temp{7}, + 22, + ), + ControlPoint(4), + ), + ControlPoint(4): Statement( + AssignExpr( + temp{8}, + 44, + ), + ControlPoint(6), + ), + ControlPoint(5): Statement( + Noop, + ControlPoint(7), + ), + ControlPoint(6): Assign( + p{0}, + Call( + temp{6}, + [ + temp{7}, + temp{8}, + ], + [ + Some( + "x", + ), + Some( + "y", + ), + ], + ), + ControlPoint(5), + ), + ControlPoint(7): Statement( + Clear( + temp{8}, + ), + ControlPoint(8), + ), + ControlPoint(8): Statement( + Clear( + temp{7}, + ), + ControlPoint(9), + ), + ControlPoint(9): Statement( + Clear( + temp{6}, + ), + ControlPoint(10), + ), + ControlPoint(10): Statement( + AssignExpr( + q{1}, + p{0}.lease, + ), + ControlPoint(11), + ), + ControlPoint(11): Statement( + AssignExpr( + temp{10}, + q{1}.x.give, + ), + ControlPoint(12), + ), + ControlPoint(12): Statement( + AssignExpr( + temp{11}, + 1, + ), + ControlPoint(13), + ), + ControlPoint(13): Statement( + AssignExpr( + temp{2}, + temp{10} + temp{11}, + ), + ControlPoint(14), + ), + ControlPoint(14): Statement( + Clear( + temp{11}, + ), + ControlPoint(15), + ), + ControlPoint(15): Statement( + Clear( + temp{10}, + ), + ControlPoint(16), + ), + ControlPoint(16): Statement( + AssignExpr( + q{1}.x, + temp{2}.give, + ), + ControlPoint(17), + ), + ControlPoint(17): Statement( + AssignExpr( + temp{9}, + (), + ), + ControlPoint(18), + ), + ControlPoint(18): Statement( + Clear( + temp{9}, + ), + ControlPoint(19), + ), + ControlPoint(19): Statement( + BreakpoingStart( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-lease-30.dada", ), - ], - Return( + 0, + ), + ControlPoint(20), + ), + ControlPoint(20): Statement( + AssignExpr( + x{3}, + p{0}.x.share, + ), + ControlPoint(21), + ), + ControlPoint(21): Statement( + BreakpointEnd( + SourceFile( + "dada_tests/permissions/dyn_tutorial/tutorial-lease-30.dada", + ), + 0, + Expr(14), + None, + ), + ControlPoint(22), + ), + ControlPoint(22): Statement( + AssignExpr( + x{4}, + q{1}.x.share, + ), + ControlPoint(23), + ), + ControlPoint(23): Statement( + AssignExpr( temp{5}, + (), ), + ControlPoint(24), + ), + ControlPoint(24): Return( + temp{5}, ), }, ] \ No newline at end of file From c42f6b894c14bf3e1640c1aff48a445f6fbce533 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sat, 28 Oct 2023 06:11:33 -0400 Subject: [PATCH 10/13] explain why this approach did not work --- .../why_not_explicit_end_for_lease.md | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 book/docs/design_docs/why_not_explicit_end_for_lease.md diff --git a/book/docs/design_docs/why_not_explicit_end_for_lease.md b/book/docs/design_docs/why_not_explicit_end_for_lease.md new file mode 100644 index 00000000..172def56 --- /dev/null +++ b/book/docs/design_docs/why_not_explicit_end_for_lease.md @@ -0,0 +1,64 @@ +# Why not have an explicit end for lease? + +For a while I attempted to have an **explicit end** for every lease +rather than adopting the "stacked borrows"-like approach in which +leases are ended by their owner taking contrary action. + +In many ways, explicit ends of leases is a cleaner approach. +The difference is where the error occurs: + +``` +class Counter(counter) + +let x = Counter(0) + +// Create a lease of x +let y = x.lease + +// In the "explicit end" version, this is an error. +// In the "permissive" variant, it cancels the lease. +x.counter = 1 + +// In the "permissive" variant, error occurs here. +print(y.counter) +``` + +It's hard to say which of these statements is wrong. +Deferring the error until something has definitively gone wrong +is more permissive and hence the required approach for Rust's unsafe code +(which wants to be as backwards compatible with common practice as possible). +Dada's untyped mode is analogous to unsafe code, so that's plausibly a good choice here, +but I wanted to try the alternative. + +## Where it goes wrong + +To make things usable, you don't want to _EXPLICITLY_ end leases, +so we want to have some kind of _drop_ that is auto-inserted. +I imagined we would do this based on liveness information. +But that has a flaw: when you compute liveness, you see direct +uses of a variable, but not indirect. Consider this (correct) code: + +``` +class Counter(counter) +let x = Counter(0) +let y = x.lease // <-- last (direct) use of `x` +print(y.counter) +``` + +Liveness-based analysis would drop `x` immediately after the lease, +since it has no more direct uses. But that's not what we want. + +We could in principle say that when something is dropped, +it remains in scope until the leases end, +but that's basically GC. + +## Doing better requires type data + +We could do better if we took types into account, but gradual typing implies they may not be available. +Besides, that's getting pretty complex. + +## Implications for Rust + +I would like to have liveness-based drops for Rust, but this reveals the (obvious in hindsight) flaw: +we never know when raw pointers are out there. So unless we know that, or declare it UB in some way, +we can't promote drops earlier. From 6319a0b55102276af5039a31e1e1b79801f4a496 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sat, 28 Oct 2023 06:15:10 -0400 Subject: [PATCH 11/13] apply cargo fmt --- components/dada-parse/src/parser/ty.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/dada-parse/src/parser/ty.rs b/components/dada-parse/src/parser/ty.rs index 5cbbe9d0..105574bd 100644 --- a/components/dada-parse/src/parser/ty.rs +++ b/components/dada-parse/src/parser/ty.rs @@ -8,7 +8,9 @@ use super::{CodeParser, Parser, SpanFallover}; impl CodeParser<'_, '_> { /// Parse `: Ty`. pub(crate) fn parse_colon_ty(&mut self) -> Option { - let Some(colon_span) = self.eat_op(Op::Colon) else { return None }; + let Some(colon_span) = self.eat_op(Op::Colon) else { + return None; + }; let opt_ty = self.parse_ty(); if opt_ty.is_none() { self.error_at_current_token("expected type after `:`") @@ -68,7 +70,9 @@ impl CodeParser<'_, '_> { } pub(crate) fn disallow_perm_paths(&mut self, keyword: Keyword) { - let Some((span, _)) = self.delimited('{') else { return }; + let Some((span, _)) = self.delimited('{') else { + return; + }; self.error( span, format!("no paths are needed after the {keyword} permission"), @@ -77,7 +81,9 @@ impl CodeParser<'_, '_> { } pub(crate) fn parse_perm_paths(&mut self) -> Option { - let Some((span, token_tree)) = self.delimited('{') else { return None; }; + let Some((span, token_tree)) = self.delimited('{') else { + return None; + }; let mut parser = Parser::new(self.db, token_tree); let mut subparser = parser.code_parser(self.tables, self.spans); let paths = subparser.parse_only_paths(); From 6788b0103fd11e1bacd4413f9189e94c2703fb2f Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sat, 28 Oct 2023 06:17:36 -0400 Subject: [PATCH 12/13] fix some clippy warnings --- components/dada-brew/src/scope.rs | 10 +++++----- components/dada-execute/src/heap_graph/graphviz.rs | 12 ++++-------- components/dada-execute/src/machine.rs | 8 ++++---- components/dada-lang/src/test_harness.rs | 2 +- components/dada-parse/src/tokens.rs | 2 +- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/components/dada-brew/src/scope.rs b/components/dada-brew/src/scope.rs index a3203f85..ed8f3a9d 100644 --- a/components/dada-brew/src/scope.rs +++ b/components/dada-brew/src/scope.rs @@ -90,14 +90,14 @@ impl Scope<'_> { /// Creates a subscope with the given `cause` that shares the same start block but is now appending /// to `end_block`. It is your reponsibility to connect `end_block` (or some successor of it) back to /// `self.end_block` in this subscope. - pub(crate) fn subscope<'s>( - &'s self, + pub(crate) fn subscope( + &self, end_block: Option, cause: ScopeCause, - ) -> Scope<'s> { + ) -> Scope<'_> { Scope { start_block: self.start_block, - end_block: end_block, + end_block, cause, previous: Some(self), variables: vec![], @@ -167,7 +167,7 @@ impl Scope<'_> { pub(crate) fn push_declared_variables( &mut self, vars: &[validated::LocalVariable], - brewery: &mut Brewery<'_>, + brewery: &Brewery<'_>, ) -> VariableMarker { let marker = self.mark_variables(); for &v in vars { diff --git a/components/dada-execute/src/heap_graph/graphviz.rs b/components/dada-execute/src/heap_graph/graphviz.rs index 3ae853f8..2b187bd6 100644 --- a/components/dada-execute/src/heap_graph/graphviz.rs +++ b/components/dada-execute/src/heap_graph/graphviz.rs @@ -352,7 +352,7 @@ impl HeapGraph { if let Some(name) = name { w.permissions .entry(edge.permission) - .or_insert(vec![]) + .or_default() .push(GraphvizPlace { node: source.to_string(), port: index, @@ -400,7 +400,7 @@ impl HeapGraph { /// /// If there is no graph to diff against, return true, as everything /// is considered to have changed. - fn value_edge_did_change(&self, w: &mut GraphvizWriter<'_>, edge: ValueEdge) -> bool { + fn value_edge_did_change(&self, w: &GraphvizWriter<'_>, edge: ValueEdge) -> bool { let edge_data = edge.data(&self.tables); if self.permission_node_did_change(w, edge_data.permission) { @@ -414,11 +414,7 @@ impl HeapGraph { /// /// If there is no graph to diff against, return true, as everything /// is considered to have changed. - fn value_edge_target_did_change( - &self, - w: &mut GraphvizWriter<'_>, - edge: ValueEdgeTarget, - ) -> bool { + fn value_edge_target_did_change(&self, w: &GraphvizWriter<'_>, edge: ValueEdgeTarget) -> bool { let Some(diff_against) = w.diff_against else { return true; }; @@ -452,7 +448,7 @@ impl HeapGraph { /// is considered to have changed. fn permission_node_did_change( &self, - w: &mut GraphvizWriter<'_>, + w: &GraphvizWriter<'_>, permission: PermissionNode, ) -> bool { let Some(diff_against) = w.diff_against else { diff --git a/components/dada-execute/src/machine.rs b/components/dada-execute/src/machine.rs index 3b23bfcd..4975136f 100644 --- a/components/dada-execute/src/machine.rs +++ b/components/dada-execute/src/machine.rs @@ -469,10 +469,10 @@ impl ProgramCounter { /// True if this PC represents a `return` terminator. pub fn is_return(&self, db: &dyn crate::Db) -> bool { let bir_data = self.bir.data(db); - match &bir_data.tables[self.control_point] { - bir::ControlPointData::Terminator(TerminatorData::Return(_)) => true, - _ => false, - } + matches!( + &bir_data.tables[self.control_point], + bir::ControlPointData::Terminator(TerminatorData::Return(_)), + ) } pub fn span(&self, db: &dyn crate::Db) -> FileSpan { diff --git a/components/dada-lang/src/test_harness.rs b/components/dada-lang/src/test_harness.rs index dd35a44f..90884d1c 100644 --- a/components/dada-lang/src/test_harness.rs +++ b/components/dada-lang/src/test_harness.rs @@ -820,7 +820,7 @@ fn expected_diagnostics(path: &Path) -> eyre::Result { } if let Some(any_line) = any_output_marker_seen { - if let Some(o) = output.get(0) { + if let Some(o) = output.first() { eyre::bail!( "both 'OUTPUT ANY' (on line {}) and specific output (e.g. on line {}) found", any_line, diff --git a/components/dada-parse/src/tokens.rs b/components/dada-parse/src/tokens.rs index f2571b9d..ae361a80 100644 --- a/components/dada-parse/src/tokens.rs +++ b/components/dada-parse/src/tokens.rs @@ -108,7 +108,7 @@ impl<'me> Tokens<'me> { /// Span of the next pending token (or last span if there are no more tokens). pub(crate) fn peek_span(&self) -> Span { - match self.tokens.get(0) { + match self.tokens.first() { None => self.last_span, Some(token) => { let len = token.span_len(self.db); From 382f6d1a9fa725e177696bf756fab402b77958a1 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sat, 28 Oct 2023 06:41:50 -0400 Subject: [PATCH 13/13] add explanation to sidebar --- book/sidebars.js | 1 + 1 file changed, 1 insertion(+) diff --git a/book/sidebars.js b/book/sidebars.js index c9758568..47a39bc2 100644 --- a/book/sidebars.js +++ b/book/sidebars.js @@ -63,6 +63,7 @@ const sidebars = { "design_docs/calculus", "design_docs/sketchy_ideas", "design_docs/sharing_synthesized_values", + "design_docs/why_not_explicit_end_for_lease", "reference", ], },