about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2017-07-26 14:41:08 -0700
committerRalf Jung <post@ralfj.de>2017-08-03 18:10:47 -0700
commitdd533a9ec60263959cbfb8fea8dcd14c6c7da409 (patch)
tree255af9d0e290ab4e54db5d683ea023959592ec02
parent726b027ba3d2658d1a7796f46ea404c7299b7c0c (diff)
downloadrust-dd533a9ec60263959cbfb8fea8dcd14c6c7da409.tar.gz
rust-dd533a9ec60263959cbfb8fea8dcd14c6c7da409.zip
Revert "disable validation code so that it all compiles against current nightly"
This reverts commit 791dbaf58402ef87c16485be8d8ee37b5aa1dda3.
-rw-r--r--miri/bin/miri.rs1
-rw-r--r--src/librustc_mir/interpret/eval_context.rs2
-rw-r--r--src/librustc_mir/interpret/memory.rs10
-rw-r--r--src/librustc_mir/interpret/step.rs11
-rw-r--r--src/librustc_mir/interpret/validation.rs22
5 files changed, 11 insertions, 35 deletions
diff --git a/miri/bin/miri.rs b/miri/bin/miri.rs
index 01a4a8656b4..76a9b3d0e05 100644
--- a/miri/bin/miri.rs
+++ b/miri/bin/miri.rs
@@ -202,6 +202,7 @@ fn main() {
 
     // for auxilary builds in unit tests
     args.push("-Zalways-encode-mir".to_owned());
+    args.push("-Zmir-emit-validate".to_owned());
 
     rustc_driver::run_compiler(&args, &mut MiriCompilerCalls(RustcDefaultCalls), None, None);
 }
diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs
index 9f37b3521dc..afbdc95fa82 100644
--- a/src/librustc_mir/interpret/eval_context.rs
+++ b/src/librustc_mir/interpret/eval_context.rs
@@ -37,8 +37,6 @@ pub struct EvalContext<'a, 'tcx: 'a, M: Machine<'tcx>> {
     /// The virtual memory system.
     pub memory: Memory<'a, 'tcx, M>,
 
-    #[allow(dead_code)]
-    // FIXME(@RalfJung): validation branch
     /// Lvalues that were suspended by the validation subsystem, and will be recovered later
     pub(crate) suspended: HashMap<DynamicLifetime, Vec<ValidationQuery<'tcx>>>,
 
diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs
index 9c436fb76cc..b200ece4ccf 100644
--- a/src/librustc_mir/interpret/memory.rs
+++ b/src/librustc_mir/interpret/memory.rs
@@ -35,8 +35,6 @@ mod range {
     }
 
     impl MemoryRange {
-        #[allow(dead_code)]
-        // FIXME(@RalfJung): validation branch
         pub fn new(offset: u64, len: u64) -> MemoryRange {
             assert!(len > 0);
             MemoryRange {
@@ -61,8 +59,6 @@ mod range {
             left..right
         }
 
-        #[allow(dead_code)]
-        // FIXME(@RalfJung): validation branch
         pub fn contained_in(&self, offset: u64, len: u64) -> bool {
             assert!(len > 0);
             offset <= self.start && self.end <= (offset + len)
@@ -143,8 +139,6 @@ impl<M> Allocation<M> {
             .filter(move |&(range, _)| range.overlaps(offset, len))
     }
 
-    #[allow(dead_code)]
-    // FIXME(@RalfJung): validation branch
     fn iter_locks_mut<'a>(&'a mut self, offset: u64, len: u64) -> impl Iterator<Item=(&'a MemoryRange, &'a mut LockInfo)> + 'a {
         self.locks.range_mut(MemoryRange::range(offset, len))
             .filter(move |&(range, _)| range.overlaps(offset, len))
@@ -474,8 +468,6 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> {
             .map_err(|lock| EvalErrorKind::MemoryLockViolation { ptr, len, frame, access, lock }.into())
     }
 
-    #[allow(dead_code)]
-    // FIXME(@RalfJung): validation branch
     /// Acquire the lock for the given lifetime
     pub(crate) fn acquire_lock(&mut self, ptr: MemoryPointer, len: u64, region: Option<CodeExtent>, kind: AccessKind) -> EvalResult<'tcx> {
         use std::collections::btree_map::Entry::*;
@@ -504,8 +496,6 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> {
         Ok(())
     }
 
-    #[allow(dead_code)]
-    // FIXME(@RalfJung): validation branch
     /// Release a write lock prematurely. If there's a read lock or someone else's lock, fail.
     pub(crate) fn release_write_lock(&mut self, ptr: MemoryPointer, len: u64) -> EvalResult<'tcx> {
         assert!(len > 0);
diff --git a/src/librustc_mir/interpret/step.rs b/src/librustc_mir/interpret/step.rs
index 7ad51a08a46..9b3bf3b13ea 100644
--- a/src/librustc_mir/interpret/step.rs
+++ b/src/librustc_mir/interpret/step.rs
@@ -133,8 +133,15 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
                 self.deallocate_local(old_val)?;
             }
 
-            // NOPs for now.
-            EndRegion(_ce) => {}
+            // Validity checks.
+            Validate(op, ref lvalues) => {
+                for operand in lvalues {
+                    self.validation_op(op, operand)?;
+                }
+            }
+            EndRegion(ce) => {
+                self.end_region(ce)?;
+            }
 
             // Defined to do nothing. These are added by optimization passes, to avoid changing the
             // size of MIR constantly.
diff --git a/src/librustc_mir/interpret/validation.rs b/src/librustc_mir/interpret/validation.rs
index 23ac6bbfcd8..f6986f2de05 100644
--- a/src/librustc_mir/interpret/validation.rs
+++ b/src/librustc_mir/interpret/validation.rs
@@ -1,9 +1,6 @@
-// code for @RalfJung's validation branch is dead for now
-#![allow(dead_code)]
-
 use rustc::hir::Mutability;
 use rustc::hir::Mutability::*;
-use rustc::mir;
+use rustc::mir::{self, ValidationOp, ValidationOperand};
 use rustc::ty::{self, Ty, TypeFoldable};
 use rustc::ty::subst::Subst;
 use rustc::traits::Reveal;
@@ -19,23 +16,6 @@ use super::{
     Machine,
 };
 
-// FIXME remove this once it lands in rustc
-#[derive(Copy, Clone, PartialEq, Eq)]
-pub enum ValidationOp {
-    Acquire,
-    Release,
-    Suspend(CodeExtent),
-}
-
-#[derive(Clone, Debug)]
-pub struct ValidationOperand<'tcx, T> {
-    pub lval: T,
-    pub ty: Ty<'tcx>,
-    pub re: Option<CodeExtent>,
-    pub mutbl: Mutability,
-}
-// FIXME end
-
 pub type ValidationQuery<'tcx> = ValidationOperand<'tcx, Lvalue<'tcx>>;
 
 #[derive(Copy, Clone, Debug)]