]> git.lizzy.rs Git - rust.git/commitdiff
Added clarification regarding rust_try_inner.
authorVadim Chugunov <vadimcn@gmail.com>
Wed, 6 Aug 2014 02:07:38 +0000 (19:07 -0700)
committerVadim Chugunov <vadimcn@gmail.com>
Wed, 6 Aug 2014 02:14:15 +0000 (19:14 -0700)
src/librustrt/unwind.rs
src/rt/rust_try.ll
src/rustllvm/llvm-auto-clean-trigger

index 9c62936ef9a4922c253a521c70e7f9bea1ce3cc5..f0967edc82061f469aa63df10c0d0da1ac3c2ed0 100644 (file)
@@ -220,12 +220,19 @@ fn rust_exception_class() -> uw::_Unwind_Exception_Class {
 //
 // This is pretty close to Rust's exception handling approach, except that Rust
 // does have a single "catch-all" handler at the bottom of each task's stack.
-// So we have two versions:
+// So we have two versions of the personality routine:
 // - rust_eh_personality, used by all cleanup landing pads, which never catches,
 //   so the behavior of __gcc_personality_v0 is perfectly adequate there, and
 // - rust_eh_personality_catch, used only by rust_try(), which always catches.
-//   This is achieved by overriding the return value in search phase to always
-//   say "catch!".
+//
+// Note, however, that for implementation simplicity, rust_eh_personality_catch
+// lacks code to install a landing pad, so in order to obtain exception object
+// pointer (which it needs to return upstream), rust_try() employs another trick:
+// it calls into the nested rust_try_inner(), whose landing pad does not resume
+// unwinds.  Instead, it extracts the exception pointer and performs a "normal"
+// return.
+//
+// See also: rt/rust_try.ll
 
 #[cfg(not(target_arch = "arm"), not(windows, target_arch = "x86_64"), not(test))]
 #[doc(hidden)]
@@ -334,7 +341,8 @@ pub extern "C" fn rust_eh_personality_catch(
 
 // ARM EHABI uses a slightly different personality routine signature,
 // but otherwise works the same.
-#[cfg(target_arch = "arm", not(target_os = "ios", not(test)))]
+#[cfg(target_arch = "arm", not(target_os = "ios"), not(test))]
+#[doc(hidden)]
 #[allow(visible_private_types)]
 pub mod eabi {
     use uw = libunwind;
@@ -384,10 +392,9 @@ pub extern "C" fn rust_eh_personality_catch(
 // with an "API translator" layer (_GCC_specific_handler).
 
 #[cfg(windows, target_arch = "x86_64", not(test))]
+#[doc(hidden)]
 #[allow(visible_private_types)]
 #[allow(non_camel_case_types)]
-#[allow(unused_variable)]
-#[allow(uppercase_variables)]
 pub mod eabi {
     use uw = libunwind;
     use libc::{c_void, c_int};
index 08bf5e3dface47ced6d9f958cfd50ca16ce94d2f..33d2d31a2e0c1775865b33ae9f90c8ddfa93153e 100644 (file)
@@ -11,6 +11,7 @@
 ; Rust's try-catch
 ; When f(...) returns normally, the return value is null.
 ; When f(...) throws, the return value is a pointer to the caught exception object.
+
 ; See also: librustrt/unwind.rs
 
 define i8* @rust_try(void (i8*,i8*)* %f, i8* %fptr, i8* %env) {
@@ -25,7 +26,7 @@ normal:
 catch:
     landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @rust_eh_personality_catch to i8*)
         catch i8* null
-    ; execution will never reach here because rust_try_inner's landing pad does not resume unwinds
+    ; rust_try_inner's landing pad does not resume unwinds, so execution will never reach here
     ret i8* null
 }
 
index bf488ca1527c1d333052f1ef62afc4900c2ab766..dd1c444119bde49b720f558ebfa90d5d889f377d 100644 (file)
@@ -1,4 +1,4 @@
 # If this file is modified, then llvm will be forcibly cleaned and then rebuilt.
 # The actual contents of this file do not matter, but to trigger a change on the
 # build bots then the contents should be changed so git updates the mtime.
-2014-08-24
+2014-08-05