Skip to content

Commit

Permalink
Auto merge of #93934 - rusticstuff:inline_ensure_sufficient_stack, r=…
Browse files Browse the repository at this point in the history
…estebank

Allow inlining of `ensure_sufficient_stack()`

This functions is monomorphized a lot and allowing the compiler to inline it improves instructions count and max RSS significantly in my local tests.
  • Loading branch information
bors committed Feb 20, 2022
2 parents 3b18651 + 59536fb commit c1aa854
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_data_structures/src/stack.rs
Expand Up @@ -12,6 +12,7 @@ const STACK_PER_RECURSION: usize = 1 * 1024 * 1024; // 1MB
/// from this.
///
/// Should not be sprinkled around carelessly, as it causes a little bit of overhead.
#[inline]
pub fn ensure_sufficient_stack<R>(f: impl FnOnce() -> R) -> R {
stacker::maybe_grow(RED_ZONE, STACK_PER_RECURSION, f)
}

0 comments on commit c1aa854

Please sign in to comment.