Stdlib compiled once per flag setting (the flag changes its codegen too). Each module is its own object (no source concatenation).
(regalloc: bool)
| 14 | // Stdlib compiled once per flag setting (the flag changes its codegen too). |
| 15 | // Each module is its own object (no source concatenation). |
| 16 | fn cached_stdlib_objs(regalloc: bool) -> &'static [(String, AssembledOutput)] { |
| 17 | static STDLIB_OFF: OnceLock<Vec<(String, AssembledOutput)>> = OnceLock::new(); |
| 18 | static STDLIB_ON: OnceLock<Vec<(String, AssembledOutput)>> = OnceLock::new(); |
| 19 | let cell = if regalloc { &STDLIB_ON } else { &STDLIB_OFF }; |
| 20 | cell.get_or_init(|| { |
| 21 | let mut pipeline = CompilationPipeline::new(); |
| 22 | pipeline.set_write_artifacts(false); |
| 23 | pipeline.set_register_allocation(regalloc); |
| 24 | let modules = get_stdlib_modules_for_mode(TargetMode::Hosted); |
| 25 | let objects = pipeline |
| 26 | .compile_modules(&modules) |
| 27 | .expect("stdlib compile failed"); |
| 28 | modules |
| 29 | .into_iter() |
| 30 | .map(|(name, _)| name.to_owned()) |
| 31 | .zip(objects) |
| 32 | .collect() |
| 33 | }) |
| 34 | } |
| 35 | |
| 36 | // Returns the VM outcome, UART output, emitted user-code instruction count, |
| 37 | // and executed cycles. |
| 38 | fn run_with_regalloc(src: &str, regalloc: bool) -> (RunOutcome, String, usize, u64) { |
| 39 | let mut pipeline = CompilationPipeline::new(); |
| 40 | pipeline.set_write_artifacts(false); |