Skip to content

Commit

Permalink
rustup
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Aug 27, 2022
1 parent 3a2252b commit df19b85
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 54 deletions.
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e1b28cd2f16bd5b832183d7968cae3bb9213e78d
4065b89b1e7287047d7d6c65e7abd7b8ee70bcf0
19 changes: 3 additions & 16 deletions src/concurrency/data_race.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,12 +530,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {

this.validate_atomic_rmw(place, atomic)?;

this.buffered_atomic_rmw(
val.to_scalar(),
place,
atomic,
old.to_scalar(),
)?;
this.buffered_atomic_rmw(val.to_scalar(), place, atomic, old.to_scalar())?;
Ok(old)
}

Expand Down Expand Up @@ -586,12 +581,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {

this.validate_atomic_rmw(place, atomic)?;

this.buffered_atomic_rmw(
new_val.to_scalar(),
place,
atomic,
old.to_scalar(),
)?;
this.buffered_atomic_rmw(new_val.to_scalar(), place, atomic, old.to_scalar())?;

// Return the old value.
Ok(old)
Expand Down Expand Up @@ -633,10 +623,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
} else {
true
};
let res = Immediate::ScalarPair(
old.to_scalar(),
Scalar::from_bool(cmpxchg_success).into(),
);
let res = Immediate::ScalarPair(old.to_scalar(), Scalar::from_bool(cmpxchg_success));

// Update ptr depending on comparison.
// if successful, perform a full rw-atomic validation
Expand Down
10 changes: 2 additions & 8 deletions src/concurrency/weak_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ use std::{
collections::VecDeque,
};

use rustc_const_eval::interpret::{
alloc_range, AllocRange, InterpResult, MPlaceTy, Scalar,
};
use rustc_const_eval::interpret::{alloc_range, AllocRange, InterpResult, MPlaceTy, Scalar};
use rustc_data_structures::fx::FxHashMap;

use crate::*;
Expand Down Expand Up @@ -417,11 +415,7 @@ impl StoreElement {
/// buffer regardless of subsequent loads by the same thread; if the earliest load of another
/// thread doesn't happen before the current one, then no subsequent load by the other thread
/// can happen before the current one.
fn load_impl(
&self,
index: VectorIdx,
clocks: &ThreadClockSet,
) -> Scalar<Provenance> {
fn load_impl(&self, index: VectorIdx, clocks: &ThreadClockSet) -> Scalar<Provenance> {
let _ = self.loads.borrow_mut().try_insert(index, clocks.clock[index]);
self.val
}
Expand Down
2 changes: 1 addition & 1 deletion src/shims/ffi_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
/// Extract the scalar value from the result of reading a scalar from the machine,
/// and convert it to a `CArg`.
fn scalar_to_carg(
k: ScalarMaybeUninit<Provenance>,
k: Scalar<Provenance>,
arg_type: Ty<'tcx>,
cx: &impl HasDataLayout,
) -> InterpResult<'tcx, CArg> {
Expand Down
7 changes: 2 additions & 5 deletions src/shims/intrinsics/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
let dest_len = u32::try_from(dest_len).unwrap();
let bitmask_len = u32::try_from(bitmask_len).unwrap();

let mask: u64 = this
.read_scalar(mask)?
.to_bits(mask.layout.size)?
.try_into()
.unwrap();
let mask: u64 =
this.read_scalar(mask)?.to_bits(mask.layout.size)?.try_into().unwrap();
for i in 0..dest_len {
let mask = mask
& 1u64
Expand Down
3 changes: 1 addition & 2 deletions src/shims/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
.unwrap(); // not a ZST, so we will get a result
for (offset, wchar) in u16_vec.into_iter().chain(iter::once(0x0000)).enumerate() {
let offset = u64::try_from(offset).unwrap();
alloc
.write_scalar(alloc_range(size2 * offset, size2), Scalar::from_u16(wchar).into())?;
alloc.write_scalar(alloc_range(size2 * offset, size2), Scalar::from_u16(wchar))?;
}
Ok((true, string_length))
}
Expand Down
6 changes: 2 additions & 4 deletions src/shims/unix/freebsd/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
"pthread_set_name_np" => {
let [thread, name] =
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
let res = this.pthread_setname_np(
this.read_scalar(thread)?.check_init()?,
this.read_scalar(name)?.check_init()?,
)?;
let res =
this.pthread_setname_np(this.read_scalar(thread)?, this.read_scalar(name)?)?;
this.write_scalar(res, dest)?;
}

Expand Down
6 changes: 2 additions & 4 deletions src/shims/unix/linux/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
"pthread_setname_np" => {
let [thread, name] =
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
let res = this.pthread_setname_np(
this.read_scalar(thread)?.check_init()?,
this.read_scalar(name)?.check_init()?,
)?;
let res =
this.pthread_setname_np(this.read_scalar(thread)?, this.read_scalar(name)?)?;
this.write_scalar(res, dest)?;
}

Expand Down
2 changes: 1 addition & 1 deletion src/shims/unix/macos/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
"pthread_setname_np" => {
let [name] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
let thread = this.pthread_self()?;
this.pthread_setname_np(thread, this.read_scalar(name)?.check_init()?)?;
this.pthread_setname_np(thread, this.read_scalar(name)?)?;
}

// Incomplete shims that we "stub out" just to get pre-main initialization code to work.
Expand Down
6 changes: 3 additions & 3 deletions src/shims/unix/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fn mutex_get_or_create_id<'mir, 'tcx: 'mir>(
.atomic_compare_exchange_scalar(
&value_place,
&ImmTy::from_uint(0u32, ecx.machine.layouts.u32),
next_id.to_u32_scalar().into(),
next_id.to_u32_scalar(),
AtomicRwOrd::Relaxed,
AtomicReadOrd::Relaxed,
false,
Expand Down Expand Up @@ -160,7 +160,7 @@ fn rwlock_get_or_create_id<'mir, 'tcx: 'mir>(
.atomic_compare_exchange_scalar(
&value_place,
&ImmTy::from_uint(0u32, ecx.machine.layouts.u32),
next_id.to_u32_scalar().into(),
next_id.to_u32_scalar(),
AtomicRwOrd::Relaxed,
AtomicReadOrd::Relaxed,
false,
Expand Down Expand Up @@ -243,7 +243,7 @@ fn cond_get_or_create_id<'mir, 'tcx: 'mir>(
.atomic_compare_exchange_scalar(
&value_place,
&ImmTy::from_uint(0u32, ecx.machine.layouts.u32),
next_id.to_u32_scalar().into(),
next_id.to_u32_scalar(),
AtomicRwOrd::Relaxed,
AtomicReadOrd::Relaxed,
false,
Expand Down
2 changes: 1 addition & 1 deletion src/shims/windows/dlsym.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
Dlsym::SetThreadDescription => {
let [handle, name] = check_arg_count(args)?;

let handle = this.read_scalar(handle)?.check_init()?;
let handle = this.read_scalar(handle)?;

let name = this.read_wide_str(this.read_pointer(name)?)?;

Expand Down
2 changes: 1 addition & 1 deletion src/shims/windows/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
fn CloseHandle(&mut self, handle_op: &OpTy<'tcx, Provenance>) -> InterpResult<'tcx> {
let this = self.eval_context_mut();

let handle = this.read_scalar(handle_op)?.check_init()?;
let handle = this.read_scalar(handle_op)?;

match Handle::from_scalar(handle, this)? {
Some(Handle::Thread(thread)) =>
Expand Down
2 changes: 1 addition & 1 deletion src/shims/windows/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn srwlock_get_or_create_id<'mir, 'tcx: 'mir>(
.atomic_compare_exchange_scalar(
&value_place,
&ImmTy::from_uint(0u32, ecx.machine.layouts.u32),
next_id.to_u32_scalar().into(),
next_id.to_u32_scalar(),
AtomicRwOrd::Relaxed,
AtomicReadOrd::Relaxed,
false,
Expand Down
7 changes: 1 addition & 6 deletions src/shims/windows/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
let this = self.eval_context_mut();

let security = this.read_pointer(security_op)?;

// stacksize is ignored, but still needs to be a valid usize
this.read_scalar(stacksize_op)?.to_machine_usize(this)?;

let start_routine = this.read_pointer(start_op)?;

let func_arg = this.read_immediate(arg_op)?;

let flags = this.read_scalar(flags_op)?.to_u32()?;

let thread = if this.ptr_is_null(this.read_pointer(thread_op)?)? {
Expand Down Expand Up @@ -66,8 +62,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
) -> InterpResult<'tcx, u32> {
let this = self.eval_context_mut();

let handle = this.read_scalar(handle_op)?.check_init()?;

let handle = this.read_scalar(handle_op)?;
let timeout = this.read_scalar(timeout_op)?.to_u32()?;

let thread = match Handle::from_scalar(handle, this)? {
Expand Down

0 comments on commit df19b85

Please sign in to comment.