Closed
Description
Right now TypingMode
has a size of 16 bytes, which, given that we use it a lot of queries and in the global trait solver caches, results in a small, but noticeable perf cost. We should be able to convert it use a tagged pointer instead, copying the impl of GenericArg
struct TypingMode<'tcx> {
ptr: NonNull<()>,
marker: PhantomData<&'tcx ty::List<DefId>>,
}
enum TypingModeKind<'tcx> {
Coherence,
Analysis {
defining_opaque_types: I::DefiningOpaqueTypes,
},
PostAnalysis,
}
impl<'tcx> TypingModeKind<'tcx> {
fn pack(self) -> TypingMode<'tcx> {
match self {
Coherence => TypingMode { ptr: 0x1 },
PostAnalysis => TypingMode { ptr: 0x2 },
Analysis { defining_opaque_types } => TypingMode { ptr: defining_opaque_types },
}
}
}