Skip to content

Commit 1ba46dc

Browse files
committed
Move mir validation out of tree
1 parent acac585 commit 1ba46dc

File tree

14 files changed

+61
-1498
lines changed

14 files changed

+61
-1498
lines changed

src/Cargo.lock

-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/librustc/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ rustc_errors = { path = "../librustc_errors" }
2424
serialize = { path = "../libserialize" }
2525
syntax = { path = "../libsyntax" }
2626
syntax_pos = { path = "../libsyntax_pos" }
27-
regex = "0.2.2"
2827
backtrace = "0.3.3"
2928
byteorder = { version = "1.1", features = ["i128"]}
3029

src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ extern crate serialize as rustc_serialize; // used by deriving
9292

9393
extern crate rustc_apfloat;
9494
extern crate byteorder;
95-
extern crate regex;
9695
extern crate backtrace;
9796

9897
// Note that librustc doesn't actually depend on these crates, see the note in

src/librustc_mir/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ bitflags = "1.0"
1313
graphviz = { path = "../libgraphviz" }
1414
log = "0.3"
1515
log_settings = "0.1.1"
16-
lazy_static = "1.0"
1716
rustc = { path = "../librustc" }
1817
rustc_const_eval = { path = "../librustc_const_eval" }
1918
rustc_const_math = { path = "../librustc_const_math" }
@@ -23,5 +22,4 @@ serialize = { path = "../libserialize" }
2322
syntax = { path = "../libsyntax" }
2423
syntax_pos = { path = "../libsyntax_pos" }
2524
byteorder = { version = "1.1", features = ["i128"] }
26-
regex = "0.2"
2725
rustc_apfloat = { path = "../librustc_apfloat" }

src/librustc_mir/interpret/eval_context.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::collections::{HashMap, HashSet};
1+
use std::collections::HashSet;
22
use std::fmt::Write;
33

44
use rustc::hir::def_id::DefId;
@@ -13,13 +13,13 @@ use rustc_data_structures::indexed_vec::Idx;
1313
use syntax::codemap::{self, DUMMY_SP};
1414
use syntax::ast::Mutability;
1515
use rustc::mir::interpret::{
16-
PtrAndAlign, DynamicLifetime, GlobalId, Value, Pointer, PrimVal, PrimValKind,
16+
PtrAndAlign, GlobalId, Value, Pointer, PrimVal, PrimValKind,
1717
EvalError, EvalResult, EvalErrorKind, MemoryPointer,
1818
};
1919

2020
use super::{Place, PlaceExtra, Memory,
2121
HasMemory, MemoryKind, operator,
22-
ValidationQuery, Machine};
22+
Machine};
2323

2424
pub struct EvalContext<'a, 'tcx: 'a, M: Machine<'tcx>> {
2525
/// Stores the `Machine` instance.
@@ -34,9 +34,6 @@ pub struct EvalContext<'a, 'tcx: 'a, M: Machine<'tcx>> {
3434
/// The virtual memory system.
3535
pub memory: Memory<'a, 'tcx, M>,
3636

37-
/// Places that were suspended by the validation subsystem, and will be recovered later
38-
pub(crate) suspended: HashMap<DynamicLifetime, Vec<ValidationQuery<'tcx>>>,
39-
4037
/// The virtual call stack.
4138
pub(crate) stack: Vec<Frame<'tcx>>,
4239

@@ -203,7 +200,6 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
203200
tcx,
204201
param_env,
205202
memory: Memory::new(tcx, limits.memory_size, memory_data),
206-
suspended: HashMap::new(),
207203
stack: Vec::new(),
208204
stack_limit: limits.stack_limit,
209205
steps_remaining: limits.step_limit,
@@ -471,7 +467,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
471467

472468
pub(super) fn pop_stack_frame(&mut self) -> EvalResult<'tcx> {
473469
::log_settings::settings().indentation -= 1;
474-
self.end_region(None)?;
470+
M::end_region(self, None)?;
475471
let frame = self.stack.pop().expect(
476472
"tried to pop a stack frame, but there were none",
477473
);
@@ -996,7 +992,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
996992
}
997993

998994
/// ensures this Value is not a ByRef
999-
pub(super) fn follow_by_ref_value(
995+
pub fn follow_by_ref_value(
1000996
&self,
1001997
value: Value,
1002998
ty: Ty<'tcx>,
@@ -1396,15 +1392,15 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
13961392
self.stack.last().expect("no call frames exist")
13971393
}
13981394

1399-
pub(super) fn frame_mut(&mut self) -> &mut Frame<'tcx> {
1395+
pub fn frame_mut(&mut self) -> &mut Frame<'tcx> {
14001396
self.stack.last_mut().expect("no call frames exist")
14011397
}
14021398

14031399
pub(super) fn mir(&self) -> &'tcx mir::Mir<'tcx> {
14041400
self.frame().mir
14051401
}
14061402

1407-
pub(super) fn substs(&self) -> &'tcx Substs<'tcx> {
1403+
pub fn substs(&self) -> &'tcx Substs<'tcx> {
14081404
if let Some(frame) = self.stack.last() {
14091405
frame.instance.substs
14101406
} else {

src/librustc_mir/interpret/machine.rs

+39-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
//! This separation exists to ensure that no fancy miri features like
33
//! interpreting common C functions leak into CTFE.
44
5-
use rustc::mir::interpret::{EvalResult, PrimVal};
6-
use super::{EvalContext, Place, ValTy};
5+
use rustc::mir::interpret::{EvalResult, PrimVal, MemoryPointer, AccessKind};
6+
use super::{EvalContext, Place, ValTy, Memory};
77

88
use rustc::mir;
99
use rustc::ty::{self, Ty};
@@ -77,4 +77,41 @@ pub trait Machine<'tcx>: Sized {
7777
instance: ty::Instance<'tcx>,
7878
mutability: Mutability,
7979
) -> EvalResult<'tcx>;
80+
81+
fn check_locks<'a>(
82+
_mem: &Memory<'a, 'tcx, Self>,
83+
_ptr: MemoryPointer,
84+
_size: u64,
85+
_access: AccessKind,
86+
) -> EvalResult<'tcx> {
87+
Ok(())
88+
}
89+
90+
fn add_lock<'a>(
91+
_mem: &mut Memory<'a, 'tcx, Self>,
92+
_id: u64,
93+
) {}
94+
95+
fn free_lock<'a>(
96+
_mem: &mut Memory<'a, 'tcx, Self>,
97+
_id: u64,
98+
_len: u64,
99+
) -> EvalResult<'tcx> {
100+
Ok(())
101+
}
102+
103+
fn end_region<'a>(
104+
_ecx: &mut EvalContext<'a, 'tcx, Self>,
105+
_reg: Option<::rustc::middle::region::Scope>,
106+
) -> EvalResult<'tcx> {
107+
Ok(())
108+
}
109+
110+
fn validation_op<'a>(
111+
_ecx: &mut EvalContext<'a, 'tcx, Self>,
112+
_op: ::rustc::mir::ValidationOp,
113+
_operand: &::rustc::mir::ValidationOperand<'tcx, ::rustc::mir::Place<'tcx>>,
114+
) -> EvalResult<'tcx> {
115+
Ok(())
116+
}
80117
}

0 commit comments

Comments
 (0)