Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/terminator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,14 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
self.write_primval(dest, PrimVal::Ptr(ptr), dest_ty)?;
}

"__rust_allocate_zeroed" => {
let size = self.value_to_primval(args[0], usize)?.to_u64()?;
let align = self.value_to_primval(args[1], usize)?.to_u64()?;
let ptr = self.memory.allocate(size, align)?;
self.memory.write_repeat(ptr, 0, size)?;
self.write_primval(dest, PrimVal::Ptr(ptr), dest_ty)?;
}

"__rust_deallocate" => {
let ptr = args[0].read_ptr(&self.memory)?;
// FIXME: insert sanity check for size and align?
Expand Down
5 changes: 5 additions & 0 deletions tests/run-pass/vecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ fn make_vec_macro_repeat() -> Vec<u8> {
vec![42; 5]
}

fn make_vec_macro_repeat_zeroed() -> Vec<u8> {
vec![0; 7]
}

fn vec_into_iter() -> u8 {
vec![1, 2, 3, 4]
.into_iter()
Expand All @@ -34,4 +38,5 @@ fn main() {
assert_eq!(make_vec().capacity(), 4);
assert_eq!(make_vec_macro(), [1, 2]);
assert_eq!(make_vec_macro_repeat(), [42; 5]);
assert_eq!(make_vec_macro_repeat_zeroed(), [0; 7]);
}