From 991cbfe42c8836e8b4adfcaf288d5c0b8d57397c Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 24 Sep 2012 14:14:03 -0700 Subject: [PATCH] Revert "rt: Call the Rust box annihilator; stop calling the cycle collector" due to crashes This reverts commit bb0ad11252c493ca8de85025411c3f068f529039. --- src/rt/rust.cpp | 4 ---- src/rt/rust_globals.h | 2 -- src/rt/rust_task.cpp | 17 ++++++++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/rt/rust.cpp b/src/rt/rust.cpp index dc28f624415..705a96303d4 100644 --- a/src/rt/rust.cpp +++ b/src/rt/rust.cpp @@ -72,8 +72,6 @@ command_line_args : public kernel_owned // FIXME (#2670): This belongs somewhere else int check_claims = 0; -void* global_crate_map = NULL; - /** The runtime entrypoint. The (C ABI) main function generated by rustc calls `rust_start`, providing the address of the Rust ABI main function, the @@ -88,8 +86,6 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) { // line as well. rust_env *env = load_env(); - global_crate_map = crate_map; - update_gc_metadata(crate_map); update_log_settings(crate_map, env->logspec); diff --git a/src/rt/rust_globals.h b/src/rt/rust_globals.h index 84c5eca0afb..2d69edebd0e 100644 --- a/src/rt/rust_globals.h +++ b/src/rt/rust_globals.h @@ -101,6 +101,4 @@ static size_t const BUF_BYTES = 2048; // (writing), a port (reading) or a task (waiting). struct rust_cond { }; -extern void* global_crate_map; - #endif /* RUST_GLOBALS_H */ diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 1d1dae046f0..1efd641b343 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -9,8 +9,6 @@ #include "rust_cc.h" #include "rust_env.h" #include "rust_port.h" -#include "rust_globals.h" -#include "rust_crate_map.h" // Tasks rust_task::rust_task(rust_sched_loop *sched_loop, rust_task_state state, @@ -127,9 +125,18 @@ cleanup_task(cleanup_args *args) { main_task_failed_without_spawning = true; } - // Call the box annihilator. - cratemap* map = reinterpret_cast(global_crate_map); - task->call_on_rust_stack(NULL, const_cast(map->annihilate_fn())); + // FIXME (#2676): For performance we should do the annihilator + // instead of the cycle collector even under normal termination, but + // since that would hide memory management errors (like not derefing + // boxes), it needs to be disableable in debug builds. + if (threw_exception) { + // FIXME (#2676): When the annihilator is more powerful and + // successfully runs resource destructors, etc. we can get rid + // of this cc + cc::do_cc(task); + annihilate_boxes(task); + } + cc::do_final_cc(task); task->die();