Skip to content

Commit 3e838b3

Browse files
committed
EXPERIMENT: Use rust-cold for reserve_for_push
This is *probably* bad, since it means `reserve_for_push` ends up needing to save all the xmm* registers, but it also reduces register pressure in the code calling `push`, so it'll depend on what the balance is between reallocating pushes and existing-capacity pushes.
1 parent 766c0c0 commit 3e838b3

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

library/alloc/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
#![feature(negative_impls)]
191191
#![feature(never_type)]
192192
#![feature(pointer_is_aligned)]
193+
#![feature(rust_cold_cc)]
193194
#![feature(rustc_allow_const_fn_unstable)]
194195
#![feature(rustc_attrs)]
195196
#![feature(slice_internals)]

library/alloc/src/raw_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ impl<T, A: Allocator> RawVec<T, A> {
298298
/// oft-instantiated `Vec::push()`, which does its own capacity check.
299299
#[cfg(not(no_global_oom_handling))]
300300
#[inline(never)]
301-
pub fn reserve_for_push(&mut self, len: usize) {
301+
pub extern "rust-cold" fn reserve_for_push(&mut self, len: usize) {
302302
handle_reserve(self.grow_amortized(len, 1));
303303
}
304304

0 commit comments

Comments
 (0)