Skip to content

Commit 69130fb

Browse files
authored
Unrolled build for #155666
Rollup merge of #155666 - nnethercote:interning-cleanups, r=mejrs Interning cleanups Details in individual commits. r? @JohnTitor
2 parents 44860d3 + d06d50c commit 69130fb

1 file changed

Lines changed: 17 additions & 15 deletions

File tree

compiler/rustc_middle/src/ty/context.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,15 @@ pub struct CtxtInterners<'tcx> {
161161

162162
impl<'tcx> CtxtInterners<'tcx> {
163163
fn new(arena: &'tcx WorkerLocal<Arena<'tcx>>) -> CtxtInterners<'tcx> {
164-
// Default interner size - this value has been chosen empirically, and may need to be adjusted
165-
// as the compiler evolves.
164+
// Default interner size - this value has been chosen empirically, and may need to be
165+
// adjusted as the compiler evolves.
166166
const N: usize = 2048;
167167
CtxtInterners {
168168
arena,
169-
// The factors have been chosen by @FractalFir based on observed interner sizes, and local perf runs.
170-
// To get the interner sizes, insert `eprintln` printing the size of the interner in functions like `intern_ty`.
171-
// Bigger benchmarks tend to give more accurate ratios, so use something like `x perf eprintln --includes cargo`.
169+
// The factors have been chosen by @FractalFir based on observed interner sizes, and
170+
// local perf runs. To get the interner sizes, insert `eprintln` printing the size of
171+
// the interner in functions like `intern_ty`. Bigger benchmarks tend to give more
172+
// accurate ratios, so use something like `x perf eprintln --includes cargo`.
172173
type_: InternedSet::with_capacity(N * 16),
173174
const_lists: InternedSet::with_capacity(N * 4),
174175
args: InternedSet::with_capacity(N * 4),
@@ -282,11 +283,12 @@ const NUM_PREINTERNED_ANON_BOUND_TYS_I: u32 = 3;
282283
// From general profiling of the *max vars during canonicalization* of a value:
283284
// - about 90% of the time, there are no canonical vars
284285
// - about 9% of the time, there is only one canonical var
285-
// - there are rarely more than 3-5 canonical vars (with exceptions in particularly pathological cases)
286+
// - there are rarely more than 3-5 canonical vars (with exceptions in particularly pathological
287+
// cases)
286288
// This may not match the number of bound vars found in `for`s.
287289
// Given that this is all heap interned, it seems likely that interning fewer
288-
// vars here won't make an appreciable difference. Though, if we were to inline the data (in an array),
289-
// we may want to consider reducing the number for canonicalized vars down to 4 or so.
290+
// vars here won't make an appreciable difference. Though, if we were to inline the data (in an
291+
// array), we may want to consider reducing the number for canonicalized vars down to 4 or so.
290292
const NUM_PREINTERNED_ANON_BOUND_TYS_V: u32 = 20;
291293

292294
// This number may seem high, but it is reached in all but the smallest crates.
@@ -337,8 +339,8 @@ pub struct CommonTypes<'tcx> {
337339
pub fresh_float_tys: Vec<Ty<'tcx>>,
338340

339341
/// Pre-interned values of the form:
340-
/// `Bound(BoundVarIndexKind::Bound(DebruijnIndex(i)), BoundTy { var: v, kind: BoundTyKind::Anon})`
341-
/// for small values of `i` and `v`.
342+
/// `Bound(BoundVarIndexKind::Bound(DebruijnIndex(i)), BoundTy { var: v, kind:
343+
/// BoundTyKind::Anon})` for small values of `i` and `v`.
342344
pub anon_bound_tys: Vec<Vec<Ty<'tcx>>>,
343345

344346
// Pre-interned values of the form:
@@ -931,7 +933,7 @@ impl<'tcx> TyCtxt<'tcx> {
931933
/// has a valid reference to the context, to allow formatting values that need it.
932934
pub fn create_global_ctxt<T>(
933935
gcx_cell: &'tcx OnceLock<GlobalCtxt<'tcx>>,
934-
s: &'tcx Session,
936+
sess: &'tcx Session,
935937
crate_types: Vec<CrateType>,
936938
stable_crate_id: StableCrateId,
937939
arena: &'tcx WorkerLocal<Arena<'tcx>>,
@@ -945,24 +947,24 @@ impl<'tcx> TyCtxt<'tcx> {
945947
jobserver_proxy: Arc<Proxy>,
946948
f: impl FnOnce(TyCtxt<'tcx>) -> T,
947949
) -> T {
948-
let data_layout = s.target.parse_data_layout().unwrap_or_else(|err| {
949-
s.dcx().emit_fatal(err);
950+
let data_layout = sess.target.parse_data_layout().unwrap_or_else(|err| {
951+
sess.dcx().emit_fatal(err);
950952
});
951953
let interners = CtxtInterners::new(arena);
952954
let common_types = CommonTypes::new(&interners);
953955
let common_lifetimes = CommonLifetimes::new(&interners);
954956
let common_consts = CommonConsts::new(&interners, &common_types);
955957

956958
let gcx = gcx_cell.get_or_init(|| GlobalCtxt {
957-
sess: s,
959+
sess,
958960
crate_types,
959961
stable_crate_id,
960962
arena,
961963
hir_arena,
962964
interners,
963965
dep_graph,
964966
hooks,
965-
prof: s.prof.clone(),
967+
prof: sess.prof.clone(),
966968
types: common_types,
967969
lifetimes: common_lifetimes,
968970
consts: common_consts,

0 commit comments

Comments
 (0)