diff --git a/src/rt/boxed_region.cpp b/src/rt/boxed_region.cpp index 2612d0f47b9a..247424088d6b 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 bd5312fee99f..a3a90f9b7d66 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 20727dbcbfd0..d7c62780fbb1 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), diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs index 2e9dffb1c2cd..99c6d1ab11e1 100644 --- a/src/rustc/driver/session.rs +++ b/src/rustc/driver/session.rs @@ -48,7 +48,10 @@ type options = no_trans: bool, no_asm_comments: bool, debug_rustc: bool, - borrowck: uint}; // 0=off,1=warn,2=err + + // temporary hack: 0=off,1=warn,2=err --> if 2, alias is disabled + borrowck: uint, + }; type crate_metadata = {name: str, data: [u8]}; diff --git a/src/rustc/middle/alias.rs b/src/rustc/middle/alias.rs index 81f90c8eef2e..471e68137e82 100644 --- a/src/rustc/middle/alias.rs +++ b/src/rustc/middle/alias.rs @@ -159,6 +159,12 @@ fn visit_block(cx: @ctx, b: ast::blk, sc: scope, v: vt) { } fn cant_copy(cx: ctx, b: binding) -> bool { + + if cx.tcx.sess.opts.borrowck == 2u { + // borrowck is enabled. disable alias analysis. + ret false; + } + alt b.copied { not_allowed { ret true; } copied { ret false; }