diff --git a/crates/oxc_allocator/src/bump.rs b/crates/oxc_allocator/src/bump.rs index 55ff5ec5cedbf..96fb56bd84d00 100644 --- a/crates/oxc_allocator/src/bump.rs +++ b/crates/oxc_allocator/src/bump.rs @@ -512,6 +512,7 @@ fn layout_from_size_align(size: usize, align: usize) -> Result Layout::from_size_align(size, align).map_err(|_| AllocErr) } +#[cold] #[inline(never)] fn allocation_size_overflow() -> T { panic!("requested allocation size overflowed") diff --git a/crates/oxc_allocator/src/bumpalo_alloc.rs b/crates/oxc_allocator/src/bumpalo_alloc.rs index 4e12c32fe6fe4..673c1414815be 100644 --- a/crates/oxc_allocator/src/bumpalo_alloc.rs +++ b/crates/oxc_allocator/src/bumpalo_alloc.rs @@ -45,10 +45,14 @@ use core::usize; pub use core::alloc::{Layout, LayoutErr}; +#[cold] +#[inline(never)] fn new_layout_err() -> LayoutErr { Layout::from_size_align(1, 3).unwrap_err() } +#[cold] +#[inline(never)] pub fn handle_alloc_error(layout: Layout) -> ! { panic!("encountered allocation error: {:?}", layout) } diff --git a/crates/oxc_allocator/src/vec2/raw_vec.rs b/crates/oxc_allocator/src/vec2/raw_vec.rs index aecf27d832f66..203e55cd2801a 100644 --- a/crates/oxc_allocator/src/vec2/raw_vec.rs +++ b/crates/oxc_allocator/src/vec2/raw_vec.rs @@ -856,6 +856,8 @@ fn alloc_guard(alloc_size: usize) -> Result<(), AllocError> { // One central function responsible for reporting capacity overflows. This'll // ensure that the code generation related to these panics is minimal as there's // only one location which panics rather than a bunch throughout the module. +#[cold] +#[inline(never)] fn capacity_overflow() -> ! { panic!("capacity overflow") }