Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changes/three-trees-t6u.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Seal the lowered program in the naming replay: the walk applies the flatten
rules to each statement it takes out of a list, and check mode no longer runs
the flatten pass on the new side.
4 changes: 4 additions & 0 deletions compiler-rust/src/bir/lower/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2265,6 +2265,10 @@ mod tests {
let mut a = a;
let mut compiler = LambdaCompiler::new();
let before = compiler.bir_export_oracle(&mut a, root);
// The lowering's statements are flattened by the seal: the legacy
// program is compared after its flatten pass, and the lowering's
// program runs the passes after it, as the gate does.
let before = crate::lambda::js_pass_flatten_and_mark_dead::apply_js_flatten_pass(before);
let text = print(&before);
assert_eq!(print(&new_before), text, "before the passes");
let after = compiler.bir_passes_oracle(before);
Expand Down
3 changes: 3 additions & 0 deletions compiler-rust/src/bir/lower/ffi_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,9 @@ mod tests {
modules: vec![],
side_effect: None,
};
// The seal flattens the lowering's statements in the replay's
// walk: the legacy program is compared after its flatten pass.
let expected = crate::lambda::js_pass_flatten_and_mark_dead::apply_js_flatten_pass(expected);
let print = |p: &JsDepsProgram| {
crate::js_ir::print_deps_program_with_directives_and_options(
p,
Expand Down
7 changes: 5 additions & 2 deletions compiler-rust/src/bir/lower/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,11 @@ fn simple_element<B: Js>(js: &B, a: &Pools, idents: &[Ident], item: B::Ref<'_>)
/// node of the element it reads, up to the first that is none. A loop
/// over the options and blocks that are open, innermost last, each with
/// the operand to read next: no recursion, and no allocation for an
/// element that nests at most eight deep (a deeper one spills the stack
/// once).
/// element that nests at most eight deep. The stack is the call's own
/// (a local of eight entries, not a scratch of the walk), so an element
/// that nests deeper allocates once in every call that reads it, and
/// frees it at the call's end. It is called for the elements of a block
/// declaration in a unit that has an underscored global only.
fn deep_constant<'r, B: Js>(js: &B, a: &'r Pools, item: B::Ref<'r>, steps: &mut usize) -> bool {
let mut open: smallvec::SmallVec<[(B::Ref<'r>, u32); 8]> = smallvec::SmallVec::new();
let mut next = Some(item);
Expand Down
6 changes: 6 additions & 0 deletions compiler-rust/src/bir/lower/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ mod globals;
pub mod js;
pub mod js_stmt;
pub(crate) mod names;
pub(crate) mod seal;
mod expr;
mod konst;
mod prim;
Expand Down Expand Up @@ -330,6 +331,9 @@ pub(crate) struct SwitchStats {
/// when the pass does not support the unit.
pub names_compared: usize,
pub names_uncompared: usize,
/// What the seal of the replay's walk rewrote, per rule.
#[serde(flatten)]
pub sealed: seal::Sealed,
}

/// The decisions of step A (`close::decide`) compared with those of the
Expand Down Expand Up @@ -847,6 +851,7 @@ impl<B: js_stmt::JsStmt> State<'_, B> {
globals::decide(&mut self.arena, &self.idents);
let mut printed = crate::emit::Printed::default();
let (replayed, name_imports) = self.replay_names(&mut block, &mut printed);
let sealed = self.names.sealed();
debug_assert_eq!(self.js.stmt_id(&self.arena, &block), root.0, "the root keeps its id through the replay");
let (adopted_nodes, name_log_steps) = self.arena.js_scope.as_ref()
.map_or((0, 0), |scope| (scope.names.adopted_nodes, scope.names.steps));
Expand Down Expand Up @@ -876,6 +881,7 @@ impl<B: js_stmt::JsStmt> State<'_, B> {
name_replay_steps: replayed.steps(),
names_compared: 0,
names_uncompared: 0,
sealed,
},
printed,
name_imports,
Expand Down
Loading
Loading