diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-12-18 16:59:49 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-12-18 17:17:31 -0800 |
| commit | bd6b80c9720bb4b0143378a052b568697ce3abe6 (patch) | |
| tree | 4d261511241d91b59b485f3192803c922d98b728 /src/rt/rust_upcall.cpp | |
| parent | c73eb8ff51da170ff10aba73934f10e40d26366d (diff) | |
| download | rust-bd6b80c9720bb4b0143378a052b568697ce3abe6.tar.gz rust-bd6b80c9720bb4b0143378a052b568697ce3abe6.zip | |
rt: Get rid of the rethrow in upcall_fail
Throwing in upcall_fail ends up running lots of code in the red zone. To avoid it we have the personality function figure out which stack it's on and switch as needed.
Diffstat (limited to 'src/rt/rust_upcall.cpp')
| -rw-r--r-- | src/rt/rust_upcall.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index 506441979ca..5febc5098a2 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -88,12 +88,8 @@ extern "C" CDECL void upcall_fail(char const *expr, char const *file, size_t line) { - try { - s_fail_args args = {expr,file,line}; - UPCALL_SWITCH_STACK(&args, upcall_s_fail); - } catch (rust_task*) { - throw; - } + s_fail_args args = {expr,file,line}; + UPCALL_SWITCH_STACK(&args, upcall_s_fail); } /********************************************************************** @@ -536,7 +532,18 @@ upcall_rust_personality(int version, s_rust_personality_args args = {(_Unwind_Reason_Code)0, version, actions, exception_class, ue_header, context}; - UPCALL_SWITCH_STACK(&args, upcall_s_rust_personality); + rust_task *task = rust_scheduler::get_task(); + + // The personality function is run on the stack of the + // last function that threw or landed, which is going + // to sometimes be the C stack. If we're on the Rust stack + // then switch to the C stack. + + if (task->on_rust_stack()) { + UPCALL_SWITCH_STACK(&args, upcall_s_rust_personality); + } else { + upcall_s_rust_personality(&args); + } return args.retval; } |
