From 134c2910ec53016dd4319206921c623e8c9a57b7 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 20 Feb 2018 10:32:33 +0100 Subject: [PATCH] Const eval will oom together with rustc now --- src/librustc/ich/impls_ty.rs | 9 --------- src/librustc/mir/interpret/error.rs | 10 ---------- src/librustc/session/mod.rs | 3 --- src/librustc/ty/structural_impls.rs | 5 ----- src/librustc_mir/interpret/memory.rs | 17 ----------------- 5 files changed, 44 deletions(-) diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index d5476f742c8..874c7c27dea 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -562,15 +562,6 @@ for ::mir::interpret::EvalError<'gcx> { }, Intrinsic(ref s) => s.hash_stable(hcx, hasher), InvalidChar(c) => c.hash_stable(hcx, hasher), - OutOfMemory { - allocation_size, - memory_size, - memory_usage, - } => { - allocation_size.hash_stable(hcx, hasher); - memory_size.hash_stable(hcx, hasher); - memory_usage.hash_stable(hcx, hasher) - }, AbiViolation(ref s) => s.hash_stable(hcx, hasher), AlignmentCheckFailed { required, diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index d6df340e2f6..51660b180cd 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -65,11 +65,6 @@ pub enum EvalErrorKind<'tcx> { Intrinsic(String), OverflowingMath, InvalidChar(u128), - OutOfMemory { - allocation_size: u64, - memory_size: u64, - memory_usage: u64, - }, ExecutionTimeLimitReached, StackFrameLimitReached, OutOfTls, @@ -193,8 +188,6 @@ impl<'tcx> Error for EvalError<'tcx> { "mir not found", InvalidChar(..) => "tried to interpret an invalid 32-bit value as a char", - OutOfMemory{..} => - "could not allocate more memory", ExecutionTimeLimitReached => "the expression was too complex to be evaluated or resulted in an infinite loop", StackFrameLimitReached => @@ -297,9 +290,6 @@ impl<'tcx> fmt::Display for EvalError<'tcx> { write!(f, "{}", err), InvalidChar(c) => write!(f, "tried to interpret an invalid 32-bit value as a char: {}", c), - OutOfMemory { allocation_size, memory_size, memory_usage } => - write!(f, "tried to allocate {} more bytes, but only {} bytes are free of the {} byte memory", - allocation_size, memory_size - memory_usage, memory_size), AlignmentCheckFailed { required, has } => write!(f, "tried to access memory with alignment {}, but alignment {} is required", has, required), diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 232344a0367..defc5731f2f 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -107,8 +107,6 @@ pub struct Session { pub const_eval_stack_frame_limit: Cell, /// The maximum number miri steps per constant pub const_eval_step_limit: Cell, - /// The maximum number of virtual bytes per constant - pub const_eval_memory_limit: Cell, /// The metadata::creader module may inject an allocator/panic_runtime /// dependency if it didn't already find one, and this tracks what was @@ -1013,7 +1011,6 @@ pub fn build_session_(sopts: config::Options, type_length_limit: Cell::new(1048576), const_eval_stack_frame_limit: Cell::new(100), const_eval_step_limit: Cell::new(1_000_000), - const_eval_memory_limit: Cell::new(100 * 1024 * 1024), // 100 MB next_node_id: Cell::new(NodeId::new(1)), injected_allocator: Cell::new(None), allocator_kind: Cell::new(None), diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index 243e17ee5c7..78fccaa1131 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -625,11 +625,6 @@ impl<'a, 'tcx> Lift<'tcx> for interpret::EvalError<'a> { Intrinsic(ref s) => Intrinsic(s.clone()), OverflowingMath => OverflowingMath, InvalidChar(c) => InvalidChar(c), - OutOfMemory { - allocation_size, - memory_size, - memory_usage, - } => OutOfMemory { allocation_size, memory_size, memory_usage }, ExecutionTimeLimitReached => ExecutionTimeLimitReached, StackFrameLimitReached => StackFrameLimitReached, OutOfTls => OutOfTls, diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 7dceacabb29..72a966ab38d 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -43,12 +43,6 @@ pub struct Memory<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> { /// Stores statics while they are being processed, before they are interned and thus frozen uninitialized_statics: HashMap, - /// Number of virtual bytes allocated. - memory_usage: u64, - - /// Maximum number of virtual bytes that may be allocated. - memory_size: u64, - /// The current stack frame. Used to check accesses against locks. pub cur_frame: usize, @@ -63,8 +57,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { alloc_map: HashMap::new(), uninitialized_statics: HashMap::new(), tcx, - memory_size: tcx.sess.const_eval_memory_limit.get(), - memory_usage: 0, cur_frame: usize::max_value(), } } @@ -92,14 +84,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { align: Align, kind: Option>, ) -> EvalResult<'tcx, MemoryPointer> { - if self.memory_size - self.memory_usage < size { - return err!(OutOfMemory { - allocation_size: size, - memory_size: self.memory_size, - memory_usage: self.memory_usage, - }); - } - self.memory_usage += size; assert_eq!(size as usize as u64, size); let alloc = Allocation { bytes: vec![0; size as usize], @@ -223,7 +207,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { } } - self.memory_usage -= alloc.bytes.len() as u64; debug!("deallocated : {}", ptr.alloc_id); Ok(())