Skip to content

Commit

Permalink
bump rust
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jul 21, 2019
1 parent 619d29a commit a2541aa
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
527dce7137f7a3c7bf47d9a503abf25f88ea22de
1301422a6c2e8916560b8cc2f0564f38d8858a75
9 changes: 4 additions & 5 deletions src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ use syntax::source_map::DUMMY_SP;
use rustc::ty::{self, TyCtxt};
use rustc::ty::layout::{LayoutOf, Size, Align};
use rustc::hir::def_id::DefId;
use rustc::mir;

use crate::{
InterpResult, InterpError, InterpCx, StackPopCleanup, struct_error,
Scalar, Tag, Pointer, FnVal,
MemoryExtra, MiriMemoryKind, Evaluator, TlsEvalContextExt,
MemoryExtra, MiriMemoryKind, Evaluator, TlsEvalContextExt, HelpersEvalContextExt,
};

/// Configuration needed to spawn a Miri instance.
Expand Down Expand Up @@ -85,11 +84,11 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(

// First argument: pointer to `main()`.
let main_ptr = ecx.memory_mut().create_fn_alloc(FnVal::Instance(main_instance));
let dest = ecx.eval_place(&mir::Place::Base(mir::PlaceBase::Local(args.next().unwrap())))?;
let dest = ecx.local_place(args.next().unwrap())?;
ecx.write_scalar(Scalar::Ptr(main_ptr), dest)?;

// Second argument (argc): `1`.
let dest = ecx.eval_place(&mir::Place::Base(mir::PlaceBase::Local(args.next().unwrap())))?;
let dest = ecx.local_place(args.next().unwrap())?;
let argc = Scalar::from_uint(config.args.len() as u128, dest.layout.size);
ecx.write_scalar(argc, dest)?;
// Store argc for macOS's `_NSGetArgc`.
Expand All @@ -100,7 +99,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
}

// Third argument (`argv`): created from `config.args`.
let dest = ecx.eval_place(&mir::Place::Base(mir::PlaceBase::Local(args.next().unwrap())))?;
let dest = ecx.local_place(args.next().unwrap())?;
// For Windows, construct a command string with all the aguments.
let mut cmd = String::new();
for arg in config.args.iter() {
Expand Down
8 changes: 8 additions & 0 deletions src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::mem;

use rustc::ty::{self, layout::{self, Size, Align}};
use rustc::hir::def_id::{DefId, CRATE_DEF_INDEX};
use rustc::mir;

use rand::RngCore;

Expand Down Expand Up @@ -67,6 +68,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
})
}

/// Get the `Place` for a local
fn local_place(&mut self, local: mir::Local) -> InterpResult<'tcx, PlaceTy<'tcx, Tag>> {
let this = self.eval_context_mut();
let place = mir::Place { base: mir::PlaceBase::Local(local), projection: None };
this.eval_place(&place)
}

/// Generate some random bytes, and write them to `dest`.
fn gen_random(
&mut self,
Expand Down
4 changes: 2 additions & 2 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {

// First argument: `size`.
// (`0` is allowed here -- this is expected to be handled by the lang item).
let arg = ecx.eval_place(&mir::Place::Base(mir::PlaceBase::Local(args.next().unwrap())))?;
let arg = ecx.local_place(args.next().unwrap())?;
let size = layout.size.bytes();
ecx.write_scalar(Scalar::from_uint(size, arg.layout.size), arg)?;

// Second argument: `align`.
let arg = ecx.eval_place(&mir::Place::Base(mir::PlaceBase::Local(args.next().unwrap())))?;
let arg = ecx.local_place(args.next().unwrap())?;
let align = layout.align.abi.bytes();
ecx.write_scalar(Scalar::from_uint(align, arg.layout.size), arg)?;

Expand Down
2 changes: 1 addition & 1 deletion src/shims/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
.to_owned(),
),
)?;
let arg_dest = this.eval_place(&mir::Place::Base(mir::PlaceBase::Local(arg_local)))?;
let arg_dest = this.local_place(arg_local)?;
this.write_scalar(data, arg_dest)?;

assert!(args.next().is_none(), "__rust_maybe_catch_panic argument has more arguments than expected");
Expand Down
4 changes: 2 additions & 2 deletions src/shims/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::collections::BTreeMap;

use rustc_target::abi::LayoutOf;
use rustc::{ty, ty::layout::HasDataLayout, mir};
use rustc::{ty, ty::layout::HasDataLayout};

use crate::{
InterpResult, InterpError, StackPopCleanup,
Expand Down Expand Up @@ -160,7 +160,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
let arg_local = this.frame().body.args_iter().next().ok_or_else(
|| InterpError::AbiViolation("TLS dtor does not take enough arguments.".to_owned()),
)?;
let dest = this.eval_place(&mir::Place::Base(mir::PlaceBase::Local(arg_local)))?;
let dest = this.local_place(arg_local)?;
this.write_scalar(ptr, dest)?;

// step until out of stackframes
Expand Down

0 comments on commit a2541aa

Please sign in to comment.