summary refs log tree commit diff
path: root/src/libcore/mem.rs
AgeCommit message (Collapse)AuthorLines
2017-08-12std: Stabilize `manually_drop` featureAlex Crichton-10/+7
Stabilizes * `core::mem::ManuallyDrop` * `std::mem::ManuallyDrop` * `ManuallyDrop::new` * `ManuallyDrop::into_inner` * `ManuallyDrop::drop` * `Deref for ManuallyDrop` * `DerefMut for ManuallyDrop` Closes #40673
2017-06-28Auto merge of #42819 - scottmcm:swap-nonoverlapping, r=sfacklerbors-53/+1
Reuse the mem::swap optimizations to speed up slice::rotate This is most helpful for compound types where LLVM didn't vectorize the loop. Highlight: bench slice::rotate_medium_by727_strings gets 38% faster. Exposes the swapping logic from PR https://github.com/rust-lang/rust/pull/40454 as `pub unsafe fn ptr::swap_nonoverlapping` under library feature `swap_nonoverlapping` https://github.com/rust-lang/rust/issues/42818. (The new method seemed plausible, and was the simplest way to share the logic. I'm not attached to it, though, so let me know if a different way would be better.)
2017-06-23Removed as many "```ignore" as possible.kennytm-4/+11
Replaced by adding extra imports, adding hidden code (`# ...`), modifying examples to be runnable (sorry Homura), specifying non-Rust code, and converting to should_panic, no_run, or compile_fail. Remaining "```ignore"s received an explanation why they are being ignored.
2017-06-21Reuse the mem::swap optimizations to speed up slice::rotateScott McMurray-53/+1
Exposes the swapping logic from PR 40454 as `pub unsafe fn ptr::swap_nonoverlapping` under feature swap_nonoverlapping This is most helpful for compound types where LLVM didn't vectorize the loop. Highlight: bench slice::rotate_medium_by727_strings gets 38% faster.
2017-06-19Disable repr(simd) in mem::swap on RedoxJeremy Soller-2/+2
2017-06-11Auto merge of #40454 - djzin:fast-swap, r=sfacklerbors-13/+54
speed up mem::swap I would have thought that the mem::swap code didn't need an intermediate variable precisely because the pointers are guaranteed never to alias. And.. it doesn't! It seems that llvm will also auto-vectorize this case for large structs, but alas it doesn't seem to have all the aliasing info it needs and so will add redundant checks (and even not bother with autovectorizing for small types). Looks like a lot of performance could still be gained here, so this might be a good test case for future optimizer improvements. Here are the current benchmarks for the simd version of mem::swap; the timings are in cycles (code below) measured with 10 iterations. The timings for sizes > 32 which are not a multiple of 8 tend to be ever so slightly faster in the old code, but not always. For large struct sizes (> 1024) the new code shows a marked improvement. \* = latest commit † = subtracted from other measurements | arr_length | noop<sup>†</sup> | rust_stdlib | simd_u64x4\* | simd_u64x8 |------------------|------------|-------------------|-------------------|------------------- 8|80|90|90|90 16|72|177|177|177 24|32|76|76|76 32|68|188|112|188 40|32|80|60|80 48|32|84|56|84 56|32|108|72|108 64|32|108|72|76 72|80|350|220|230 80|80|350|220|230 88|80|420|270|270 96|80|420|270|270 104|80|500|320|320 112|80|490|320|320 120|72|528|342|342 128|48|360|234|234 136|72|987|387|387 144|80|1070|420|420 152|64|856|376|376 160|68|804|400|400 168|80|1060|520|520 176|80|1070|520|520 184|32|464|228|228 192|32|504|228|228 200|32|440|248|248 208|72|987|573|573 216|80|1464|220|220 224|48|852|450|450 232|72|1182|666|666 240|32|428|288|288 248|32|428|308|308 256|80|860|770|770 264|80|1130|820|820 272|80|1340|820|820 280|80|1220|870|870 288|72|1227|804|804 296|72|1356|849|849
2017-06-09hack around bug in emscriptenDjzin-1/+3
2017-05-31Rollup merge of #42252 - stjepang:clarify-alignof-docs, r=nikomatsakisMark Simulacrum-4/+4
Clarify the docs for align_of and its variants It's okay to have unaligned raw pointers and then use `ptr::write_unaligned` and `ptr::read_unaligned`. However, using unaligned `&T` and `&mut T` would be undefined behavior. The current documentation seems to indicate that everything has to be aligned, but in reality only references do. This PR changes the text of docs accordingly. r? @sfackler
2017-05-30Add 'the'Stjepan Glavina-4/+4
2017-05-28restore old behaviourDjzin-18/+1
2017-05-28restore old behaviour for sizes < 128Djzin-41/+34
2017-05-27better respect alignment for copying tailDjzin-25/+37
2017-05-27Merge remote-tracking branch 'upstream/master' into fast-swapDjzin-8/+178
2017-05-27copy tail bytes better for aligned typesDjzin-0/+21
2017-05-27Clarify the docs for align_of and its variantsStjepan Glavina-4/+4
2017-05-20expose needs_drop under mem::Alexis Beingessner-0/+52
2017-05-07fix nitDjzin-1/+1
2017-05-07improve wordingDjzin-2/+1
2017-05-07optimize out stack alignment for sizes < 32Djzin-5/+12
2017-04-29process:exit -> process::exit in mem::forget docsNathan Moos-1/+1
The documentation in mem::forget says "...or call `process:exit`..." instead of `process::exit`. r? @steveklabnik
2017-04-24change wordingDjzin-1/+1
2017-04-09into_inner to associated functionSimonas Kazlauskas-2/+19
2017-04-09 Replace the `forget` intrinsic with ManuallyDropSimonas Kazlauskas-1/+6
less intrinsics = better life
2017-04-09Implement Manually DropSimonas Kazlauskas-0/+96
2017-03-20Fix up various linkssteveklabnik-5/+5
The unstable book, libstd, libcore, and liballoc all needed some adjustment.
2017-03-15use simd blocksDjzin-10/+20
2017-03-13Remove function invokation parens from documentation links.Corey Farwell-1/+1
This was never established as a convention we should follow in the 'More API Documentation Conventions' RFC: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2017-03-13add SWAP_BLOCK_SIZE constantDjzin-7/+9
2017-03-12fix typoDjzin-1/+1
2017-03-12a new approach; ditch xor cuteness and maximize cache localityDjzin-6/+18
2017-03-12avoid recursionDjzin-2/+5
2017-03-12speed up mem::swapDjzin-12/+9
2017-02-21Get linkchecker cleanSteve Klabnik-4/+4
This affects the book, some missed things in the reference, the grammar, and the standard library. Whew!
2017-02-20Revert "Fix up links"Steve Klabnik-1/+1
This reverts commit 7f1d1c6d9a7be5e427bace30e740b16b25f25c92. The original commit was created because mdBook and rustdoc had different generation algorithms for header links; now with https://github.com/rust-lang/rust/pull/39966 , the algorithms are the same. So let's undo this change. ... when I came across this problem, I said "eh, this isn't fun, but it doesn't take that long." I probably should have just actually taken the time to fix upstream, given that they were amenable. Oh well!
2017-02-13Fix up linksSteve Klabnik-1/+1
mdbook and rustdoc generate links differently, so we need to change all these links.
2016-11-11Add missing urls for mem moduleGuillaume Gomez-16/+23
2016-09-27add wrapper for discriminant_valueAlex Burka-0/+82
2016-09-10Tweak std::mem docsKeegan McAllister-93/+201
Fixes #29362.
2016-08-25Auto merge of #35906 - jseyfried:local_prelude, r=eddybbors-1/+0
Use `#[prelude_import]` in `libcore` and `libstd` r? @eddyb
2016-08-24Use `#[prelude_import]` in `libcore`.Jeffrey Seyfried-1/+0
2016-08-24Remove drop flags from structs and enums implementing Drop.Eduard Burtescu-71/+0
2016-05-19Support 16-bit pointers as well as i/usizeJake Goulding-0/+11
This is based on the original work of Dylan McKay for the [avr-rust project][ar]. [ar]: https://github.com/avr-rust/rust
2016-05-03Rollup merge of #33357 - pcwalton:inline-mem-forget, r=brsonManish Goregaokar-0/+1
libcore: Inline `mem::forget()`. Was causing severe performance problems in WebRender. r? @brson
2016-05-02libcore: Inline `mem::forget()`.Patrick Walton-0/+1
Was causing severe performance problems in WebRender.
2016-05-01docs: Changed docs for `size_of` to describe size as a stride offsetTaylor Cramer-0/+3
Current description of `std::mem::size_of` is ambiguous, and the `std::intrinsics::size_of` description incorrectly defines size as the number of bytes necessary to exactly overwrite a value, not including the padding between elements necessary in a vector or structure.
2016-03-04End stdlib module summaries with a full stop.Steve Klabnik-1/+1
Fixes #9447
2016-02-16Improve 'std::mem::transmute_copy' doc example.Corey Farwell-2/+18
Prior to this commit, it was a trivial example that did not demonstrate the effects of using the function. Fixes https://github.com/rust-lang/rust/issues/31094
2016-02-08Remove old #[allow(trivial_casts)] annotationsAlex Crichton-2/+0
These were added a long time ago but we long since switched the lint back to allow-by-default, so these annotations shouldn't be necessary.
2016-01-14doc: this is more easy to read, and less prone mis-interpretationTshepang Lekhonkhobe-1/+1
This function returns the size on the stack, not that of the value that may be allocated on the heap.
2015-11-20Rename #[deprecated] to #[rustc_deprecated]Vadim Petrochenkov-2/+2