about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2014-07-25 00:38:37 -0700
committerBrian Anderson <banderson@mozilla.com>2014-07-25 00:40:58 -0700
commitf7ab07c7806bb4a7418f228c1cf266cdf011a878 (patch)
treec853221738a02faadde1721054d81b70379a04cf
parent4636b32a42ea3111f53048197092e7ac08e6f792 (diff)
downloadrust-f7ab07c7806bb4a7418f228c1cf266cdf011a878.tar.gz
rust-f7ab07c7806bb4a7418f228c1cf266cdf011a878.zip
Put the struct passed to unwinding functions into a static
Produces very clean asm, but makes bigger binaries.
-rw-r--r--src/libcore/macros.rs3
-rw-r--r--src/libstd/macros.rs19
2 files changed, 14 insertions, 8 deletions
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs
index e2709c4edde..26bb69943f8 100644
--- a/src/libcore/macros.rs
+++ b/src/libcore/macros.rs
@@ -33,7 +33,8 @@ macro_rules! fail(
         // up with the number of calls to fail!()
         #[inline(always)]
         fn run_fmt(fmt: &::std::fmt::Arguments) -> ! {
-            ::core::failure::begin_unwind(fmt, &(file!(), line!()))
+            static file_line: (&'static str, uint) = (file!(), line!());
+            ::core::failure::begin_unwind(fmt, &file_line)
         }
         format_args!(run_fmt, $fmt, $($arg)*)
     });
diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs
index fd0c72ce313..9ce142836cf 100644
--- a/src/libstd/macros.rs
+++ b/src/libstd/macros.rs
@@ -38,12 +38,16 @@
 /// ```
 #[macro_export]
 macro_rules! fail(
-    () => (
-        ::std::rt::begin_unwind_no_time_to_explain(&(file!(), line!()))
-    );
-    ($msg:expr) => (
-        ::std::rt::begin_unwind($msg, file!(), line!())
-    );
+    () => ({
+        // static requires less code at runtime, more constant data
+        static file_line: (&'static str, uint) = (file!(), line!());
+        ::std::rt::begin_unwind_no_time_to_explain(&file_line)
+    });
+    ($msg:expr) => ({
+        static file_line: (&'static str, uint) = (file!(), line!());
+        let (file, line) = file_line;
+        ::std::rt::begin_unwind($msg, file, line)
+    });
     ($fmt:expr, $($arg:tt)*) => ({
         // a closure can't have return type !, so we need a full
         // function to pass to format_args!, *and* we need the
@@ -58,7 +62,8 @@ macro_rules! fail(
         // up with the number of calls to fail!()
         #[inline(always)]
         fn run_fmt(fmt: &::std::fmt::Arguments) -> ! {
-            ::std::rt::begin_unwind_fmt(fmt, &(file!(), line!()))
+            static file_line: (&'static str, uint) = (file!(), line!());
+            ::std::rt::begin_unwind_fmt(fmt, &file_line)
         }
         format_args!(run_fmt, $fmt, $($arg)*)
     });