From bfcbd93036fe87a7b6776b146811bde1d70fac90 Mon Sep 17 00:00:00 2001 From: Morgan Thomas Date: Tue, 28 Oct 2025 13:42:41 +0000 Subject: [PATCH] issue/83: function-level memory profiling --- .../src/b_compile_intermediate.rs | 42 +++- crates/lean_compiler/src/c_compile_final.rs | 43 +++- crates/lean_compiler/src/ir/bytecode.rs | 18 +- crates/lean_compiler/src/ir/mod.rs | 2 +- crates/lean_vm/src/core/constants.rs | 2 +- crates/lean_vm/src/core/types.rs | 3 + crates/lean_vm/src/diagnostics/error.rs | 2 + crates/lean_vm/src/diagnostics/profiler.rs | 235 +++++++++++++++++- crates/lean_vm/src/execution/runner.rs | 37 ++- crates/lean_vm/src/isa/hint.rs | 58 ++++- crates/lean_vm/tests/test_lean_vm.rs | 4 + crates/poseidon_circuit/src/tests.rs | 2 +- crates/rec_aggregation/src/recursion.rs | 2 +- crates/rec_aggregation/src/xmss_aggregate.rs | 2 +- 14 files changed, 412 insertions(+), 40 deletions(-) diff --git a/crates/lean_compiler/src/b_compile_intermediate.rs b/crates/lean_compiler/src/b_compile_intermediate.rs index 92818757..cffa8f45 100644 --- a/crates/lean_compiler/src/b_compile_intermediate.rs +++ b/crates/lean_compiler/src/b_compile_intermediate.rs @@ -10,7 +10,7 @@ use utils::ToUsize; #[derive(Default)] struct Compiler { bytecode: BTreeMap>, - match_blocks: Vec>>, // each match = many bytecode blocks, each bytecode block = many instructions + match_blocks: Vec, if_counter: usize, call_counter: usize, func_name: String, @@ -152,10 +152,17 @@ fn compile_function( compiler.args_count = function.arguments.len(); let mut declared_vars: BTreeSet = function.arguments.iter().cloned().collect(); - compile_lines(&function.instructions, compiler, None, &mut declared_vars) + compile_lines( + &Label::function(function.name.clone()), + &function.instructions, + compiler, + None, + &mut declared_vars, + ) } fn compile_lines( + function_name: &Label, lines: &[SimpleLine], compiler: &mut Compiler, final_jump: Option