MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / cached_stdlib_objs

Function cached_stdlib_objs

tests/integration/regalloc.rs:16–37  ·  view source on GitHub ↗

Stdlib compiled once per flag setting (the flag changes its codegen too). Each module is its own object (no source concatenation).

(regalloc: bool)

Source from the content-addressed store, hash-verified

14// Stdlib compiled once per flag setting (the flag changes its codegen too).
15// Each module is its own object (no source concatenation).
16fn 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.
38fn run_with_regalloc(src: &str, regalloc: bool) -> (RunOutcome, String, usize, u64) {
39 let mut pipeline = CompilationPipeline::new();
40 pipeline.set_write_artifacts(false);

Callers 2

run_with_regallocFunction · 0.70

Calls 9

get_stdlib_type_preludeFunction · 0.85
set_write_artifactsMethod · 0.80
collectMethod · 0.80
assemble_namedMethod · 0.80
set_type_preludeMethod · 0.45
compileMethod · 0.45