Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a0bd59e
Update Source Serif to release 4.004
tspiteri Mar 29, 2021
6530b32
rustdoc: use Array.prototype.filter instead of open-coding it
notriddle Mar 31, 2021
227f5ed
rustdoc: Separate filter-empty-string out into its own function
notriddle Apr 1, 2021
a4a6bdd
addr_of_mut: add example for creating a pointer to uninit data
RalfJung Apr 3, 2021
b93137a
explain that even addr_of cannot deref a NULL ptr
RalfJung Apr 3, 2021
5839bff
Remove attribute `#[link_args]`
petrochenkov Apr 3, 2021
3ea62cb
Remove redundant `ignore-tidy-linelength` annotations
sjakobi Apr 3, 2021
5d1747b
rely on intra-doc links
RalfJung Apr 4, 2021
ddc53f8
Allow clobbering unsupported registers in asm!
Amanieu Apr 4, 2021
31d0459
Update clobber example in the asm documentation
Amanieu Apr 4, 2021
da66a31
wasm64
devsnek Dec 30, 2020
b577d7e
fix typo
RalfJung Apr 4, 2021
3c3d3dd
core: rearrange `ptr::swap_nonoverlapping_one`'s cases (no functional…
eddyb Mar 11, 2021
bc6af97
core: disable `ptr::swap_nonoverlapping_one`'s block optimization on …
eddyb Mar 11, 2021
5b5529a
Rollup merge of #80525 - devsnek:wasm64, r=nagisa
Dylan-DPC Apr 4, 2021
c5a3f85
Rollup merge of #83019 - eddyb:spirv-no-block-swap, r=nagisa
Dylan-DPC Apr 4, 2021
39638d1
Rollup merge of #83650 - tspiteri:source-serif-4, r=GuillaumeGomez
Dylan-DPC Apr 4, 2021
37efee6
Rollup merge of #83717 - notriddle:main-js-slice-loop, r=GuillaumeGomez
Dylan-DPC Apr 4, 2021
c2be285
Rollup merge of #83807 - sjakobi:77548-remove-ignore-annotations, r=M…
Dylan-DPC Apr 4, 2021
7056647
Rollup merge of #83815 - RalfJung:addr_of, r=kennytm
Dylan-DPC Apr 4, 2021
ade2667
Rollup merge of #83820 - petrochenkov:nolinkargs, r=nagisa
Dylan-DPC Apr 4, 2021
78ae63b
Rollup merge of #83841 - Amanieu:asm_clobber_feature, r=nagisa
Dylan-DPC Apr 4, 2021
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
37 changes: 25 additions & 12 deletions library/core/src/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,19 +473,32 @@ pub const unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
#[inline]
#[rustc_const_unstable(feature = "const_swap", issue = "83163")]
pub(crate) const unsafe fn swap_nonoverlapping_one<T>(x: *mut T, y: *mut T) {
// For types smaller than the block optimization below,
// just swap directly to avoid pessimizing codegen.
if mem::size_of::<T>() < 32 {
// SAFETY: the caller must guarantee that `x` and `y` are valid
// for writes, properly aligned, and non-overlapping.
unsafe {
let z = read(x);
copy_nonoverlapping(y, x, 1);
write(y, z);
// NOTE(eddyb) SPIR-V's Logical addressing model doesn't allow for arbitrary
// reinterpretation of values as (chunkable) byte arrays, and the loop in the
// block optimization in `swap_nonoverlapping_bytes` is hard to rewrite back
// into the (unoptimized) direct swapping implementation, so we disable it.
// FIXME(eddyb) the block optimization also prevents MIR optimizations from
// understanding `mem::replace`, `Option::take`, etc. - a better overall
// solution might be to make `swap_nonoverlapping` into an intrinsic, which
// a backend can choose to implement using the block optimization, or not.
#[cfg(not(target_arch = "spirv"))]
{
// Only apply the block optimization in `swap_nonoverlapping_bytes` for types
// at least as large as the block size, to avoid pessimizing codegen.
if mem::size_of::<T>() >= 32 {
// SAFETY: the caller must uphold the safety contract for `swap_nonoverlapping`.
unsafe { swap_nonoverlapping(x, y, 1) };
return;
}
} else {
// SAFETY: the caller must uphold the safety contract for `swap_nonoverlapping`.
unsafe { swap_nonoverlapping(x, y, 1) };
}

// Direct swapping, for the cases not going through the block optimization.
// SAFETY: the caller must guarantee that `x` and `y` are valid
// for writes, properly aligned, and non-overlapping.
unsafe {
let z = read(x);
copy_nonoverlapping(y, x, 1);
write(y, z);
}
}

Expand Down