diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-09-12 09:36:51 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-09-12 09:36:51 -0700 |
| commit | 393deeb06ff8017a93b0fd26c1f6968fdff2b15b (patch) | |
| tree | 3dacb71e604095ec94a8f350f44467b7640f289d /src/rt | |
| parent | edde2e0c457de6e5d17373bfa90ef319df4a1566 (diff) | |
| parent | 6ffcfba6b990d6f27243e4dd6ddfffab141e1f44 (diff) | |
| download | rust-393deeb06ff8017a93b0fd26c1f6968fdff2b15b.tar.gz rust-393deeb06ff8017a93b0fd26c1f6968fdff2b15b.zip | |
Merge branch 'unwind'
Conflicts: src/comp/middle/trans.rs src/comp/middle/trans_build.rs src/lib/run_program.rs src/test/compiletest/runtest.rs
Diffstat (limited to 'src/rt')
| -rw-r--r-- | src/rt/memory_region.cpp | 11 | ||||
| -rw-r--r-- | src/rt/memory_region.h | 5 | ||||
| -rw-r--r-- | src/rt/rust_builtin.cpp | 7 | ||||
| -rw-r--r-- | src/rt/rust_internal.h | 3 | ||||
| -rw-r--r-- | src/rt/rust_kernel.cpp | 2 | ||||
| -rw-r--r-- | src/rt/rust_scheduler.cpp | 2 | ||||
| -rw-r--r-- | src/rt/rust_task.cpp | 12 | ||||
| -rw-r--r-- | src/rt/rust_upcall.cpp | 22 | ||||
| -rw-r--r-- | src/rt/rustrt.def.in | 2 |
9 files changed, 31 insertions, 35 deletions
diff --git a/src/rt/memory_region.cpp b/src/rt/memory_region.cpp index ef8a92b427f..a55d073543d 100644 --- a/src/rt/memory_region.cpp +++ b/src/rt/memory_region.cpp @@ -15,13 +15,13 @@ memory_region::alloc_header *memory_region::get_header(void *mem) { memory_region::memory_region(rust_srv *srv, bool synchronized) : _srv(srv), _parent(NULL), _live_allocations(0), _detailed_leaks(srv->env->detailed_leaks), - _synchronized(synchronized), _hack_allow_leaks(false) { + _synchronized(synchronized) { } memory_region::memory_region(memory_region *parent) : _srv(parent->_srv), _parent(parent), _live_allocations(0), _detailed_leaks(parent->_detailed_leaks), - _synchronized(parent->_synchronized), _hack_allow_leaks(false) { + _synchronized(parent->_synchronized) { } void memory_region::add_alloc() { @@ -127,7 +127,7 @@ memory_region::~memory_region() { assert(leak_count == _live_allocations); } #endif - if (!_hack_allow_leaks && _live_allocations > 0) { + if (_live_allocations > 0) { _srv->fatal(msg, __FILE__, __LINE__, "%d objects", _live_allocations); } @@ -135,11 +135,6 @@ memory_region::~memory_region() { } void -memory_region::hack_allow_leaks() { - _hack_allow_leaks = true; -} - -void memory_region::release_alloc(void *mem) { alloc_header *alloc = get_header(mem); assert(alloc->magic == MAGIC); diff --git a/src/rt/memory_region.h b/src/rt/memory_region.h index 0197057268c..9d2106c1eaf 100644 --- a/src/rt/memory_region.h +++ b/src/rt/memory_region.h @@ -32,7 +32,6 @@ private: const bool _detailed_leaks; const bool _synchronized; lock_and_signal _lock; - bool _hack_allow_leaks; void add_alloc(); void dec_alloc(); @@ -46,10 +45,6 @@ public: void *realloc(void *mem, size_t size); void free(void *mem); virtual ~memory_region(); - // FIXME (236: This is a temporary hack to allow failing tasks that leak - // to not kill the entire process, which the test runner needs. Please - // kill with prejudice once unwinding works. - void hack_allow_leaks(); void release_alloc(void *mem); void claim_alloc(void *mem); diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 5e0c9dbf4c2..2499dea0328 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -224,13 +224,6 @@ debug_opaque(rust_task *task, type_desc *t, uint8_t *front) } } -extern "C" CDECL void -hack_allow_leaks(rust_task *task) -{ - LOG(task, stdlib, "hack_allow_leaks"); - task->local_region.hack_allow_leaks(); -} - struct rust_box { RUST_REFCOUNTED(rust_box) diff --git a/src/rt/rust_internal.h b/src/rt/rust_internal.h index d2c8574280b..c01fc5f3127 100644 --- a/src/rt/rust_internal.h +++ b/src/rt/rust_internal.h @@ -99,6 +99,9 @@ static size_t const TIME_SLICE_IN_MS = 10; static size_t const BUF_BYTES = 2048; +// The error status to use when the process fails +#define PROC_FAIL_CODE 101; + // Every reference counted object should use this macro and initialize // ref_count. diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp index 54b1cc98d43..e5234b9d6f5 100644 --- a/src/rt/rust_kernel.cpp +++ b/src/rt/rust_kernel.cpp @@ -140,7 +140,7 @@ rust_kernel::fail() { // Runtime to terminate it in an unusual way" when trying to shutdown // cleanly. #if defined(__WIN32__) - exit(1); + exit(rval); #endif for(size_t i = 0; i < num_threads; ++i) { rust_scheduler *thread = threads[i]; diff --git a/src/rt/rust_scheduler.cpp b/src/rt/rust_scheduler.cpp index 3a69184d3fe..b127ec77efa 100644 --- a/src/rt/rust_scheduler.cpp +++ b/src/rt/rust_scheduler.cpp @@ -71,7 +71,7 @@ rust_scheduler::fail() { log(NULL, log_err, "domain %s @0x%" PRIxPTR " root task failed", name, this); I(this, kernel->rval == 0); - kernel->rval = 1; + kernel->rval = PROC_FAIL_CODE; kernel->fail(); } diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 57b5d16e427..b861c60b521 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -138,18 +138,6 @@ struct rust_closure_env { }; extern "C" CDECL -void task_exit(rust_closure_env *env, int rval, rust_task *task) { - LOG(task, task, "task exited with value %d", rval); - if(env) { - // free the environment. - I(task->sched, 1 == env->ref_count); // the ref count better be 1 - //env->td->drop_glue(NULL, task, NULL, env->td->first_param, env); - //env->td->free_glue(NULL, task, NULL, env->td->first_param, env); - task->free(env); - } -} - -extern "C" CDECL void task_start_wrapper(spawn_args *a) { rust_task *task = a->task; diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index 2d7791e876f..0f5c11537fe 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -1,6 +1,8 @@ #include "rust_gc.h" #include "rust_internal.h" #include "rust_upcall.h" +#include <stdint.h> +#include <unwind.h> // Upcalls. @@ -190,6 +192,26 @@ upcall_dynastack_free(rust_task *task, void *ptr) { return task->dynastack.free(ptr); } +extern "C" _Unwind_Reason_Code +__gxx_personality_v0(int version, + _Unwind_Action actions, + uint64_t exception_class, + _Unwind_Exception *ue_header, + _Unwind_Context *context); + +extern "C" _Unwind_Reason_Code +upcall_rust_personality(int version, + _Unwind_Action actions, + uint64_t exception_class, + _Unwind_Exception *ue_header, + _Unwind_Context *context) { + return __gxx_personality_v0(version, + actions, + exception_class, + ue_header, + context); +} + // // Local Variables: // mode: C++ diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index a0e7c972eeb..bf8155b7998 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -28,7 +28,6 @@ get_task_id get_task_pointer get_task_trampoline get_time -hack_allow_leaks last_os_error leak migrate_alloc @@ -78,5 +77,6 @@ upcall_vec_grow upcall_vec_push upcall_log_type upcall_malloc +upcall_rust_personality upcall_shared_malloc upcall_shared_free |
