Skip to content

Commit

Permalink
Showing 14 changed files with 61 additions and 1,498 deletions.
9 changes: 0 additions & 9 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/librustc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -24,7 +24,6 @@ rustc_errors = { path = "../librustc_errors" }
serialize = { path = "../libserialize" }
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
regex = "0.2.2"
backtrace = "0.3.3"
byteorder = { version = "1.1", features = ["i128"]}

1 change: 0 additions & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
@@ -92,7 +92,6 @@ extern crate serialize as rustc_serialize; // used by deriving

extern crate rustc_apfloat;
extern crate byteorder;
extern crate regex;
extern crate backtrace;

// Note that librustc doesn't actually depend on these crates, see the note in
2 changes: 0 additions & 2 deletions src/librustc_mir/Cargo.toml
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ bitflags = "1.0"
graphviz = { path = "../libgraphviz" }
log = "0.3"
log_settings = "0.1.1"
lazy_static = "1.0"
rustc = { path = "../librustc" }
rustc_const_eval = { path = "../librustc_const_eval" }
rustc_const_math = { path = "../librustc_const_math" }
@@ -23,5 +22,4 @@ serialize = { path = "../libserialize" }
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
byteorder = { version = "1.1", features = ["i128"] }
regex = "0.2"
rustc_apfloat = { path = "../librustc_apfloat" }
18 changes: 7 additions & 11 deletions src/librustc_mir/interpret/eval_context.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::{HashMap, HashSet};
use std::collections::HashSet;
use std::fmt::Write;

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

use super::{Place, PlaceExtra, Memory,
HasMemory, MemoryKind, operator,
ValidationQuery, Machine};
Machine};

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

/// Places that were suspended by the validation subsystem, and will be recovered later
pub(crate) suspended: HashMap<DynamicLifetime, Vec<ValidationQuery<'tcx>>>,

/// The virtual call stack.
pub(crate) stack: Vec<Frame<'tcx>>,

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

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

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

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

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

pub(super) fn substs(&self) -> &'tcx Substs<'tcx> {
pub fn substs(&self) -> &'tcx Substs<'tcx> {
if let Some(frame) = self.stack.last() {
frame.instance.substs
} else {
41 changes: 39 additions & 2 deletions src/librustc_mir/interpret/machine.rs
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@
//! This separation exists to ensure that no fancy miri features like
//! interpreting common C functions leak into CTFE.
use rustc::mir::interpret::{EvalResult, PrimVal};
use super::{EvalContext, Place, ValTy};
use rustc::mir::interpret::{EvalResult, PrimVal, MemoryPointer, AccessKind};
use super::{EvalContext, Place, ValTy, Memory};

use rustc::mir;
use rustc::ty::{self, Ty};
@@ -77,4 +77,41 @@ pub trait Machine<'tcx>: Sized {
instance: ty::Instance<'tcx>,
mutability: Mutability,
) -> EvalResult<'tcx>;

fn check_locks<'a>(
_mem: &Memory<'a, 'tcx, Self>,
_ptr: MemoryPointer,
_size: u64,
_access: AccessKind,
) -> EvalResult<'tcx> {
Ok(())
}

fn add_lock<'a>(
_mem: &mut Memory<'a, 'tcx, Self>,
_id: u64,
) {}

fn free_lock<'a>(
_mem: &mut Memory<'a, 'tcx, Self>,
_id: u64,
_len: u64,
) -> EvalResult<'tcx> {
Ok(())
}

fn end_region<'a>(
_ecx: &mut EvalContext<'a, 'tcx, Self>,
_reg: Option<::rustc::middle::region::Scope>,
) -> EvalResult<'tcx> {
Ok(())
}

fn validation_op<'a>(
_ecx: &mut EvalContext<'a, 'tcx, Self>,
_op: ::rustc::mir::ValidationOp,
_operand: &::rustc::mir::ValidationOperand<'tcx, ::rustc::mir::Place<'tcx>>,
) -> EvalResult<'tcx> {
Ok(())
}
}
Loading

0 comments on commit 1ba46dc

Please sign in to comment.