From 413a3515525829e1ddd93dbb391da0fe45e16ff8 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Wed, 26 Jun 2019 13:09:50 -0500 Subject: [PATCH 1/6] Initialize MemoryExtra with StdRng --- src/lib.rs | 6 ++---- src/memory.rs | 10 ++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6b1ada69d3..7bab1762bd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,7 +50,7 @@ use crate::range_map::RangeMap; pub use crate::helpers::{EvalContextExt as HelpersEvalContextExt}; use crate::mono_hash_map::MonoHashMap; pub use crate::stacked_borrows::{EvalContextExt as StackedBorEvalContextExt}; -use crate::memory::AllocExtra; +use crate::memory::{MemoryExtra, AllocExtra}; // Used by priroda. pub use crate::stacked_borrows::{Tag, Permission, Stack, Stacks, Item}; @@ -83,10 +83,8 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( tcx.at(syntax::source_map::DUMMY_SP), ty::ParamEnv::reveal_all(), Evaluator::new(config.validate), + MemoryExtra::with_rng(config.seed.map(StdRng::seed_from_u64)), ); - - // FIXME: InterpretCx::new should take an initial MemoryExtra - ecx.memory_mut().extra.rng = config.seed.map(StdRng::seed_from_u64); let main_instance = ty::Instance::mono(ecx.tcx.tcx, main_id); let main_mir = ecx.load_mir(main_instance.def)?; diff --git a/src/memory.rs b/src/memory.rs index ea8f01a808..252e1cc08a 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -15,6 +15,16 @@ pub struct MemoryExtra { pub(crate) rng: Option } +impl MemoryExtra { + pub fn with_rng(rng: Option) -> Self { + MemoryExtra { + stacked_borrows: Default::default(), + intptrcast: Default::default(), + rng, + } + } +} + #[derive(Debug, Clone)] pub struct AllocExtra { pub stacked_borrows: stacked_borrows::AllocExtra, From 373a4ee1e99661dd9d708626b41d0ed0e9fbe254 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Wed, 26 Jun 2019 13:55:56 -0500 Subject: [PATCH 2/6] Remove default derive for MemoryExtra --- src/memory.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/memory.rs b/src/memory.rs index 252e1cc08a..e1ccafaae2 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -6,7 +6,7 @@ use rustc_target::abi::Size; use crate::{stacked_borrows, intptrcast}; use crate::stacked_borrows::Tag; -#[derive(Default, Clone, Debug)] +#[derive(Clone, Debug)] pub struct MemoryExtra { pub stacked_borrows: stacked_borrows::MemoryExtra, pub intptrcast: intptrcast::MemoryExtra, From aa5a9bc15233960b8c375e1fa45fd11e5ae5b6cb Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 29 Jun 2019 14:15:05 +0200 Subject: [PATCH 3/6] some module comments --- src/eval.rs | 2 ++ src/machine.rs | 3 +++ src/range_map.rs | 5 +---- src/stacked_borrows.rs | 3 +++ src/tls.rs | 2 ++ 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/eval.rs b/src/eval.rs index fd5404a981..616e11a515 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -1,3 +1,5 @@ +//! Main evaluator loop and setting up the initial stack frame. + use rand::rngs::StdRng; use rand::SeedableRng; diff --git a/src/machine.rs b/src/machine.rs index 8ef5410f39..9785d6a455 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -1,3 +1,6 @@ +//! Global machine state as well as implementation of the interpreter engine +//! `Machine` trait. + use std::rc::Rc; use std::borrow::Cow; use std::collections::HashMap; diff --git a/src/range_map.rs b/src/range_map.rs index 16e7e27241..f2cbd89f64 100644 --- a/src/range_map.rs +++ b/src/range_map.rs @@ -1,5 +1,3 @@ -#![allow(unused)] - //! Implements a map from integer indices to data. //! Rather than storing data for every index, internally, this maps entire ranges to the data. //! To this end, the APIs all work on ranges, not on individual integers. Ranges are split as @@ -8,7 +6,6 @@ //! via the iteration APIs. use std::ops; -use std::num::NonZeroU64; use rustc::ty::layout::Size; @@ -158,7 +155,7 @@ impl RangeMap { let mut end_idx = first_idx; // when the loop is done, this is the first excluded element. loop { // Compute if `end` is the last element we need to look at. - let done = (self.v[end_idx].range.end >= offset+len); + let done = self.v[end_idx].range.end >= offset+len; // We definitely need to include `end`, so move the index. end_idx += 1; debug_assert!(done || end_idx < self.v.len(), "iter_mut: end-offset {} is out-of-bounds", offset+len); diff --git a/src/stacked_borrows.rs b/src/stacked_borrows.rs index 524ad2b47a..6e5bbf5094 100644 --- a/src/stacked_borrows.rs +++ b/src/stacked_borrows.rs @@ -1,3 +1,6 @@ +//! Implements "Stacked Borrows". See +//! for further information. + use std::cell::RefCell; use std::collections::{HashMap, HashSet}; use std::rc::Rc; diff --git a/src/tls.rs b/src/tls.rs index ddc301447c..73c778f66d 100644 --- a/src/tls.rs +++ b/src/tls.rs @@ -1,3 +1,5 @@ +//! Implement thread-local storage. + use std::collections::BTreeMap; use rustc_target::abi::LayoutOf; From 67882459f3ce77199f1a74180c3bccf730b5d5cb Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 6 Jul 2019 09:29:58 +0200 Subject: [PATCH 4/6] bump rustc --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index cbd8e33577..e278a80633 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -24a9bcbb7cb0d8bdc11b8252a9c13f7562c7e4ca +481068a707679257e2a738b40987246e0420e787 From 5e022773f3e5b6a8218e94d08566a931d713bb0e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 6 Jul 2019 09:32:35 +0200 Subject: [PATCH 5/6] fix unused variable warning --- src/range_map.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/range_map.rs b/src/range_map.rs index f2cbd89f64..aa9a87887d 100644 --- a/src/range_map.rs +++ b/src/range_map.rs @@ -281,7 +281,7 @@ mod tests { .map(|&t| t).collect::>(), vec![19, 19]); // A NOP `iter_mut` should trigger merging. - for x in map.iter_mut(Size::from_bytes(15), Size::from_bytes(5)) { } + for _ in map.iter_mut(Size::from_bytes(15), Size::from_bytes(5)) { } assert_eq!(map.v.len(), 5); assert_eq!( to_vec(&map, 10, 10), From ba8728cd8bbb9852d8884b7444a8b049a432dcd1 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 6 Jul 2019 09:33:22 +0200 Subject: [PATCH 6/6] fix test using mem::uninitialized --- tests/run-pass/move-undef-primval.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/run-pass/move-undef-primval.rs b/tests/run-pass/move-undef-primval.rs index 73c33943a6..b8bd869b48 100644 --- a/tests/run-pass/move-undef-primval.rs +++ b/tests/run-pass/move-undef-primval.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + struct Foo { _inner: i32, }