diff options
| author | bors <bors@rust-lang.org> | 2018-11-30 19:24:17 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-11-30 19:24:17 +0000 |
| commit | d09466ceb1374bd0ff1c490bfd50133b8ca67558 (patch) | |
| tree | f7d8b25b1458f3510341df1ff85dba2a910fecf3 /src/libstd | |
| parent | d48ab693d1ce99f30c0cf9abdf45c209824fe825 (diff) | |
| parent | a6c477152026f9b652bbca3fd1dbe13c7a47ffdf (diff) | |
| download | rust-d09466ceb1374bd0ff1c490bfd50133b8ca67558.tar.gz rust-d09466ceb1374bd0ff1c490bfd50133b8ca67558.zip | |
Auto merge of #56381 - kennytm:rollup, r=kennytm
Rollup of 19 pull requests
Successful merges:
- #55011 (Add libstd Cargo feature "panic_immediate_abort")
- #55821 (Use sort_by_cached_key when the key function is not trivial/free)
- #56014 (add test for issue #21335)
- #56131 (Assorted tweaks)
- #56214 (Implement chalk unification routines)
- #56216 (Add TryFrom<&[T]> for [T; $N] where T: Copy)
- #56268 (Reuse the `P` in `InvocationCollector::fold_{,opt_}expr`.)
- #56324 (Use raw_entry for more efficient interning)
- #56336 (Clean up and streamline the pretty-printer)
- #56337 (Fix const_fn ICE with non-const function pointer)
- #56339 (Remove not used option)
- #56341 (Rename conversion util; remove duplicate util in librustc_codegen_llvm.)
- #56349 (rustc 1.30.0's linker flavor inference is a non-backwards compat change to -Clinker)
- #56355 (Add inline attributes and add unit to CommonTypes)
- #56360 (Optimize local linkchecker program)
- #56364 (Fix panic with outlives in existential type)
- #56365 (Stabilize self_struct_ctor feature.)
- #56367 (Moved some feature gate tests to correct location)
- #56373 (Update books)
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/Cargo.toml | 3 | ||||
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 7 | ||||
| -rw-r--r-- | src/libstd/collections/hash/table.rs | 4 | ||||
| -rw-r--r-- | src/libstd/panicking.rs | 19 |
4 files changed, 31 insertions, 2 deletions
diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 2b1d515c83b..c1446218367 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -47,6 +47,9 @@ backtrace = [] panic-unwind = ["panic_unwind"] profiler = ["profiler_builtins"] +# Make panics and failed asserts immediately abort without formatting any message +panic_immediate_abort = ["core/panic_immediate_abort"] + # An off-by-default feature which enables a linux-syscall-like ABI for libstd to # interoperate with the host environment. Currently not well documented and # requires rebuilding the standard library to use it. diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 7c717d832fa..349aa029ba8 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -849,6 +849,7 @@ impl<K, V, S> HashMap<K, V, S> /// let mut map: HashMap<&str, i32> = HashMap::new(); /// map.reserve(10); /// ``` + #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn reserve(&mut self, additional: usize) { match self.reserve_internal(additional, Infallible) { @@ -880,6 +881,7 @@ impl<K, V, S> HashMap<K, V, S> self.reserve_internal(additional, Fallible) } + #[inline] fn reserve_internal(&mut self, additional: usize, fallibility: Fallibility) -> Result<(), CollectionAllocErr> { @@ -1571,6 +1573,7 @@ impl<K, V, S> HashMap<K, V, S> /// so that the map now contains keys which compare equal, search may start /// acting erratically, with two keys randomly masking each other. Implementations /// are free to assume this doesn't happen (within the limits of memory-safety). + #[inline(always)] #[unstable(feature = "hash_raw_entry", issue = "56167")] pub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<K, V, S> { self.reserve(1); @@ -1911,6 +1914,7 @@ impl<'a, K, V, S> RawEntryBuilderMut<'a, K, V, S> } /// Create a `RawEntryMut` from the given key and its hash. + #[inline] #[unstable(feature = "hash_raw_entry", issue = "56167")] pub fn from_key_hashed_nocheck<Q: ?Sized>(self, hash: u64, k: &Q) -> RawEntryMut<'a, K, V, S> where K: Borrow<Q>, @@ -1919,6 +1923,7 @@ impl<'a, K, V, S> RawEntryBuilderMut<'a, K, V, S> self.from_hash(hash, |q| q.borrow().eq(k)) } + #[inline] fn search<F>(self, hash: u64, is_match: F, compare_hashes: bool) -> RawEntryMut<'a, K, V, S> where for<'b> F: FnMut(&'b K) -> bool, { @@ -1941,6 +1946,7 @@ impl<'a, K, V, S> RawEntryBuilderMut<'a, K, V, S> } } /// Create a `RawEntryMut` from the given hash. + #[inline] #[unstable(feature = "hash_raw_entry", issue = "56167")] pub fn from_hash<F>(self, hash: u64, is_match: F) -> RawEntryMut<'a, K, V, S> where for<'b> F: FnMut(&'b K) -> bool, @@ -2215,6 +2221,7 @@ impl<'a, K, V, S> RawVacantEntryMut<'a, K, V, S> { /// Sets the value of the entry with the VacantEntry's key, /// and returns a mutable reference to it. + #[inline] #[unstable(feature = "hash_raw_entry", issue = "56167")] pub fn insert_hashed_nocheck(self, hash: u64, key: K, value: V) -> (&'a mut K, &'a mut V) { let hash = SafeHash::new(hash); diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index 547f97cc8ac..479e6dccb90 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -329,6 +329,7 @@ impl<K, V, M> Put<K, V> for FullBucket<K, V, M> } impl<K, V, M: Deref<Target = RawTable<K, V>>> Bucket<K, V, M> { + #[inline] pub fn new(table: M, hash: SafeHash) -> Bucket<K, V, M> { Bucket::at_index(table, hash.inspect() as usize) } @@ -342,6 +343,7 @@ impl<K, V, M: Deref<Target = RawTable<K, V>>> Bucket<K, V, M> { } } + #[inline] pub fn at_index(table: M, ib_index: usize) -> Bucket<K, V, M> { // if capacity is 0, then the RawBucket will be populated with bogus pointers. // This is an uncommon case though, so avoid it in release builds. @@ -654,6 +656,7 @@ impl<K, V, M> GapThenFull<K, V, M> // Returns a Layout which describes the allocation required for a hash table, // and the offset of the array of (key, value) pairs in the allocation. +#[inline(always)] fn calculate_layout<K, V>(capacity: usize) -> Result<(Layout, usize), LayoutErr> { let hashes = Layout::array::<HashUint>(capacity)?; let pairs = Layout::array::<(K, V)>(capacity)?; @@ -722,6 +725,7 @@ impl<K, V> RawTable<K, V> { } } + #[inline(always)] fn raw_bucket_at(&self, index: usize) -> RawBucket<K, V> { let (_, pairs_offset) = calculate_layout::<K, V>(self.capacity()) .unwrap_or_else(|_| unsafe { hint::unreachable_unchecked() }); diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index a0590a800d3..4930d356608 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -334,9 +334,17 @@ pub fn rust_begin_panic(info: &PanicInfo) -> ! { #[unstable(feature = "libstd_sys_internals", reason = "used by the panic! macro", issue = "0")] -#[inline(never)] #[cold] +#[cold] +// If panic_immediate_abort, inline the abort call, +// otherwise avoid inlining because of it is cold path. +#[cfg_attr(not(feature="panic_immediate_abort"),inline(never))] +#[cfg_attr( feature="panic_immediate_abort" ,inline)] pub fn begin_panic_fmt(msg: &fmt::Arguments, file_line_col: &(&'static str, u32, u32)) -> ! { + if cfg!(feature = "panic_immediate_abort") { + unsafe { intrinsics::abort() } + } + let (file, line, col) = *file_line_col; let info = PanicInfo::internal_constructor( Some(msg), @@ -398,8 +406,15 @@ fn continue_panic_fmt(info: &PanicInfo) -> ! { reason = "used by the panic! macro", issue = "0")] #[cfg_attr(not(test), lang = "begin_panic")] -#[inline(never)] #[cold] // avoid code bloat at the call sites as much as possible +// never inline unless panic_immediate_abort to avoid code +// bloat at the call sites as much as possible +#[cfg_attr(not(feature="panic_immediate_abort"),inline(never))] +#[cold] pub fn begin_panic<M: Any + Send>(msg: M, file_line_col: &(&'static str, u32, u32)) -> ! { + if cfg!(feature = "panic_immediate_abort") { + unsafe { intrinsics::abort() } + } + // Note that this should be the only allocation performed in this code path. // Currently this means that panic!() on OOM will invoke this code path, // but then again we're not really ready for panic on OOM anyway. If |
