about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2018-02-20 10:32:33 +0100
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2018-03-08 08:34:18 +0100
commit134c2910ec53016dd4319206921c623e8c9a57b7 (patch)
tree81fbe8b495e8197b11dfa6743872f70b09d9a251 /src
parent0ca4b45a0ccf9e29a17f0613fb280411910b3dbd (diff)
Const eval will oom together with rustc now
Diffstat (limited to 'src')
-rw-r--r--src/librustc/ich/impls_ty.rs9
-rw-r--r--src/librustc/mir/interpret/error.rs10
-rw-r--r--src/librustc/session/mod.rs3
-rw-r--r--src/librustc/ty/structural_impls.rs5
-rw-r--r--src/librustc_mir/interpret/memory.rs17
5 files changed, 0 insertions, 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<usize>,
     /// The maximum number miri steps per constant
     pub const_eval_step_limit: Cell<usize>,
-    /// The maximum number of virtual bytes per constant
-    pub const_eval_memory_limit: Cell<u64>,
 
     /// 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<AllocId, Allocation>,
 
-    /// 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<MemoryKind<M::MemoryKinds>>,
     ) -> 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(())