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 pipeline.set_type_prelude(get_stdlib_type_prelude());
25 get_stdlib_modules_for_mode(TargetMode::Hosted)
26 .iter()
27 .map(|(name, src)| {
28 let r = pipeline.compile(src).expect("stdlib compile failed");
29 let (_, tokens) = pipeline.compile_ir_to_assembly_with_tokens(&r.ir_program);
30 let obj = pipeline
31 .assemble_named(name, &tokens)
32 .expect("stdlib assemble failed");
33 ((*name).to_owned(), obj)
34 })
35 .collect()
36 })
37}
38
39// Returns the VM outcome, UART output, emitted user-code instruction count,
40// and executed cycles.

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