+use std::iter;
+
use rustc_apfloat::Float;
use rustc::mir;
use rustc::mir::interpret::{InterpResult, PointerArithmetic};
// (as opposed to through a place), we have to remember to erase any tag
// that might still hang around!
- let intrinsic_name = &*this.tcx.item_name(instance.def_id()).as_str();
+ let intrinsic_name = &*tcx.item_name(instance.def_id()).as_str();
match intrinsic_name {
"arith_offset" => {
let offset = this.read_scalar(args[1])?.to_isize(this)?;
_ => {
// Do it in memory
let mplace = this.force_allocation(dest)?;
- assert!(mplace.meta.is_none());
- // not a zst, must be valid pointer
- let ptr = mplace.ptr.to_ptr()?;
- this.memory.get_mut(ptr.alloc_id)?.write_repeat(tcx, ptr, 0, dest.layout.size)?;
+ mplace.meta.unwrap_none(); // must be sized
+ this.memory.write_bytes(mplace.ptr, iter::repeat(0u8).take(dest.layout.size.bytes() as usize))?;
}
}
}
_ => {
// Do it in memory
let mplace = this.force_allocation(dest)?;
- assert!(mplace.meta.is_none());
+ mplace.meta.unwrap_none();
let ptr = mplace.ptr.to_ptr()?;
+ // We know the return place is in-bounds
this.memory
.get_mut(ptr.alloc_id)?
.mark_definedness(ptr, dest.layout.size, false);
let ptr = this.read_scalar(args[0])?.not_undef()?;
let count = this.read_scalar(args[2])?.to_usize(this)?;
let byte_count = ty_layout.size * count;
- match this.memory.check_ptr_access(ptr, byte_count, ty_layout.align.abi)? {
- Some(ptr) => {
- this.memory
- .get_mut(ptr.alloc_id)?
- .write_repeat(tcx, ptr, val_byte, byte_count)?;
- }
- None => {
- // Size is 0, nothing to do.
- }
- }
+ this.memory.write_bytes(ptr, iter::repeat(val_byte).take(byte_count.bytes() as usize))?;
}
name => throw_unsup_format!("unimplemented intrinsic: {}", name),