mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 20:54:13 +00:00
Const eval will oom together with rustc now
This commit is contained in:
parent
0ca4b45a0c
commit
134c2910ec
@ -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,
|
||||
|
@ -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),
|
||||
|
@ -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),
|
||||
|
@ -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,
|
||||
|
@ -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(())
|
||||
|
Loading…
Reference in New Issue
Block a user