make poison-on-free work, disable copying if borrowck is enabled
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "boxed_region.h"
|
#include "boxed_region.h"
|
||||||
#include "rust_globals.h"
|
#include "rust_globals.h"
|
||||||
#include "rust_task.h"
|
#include "rust_task.h"
|
||||||
|
#include "rust_env.h"
|
||||||
|
|
||||||
// #define DUMP_BOXED_REGION
|
// #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->prev) box->prev->next = box->next;
|
||||||
if (box->next) box->next->prev = box->prev;
|
if (box->next) box->next->prev = box->prev;
|
||||||
if (live_allocs == box) live_allocs = box->next;
|
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->prev = NULL;
|
||||||
box->next = NULL;
|
box->next = NULL;
|
||||||
box->td = NULL;
|
box->td = NULL;
|
||||||
|
|
||||||
backing_region->free(box);
|
backing_region->free(box);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
struct type_desc;
|
struct type_desc;
|
||||||
class memory_region;
|
class memory_region;
|
||||||
struct rust_opaque_box;
|
struct rust_opaque_box;
|
||||||
|
struct rust_env;
|
||||||
|
|
||||||
/* Tracks the data allocated by a particular task in the '@' region.
|
/* Tracks the data allocated by a particular task in the '@' region.
|
||||||
* Currently still relies on the standard malloc as a backing allocator, but
|
* 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). */
|
* a type descr which describes the payload (what follows the header). */
|
||||||
class boxed_region {
|
class boxed_region {
|
||||||
private:
|
private:
|
||||||
|
rust_env *env;
|
||||||
memory_region *backing_region;
|
memory_region *backing_region;
|
||||||
rust_opaque_box *live_allocs;
|
rust_opaque_box *live_allocs;
|
||||||
|
|
||||||
@@ -24,8 +26,9 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
boxed_region(memory_region *br)
|
boxed_region(rust_env *e, memory_region *br)
|
||||||
: backing_region(br)
|
: env(e)
|
||||||
|
, backing_region(br)
|
||||||
, live_allocs(NULL)
|
, live_allocs(NULL)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ rust_task::rust_task(rust_sched_loop *sched_loop, rust_task_state state,
|
|||||||
list_index(-1),
|
list_index(-1),
|
||||||
rendezvous_ptr(0),
|
rendezvous_ptr(0),
|
||||||
local_region(&sched_loop->local_region),
|
local_region(&sched_loop->local_region),
|
||||||
boxed(&local_region),
|
boxed(sched_loop->kernel->env, &local_region),
|
||||||
unwinding(false),
|
unwinding(false),
|
||||||
propagate_failure(true),
|
propagate_failure(true),
|
||||||
cc_counter(0),
|
cc_counter(0),
|
||||||
|
|||||||
@@ -48,7 +48,10 @@ type options =
|
|||||||
no_trans: bool,
|
no_trans: bool,
|
||||||
no_asm_comments: bool,
|
no_asm_comments: bool,
|
||||||
debug_rustc: 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]};
|
type crate_metadata = {name: str, data: [u8]};
|
||||||
|
|
||||||
|
|||||||
@@ -159,6 +159,12 @@ fn visit_block(cx: @ctx, b: ast::blk, sc: scope, v: vt<scope>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn cant_copy(cx: ctx, b: binding) -> bool {
|
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 {
|
alt b.copied {
|
||||||
not_allowed { ret true; }
|
not_allowed { ret true; }
|
||||||
copied { ret false; }
|
copied { ret false; }
|
||||||
|
|||||||
Reference in New Issue
Block a user