about summary refs log tree commit diff
path: root/src/libstd/rt/task.rs
diff options
context:
space:
mode:
authorVadim Chugunov <vadimcn@gmail.com>2013-12-15 17:17:07 -0800
committerVadim Chugunov <vadimcn@gmail.com>2013-12-24 12:13:42 -0800
commite3b37154b0f321ad74f293d98d9be2ae512c2ec7 (patch)
tree2b55a6286b9ec6591b1c9b2d7869be345914b208 /src/libstd/rt/task.rs
parent619c4fce891f31ec234a3ac162d40d3def95956e (diff)
downloadrust-e3b37154b0f321ad74f293d98d9be2ae512c2ec7.tar.gz
rust-e3b37154b0f321ad74f293d98d9be2ae512c2ec7.zip
Stop using C++ exceptions for stack unwinding.
Diffstat (limited to 'src/libstd/rt/task.rs')
-rw-r--r--src/libstd/rt/task.rs68
1 files changed, 2 insertions, 66 deletions
diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs
index 3299caa089a..30e05e9091f 100644
--- a/src/libstd/rt/task.rs
+++ b/src/libstd/rt/task.rs
@@ -18,10 +18,9 @@ use super::local_heap::LocalHeap;
 use prelude::*;
 
 use borrow;
-use cast::transmute;
 use cleanup;
 use io::Writer;
-use libc::{c_void, uintptr_t, c_char, size_t};
+use libc::{c_char, size_t};
 use local_data;
 use option::{Option, Some, None};
 use rt::borrowck::BorrowRecord;
@@ -33,8 +32,8 @@ use rt::local::Local;
 use rt::logging::StdErrLogger;
 use rt::sched::{Scheduler, SchedHandle};
 use rt::stack::{StackSegment, StackPool};
+use rt::unwind::Unwinder;
 use send_str::SendStr;
-use task::TaskResult;
 use unstable::finally::Finally;
 use unstable::mutex::Mutex;
 
@@ -91,21 +90,6 @@ pub enum SchedHome {
 pub struct GarbageCollector;
 pub struct LocalStorage(Option<local_data::Map>);
 
-pub struct Unwinder {
-    unwinding: bool,
-    cause: Option<~Any>
-}
-
-impl Unwinder {
-    fn result(&mut self) -> TaskResult {
-        if self.unwinding {
-            Err(self.cause.take().unwrap())
-        } else {
-            Ok(())
-        }
-    }
-}
-
 impl Task {
 
     // A helper to build a new task using the dynamically found
@@ -452,54 +436,6 @@ impl Coroutine {
 
 }
 
-
-// Just a sanity check to make sure we are catching a Rust-thrown exception
-static UNWIND_TOKEN: uintptr_t = 839147;
-
-impl Unwinder {
-    pub fn try(&mut self, f: ||) {
-        use unstable::raw::Closure;
-
-        unsafe {
-            let closure: Closure = transmute(f);
-            let code = transmute(closure.code);
-            let env = transmute(closure.env);
-
-            let token = rust_try(try_fn, code, env);
-            assert!(token == 0 || token == UNWIND_TOKEN);
-        }
-
-        extern fn try_fn(code: *c_void, env: *c_void) {
-            unsafe {
-                let closure: Closure = Closure {
-                    code: transmute(code),
-                    env: transmute(env),
-                };
-                let closure: || = transmute(closure);
-                closure();
-            }
-        }
-
-        extern {
-            fn rust_try(f: extern "C" fn(*c_void, *c_void),
-                        code: *c_void,
-                        data: *c_void) -> uintptr_t;
-        }
-    }
-
-    pub fn begin_unwind(&mut self, cause: ~Any) -> ! {
-        self.unwinding = true;
-        self.cause = Some(cause);
-        unsafe {
-            rust_begin_unwind(UNWIND_TOKEN);
-            return transmute(());
-        }
-        extern {
-            fn rust_begin_unwind(token: uintptr_t);
-        }
-    }
-}
-
 /// This function is invoked from rust's current __morestack function. Segmented
 /// stacks are currently not enabled as segmented stacks, but rather one giant
 /// stack segment. This means that whenever we run out of stack, we want to