rust/library/core/src
Dylan DPC 8ed3a80b9a
Rollup merge of #103287 - saethlin:faster-len-check, r=thomcc
Use a faster allocation size check in slice::from_raw_parts

I've been perusing through the codegen changes that result from turning on the standard library debug assertions. The previous check in here uses saturating arithmetic, which in my experience sometimes makes LLVM just fail to optimize things around the saturating operation.

Here is a demo of the codegen difference: https://godbolt.org/z/WMEqrjajW
Before:
```asm
example::len_check_old:
        mov     rax, rdi
        mov     ecx, 3
        mul     rcx
        setno   cl
        test    rax, rax
        setns   al
        and     al, cl
        ret

example::len_check_old:
        mov     rax, rdi
        mov     ecx, 8
        mul     rcx
        setno   cl
        test    rax, rax
        setns   al
        and     al, cl
        ret
```
After:
```asm
example::len_check_new:
        movabs  rax, 3074457345618258603
        cmp     rdi, rax
        setb    al
        ret

example::len_check_new:
        shr     rdi, 60
        sete    al
        ret
```

Running rustc-perf locally, this looks like up to a 4.5% improvement when `debug-assertions-std = true`.

Thanks ```@LegionMammal978``` (I think that's you?) for turning my idea into a much cleaner implementation.

r? ```@thomcc```
2022-10-26 11:29:53 +05:30
..
alloc Rollup merge of #102072 - scottmcm:ptr-alignment-type, r=thomcc 2022-10-10 00:09:40 +09:00
array Rollup merge of #100462 - zohnannor:master, r=thomcc 2022-10-23 14:48:13 -07:00
async_iter Add Stream alias for AsyncIterator 2022-03-15 20:59:13 -07:00
cell Move/rename lazy::{OnceCell, Lazy} to cell::{OnceCell, LazyCell} 2022-06-16 19:53:59 +04:00
char Clarify the possible return values of len_utf16 2022-10-16 11:06:19 -04:00
convert Rollup merge of #102628 - H4x5:master, r=scottmcm 2022-10-04 06:14:12 +02:00
ffi Add is_empty() method to core::ffi::CStr. 2022-09-29 07:55:12 +09:00
fmt Auto merge of #99099 - Stargateur:phantomdata_debug, r=joshtriplett 2022-10-04 00:56:14 +00:00
future Implement Ready::into_inner() 2022-08-30 13:39:30 +02:00
hash Adjust cfgs 2022-08-12 16:28:15 -04:00
iter specialize slice_iter.copied().next_chunk() 2022-10-19 00:02:00 +02:00
macros Fix typo in concat_bytes documentation 2022-09-12 21:40:28 -04:00
mem MaybeUninit: use assume_init_drop() in the partially initialized array example 2022-10-23 19:09:18 +02:00
num Rollup merge of #101889 - tspiteri:redoc-uint-adc-sbb, r=m-ou-se 2022-10-18 21:18:46 +02:00
ops Fixed Documentation for wrap_mut_2_imp 2022-09-30 17:16:59 +02:00
panic Change tracking issue from #76156 to #102911 2022-10-11 06:40:37 +00:00
prelude Create 2024 edition 2022-04-02 02:45:49 -04:00
ptr Auto merge of #100848 - xfix:use-metadata-for-slice-len, r=thomcc 2022-10-24 04:14:46 +00:00
slice Rollup merge of #103287 - saethlin:faster-len-check, r=thomcc 2022-10-26 11:29:53 +05:30
str Fix typo in ReverseSearcher docs 2022-10-17 13:14:15 -04:00
sync Remove extra spaces 2022-10-19 23:54:00 +01:00
task Added tracking issue 2022-09-19 15:07:12 +02:00
unicode Bump Unicode to version 15.0.0, regenerate tables 2022-09-14 13:21:19 -07:00
any.rs Add Provider::{would_be_satisfied_by_value_of,would_be_satisfied_by_ref_of} 2022-08-23 10:48:59 -04:00
ascii.rs Inline <EscapeDefault as Iterator>::next 2022-03-10 15:35:22 +01:00
asserting.rs [RFC 2011] Library code 2022-05-22 07:18:32 -03:00
bool.rs Add missing assertion 2022-09-22 02:12:06 -04:00
borrow.rs Add const_traits 2022-09-16 11:48:42 +08:00
cell.rs Rollup merge of #101717 - Pointerbender:unsafecell-memory-layout, r=Amanieu 2022-10-16 11:41:12 +09:00
clone.rs update cfg(bootstrap)s 2022-07-01 15:48:23 +02:00
cmp.rs Add back ConstFnMutClosure::new, fix formatting 2022-09-30 17:41:01 +02:00
const_closure.rs Add back ConstFnMutClosure::new, fix formatting 2022-09-30 17:41:01 +02:00
default.rs Prevent errors for stage0 rustc build 2022-09-16 11:48:42 +08:00
error.md Move error trait into core 2022-08-22 13:28:25 -07:00
error.rs Stabilize duration_checked_float 2022-10-15 12:02:13 -07:00
hint.rs add a few more assert_unsafe_precondition 2022-10-07 14:35:12 +02:00
internal_macros.rs ignore a doctest for the non-exported macro 2022-05-03 18:33:56 +09:00
intrinsics.rs Rollup merge of #103287 - saethlin:faster-len-check, r=thomcc 2022-10-26 11:29:53 +05:30
lib.rs Rollup merge of #103287 - saethlin:faster-len-check, r=thomcc 2022-10-26 11:29:53 +05:30
marker.rs PhantomData: inline a macro that is used only once 2022-10-16 10:37:51 +02:00
option.rs Rollup merge of #98204 - Kixiron:stable-unzip, r=thomcc 2022-10-25 14:43:13 +05:30
panic.rs resolve the conflict in compiler/rustc_session/src/parse.rs 2022-03-16 20:12:30 +08:00
panicking.rs reorder panicking.rs to put main entry points at the top 2022-10-11 22:47:31 +02:00
pin.rs Fix the generator example for pin!() 2022-05-05 09:58:13 +10:00
primitive.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
primitive_docs.rs array docs - advertise how to get array from slice 2022-09-10 19:37:07 -07:00
result.rs Auto merge of #98354 - camsteffen:is-some-and-by-value, r=m-ou-se 2022-10-02 12:48:15 +00:00
time.rs Stabilize duration_checked_float 2022-10-15 12:02:13 -07:00
tuple.rs Added const Default impls for Arrays and Tuples. 2022-09-23 17:53:59 +02:00
unit.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00