diff --git a/src/host/encode_def.rs b/src/host/encode_def.rs index 5e9706c9..106e6d18 100644 --- a/src/host/encode_def.rs +++ b/src/host/encode_def.rs @@ -1,3 +1,5 @@ +use crate::util::maybe_grow; + use super::*; /// Converts an ast net to a list of instructions to create the net. @@ -54,7 +56,7 @@ pub(crate) fn ast_net_to_instructions Port>(net: &Net, get_def self.visit_tree(tree, trg); } fn visit_tree(&mut self, tree: &'a Tree, trg: TrgId) { - match tree { + maybe_grow(move || match tree { Tree::Era => { self.instr.push(Instruction::LinkConst { trg, port: Port::ERA }); } @@ -100,7 +102,7 @@ pub(crate) fn ast_net_to_instructions Port>(net: &Net, get_def self.visit_tree(sel, l); self.visit_tree(ret, r); } - } + }) } } } diff --git a/src/main.rs b/src/main.rs index 2f7c2fab..1acba438 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,7 +33,7 @@ fn main() { compile_executable(output, &host.lock().unwrap()).unwrap(); } CliMode::Run { run_opts, mut transform_opts, file, args } => { - // Don't pre-reduce the main reduction + // Don't pre-reduce the entry point transform_opts.pre_reduce_skip.push(args.entry_point.clone()); let host = create_host(&load_book(&[file], &transform_opts)); run(&host.lock().unwrap(), run_opts, args); @@ -285,6 +285,7 @@ fn load_book(files: &[String], transform_opts: &TransformOpts) -> Book { acc }); let transform_passes = TransformPass::passes_from_cli(&transform_opts.transform_passes); + if transform_passes.pre_reduce { book.pre_reduce( &|x| transform_opts.pre_reduce_skip.iter().any(|y| x == y), diff --git a/src/run.rs b/src/run.rs index f003fc4d..ae0790cd 100644 --- a/src/run.rs +++ b/src/run.rs @@ -136,8 +136,8 @@ impl AtomicRewrites { } } -impl, U> Add for Rewrites { - type Output = Rewrites; +impl Add for Rewrites { + type Output = Rewrites; fn add(self, rhs: Self) -> Self::Output { Rewrites { diff --git a/src/transform/pre_reduce.rs b/src/transform/pre_reduce.rs index 1f0f3a98..1cb74e3f 100644 --- a/src/transform/pre_reduce.rs +++ b/src/transform/pre_reduce.rs @@ -1,4 +1,18 @@ -//! Reduce the solving any annihilations and commutations. +//! Reduce the nets in the book, to avoid repeating work at runtime. +//! +//! Here's how it works: +//! - Each definition is visited in topological order (dependencies before +//! dependents). In the case of cycles, one will be arbitrarily selected to be +//! first. +//! - The definition is reduced in a [`run::Net`] +//! - The reduced [`run::Net`] is readback into an [`ast::Net`] +//! - The [`ast::Net`] is encoded into a [`Vec`] +//! - The [`ast::Net`] is stored in the [`State`], as it will be used later. +//! - The [`InterpretedDef`] corresponding to the definition is mutated in-place +//! and its instructions are replaced with the generated [`Vec`] +//! +//! At the end, each mutated [`ast::Net`] is placed into the [`Book`], +//! overriding the previous one. use std::{ collections::HashMap, @@ -77,20 +91,6 @@ impl run::AsDef for InertDef { } /// State of the pre-reduction algorithm. -/// -/// Here's how it works: -/// - Each definition is visited in topological order (dependencies before -/// dependents). In the case of cycles, one will be arbitrarily selected to be -/// first. -/// - The definition is reduced in a [`run::Net`] -/// - The reduced [`run::Net`] is readback into an [`ast::Net`] -/// - The [`ast::Net`] is encoded into a [`Vec`] -/// - The [`ast::Net`] is stored in the [`State`], as it will be used later. -/// - The [`InterpretedDef`] corresponding to the definition is mutated in-place -/// and its instructions are replaced with the generated [`Vec`] -/// -/// At the end, each mutated [`ast::Net`] is placed into the [`Book`], -/// overriding the previous one. struct State<'a> { book: &'a Book, @@ -131,6 +131,7 @@ impl<'a> State<'a> { if self.seen.contains_key(nam) || (self.skip)(nam) || self.book.get(nam).is_none() { return; } + self.seen.insert(nam.to_owned(), SeenState::Cycled); // First, pre-reduce all nets referenced by this net by walking the tree self.visit_net(self.book.get(nam).unwrap()); @@ -143,7 +144,7 @@ impl<'a> State<'a> { self.rewrites += rt.rwts; // Move interactions with inert defs back into the net redexes array - rt.redexes.extend(core::mem::take::>(self.captured_redexes.lock().unwrap().as_mut()).into_iter()); + rt.redexes.extend(self.captured_redexes.lock().unwrap().drain(..)); let net = self.host.readback(&mut rt); diff --git a/tests/snapshots/tests__pre_reduce_run@alloc_big_tree.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@alloc_big_tree.hvmc.snap index a3a9e835..6a54f38f 100644 --- a/tests/snapshots/tests__pre_reduce_run@alloc_big_tree.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@alloc_big_tree.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 20_495 - DREF : 43 - OPER : 0 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@alloc_small_tree.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@alloc_small_tree.hvmc.snap index 63df753d..80a139e4 100644 --- a/tests/snapshots/tests__pre_reduce_run@alloc_small_tree.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@alloc_small_tree.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 114 - DREF : 40 - OPER : 0 run: -RWTS : 2 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 2 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@arithmetic.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@arithmetic.hvmc.snap index 3ff941f6..f9ecab18 100644 --- a/tests/snapshots/tests__pre_reduce_run@arithmetic.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@arithmetic.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 12 - DREF : 8 - OPER : 0 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@chained_ops.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@chained_ops.hvmc.snap index c8d44375..460bd505 100644 --- a/tests/snapshots/tests__pre_reduce_run@chained_ops.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@chained_ops.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 47 - DREF : 1 - OPER : 40 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@church_encoding__church.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@church_encoding__church.hvmc.snap index c3e9dc2f..b8effcda 100644 --- a/tests/snapshots/tests__pre_reduce_run@church_encoding__church.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@church_encoding__church.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 44 - DREF : 18 - OPER : 0 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@church_exp.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@church_exp.hvmc.snap index a41b3e87..75cb5f9f 100644 --- a/tests/snapshots/tests__pre_reduce_run@church_exp.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@church_exp.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 857 - DREF : 76 - OPER : 0 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@church_mul.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@church_mul.hvmc.snap index 77aa8645..d744e724 100644 --- a/tests/snapshots/tests__pre_reduce_run@church_mul.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@church_mul.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 50 - DREF : 6 - OPER : 0 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@dec_bits.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@dec_bits.hvmc.snap index 12bdd0b1..662ad4a6 100644 --- a/tests/snapshots/tests__pre_reduce_run@dec_bits.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@dec_bits.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 71_716 - DREF : 10_301 - OPER : 0 run: -RWTS : 2 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 2 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@dec_bits_tree.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@dec_bits_tree.hvmc.snap index 9a0ade36..9383d948 100644 --- a/tests/snapshots/tests__pre_reduce_run@dec_bits_tree.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@dec_bits_tree.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 18_916 - DREF : 2_763 - OPER : 0 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@heavy_pre_reduction.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@heavy_pre_reduction.hvmc.snap index fbe82751..3dfe8783 100644 --- a/tests/snapshots/tests__pre_reduce_run@heavy_pre_reduction.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@heavy_pre_reduction.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 53_148 - DREF : 55 - OPER : 0 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@lambda_calculus__hoas.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@lambda_calculus__hoas.hvmc.snap index 909d445f..9b18bda8 100644 --- a/tests/snapshots/tests__pre_reduce_run@lambda_calculus__hoas.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@lambda_calculus__hoas.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 805 - DREF : 213 - OPER : 0 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@list_put_got.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@list_put_got.hvmc.snap index 02c6d3be..31af1588 100644 --- a/tests/snapshots/tests__pre_reduce_run@list_put_got.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@list_put_got.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 774 - DREF : 657 - OPER : 0 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@log.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@log.hvmc.snap index cad45ca9..e9173c76 100644 --- a/tests/snapshots/tests__pre_reduce_run@log.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@log.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 2 - DREF : 2 - OPER : 0 run: -RWTS : 7 +RWTS : 3 - ANNI : 2 - COMM : 0 - ERAS : 1 -- DREF : 4 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@machine_u32__num_add.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@machine_u32__num_add.hvmc.snap index 863719be..dff155c6 100644 --- a/tests/snapshots/tests__pre_reduce_run@machine_u32__num_add.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@machine_u32__num_add.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 7 - DREF : 3 - OPER : 2 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@machine_u32__num_match.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@machine_u32__num_match.hvmc.snap index 301aedf3..5821d4c9 100644 --- a/tests/snapshots/tests__pre_reduce_run@machine_u32__num_match.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@machine_u32__num_match.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 8 - DREF : 3 - OPER : 1 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@neg_fusion.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@neg_fusion.hvmc.snap index 7214fc69..ebb67258 100644 --- a/tests/snapshots/tests__pre_reduce_run@neg_fusion.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@neg_fusion.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 160 - DREF : 39 - OPER : 0 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@queue.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@queue.hvmc.snap index 7d1dd289..f2e45410 100644 --- a/tests/snapshots/tests__pre_reduce_run@queue.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@queue.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 63 - DREF : 19 - OPER : 0 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@sort__bitonic__bitonic_sort_lam.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@sort__bitonic__bitonic_sort_lam.hvmc.snap index d7e2253c..0b290218 100644 --- a/tests/snapshots/tests__pre_reduce_run@sort__bitonic__bitonic_sort_lam.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@sort__bitonic__bitonic_sort_lam.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 1_623_642 - DREF : 209_486 - OPER : 151_031 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@sort__merge__merge_sort.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@sort__merge__merge_sort.hvmc.snap index de233b98..bb62a082 100644 --- a/tests/snapshots/tests__pre_reduce_run@sort__merge__merge_sort.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@sort__merge__merge_sort.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 454 - DREF : 43 - OPER : 25 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@sort__radix__radix_sort_lam.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@sort__radix__radix_sort_lam.hvmc.snap index 46d031c7..b9c70b8f 100644 --- a/tests/snapshots/tests__pre_reduce_run@sort__radix__radix_sort_lam.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@sort__radix__radix_sort_lam.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 1_167_065_250 - DREF : 171_966_556 - OPER : 92_274_713 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@stress_tests__all_tree.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@stress_tests__all_tree.hvmc.snap index 52b9ac3f..889ea2cf 100644 --- a/tests/snapshots/tests__pre_reduce_run@stress_tests__all_tree.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@stress_tests__all_tree.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 503_316_491 - DREF : 50_331_667 - OPER : 33_554_431 run: -RWTS : 2 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 2 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@stress_tests__apelacion.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@stress_tests__apelacion.hvmc.snap index 90a01264..f8c29751 100644 --- a/tests/snapshots/tests__pre_reduce_run@stress_tests__apelacion.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@stress_tests__apelacion.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 34_000_727 - DREF : 5_000_075 - OPER : 9_000_256 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@stress_tests__boom.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@stress_tests__boom.hvmc.snap index 15bca358..2019b657 100644 --- a/tests/snapshots/tests__pre_reduce_run@stress_tests__boom.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@stress_tests__boom.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 134_217_925 - DREF : 16_777_258 - OPER : 0 run: -RWTS : 2 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 2 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@stress_tests__burn.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@stress_tests__burn.hvmc.snap index 8e82f1c2..f961ce47 100644 --- a/tests/snapshots/tests__pre_reduce_run@stress_tests__burn.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@stress_tests__burn.hvmc.snap @@ -3,7 +3,7 @@ source: tests/tests.rs expression: output input_file: tests/programs/stress_tests/burn.hvmc --- -(((@brnZ @brnZ) ((* @E) (* @E))) (((* @E) (* @E)) ((* @E) (* @E)))) +(((@brnZ @brnZ) (@brnZ @brnZ)) ((@brnZ @brnZ) (@brnZ @brnZ))) pre-reduce: RWTS : 18_350_176 - ANNI : 10_485_759 @@ -12,9 +12,9 @@ RWTS : 18_350_176 - DREF : 2_621_512 - OPER : 0 run: -RWTS : 7 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 7 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@stress_tests__fib_rec.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@stress_tests__fib_rec.hvmc.snap index fe5a8148..ba2595b9 100644 --- a/tests/snapshots/tests__pre_reduce_run@stress_tests__fib_rec.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@stress_tests__fib_rec.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 30_374_931 - DREF : 4_356_625 - OPER : 7_563_381 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@stress_tests__sum_rec.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@stress_tests__sum_rec.hvmc.snap index 7662f9a0..d494edbe 100644 --- a/tests/snapshots/tests__pre_reduce_run@stress_tests__sum_rec.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@stress_tests__sum_rec.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 738_197_509 - DREF : 67_108_871 - OPER : 268_435_453 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@stress_tests__sum_tail.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@stress_tests__sum_tail.hvmc.snap index 9ca7b77f..21db27f3 100644 --- a/tests/snapshots/tests__pre_reduce_run@stress_tests__sum_tail.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@stress_tests__sum_tail.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 100_000_011 - DREF : 10_000_005 - OPER : 30_000_001 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@stress_tests__sum_tree.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@stress_tests__sum_tree.hvmc.snap index b167b580..23758f50 100644 --- a/tests/snapshots/tests__pre_reduce_run@stress_tests__sum_tree.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@stress_tests__sum_tree.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 452_984_844 - DREF : 33_554_449 - OPER : 67_108_861 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@stress_tests__tuple_rots.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@stress_tests__tuple_rots.hvmc.snap index b4f90d9b..91e2d6b1 100644 --- a/tests/snapshots/tests__pre_reduce_run@stress_tests__tuple_rots.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@stress_tests__tuple_rots.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 40_000_036 - DREF : 6_000_012 - OPER : 2_000_001 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/snapshots/tests__pre_reduce_run@very_large.hvmc.snap b/tests/snapshots/tests__pre_reduce_run@very_large.hvmc.snap index 77f0ca75..d449791d 100644 --- a/tests/snapshots/tests__pre_reduce_run@very_large.hvmc.snap +++ b/tests/snapshots/tests__pre_reduce_run@very_large.hvmc.snap @@ -12,9 +12,9 @@ RWTS : 1 - DREF : 1 - OPER : 0 run: -RWTS : 1 +RWTS : 0 - ANNI : 0 - COMM : 0 - ERAS : 0 -- DREF : 1 +- DREF : 0 - OPER : 0 diff --git a/tests/tests.rs b/tests/tests.rs index 29fbcab0..3b2fc2f6 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -94,10 +94,14 @@ fn test_pre_reduce_run(path: &str, mut book: Book) { let pre_stats = book.pre_reduce(&|_| false, 1 << 29, u64::MAX); let host = hvmc::stdlib::create_host(&book); - let Some((rwts, net)) = execute_host(host) else { + let Some((mut rwts, net)) = execute_host(host) else { assert_snapshot!(show_rewrites(&pre_stats.rewrites)); return; }; + // Don't take into account deref rewrites + // because expand() is terrible. + // Remove when #73 is merged. + rwts.dref = 0; let output = format!("{}\npre-reduce:\n{}run:\n{}", net, show_rewrites(&pre_stats.rewrites), show_rewrites(&rwts)); assert_snapshot!(output);