@@ -78,7 +78,7 @@ struct Exception {
78
78
cause : Option < Box < Any + Send + ' static > > ,
79
79
}
80
80
81
- pub type Callback = fn ( msg : & ( Any + Send ) , file : & ' static str , line : usize ) ;
81
+ pub type Callback = fn ( msg : & ( Any + Send ) , file : & ' static str , line : u32 ) ;
82
82
83
83
// Variables used for invoking callbacks when a thread starts to unwind.
84
84
//
@@ -484,7 +484,7 @@ pub mod eabi {
484
484
/// Entry point of panic from the libcore crate.
485
485
#[ lang = "panic_fmt" ]
486
486
pub extern fn rust_begin_unwind ( msg : fmt:: Arguments ,
487
- file : & ' static str , line : usize ) -> ! {
487
+ file : & ' static str , line : u32 ) -> ! {
488
488
begin_unwind_fmt ( msg, & ( file, line) )
489
489
}
490
490
@@ -495,7 +495,7 @@ pub extern fn rust_begin_unwind(msg: fmt::Arguments,
495
495
/// on (e.g.) the inlining of other functions as possible), by moving
496
496
/// the actual formatting into this shared place.
497
497
#[ inline( never) ] #[ cold]
498
- pub fn begin_unwind_fmt ( msg : fmt:: Arguments , file_line : & ( & ' static str , usize ) ) -> ! {
498
+ pub fn begin_unwind_fmt ( msg : fmt:: Arguments , file_line : & ( & ' static str , u32 ) ) -> ! {
499
499
use fmt:: Write ;
500
500
501
501
// We do two allocations here, unfortunately. But (a) they're
@@ -510,6 +510,7 @@ pub fn begin_unwind_fmt(msg: fmt::Arguments, file_line: &(&'static str, usize))
510
510
511
511
/// This is the entry point of unwinding for panic!() and assert!().
512
512
#[ inline( never) ] #[ cold] // avoid code bloat at the call sites as much as possible
513
+ #[ cfg( stage0) ]
513
514
pub fn begin_unwind < M : Any + Send > ( msg : M , file_line : & ( & ' static str , usize ) ) -> ! {
514
515
// Note that this should be the only allocation performed in this code path.
515
516
// Currently this means that panic!() on OOM will invoke this code path,
@@ -518,6 +519,22 @@ pub fn begin_unwind<M: Any + Send>(msg: M, file_line: &(&'static str, usize)) ->
518
519
// be performed in the parent of this thread instead of the thread that's
519
520
// panicking.
520
521
522
+ // see below for why we do the `Any` coercion here.
523
+ let ( file, line) = * file_line;
524
+ begin_unwind_inner ( Box :: new ( msg) , & ( file, line as u32 ) )
525
+ }
526
+
527
+ /// This is the entry point of unwinding for panic!() and assert!().
528
+ #[ inline( never) ] #[ cold] // avoid code bloat at the call sites as much as possible
529
+ #[ cfg( not( stage0) ) ]
530
+ pub fn begin_unwind < M : Any + Send > ( msg : M , file_line : & ( & ' static str , u32 ) ) -> ! {
531
+ // Note that this should be the only allocation performed in this code path.
532
+ // Currently this means that panic!() on OOM will invoke this code path,
533
+ // but then again we're not really ready for panic on OOM anyway. If
534
+ // we do start doing this, then we should propagate this allocation to
535
+ // be performed in the parent of this thread instead of the thread that's
536
+ // panicking.
537
+
521
538
// see below for why we do the `Any` coercion here.
522
539
begin_unwind_inner ( Box :: new ( msg) , file_line)
523
540
}
@@ -533,7 +550,7 @@ pub fn begin_unwind<M: Any + Send>(msg: M, file_line: &(&'static str, usize)) ->
533
550
/// }` from ~1900/3700 (-O/no opts) to 180/590.
534
551
#[ inline( never) ] #[ cold] // this is the slow path, please never inline this
535
552
fn begin_unwind_inner ( msg : Box < Any + Send > ,
536
- file_line : & ( & ' static str , usize ) ) -> ! {
553
+ file_line : & ( & ' static str , u32 ) ) -> ! {
537
554
// Make sure the default failure handler is registered before we look at the
538
555
// callbacks. We also use a raw sys-based mutex here instead of a
539
556
// `std::sync` one as accessing TLS can cause weird recursive problems (and
0 commit comments