Skip to content

Commit

Permalink
Flag failure functions as inline(never)
Browse files Browse the repository at this point in the history
The failure functions are generic, meaning they're candidates for getting
inlined across crates. This has been happening, leading to monstrosities like
that found in rust-lang#11549. I have verified that the codegen is *much* better now that
we're not inlining the failure path (the slow path).
  • Loading branch information
alexcrichton committed Jan 15, 2014
1 parent dd8b011 commit 86c60b6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/libstd/rt/unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ pub mod eabi {
/// This is the entry point of unwinding for things like lang items and such.
/// The arguments are normally generated by the compiler, and need to
/// have static lifetimes.
#[inline(never)] #[cold] // this is the slow path, please never inline this
pub fn begin_unwind_raw(msg: *c_char, file: *c_char, line: size_t) -> ! {
#[inline]
fn static_char_ptr(p: *c_char) -> &'static str {
Expand All @@ -381,6 +382,7 @@ pub fn begin_unwind_raw(msg: *c_char, file: *c_char, line: size_t) -> ! {
}

/// This is the entry point of unwinding for fail!() and assert!().
#[inline(never)] #[cold] // this is the slow path, please never inline this
pub fn begin_unwind<M: Any + Send>(msg: M, file: &'static str, line: uint) -> ! {
// Note that this should be the only allocation performed in this block.
// Currently this means that fail!() on OOM will invoke this code path,
Expand Down

2 comments on commit 86c60b6

@thestinger
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+

@alexcrichton
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors: retry

Please sign in to comment.