Skip to content

Commit 4e117a9

Browse files
committed
Use u64 for incr comp allocation offsets
1 parent a161ab0 commit 4e117a9

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
608608
trace!("encoding {} further alloc ids", new_n - n);
609609
for idx in n..new_n {
610610
let id = self.interpret_allocs[idx];
611-
let pos = self.position() as u32;
611+
let pos = self.position() as u64;
612612
interpret_alloc_index.push(pos);
613613
interpret::specialized_encode_alloc_id(self, tcx, id);
614614
}

compiler/rustc_metadata/src/rmeta/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ pub(crate) struct CrateRoot {
264264
traits: LazyArray<DefIndex>,
265265
impls: LazyArray<TraitImpls>,
266266
incoherent_impls: LazyArray<IncoherentImpls>,
267-
interpret_alloc_index: LazyArray<u32>,
267+
interpret_alloc_index: LazyArray<u64>,
268268
proc_macro_data: Option<ProcMacroData>,
269269

270270
tables: LazyTables,

compiler/rustc_middle/src/mir/interpret/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ pub struct AllocDecodingState {
274274
// For each `AllocId`, we keep track of which decoding state it's currently in.
275275
decoding_state: Vec<Lock<State>>,
276276
// The offsets of each allocation in the data stream.
277-
data_offsets: Vec<u32>,
277+
data_offsets: Vec<u64>,
278278
}
279279

280280
impl AllocDecodingState {
@@ -289,7 +289,7 @@ impl AllocDecodingState {
289289
AllocDecodingSession { state: self, session_id }
290290
}
291291

292-
pub fn new(data_offsets: Vec<u32>) -> Self {
292+
pub fn new(data_offsets: Vec<u64>) -> Self {
293293
let decoding_state =
294294
std::iter::repeat_with(|| Lock::new(State::Empty)).take(data_offsets.len()).collect();
295295

compiler/rustc_middle/src/query/on_disk_cache.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ struct Footer {
104104
query_result_index: EncodedDepNodeIndex,
105105
side_effects_index: EncodedDepNodeIndex,
106106
// The location of all allocations.
107-
interpret_alloc_index: Vec<u32>,
107+
// Most uses only need values up to u32::MAX, but benchmarking indicates that we can use a u64
108+
// without measurable overhead. This permits larger const allocations without ICEing.
109+
interpret_alloc_index: Vec<u64>,
108110
// See `OnDiskCache.syntax_contexts`
109111
syntax_contexts: FxHashMap<u32, AbsoluteBytePos>,
110112
// See `OnDiskCache.expn_data`
@@ -301,7 +303,7 @@ impl<'sess> OnDiskCache<'sess> {
301303
interpret_alloc_index.reserve(new_n - n);
302304
for idx in n..new_n {
303305
let id = encoder.interpret_allocs[idx];
304-
let pos: u32 = encoder.position().try_into().unwrap();
306+
let pos: u64 = encoder.position().try_into().unwrap();
305307
interpret_alloc_index.push(pos);
306308
interpret::specialized_encode_alloc_id(&mut encoder, tcx, id);
307309
}

compiler/rustc_middle/src/ty/parameterized.rs

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ trivially_parameterized_over_tcx! {
5252
usize,
5353
(),
5454
u32,
55+
u64,
5556
bool,
5657
std::string::String,
5758
crate::metadata::ModChild,

0 commit comments

Comments
 (0)