rustup for EvalResult rename
This commit is contained in:
parent
6ab014723a
commit
d6bcfc58e3
8 changed files with 59 additions and 59 deletions
|
|
@ -1 +1 @@
|
|||
7cdaffd7962c4aae0cadd82baa241901b03f9458
|
||||
5c45343f11fbf93cf4e15568aee3ff3f2f287466
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
|
|||
args: &[OpTy<'tcx, Tag>],
|
||||
dest: Option<PlaceTy<'tcx, Tag>>,
|
||||
ret: Option<mir::BasicBlock>,
|
||||
) -> EvalResult<'tcx, Option<&'mir mir::Body<'tcx>>> {
|
||||
) -> InterpResult<'tcx, Option<&'mir mir::Body<'tcx>>> {
|
||||
let this = self.eval_context_mut();
|
||||
trace!("eval_fn_call: {:#?}, {:?}", instance, dest.map(|place| *place));
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
|
|||
fn free(
|
||||
&mut self,
|
||||
ptr: Scalar<Tag>,
|
||||
) -> EvalResult<'tcx> {
|
||||
) -> InterpResult<'tcx> {
|
||||
let this = self.eval_context_mut();
|
||||
if !ptr.is_null_ptr(this) {
|
||||
this.memory_mut().deallocate(
|
||||
|
|
@ -92,7 +92,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
|
|||
&mut self,
|
||||
old_ptr: Scalar<Tag>,
|
||||
new_size: u64,
|
||||
) -> EvalResult<'tcx, Scalar<Tag>> {
|
||||
) -> InterpResult<'tcx, Scalar<Tag>> {
|
||||
let this = self.eval_context_mut();
|
||||
let align = this.tcx.data_layout.pointer_align.abi;
|
||||
if old_ptr.is_null_ptr(this) {
|
||||
|
|
@ -139,7 +139,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
|
|||
args: &[OpTy<'tcx, Tag>],
|
||||
dest: Option<PlaceTy<'tcx, Tag>>,
|
||||
ret: Option<mir::BasicBlock>,
|
||||
) -> EvalResult<'tcx> {
|
||||
) -> InterpResult<'tcx> {
|
||||
let this = self.eval_context_mut();
|
||||
let attrs = this.tcx.get_attrs(def_id);
|
||||
let link_name = match attr::first_attr_value_str_by_name(&attrs, sym::link_name) {
|
||||
|
|
@ -895,13 +895,13 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn write_null(&mut self, dest: PlaceTy<'tcx, Tag>) -> EvalResult<'tcx> {
|
||||
fn write_null(&mut self, dest: PlaceTy<'tcx, Tag>) -> InterpResult<'tcx> {
|
||||
self.eval_context_mut().write_scalar(Scalar::from_int(0, dest.layout.size), dest)
|
||||
}
|
||||
|
||||
/// Evaluates the scalar at the specified path. Returns Some(val)
|
||||
/// if the path could be resolved, and None otherwise
|
||||
fn eval_path_scalar(&mut self, path: &[&str]) -> EvalResult<'tcx, Option<ScalarMaybeUndef<Tag>>> {
|
||||
fn eval_path_scalar(&mut self, path: &[&str]) -> InterpResult<'tcx, Option<ScalarMaybeUndef<Tag>>> {
|
||||
let this = self.eval_context_mut();
|
||||
if let Ok(instance) = this.resolve_path(path) {
|
||||
let cid = GlobalId {
|
||||
|
|
@ -920,7 +920,7 @@ fn gen_random<'a, 'mir, 'tcx>(
|
|||
this: &mut MiriEvalContext<'a, 'mir, 'tcx>,
|
||||
len: usize,
|
||||
dest: Scalar<Tag>,
|
||||
) -> EvalResult<'tcx> {
|
||||
) -> InterpResult<'tcx> {
|
||||
if len == 0 {
|
||||
// Nothing to do
|
||||
return Ok(());
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'a, 'mir, 'tcx> for crate::MiriEvalContext<'
|
|||
|
||||
pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'a, 'mir, 'tcx> {
|
||||
/// Gets an instance for a path.
|
||||
fn resolve_path(&self, path: &[&str]) -> EvalResult<'tcx, ty::Instance<'tcx>> {
|
||||
fn resolve_path(&self, path: &[&str]) -> InterpResult<'tcx, ty::Instance<'tcx>> {
|
||||
let this = self.eval_context_ref();
|
||||
this.tcx
|
||||
.crates()
|
||||
|
|
@ -49,8 +49,8 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
|
|||
&self,
|
||||
place: MPlaceTy<'tcx, Tag>,
|
||||
size: Size,
|
||||
mut action: impl FnMut(Pointer<Tag>, Size, bool) -> EvalResult<'tcx>,
|
||||
) -> EvalResult<'tcx> {
|
||||
mut action: impl FnMut(Pointer<Tag>, Size, bool) -> InterpResult<'tcx>,
|
||||
) -> InterpResult<'tcx> {
|
||||
let this = self.eval_context_ref();
|
||||
trace!("visit_frozen(place={:?}, size={:?})", *place, size);
|
||||
debug_assert_eq!(size,
|
||||
|
|
@ -120,7 +120,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
|
|||
/// Visiting the memory covered by a `MemPlace`, being aware of
|
||||
/// whether we are inside an `UnsafeCell` or not.
|
||||
struct UnsafeCellVisitor<'ecx, 'a, 'mir, 'tcx, F>
|
||||
where F: FnMut(MPlaceTy<'tcx, Tag>) -> EvalResult<'tcx>
|
||||
where F: FnMut(MPlaceTy<'tcx, Tag>) -> InterpResult<'tcx>
|
||||
{
|
||||
ecx: &'ecx MiriEvalContext<'a, 'mir, 'tcx>,
|
||||
unsafe_cell_action: F,
|
||||
|
|
@ -131,7 +131,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
|
|||
for
|
||||
UnsafeCellVisitor<'ecx, 'a, 'mir, 'tcx, F>
|
||||
where
|
||||
F: FnMut(MPlaceTy<'tcx, Tag>) -> EvalResult<'tcx>
|
||||
F: FnMut(MPlaceTy<'tcx, Tag>) -> InterpResult<'tcx>
|
||||
{
|
||||
type V = MPlaceTy<'tcx, Tag>;
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
|
|||
}
|
||||
|
||||
// Hook to detect `UnsafeCell`.
|
||||
fn visit_value(&mut self, v: MPlaceTy<'tcx, Tag>) -> EvalResult<'tcx>
|
||||
fn visit_value(&mut self, v: MPlaceTy<'tcx, Tag>) -> InterpResult<'tcx>
|
||||
{
|
||||
trace!("UnsafeCellVisitor: {:?} {:?}", *v, v.layout.ty);
|
||||
let is_unsafe_cell = match v.layout.ty.sty {
|
||||
|
|
@ -164,8 +164,8 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
|
|||
fn visit_aggregate(
|
||||
&mut self,
|
||||
place: MPlaceTy<'tcx, Tag>,
|
||||
fields: impl Iterator<Item=EvalResult<'tcx, MPlaceTy<'tcx, Tag>>>,
|
||||
) -> EvalResult<'tcx> {
|
||||
fields: impl Iterator<Item=InterpResult<'tcx, MPlaceTy<'tcx, Tag>>>,
|
||||
) -> InterpResult<'tcx> {
|
||||
match place.layout.fields {
|
||||
layout::FieldPlacement::Array { .. } => {
|
||||
// For the array layout, we know the iterator will yield sorted elements so
|
||||
|
|
@ -174,7 +174,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
|
|||
}
|
||||
layout::FieldPlacement::Arbitrary { .. } => {
|
||||
// Gather the subplaces and sort them before visiting.
|
||||
let mut places = fields.collect::<EvalResult<'tcx, Vec<MPlaceTy<'tcx, Tag>>>>()?;
|
||||
let mut places = fields.collect::<InterpResult<'tcx, Vec<MPlaceTy<'tcx, Tag>>>>()?;
|
||||
places.sort_by_key(|place| place.ptr.get_ptr_offset(self.ecx()));
|
||||
self.walk_aggregate(place, places.into_iter().map(Ok))
|
||||
}
|
||||
|
|
@ -186,7 +186,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
|
|||
}
|
||||
|
||||
// We have to do *something* for unions.
|
||||
fn visit_union(&mut self, v: MPlaceTy<'tcx, Tag>) -> EvalResult<'tcx>
|
||||
fn visit_union(&mut self, v: MPlaceTy<'tcx, Tag>) -> InterpResult<'tcx>
|
||||
{
|
||||
// With unions, we fall back to whatever the type says, to hopefully be consistent
|
||||
// with LLVM IR.
|
||||
|
|
@ -200,7 +200,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
|
|||
}
|
||||
|
||||
// We should never get to a primitive, but always short-circuit somewhere above.
|
||||
fn visit_primitive(&mut self, _v: MPlaceTy<'tcx, Tag>) -> EvalResult<'tcx>
|
||||
fn visit_primitive(&mut self, _v: MPlaceTy<'tcx, Tag>) -> InterpResult<'tcx>
|
||||
{
|
||||
bug!("we should always short-circuit before coming to a primitive")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use rustc::mir;
|
||||
use rustc::mir::interpret::{EvalResult, PointerArithmetic};
|
||||
use rustc::mir::interpret::{InterpResult, PointerArithmetic};
|
||||
use rustc::ty::layout::{self, LayoutOf, Size};
|
||||
use rustc::ty;
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
|
|||
instance: ty::Instance<'tcx>,
|
||||
args: &[OpTy<'tcx, Tag>],
|
||||
dest: PlaceTy<'tcx, Tag>,
|
||||
) -> EvalResult<'tcx> {
|
||||
) -> InterpResult<'tcx> {
|
||||
let this = self.eval_context_mut();
|
||||
if this.emulate_intrinsic(instance, args, dest)? {
|
||||
return Ok(());
|
||||
|
|
|
|||
22
src/lib.rs
22
src/lib.rs
|
|
@ -75,7 +75,7 @@ pub fn create_ecx<'a, 'mir: 'a, 'tcx: 'mir>(
|
|||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
main_id: DefId,
|
||||
config: MiriConfig,
|
||||
) -> EvalResult<'tcx, InterpretCx<'a, 'mir, 'tcx, Evaluator<'tcx>>> {
|
||||
) -> InterpResult<'tcx, InterpretCx<'a, 'mir, 'tcx, Evaluator<'tcx>>> {
|
||||
let mut ecx = InterpretCx::new(
|
||||
tcx.at(syntax::source_map::DUMMY_SP),
|
||||
ty::ParamEnv::reveal_all(),
|
||||
|
|
@ -225,7 +225,7 @@ pub fn eval_main<'a, 'tcx: 'a>(
|
|||
};
|
||||
|
||||
// Perform the main execution.
|
||||
let res: EvalResult = (|| {
|
||||
let res: InterpResult = (|| {
|
||||
ecx.run()?;
|
||||
ecx.run_tls_dtors()
|
||||
})();
|
||||
|
|
@ -407,7 +407,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
|
|||
args: &[OpTy<'tcx, Tag>],
|
||||
dest: Option<PlaceTy<'tcx, Tag>>,
|
||||
ret: Option<mir::BasicBlock>,
|
||||
) -> EvalResult<'tcx, Option<&'mir mir::Body<'tcx>>> {
|
||||
) -> InterpResult<'tcx, Option<&'mir mir::Body<'tcx>>> {
|
||||
ecx.find_fn(instance, args, dest, ret)
|
||||
}
|
||||
|
||||
|
|
@ -417,7 +417,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
|
|||
instance: ty::Instance<'tcx>,
|
||||
args: &[OpTy<'tcx, Tag>],
|
||||
dest: PlaceTy<'tcx, Tag>,
|
||||
) -> EvalResult<'tcx> {
|
||||
) -> InterpResult<'tcx> {
|
||||
ecx.call_intrinsic(instance, args, dest)
|
||||
}
|
||||
|
||||
|
|
@ -427,14 +427,14 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
|
|||
bin_op: mir::BinOp,
|
||||
left: ImmTy<'tcx, Tag>,
|
||||
right: ImmTy<'tcx, Tag>,
|
||||
) -> EvalResult<'tcx, (Scalar<Tag>, bool)> {
|
||||
) -> InterpResult<'tcx, (Scalar<Tag>, bool)> {
|
||||
ecx.ptr_op(bin_op, left, right)
|
||||
}
|
||||
|
||||
fn box_alloc(
|
||||
ecx: &mut InterpretCx<'a, 'mir, 'tcx, Self>,
|
||||
dest: PlaceTy<'tcx, Tag>,
|
||||
) -> EvalResult<'tcx> {
|
||||
) -> InterpResult<'tcx> {
|
||||
trace!("box_alloc for {:?}", dest.layout.ty);
|
||||
// Call the `exchange_malloc` lang item.
|
||||
let malloc = ecx.tcx.lang_items().exchange_malloc_fn().unwrap();
|
||||
|
|
@ -476,7 +476,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
|
|||
fn find_foreign_static(
|
||||
def_id: DefId,
|
||||
tcx: TyCtxtAt<'a, 'tcx, 'tcx>,
|
||||
) -> EvalResult<'tcx, Cow<'tcx, Allocation>> {
|
||||
) -> InterpResult<'tcx, Cow<'tcx, Allocation>> {
|
||||
let attrs = tcx.get_attrs(def_id);
|
||||
let link_name = match attr::first_attr_value_str_by_name(&attrs, sym::link_name) {
|
||||
Some(name) => name.as_str(),
|
||||
|
|
@ -498,7 +498,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn before_terminator(_ecx: &mut InterpretCx<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx>
|
||||
fn before_terminator(_ecx: &mut InterpretCx<'a, 'mir, 'tcx, Self>) -> InterpResult<'tcx>
|
||||
{
|
||||
// We are not interested in detecting loops.
|
||||
Ok(())
|
||||
|
|
@ -553,7 +553,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
|
|||
ecx: &mut InterpretCx<'a, 'mir, 'tcx, Self>,
|
||||
kind: mir::RetagKind,
|
||||
place: PlaceTy<'tcx, Tag>,
|
||||
) -> EvalResult<'tcx> {
|
||||
) -> InterpResult<'tcx> {
|
||||
if !ecx.tcx.sess.opts.debugging_opts.mir_emit_retag || !Self::enforce_validity(ecx) {
|
||||
// No tracking, or no retagging. The latter is possible because a dependency of ours
|
||||
// might be called with different flags than we are, so there are `Retag`
|
||||
|
|
@ -569,7 +569,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
|
|||
#[inline(always)]
|
||||
fn stack_push(
|
||||
ecx: &mut InterpretCx<'a, 'mir, 'tcx, Self>,
|
||||
) -> EvalResult<'tcx, stacked_borrows::CallId> {
|
||||
) -> InterpResult<'tcx, stacked_borrows::CallId> {
|
||||
Ok(ecx.memory().extra.borrow_mut().new_call())
|
||||
}
|
||||
|
||||
|
|
@ -577,7 +577,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
|
|||
fn stack_pop(
|
||||
ecx: &mut InterpretCx<'a, 'mir, 'tcx, Self>,
|
||||
extra: stacked_borrows::CallId,
|
||||
) -> EvalResult<'tcx> {
|
||||
) -> InterpResult<'tcx> {
|
||||
Ok(ecx.memory().extra.borrow_mut().end_call(extra))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ pub trait EvalContextExt<'tcx> {
|
|||
bin_op: mir::BinOp,
|
||||
left: ImmTy<'tcx, Tag>,
|
||||
right: ImmTy<'tcx, Tag>,
|
||||
) -> EvalResult<'tcx, (Scalar<Tag>, bool)>;
|
||||
) -> InterpResult<'tcx, (Scalar<Tag>, bool)>;
|
||||
|
||||
fn ptr_int_arithmetic(
|
||||
&self,
|
||||
|
|
@ -17,20 +17,20 @@ pub trait EvalContextExt<'tcx> {
|
|||
left: Pointer<Tag>,
|
||||
right: u128,
|
||||
signed: bool,
|
||||
) -> EvalResult<'tcx, (Scalar<Tag>, bool)>;
|
||||
) -> InterpResult<'tcx, (Scalar<Tag>, bool)>;
|
||||
|
||||
fn ptr_eq(
|
||||
&self,
|
||||
left: Scalar<Tag>,
|
||||
right: Scalar<Tag>,
|
||||
) -> EvalResult<'tcx, bool>;
|
||||
) -> InterpResult<'tcx, bool>;
|
||||
|
||||
fn pointer_offset_inbounds(
|
||||
&self,
|
||||
ptr: Scalar<Tag>,
|
||||
pointee_ty: Ty<'tcx>,
|
||||
offset: i64,
|
||||
) -> EvalResult<'tcx, Scalar<Tag>>;
|
||||
) -> InterpResult<'tcx, Scalar<Tag>>;
|
||||
}
|
||||
|
||||
impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, 'tcx> {
|
||||
|
|
@ -39,7 +39,7 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
|
|||
bin_op: mir::BinOp,
|
||||
left: ImmTy<'tcx, Tag>,
|
||||
right: ImmTy<'tcx, Tag>,
|
||||
) -> EvalResult<'tcx, (Scalar<Tag>, bool)> {
|
||||
) -> InterpResult<'tcx, (Scalar<Tag>, bool)> {
|
||||
use rustc::mir::BinOp::*;
|
||||
|
||||
trace!("ptr_op: {:?} {:?} {:?}", *left, bin_op, *right);
|
||||
|
|
@ -138,7 +138,7 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
|
|||
&self,
|
||||
left: Scalar<Tag>,
|
||||
right: Scalar<Tag>,
|
||||
) -> EvalResult<'tcx, bool> {
|
||||
) -> InterpResult<'tcx, bool> {
|
||||
let size = self.pointer_size();
|
||||
Ok(match (left, right) {
|
||||
(Scalar::Raw { .. }, Scalar::Raw { .. }) =>
|
||||
|
|
@ -236,7 +236,7 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
|
|||
left: Pointer<Tag>,
|
||||
right: u128,
|
||||
signed: bool,
|
||||
) -> EvalResult<'tcx, (Scalar<Tag>, bool)> {
|
||||
) -> InterpResult<'tcx, (Scalar<Tag>, bool)> {
|
||||
use rustc::mir::BinOp::*;
|
||||
|
||||
fn map_to_primval((res, over): (Pointer<Tag>, bool)) -> (Scalar<Tag>, bool) {
|
||||
|
|
@ -328,7 +328,7 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
|
|||
ptr: Scalar<Tag>,
|
||||
pointee_ty: Ty<'tcx>,
|
||||
offset: i64,
|
||||
) -> EvalResult<'tcx, Scalar<Tag>> {
|
||||
) -> InterpResult<'tcx, Scalar<Tag>> {
|
||||
// FIXME: assuming here that type size is less than `i64::max_value()`.
|
||||
let pointee_size = self.layout_of(pointee_ty)?.size.bytes() as i64;
|
||||
let offset = offset
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use rustc::hir::{MutMutable, MutImmutable};
|
|||
use rustc::mir::RetagKind;
|
||||
|
||||
use crate::{
|
||||
EvalResult, InterpError, MiriEvalContext, HelpersEvalContextExt, Evaluator, MutValueVisitor,
|
||||
InterpResult, InterpError, MiriEvalContext, HelpersEvalContextExt, Evaluator, MutValueVisitor,
|
||||
MemoryKind, MiriMemoryKind, RangeMap, Allocation, AllocationExtra, AllocId, CheckInAllocMsg,
|
||||
Pointer, Immediate, ImmTy, PlaceTy, MPlaceTy,
|
||||
};
|
||||
|
|
@ -266,7 +266,7 @@ impl<'tcx> Stack {
|
|||
}
|
||||
|
||||
/// Check if the given item is protected.
|
||||
fn check_protector(item: &Item, tag: Option<Tag>, global: &GlobalState) -> EvalResult<'tcx> {
|
||||
fn check_protector(item: &Item, tag: Option<Tag>, global: &GlobalState) -> InterpResult<'tcx> {
|
||||
if let Some(call) = item.protector {
|
||||
if global.is_active(call) {
|
||||
if let Some(tag) = tag {
|
||||
|
|
@ -291,7 +291,7 @@ impl<'tcx> Stack {
|
|||
access: AccessKind,
|
||||
tag: Tag,
|
||||
global: &GlobalState,
|
||||
) -> EvalResult<'tcx> {
|
||||
) -> InterpResult<'tcx> {
|
||||
// Two main steps: Find granting item, remove incompatible items above.
|
||||
|
||||
// Step 1: Find granting item.
|
||||
|
|
@ -340,7 +340,7 @@ impl<'tcx> Stack {
|
|||
&mut self,
|
||||
tag: Tag,
|
||||
global: &GlobalState,
|
||||
) -> EvalResult<'tcx> {
|
||||
) -> InterpResult<'tcx> {
|
||||
// Step 1: Find granting item.
|
||||
self.find_granting(AccessKind::Write, tag)
|
||||
.ok_or_else(|| InterpError::MachineError(format!(
|
||||
|
|
@ -365,7 +365,7 @@ impl<'tcx> Stack {
|
|||
derived_from: Tag,
|
||||
new: Item,
|
||||
global: &GlobalState,
|
||||
) -> EvalResult<'tcx> {
|
||||
) -> InterpResult<'tcx> {
|
||||
// Figure out which access `perm` corresponds to.
|
||||
let access = if new.perm.grants(AccessKind::Write) {
|
||||
AccessKind::Write
|
||||
|
|
@ -440,8 +440,8 @@ impl<'tcx> Stacks {
|
|||
&self,
|
||||
ptr: Pointer<Tag>,
|
||||
size: Size,
|
||||
f: impl Fn(&mut Stack, &GlobalState) -> EvalResult<'tcx>,
|
||||
) -> EvalResult<'tcx> {
|
||||
f: impl Fn(&mut Stack, &GlobalState) -> InterpResult<'tcx>,
|
||||
) -> InterpResult<'tcx> {
|
||||
let global = self.global.borrow();
|
||||
let mut stacks = self.stacks.borrow_mut();
|
||||
for stack in stacks.iter_mut(ptr.offset, size) {
|
||||
|
|
@ -483,7 +483,7 @@ impl AllocationExtra<Tag> for Stacks {
|
|||
alloc: &Allocation<Tag, Stacks>,
|
||||
ptr: Pointer<Tag>,
|
||||
size: Size,
|
||||
) -> EvalResult<'tcx> {
|
||||
) -> InterpResult<'tcx> {
|
||||
trace!("read access with tag {:?}: {:?}, size {}", ptr.tag, ptr.erase_tag(), size.bytes());
|
||||
alloc.extra.for_each(ptr, size, |stack, global| {
|
||||
stack.access(AccessKind::Read, ptr.tag, global)?;
|
||||
|
|
@ -496,7 +496,7 @@ impl AllocationExtra<Tag> for Stacks {
|
|||
alloc: &mut Allocation<Tag, Stacks>,
|
||||
ptr: Pointer<Tag>,
|
||||
size: Size,
|
||||
) -> EvalResult<'tcx> {
|
||||
) -> InterpResult<'tcx> {
|
||||
trace!("write access with tag {:?}: {:?}, size {}", ptr.tag, ptr.erase_tag(), size.bytes());
|
||||
alloc.extra.for_each(ptr, size, |stack, global| {
|
||||
stack.access(AccessKind::Write, ptr.tag, global)?;
|
||||
|
|
@ -509,7 +509,7 @@ impl AllocationExtra<Tag> for Stacks {
|
|||
alloc: &mut Allocation<Tag, Stacks>,
|
||||
ptr: Pointer<Tag>,
|
||||
size: Size,
|
||||
) -> EvalResult<'tcx> {
|
||||
) -> InterpResult<'tcx> {
|
||||
trace!("deallocation with tag {:?}: {:?}, size {}", ptr.tag, ptr.erase_tag(), size.bytes());
|
||||
alloc.extra.for_each(ptr, size, |stack, global| {
|
||||
stack.dealloc(ptr.tag, global)
|
||||
|
|
@ -528,7 +528,7 @@ trait EvalContextPrivExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
|
|||
kind: RefKind,
|
||||
new_tag: Tag,
|
||||
protect: bool,
|
||||
) -> EvalResult<'tcx> {
|
||||
) -> InterpResult<'tcx> {
|
||||
let this = self.eval_context_mut();
|
||||
let protector = if protect { Some(this.frame().extra) } else { None };
|
||||
let ptr = place.ptr.to_ptr()?;
|
||||
|
|
@ -572,7 +572,7 @@ trait EvalContextPrivExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
|
|||
val: ImmTy<'tcx, Tag>,
|
||||
kind: RefKind,
|
||||
protect: bool,
|
||||
) -> EvalResult<'tcx, Immediate<Tag>> {
|
||||
) -> InterpResult<'tcx, Immediate<Tag>> {
|
||||
let this = self.eval_context_mut();
|
||||
// We want a place for where the ptr *points to*, so we get one.
|
||||
let place = this.ref_to_mplace(val)?;
|
||||
|
|
@ -605,7 +605,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
|
|||
&mut self,
|
||||
kind: RetagKind,
|
||||
place: PlaceTy<'tcx, Tag>
|
||||
) -> EvalResult<'tcx> {
|
||||
) -> InterpResult<'tcx> {
|
||||
let this = self.eval_context_mut();
|
||||
// Determine mutability and whether to add a protector.
|
||||
// Cannot use `builtin_deref` because that reports *immutable* for `Box`,
|
||||
|
|
@ -660,7 +660,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
|
|||
}
|
||||
|
||||
// Primitives of reference type, that is the one thing we are interested in.
|
||||
fn visit_primitive(&mut self, place: MPlaceTy<'tcx, Tag>) -> EvalResult<'tcx>
|
||||
fn visit_primitive(&mut self, place: MPlaceTy<'tcx, Tag>) -> InterpResult<'tcx>
|
||||
{
|
||||
// Cannot use `builtin_deref` because that reports *immutable* for `Box`,
|
||||
// making it useless.
|
||||
|
|
|
|||
10
src/tls.rs
10
src/tls.rs
|
|
@ -4,7 +4,7 @@ use rustc_target::abi::LayoutOf;
|
|||
use rustc::{ty, ty::layout::HasDataLayout, mir};
|
||||
|
||||
use crate::{
|
||||
EvalResult, InterpError, StackPopCleanup,
|
||||
InterpResult, InterpError, StackPopCleanup,
|
||||
MPlaceTy, Scalar, Tag,
|
||||
};
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ impl<'tcx> TlsData<'tcx> {
|
|||
new_key
|
||||
}
|
||||
|
||||
pub fn delete_tls_key(&mut self, key: TlsKey) -> EvalResult<'tcx> {
|
||||
pub fn delete_tls_key(&mut self, key: TlsKey) -> InterpResult<'tcx> {
|
||||
match self.keys.remove(&key) {
|
||||
Some(_) => {
|
||||
trace!("TLS key {} removed", key);
|
||||
|
|
@ -63,7 +63,7 @@ impl<'tcx> TlsData<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn load_tls(&mut self, key: TlsKey) -> EvalResult<'tcx, Scalar<Tag>> {
|
||||
pub fn load_tls(&mut self, key: TlsKey) -> InterpResult<'tcx, Scalar<Tag>> {
|
||||
match self.keys.get(&key) {
|
||||
Some(&TlsEntry { data, .. }) => {
|
||||
trace!("TLS key {} loaded: {:?}", key, data);
|
||||
|
|
@ -73,7 +73,7 @@ impl<'tcx> TlsData<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn store_tls(&mut self, key: TlsKey, new_data: Scalar<Tag>) -> EvalResult<'tcx> {
|
||||
pub fn store_tls(&mut self, key: TlsKey, new_data: Scalar<Tag>) -> InterpResult<'tcx> {
|
||||
match self.keys.get_mut(&key) {
|
||||
Some(&mut TlsEntry { ref mut data, .. }) => {
|
||||
trace!("TLS key {} stored: {:?}", key, new_data);
|
||||
|
|
@ -131,7 +131,7 @@ impl<'tcx> TlsData<'tcx> {
|
|||
|
||||
impl<'a, 'mir, 'tcx> EvalContextExt<'a, 'mir, 'tcx> for crate::MiriEvalContext<'a, 'mir, 'tcx> {}
|
||||
pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a, 'mir, 'tcx> {
|
||||
fn run_tls_dtors(&mut self) -> EvalResult<'tcx> {
|
||||
fn run_tls_dtors(&mut self) -> InterpResult<'tcx> {
|
||||
let this = self.eval_context_mut();
|
||||
let mut dtor = this.machine.tls.fetch_tls_dtor(None, &*this.tcx);
|
||||
// FIXME: replace loop by some structure that works with stepping
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue