diff --git a/Cargo.lock b/Cargo.lock index c5518b1238a270047b0d2e0e7be9d338b4988bd2..240a2144807dae9f8defff19cc6f271ad863f33f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,7 +3,7 @@ name = "miri" version = "0.1.0" dependencies = [ "byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "compiletest_rs 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiletest_rs 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "log_settings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -24,7 +24,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "compiletest_rs" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -55,7 +55,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -76,7 +76,7 @@ name = "memchr" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -102,7 +102,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/src/bin/miri.rs b/src/bin/miri.rs index 82702ae43788087ef42199340f720c8369a9b56c..123428bcad191883357aa0aaacf03bcea993456a 100644 --- a/src/bin/miri.rs +++ b/src/bin/miri.rs @@ -90,11 +90,11 @@ fn interpret_start_points<'a, 'tcx>( fn report(tcx: TyCtxt, ecx: &EvalContext, e: EvalError) { let frame = ecx.stack().last().expect("stackframe was empty"); - let block = frame.mir.basic_block_data(frame.next_block); + let block = &frame.mir.basic_blocks()[frame.next_block]; let span = if frame.stmt < block.statements.len() { - block.statements[frame.stmt].span + block.statements[frame.stmt].source_info.span } else { - block.terminator().span + block.terminator().source_info.span }; let mut err = tcx.sess.struct_span_err(span, &e.to_string()); for &Frame { def_id, substs, span, .. } in ecx.stack().iter().rev() { @@ -105,7 +105,7 @@ fn report(tcx: TyCtxt, ecx: &EvalContext, e: EvalError) { impl<'tcx> fmt::Display for Instance<'tcx> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ppaux::parameterized(f, self.1, self.0, ppaux::Ns::Value, &[], - |tcx| tcx.lookup_item_type(self.0).generics) + |tcx| Some(tcx.lookup_item_type(self.0).generics)) } } err.span_note(span, &format!("inside call to {}", Instance(def_id, substs))); diff --git a/src/interpreter/mod.rs b/src/interpreter/mod.rs index 6831ab212fb356febf647150256bd00b06f9deb9..b3de02e55b02563f54e0921d058ac6f87283ea2b 100644 --- a/src/interpreter/mod.rs +++ b/src/interpreter/mod.rs @@ -8,6 +8,7 @@ use rustc::ty::subst::{self, Subst, Substs}; use rustc::ty::{self, Ty, TyCtxt}; use rustc::util::nodemap::DefIdMap; +use rustc_data_structures::indexed_vec::Idx; use std::cell::RefCell; use std::ops::Deref; use std::rc::Rc; @@ -118,7 +119,7 @@ struct ConstantId<'tcx> { #[derive(Clone, Debug, Eq, PartialEq, Hash)] enum ConstantKind { - Promoted(usize), + Promoted(mir::Promoted), /// Statics, constants and associated constants Global, } @@ -485,7 +486,10 @@ fn eval_terminator(&mut self, terminator: &mir::Terminator<'tcx>) } let mir = self.load_mir(resolved_def_id); - self.push_stack_frame(def_id, terminator.span, mir, resolved_substs, return_ptr); + self.push_stack_frame( + def_id, terminator.source_info.span, mir, resolved_substs, + return_ptr + ); for (i, (src, src_ty)) in arg_srcs.into_iter().enumerate() { let dest = self.frame().locals[i]; @@ -501,14 +505,26 @@ fn eval_terminator(&mut self, terminator: &mir::Terminator<'tcx>) } } - Drop { ref value, target, .. } => { - let ptr = self.eval_lvalue(value)?.to_ptr(); - let ty = self.lvalue_ty(value); + Drop { ref location, target, .. } => { + let ptr = self.eval_lvalue(location)?.to_ptr(); + let ty = self.lvalue_ty(location); self.drop(ptr, ty)?; self.frame_mut().next_block = target; } + Assert { ref cond, expected, ref msg, target, cleanup } => { + let actual_ptr = self.eval_operand(cond)?; + let actual = self.memory.read_bool(actual_ptr)?; + if actual == expected { + self.frame_mut().next_block = target; + } else { + panic!("unimplemented: jump to {:?} and print {:?}", cleanup, msg); + } + } + + DropAndReplace { .. } => unimplemented!(), Resume => unimplemented!(), + Unreachable => unimplemented!(), } Ok(()) @@ -845,6 +861,8 @@ fn eval_assignment(&mut self, lvalue: &mir::Lvalue<'tcx>, rvalue: &mir::Rvalue<' self.memory.write_primval(dest, val)?; } + CheckedBinaryOp(..) => unimplemented!(), + UnaryOp(un_op, ref operand) => { let ptr = self.eval_operand(operand)?; let ty = self.operand_ty(operand); @@ -1018,7 +1036,6 @@ fn eval_assignment(&mut self, lvalue: &mir::Lvalue<'tcx>, rvalue: &mir::Rvalue<' } } - Slice { .. } => unimplemented!(), InlineAsm { .. } => unimplemented!(), } @@ -1130,9 +1147,9 @@ fn eval_lvalue(&mut self, lvalue: &mir::Lvalue<'tcx>) -> EvalResult { let ptr = match *lvalue { ReturnPointer => self.frame().return_ptr .expect("ReturnPointer used in a function with no return value"), - Arg(i) => self.frame().locals[i as usize], - Var(i) => self.frame().locals[self.frame().var_offset + i as usize], - Temp(i) => self.frame().locals[self.frame().temp_offset + i as usize], + Arg(i) => self.frame().locals[i.index()], + Var(i) => self.frame().locals[self.frame().var_offset + i.index()], + Temp(i) => self.frame().locals[self.frame().temp_offset + i.index()], Static(def_id) => { let substs = self.tcx.mk_substs(subst::Substs::empty()); @@ -1217,6 +1234,7 @@ fn eval_lvalue(&mut self, lvalue: &mir::Lvalue<'tcx>) -> EvalResult { } ConstantIndex { .. } => unimplemented!(), + Subslice { .. } => unimplemented!(), } } }; diff --git a/src/interpreter/stepper.rs b/src/interpreter/stepper.rs index 3e4816834a82dca9598f5f602ecce55d9ab1dd3b..cba76eaf5a3ceaa7896839555cc9551720edd755 100644 --- a/src/interpreter/stepper.rs +++ b/src/interpreter/stepper.rs @@ -51,12 +51,12 @@ pub(super) fn step(&mut self) -> EvalResult { let block = self.ecx.frame().next_block; let stmt = self.ecx.frame().stmt; let mir = self.ecx.mir(); - let basic_block = mir.basic_block_data(block); + let basic_block = &mir.basic_blocks()[block]; if let Some(ref stmt) = basic_block.statements.get(stmt) { let current_stack = self.ecx.stack.len(); ConstantExtractor { - span: stmt.span, + span: stmt.source_info.span, substs: self.ecx.substs(), def_id: self.ecx.frame().def_id, ecx: self.ecx, @@ -75,7 +75,7 @@ pub(super) fn step(&mut self) -> EvalResult { let terminator = basic_block.terminator(); let current_stack = self.ecx.stack.len(); ConstantExtractor { - span: terminator.span, + span: terminator.source_info.span, substs: self.ecx.substs(), def_id: self.ecx.frame().def_id, ecx: self.ecx, diff --git a/src/lib.rs b/src/lib.rs index c3369878f3554478e54d28413497a2ef77e9c259..9d2203d115c10f444feafdafdf423805eb269cc2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,6 +11,7 @@ // From rustc. #[macro_use] extern crate rustc; +extern crate rustc_data_structures; extern crate rustc_mir; extern crate syntax; #[macro_use] extern crate log;