Skip to content

Commit bb0ad11

Browse files
committed
rt: Call the Rust box annihilator; stop calling the cycle collector
1 parent afd91f8 commit bb0ad11

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

src/rt/rust.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ command_line_args : public kernel_owned<command_line_args>
7272
// FIXME (#2670): This belongs somewhere else
7373
int check_claims = 0;
7474

75+
void* global_crate_map = NULL;
76+
7577
/**
7678
The runtime entrypoint. The (C ABI) main function generated by rustc calls
7779
`rust_start`, providing the address of the Rust ABI main function, the
@@ -86,6 +88,8 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
8688
// line as well.
8789
rust_env *env = load_env();
8890

91+
global_crate_map = crate_map;
92+
8993
update_gc_metadata(crate_map);
9094

9195
update_log_settings(crate_map, env->logspec);

src/rt/rust_globals.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,6 @@ static size_t const BUF_BYTES = 2048;
101101
// (writing), a port (reading) or a task (waiting).
102102
struct rust_cond { };
103103

104+
extern void* global_crate_map;
105+
104106
#endif /* RUST_GLOBALS_H */

src/rt/rust_task.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "rust_cc.h"
1010
#include "rust_env.h"
1111
#include "rust_port.h"
12+
#include "rust_globals.h"
13+
#include "rust_crate_map.h"
1214

1315
// Tasks
1416
rust_task::rust_task(rust_sched_loop *sched_loop, rust_task_state state,
@@ -125,18 +127,9 @@ cleanup_task(cleanup_args *args) {
125127
main_task_failed_without_spawning = true;
126128
}
127129

128-
// FIXME (#2676): For performance we should do the annihilator
129-
// instead of the cycle collector even under normal termination, but
130-
// since that would hide memory management errors (like not derefing
131-
// boxes), it needs to be disableable in debug builds.
132-
if (threw_exception) {
133-
// FIXME (#2676): When the annihilator is more powerful and
134-
// successfully runs resource destructors, etc. we can get rid
135-
// of this cc
136-
cc::do_cc(task);
137-
annihilate_boxes(task);
138-
}
139-
cc::do_final_cc(task);
130+
// Call the box annihilator.
131+
cratemap* map = reinterpret_cast<cratemap*>(global_crate_map);
132+
task->call_on_rust_stack(NULL, const_cast<void*>(map->annihilate_fn()));
140133

141134
task->die();
142135

0 commit comments

Comments
 (0)