diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-05-14 08:22:51 -0700 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-05-15 11:49:08 -0700 |
| commit | be48cd87dcdaaf224a7f4338d7ab450119d1b00e (patch) | |
| tree | 484450122090e0c4ce500b37644c5d13dbdfc096 /src/rt | |
| parent | 17d6b09d14c916497a6679363308cb7822c4aafe (diff) | |
make poison-on-free work, disable copying if borrowck is enabled
Diffstat (limited to 'src/rt')
| -rw-r--r-- | src/rt/boxed_region.cpp | 10 | ||||
| -rw-r--r-- | src/rt/boxed_region.h | 7 | ||||
| -rw-r--r-- | src/rt/rust_task.cpp | 2 |
3 files changed, 14 insertions, 5 deletions
diff --git a/src/rt/boxed_region.cpp b/src/rt/boxed_region.cpp index 2612d0f47b9..247424088d6 100644 --- a/src/rt/boxed_region.cpp +++ b/src/rt/boxed_region.cpp @@ -1,8 +1,7 @@ - - #include "boxed_region.h" #include "rust_globals.h" #include "rust_task.h" +#include "rust_env.h" // #define DUMP_BOXED_REGION @@ -52,8 +51,15 @@ void boxed_region::free(rust_opaque_box *box) { if (box->prev) box->prev->next = box->next; if (box->next) box->next->prev = box->prev; if (live_allocs == box) live_allocs = box->next; + + if (env->poison_on_free) { + memset(box_body(box), 0xab, box->td->size); + return; + } + box->prev = NULL; box->next = NULL; box->td = NULL; + backing_region->free(box); } diff --git a/src/rt/boxed_region.h b/src/rt/boxed_region.h index bd5312fee99..a3a90f9b7d6 100644 --- a/src/rt/boxed_region.h +++ b/src/rt/boxed_region.h @@ -6,6 +6,7 @@ struct type_desc; class memory_region; struct rust_opaque_box; +struct rust_env; /* Tracks the data allocated by a particular task in the '@' region. * Currently still relies on the standard malloc as a backing allocator, but @@ -13,6 +14,7 @@ struct rust_opaque_box; * a type descr which describes the payload (what follows the header). */ class boxed_region { private: + rust_env *env; memory_region *backing_region; rust_opaque_box *live_allocs; @@ -24,8 +26,9 @@ private: } public: - boxed_region(memory_region *br) - : backing_region(br) + boxed_region(rust_env *e, memory_region *br) + : env(e) + , backing_region(br) , live_allocs(NULL) {} diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 20727dbcbfd..d7c62780fbb 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -27,7 +27,7 @@ rust_task::rust_task(rust_sched_loop *sched_loop, rust_task_state state, list_index(-1), rendezvous_ptr(0), local_region(&sched_loop->local_region), - boxed(&local_region), + boxed(sched_loop->kernel->env, &local_region), unwinding(false), propagate_failure(true), cc_counter(0), |
