Skip to content

Commit 134c291

Browse files
committed
Const eval will oom together with rustc now
1 parent 0ca4b45 commit 134c291

File tree

5 files changed

+0
-44
lines changed

5 files changed

+0
-44
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -562,15 +562,6 @@ for ::mir::interpret::EvalError<'gcx> {
562562
},
563563
Intrinsic(ref s) => s.hash_stable(hcx, hasher),
564564
InvalidChar(c) => c.hash_stable(hcx, hasher),
565-
OutOfMemory {
566-
allocation_size,
567-
memory_size,
568-
memory_usage,
569-
} => {
570-
allocation_size.hash_stable(hcx, hasher);
571-
memory_size.hash_stable(hcx, hasher);
572-
memory_usage.hash_stable(hcx, hasher)
573-
},
574565
AbiViolation(ref s) => s.hash_stable(hcx, hasher),
575566
AlignmentCheckFailed {
576567
required,

src/librustc/mir/interpret/error.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ pub enum EvalErrorKind<'tcx> {
6565
Intrinsic(String),
6666
OverflowingMath,
6767
InvalidChar(u128),
68-
OutOfMemory {
69-
allocation_size: u64,
70-
memory_size: u64,
71-
memory_usage: u64,
72-
},
7368
ExecutionTimeLimitReached,
7469
StackFrameLimitReached,
7570
OutOfTls,
@@ -193,8 +188,6 @@ impl<'tcx> Error for EvalError<'tcx> {
193188
"mir not found",
194189
InvalidChar(..) =>
195190
"tried to interpret an invalid 32-bit value as a char",
196-
OutOfMemory{..} =>
197-
"could not allocate more memory",
198191
ExecutionTimeLimitReached =>
199192
"the expression was too complex to be evaluated or resulted in an infinite loop",
200193
StackFrameLimitReached =>
@@ -297,9 +290,6 @@ impl<'tcx> fmt::Display for EvalError<'tcx> {
297290
write!(f, "{}", err),
298291
InvalidChar(c) =>
299292
write!(f, "tried to interpret an invalid 32-bit value as a char: {}", c),
300-
OutOfMemory { allocation_size, memory_size, memory_usage } =>
301-
write!(f, "tried to allocate {} more bytes, but only {} bytes are free of the {} byte memory",
302-
allocation_size, memory_size - memory_usage, memory_size),
303293
AlignmentCheckFailed { required, has } =>
304294
write!(f, "tried to access memory with alignment {}, but alignment {} is required",
305295
has, required),

src/librustc/session/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ pub struct Session {
107107
pub const_eval_stack_frame_limit: Cell<usize>,
108108
/// The maximum number miri steps per constant
109109
pub const_eval_step_limit: Cell<usize>,
110-
/// The maximum number of virtual bytes per constant
111-
pub const_eval_memory_limit: Cell<u64>,
112110

113111
/// The metadata::creader module may inject an allocator/panic_runtime
114112
/// dependency if it didn't already find one, and this tracks what was
@@ -1013,7 +1011,6 @@ pub fn build_session_(sopts: config::Options,
10131011
type_length_limit: Cell::new(1048576),
10141012
const_eval_stack_frame_limit: Cell::new(100),
10151013
const_eval_step_limit: Cell::new(1_000_000),
1016-
const_eval_memory_limit: Cell::new(100 * 1024 * 1024), // 100 MB
10171014
next_node_id: Cell::new(NodeId::new(1)),
10181015
injected_allocator: Cell::new(None),
10191016
allocator_kind: Cell::new(None),

src/librustc/ty/structural_impls.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -625,11 +625,6 @@ impl<'a, 'tcx> Lift<'tcx> for interpret::EvalError<'a> {
625625
Intrinsic(ref s) => Intrinsic(s.clone()),
626626
OverflowingMath => OverflowingMath,
627627
InvalidChar(c) => InvalidChar(c),
628-
OutOfMemory {
629-
allocation_size,
630-
memory_size,
631-
memory_usage,
632-
} => OutOfMemory { allocation_size, memory_size, memory_usage },
633628
ExecutionTimeLimitReached => ExecutionTimeLimitReached,
634629
StackFrameLimitReached => StackFrameLimitReached,
635630
OutOfTls => OutOfTls,

src/librustc_mir/interpret/memory.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ pub struct Memory<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> {
4343
/// Stores statics while they are being processed, before they are interned and thus frozen
4444
uninitialized_statics: HashMap<AllocId, Allocation>,
4545

46-
/// Number of virtual bytes allocated.
47-
memory_usage: u64,
48-
49-
/// Maximum number of virtual bytes that may be allocated.
50-
memory_size: u64,
51-
5246
/// The current stack frame. Used to check accesses against locks.
5347
pub cur_frame: usize,
5448

@@ -63,8 +57,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
6357
alloc_map: HashMap::new(),
6458
uninitialized_statics: HashMap::new(),
6559
tcx,
66-
memory_size: tcx.sess.const_eval_memory_limit.get(),
67-
memory_usage: 0,
6860
cur_frame: usize::max_value(),
6961
}
7062
}
@@ -92,14 +84,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
9284
align: Align,
9385
kind: Option<MemoryKind<M::MemoryKinds>>,
9486
) -> EvalResult<'tcx, MemoryPointer> {
95-
if self.memory_size - self.memory_usage < size {
96-
return err!(OutOfMemory {
97-
allocation_size: size,
98-
memory_size: self.memory_size,
99-
memory_usage: self.memory_usage,
100-
});
101-
}
102-
self.memory_usage += size;
10387
assert_eq!(size as usize as u64, size);
10488
let alloc = Allocation {
10589
bytes: vec![0; size as usize],
@@ -223,7 +207,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
223207
}
224208
}
225209

226-
self.memory_usage -= alloc.bytes.len() as u64;
227210
debug!("deallocated : {}", ptr.alloc_id);
228211

229212
Ok(())

0 commit comments

Comments
 (0)