1
Fork 0

Switch to begin_panic again

In https://github.com/rust-lang/rust/pull/42938 we made the compiler
emit a call to begin_panic_new in order to pass column info to it. Now
with stage0 updated (https://github.com/rust-lang/rust/pull/43320),
we can safely change begin_panic and start emitting calls for it again.
This commit is contained in:
est31 2017-07-25 22:10:10 +02:00
parent c417ee9ae8
commit 90ac6408ba
4 changed files with 14 additions and 13 deletions

View file

@ -46,7 +46,7 @@ macro_rules! panic {
panic!("explicit panic")
});
($msg:expr) => ({
$crate::rt::begin_panic_new($msg, {
$crate::rt::begin_panic($msg, {
// static requires less code at runtime, more constant data
static _FILE_LINE_COL: (&'static str, u32, u32) = (file!(), line!(), column!());
&_FILE_LINE_COL

View file

@ -518,7 +518,7 @@ pub fn begin_panic_fmt(msg: &fmt::Arguments,
let mut s = String::new();
let _ = s.write_fmt(*msg);
begin_panic_new(s, file_line_col)
begin_panic(s, file_line_col)
}
// FIXME: In PR #42938, we have added the column as info passed to the panic
@ -529,15 +529,17 @@ pub fn begin_panic_fmt(msg: &fmt::Arguments,
// By changing the compiler source, we can only affect behaviour of higher
// stages. We need to perform the switch over two stage0 replacements, using
// a temporary function begin_panic_new while performing the switch:
// 0. Right now, we tell stage1 onward to emit a call to begin_panic_new.
// 1. In the first SNAP, stage0 calls begin_panic_new with the new ABI,
// begin_panic stops being used. Now we can change begin_panic to
// the new ABI, and start emitting calls to begin_panic in higher
// 0. Before the current switch, we told stage1 onward to emit a call
// to begin_panic_new.
// 1. Right now, stage0 calls begin_panic_new with the new ABI,
// begin_panic stops being used. We have changed begin_panic to
// the new ABI, and started to emit calls to begin_panic in higher
// stages again, this time with the new ABI.
// 2. After the second SNAP, stage0 calls begin_panic with the new ABI,
// and we can remove the temporary begin_panic_new function.
/// This is the entry point of panicking for panic!() and assert!().
#[cfg(stage0)]
#[unstable(feature = "libstd_sys_internals",
reason = "used by the panic! macro",
issue = "0")]
@ -558,7 +560,7 @@ pub fn begin_panic_new<M: Any + Send>(msg: M, file_line_col: &(&'static str, u32
reason = "used by the panic! macro",
issue = "0")]
#[inline(never)] #[cold] // avoid code bloat at the call sites as much as possible
pub fn begin_panic<M: Any + Send>(msg: M, file_line: &(&'static str, u32)) -> ! {
pub fn begin_panic<M: Any + Send>(msg: M, file_line_col: &(&'static str, u32, u32)) -> ! {
// Note that this should be the only allocation performed in this code path.
// Currently this means that panic!() on OOM will invoke this code path,
// but then again we're not really ready for panic on OOM anyway. If
@ -566,10 +568,7 @@ pub fn begin_panic<M: Any + Send>(msg: M, file_line: &(&'static str, u32)) -> !
// be performed in the parent of this thread instead of the thread that's
// panicking.
let (file, line) = *file_line;
let file_line_col = (file, line, 0);
rust_panic_with_hook(Box::new(msg), &file_line_col)
rust_panic_with_hook(Box::new(msg), file_line_col)
}
/// Executes the primary logic for a panic, including checking for recursive

View file

@ -25,7 +25,9 @@
// Reexport some of our utilities which are expected by other crates.
pub use panicking::{begin_panic_new, begin_panic, begin_panic_fmt, update_panic_count};
#[cfg(stage0)]
pub use panicking::begin_panic_new;
pub use panicking::{begin_panic, begin_panic_fmt, update_panic_count};
#[cfg(not(test))]
#[lang = "start"]

View file

@ -774,7 +774,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
let expr_loc_ptr = self.expr_addr_of(span, expr_loc_tuple);
self.expr_call_global(
span,
self.std_path(&["rt", "begin_panic_new"]),
self.std_path(&["rt", "begin_panic"]),
vec![
self.expr_str(span, msg),
expr_loc_ptr])