MCPcopy Create free account
hub / github.com/IntegralPilot/rustc_codegen_jvm / lower_closure_to_oomir

Function lower_closure_to_oomir

src/lib.rs:62–133  ·  view source on GitHub ↗

Helper function to lower a closure definition to OOMIR This function is called when we encounter a closure call and need to ensure the closure's implementation is available in the OOMIR module.

(
    tcx: TyCtxt<'tcx>,
    closure_def_id: rustc_hir::def_id::DefId,
    oomir_module: &mut oomir::Module,
)

Source from the content-addressed store, hash-verified

60use oomir::Type;
61use rustc_codegen_ssa::back::archive::{ArArchiveBuilder, ArchiveBuilder, ArchiveBuilderBuilder};
62use rustc_codegen_ssa::{
63 CompiledModule, CompiledModules, CrateInfo, ModuleKind, traits::CodegenBackend,
64};
65use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet};
66use rustc_hir::def::DefKind;
67use std::collections::VecDeque;
68
69use rustc_data_structures::unord::UnordMap;
70use rustc_metadata::EncodedMetadata;
71use rustc_middle::{
72 dep_graph::{WorkProduct, WorkProductId},
73 mono::MonoItem,
74 ty::{
75 EarlyBinder, GenericArgs, Instance, InstanceKind, ShimKind, TyCtxt, TyKind,
76 TypeVisitableExt, TypingEnv, Unnormalized, VtblEntry,
77 },
78};
79use rustc_session::{
80 IncrCompSession, Session,
81 config::OutputFilenames,
82};
83use rustc_span::def_id::{DefId, LOCAL_CRATE};
84use rustc_structures::CrateType;
85use std::{
86 any::Any,
87 io::{BufReader, BufWriter, Read, Write},
88 path::{Path, PathBuf},
89 sync::{Arc, Mutex, mpsc},
90};
91
92mod instrumentation;
93mod lower1;
94mod lower2;
95mod oomir;
96mod optimise1;
97mod stable_hash;
98
99/// An instance of our Java bytecode codegen backend.
100struct MyBackend;
101
102/// Rustc's codegen-unit partitioning is tuned for native backends which lower
103/// functions into independently owned LLVM modules. Keep each OOMIR shard
104/// bounded as a second line of defence for unusually large codegen units.
105const MAX_MONO_ITEMS_PER_OOMIR_SHARD: usize = 256;
106// Four lower2 workers usefully saturate large crates without retaining an
107// unbounded number of prepared OOMIR modules on many-core hosts.
108const MAX_CODEGEN_WORKERS: usize = 4;
109const OOMIR_SHARD_QUEUE_DEPTH: usize = 1;
110const CLASS_BUNDLE_MAGIC: &[u8; 8] = b"RCJVMB1\0";
111
112fn combine_class_bundles(path: &Path, bundles: &[(String, PathBuf)]) -> std::io::Result<()> {
113 let mut output = BufWriter::new(std::fs::File::create(path)?);
114 output.write_all(CLASS_BUNDLE_MAGIC)?;
115 for (_, bundle_path) in bundles {
116 let mut bundle = BufReader::new(std::fs::File::open(bundle_path)?);
117 let mut magic = [0u8; CLASS_BUNDLE_MAGIC.len()];
118 bundle.read_exact(&mut magic)?;
119 if &magic != CLASS_BUNDLE_MAGIC {

Callers 1

codegen_crateMethod · 0.85

Calls 5

mir_to_oomirFunction · 0.85
get_functionMethod · 0.80
insert_functionMethod · 0.80
merge_data_typesMethod · 0.80

Tested by

no test coverage detected