Skip to content

Commit 2df8e22

Browse files
Mark-SimulacrumAmanieu
authored andcommitted
Mark cleanup cold
1 parent 5cdabb8 commit 2df8e22

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/libstd/panicking.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,11 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
307307
Err(cleanup(payload.assume_init()))
308308
};
309309

310+
// We consider unwinding to be rare, so mark this function as cold. However,
311+
// do not mark it no-inline -- that decision is best to leave to the
312+
// optimizer (in most cases this function is not inlined even as a normal,
313+
// non-cold function, though, as of the writing of this comment).
314+
#[cold]
310315
unsafe fn cleanup(mut payload: Payload) -> Box<dyn Any + Send + 'static> {
311316
let obj = crate::mem::transmute(__rust_panic_cleanup(&mut payload as *mut _ as *mut u8));
312317
update_panic_count(-1);

0 commit comments

Comments
 (0)