Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 6 pull requests #96218

Closed
wants to merge 27 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
53b2aca
Refactor loop into iterator; simplify negation logic.
IsakNyberg Apr 13, 2022
657ae03
Update compiler/rustc_error_messages/src/lib.rs
IsakNyberg Apr 16, 2022
f7ce145
Remove extra space before a where clause in the documentation
Urgau Apr 8, 2022
85ee04c
when writing uninit to an allocation, also clear relocations like oth…
RalfJung Apr 17, 2022
3ec1feb
add caution to some comments
RalfJung Apr 17, 2022
29cc8ec
explain why prepare_relocation_copy works the way it does
RalfJung Apr 17, 2022
05489e7
check Allocation invariant during printing
RalfJung Apr 18, 2022
54ab357
ptr_get_alloc_id: don't return an actual Pointer
RalfJung Apr 18, 2022
c9e568f
avoid pairing up AllocId and PointerTag, which is redundant
RalfJung Apr 18, 2022
3236092
add method to get absolute address of a pointer (useful only for Miri)
RalfJung Apr 18, 2022
c83241a
avoid an unnecessary call to Pointer::into_parts, and caution against…
RalfJung Apr 18, 2022
55f0977
remove an unnecessary use of loc_place.ptr.into_pointer_or_addr
RalfJung Apr 18, 2022
703a336
Define a dedicated error type for `HandleOrNull` and `HandleOrInvalid`.
sunfishcode Mar 27, 2022
5b3023c
Fix an incorrect word in a comment.
sunfishcode Mar 27, 2022
67994b7
Move the `Error` impl for `NotHandle` out of platform-independent code.
sunfishcode Mar 27, 2022
f934043
Split `NotHandle` into `NullHandleError` and `InvalidHandleError`.
sunfishcode Mar 28, 2022
890125d
Add a comment explaining the `(())` idiom for empty structs.
sunfishcode Apr 13, 2022
b7ff103
Update the expected stderr for coerce-issue-49593-box-never.
sunfishcode Apr 15, 2022
19ef182
Update the expected stderr for coerce-issue-49593-box-never.
sunfishcode Apr 19, 2022
6abdd0b
Make std::sys::unix::futex consistent on emscripten.
m-ou-se Apr 19, 2022
06a8f05
Use futex locks on emscripten.
m-ou-se Apr 19, 2022
9c93606
Rollup merge of #95813 - Urgau:rustdoc-where-clause-space, r=Guillaum…
Dylan-DPC Apr 19, 2022
2c8c514
Rollup merge of #96029 - IsakNyberg:error-messages-fix, r=Dylan-DPC
Dylan-DPC Apr 19, 2022
357bd4a
Rollup merge of #96162 - RalfJung:mark-uninit, r=oli-obk
Dylan-DPC Apr 19, 2022
4da2306
Rollup merge of #96165 - RalfJung:miri-provenance-cleanup, r=oli-obk
Dylan-DPC Apr 19, 2022
e0a4afd
Rollup merge of #96195 - sunfishcode:sunfishcode/handle-or-error-type…
Dylan-DPC Apr 19, 2022
7c5b0a7
Rollup merge of #96205 - m-ou-se:emscripten-futex-locks, r=thomcc
Dylan-DPC Apr 19, 2022
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
Prev Previous commit
Next Next commit
when writing uninit to an allocation, also clear relocations like oth…
…er writes do
  • Loading branch information
RalfJung committed Apr 17, 2022
commit 85ee04c44a1d4ffc2f2e3bb0c217908ce4062a18
13 changes: 9 additions & 4 deletions compiler/rustc_const_eval/src/interpret/memory.rs
Original file line number Diff line number Diff line change
@@ -892,8 +892,11 @@ impl<'tcx, 'a, Tag: Provenance, Extra> AllocRefMut<'a, 'tcx, Tag, Extra> {
}

/// Mark the entire referenced range as uninitalized
pub fn write_uninit(&mut self) {
self.alloc.mark_init(self.range, false);
pub fn write_uninit(&mut self) -> InterpResult<'tcx> {
Ok(self
.alloc
.write_uninit(&self.tcx, self.range)
.map_err(|e| e.to_interp_error(self.alloc_id))?)
}
}

@@ -1053,8 +1056,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// This also avoids writing to the target bytes so that the backing allocation is never
// touched if the bytes stay uninitialized for the whole interpreter execution. On contemporary
// operating system this can avoid physically allocating the page.
dest_alloc.mark_init(dest_range, false); // `Size` multiplication
dest_alloc.mark_relocation_range(relocations);
dest_alloc
.write_uninit(&tcx, dest_range)
.map_err(|e| e.to_interp_error(dest_alloc_id))?; // `Size` multiplication
// We can forget about the relocations, this is all not initialized anyway.
return Ok(());
}

2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/place.rs
Original file line number Diff line number Diff line change
@@ -823,7 +823,7 @@ where
// Zero-sized access
return Ok(());
};
alloc.write_uninit();
alloc.write_uninit()?;
Ok(())
}

12 changes: 9 additions & 3 deletions compiler/rustc_middle/src/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
@@ -429,8 +429,7 @@ impl<Tag: Provenance, Extra> Allocation<Tag, Extra> {
let val = match val {
ScalarMaybeUninit::Scalar(scalar) => scalar,
ScalarMaybeUninit::Uninit => {
self.mark_init(range, false);
return Ok(());
return self.write_uninit(cx, range);
}
};

@@ -455,6 +454,13 @@ impl<Tag: Provenance, Extra> Allocation<Tag, Extra> {

Ok(())
}

/// Write "uninit" to the given memory range.
pub fn write_uninit(&mut self, cx: &impl HasDataLayout, range: AllocRange) -> AllocResult {
self.mark_init(range, false);
self.clear_relocations(cx, range)?;
return Ok(());
}
}

/// Relocations.
@@ -1056,7 +1062,7 @@ impl<Tag: Copy, Extra> Allocation<Tag, Extra> {
})
}

pub fn mark_init(&mut self, range: AllocRange, is_init: bool) {
fn mark_init(&mut self, range: AllocRange, is_init: bool) {
if range.size.bytes() == 0 {
return;
}