Get rid of spill_map and associated infrastructure.

This commit is contained in:
Michael Sullivan 2012-06-05 17:29:36 -07:00
parent 868e3f9180
commit 167d726183
3 changed files with 11 additions and 63 deletions

View File

@ -194,7 +194,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
bind middle::check_loop::check_crate(ty_cx, crate));
time(time_passes, "alt checking",
bind middle::check_alt::check_crate(ty_cx, crate));
let (last_use_map, spill_map) =
let last_use_map =
time(time_passes, "liveness checking",
bind middle::liveness::check_crate(ty_cx, method_map, crate));
time(time_passes, "typestate checking",
@ -216,7 +216,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
let maps = {mutbl_map: mutbl_map, root_map: root_map,
copy_map: copy_map, last_use_map: last_use_map,
impl_map: impl_map, method_map: method_map,
vtable_map: vtable_map, spill_map: spill_map};
vtable_map: vtable_map};
let (llmod, link_meta) =
time(time_passes, "translation",

View File

@ -57,7 +57,6 @@ type maps = {
impl_map: middle::resolve::impl_map,
method_map: middle::typeck::method_map,
vtable_map: middle::typeck::vtable_map,
spill_map: middle::liveness::spill_map
};
type decode_ctxt = @{
@ -839,12 +838,6 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
}
option::iter(maps.spill_map.find(id)) {|_m|
ebml_w.tag(c::tag_table_spill) {||
ebml_w.id(id);
}
}
option::iter(maps.last_use_map.find(id)) {|m|
ebml_w.tag(c::tag_table_last_use) {||
ebml_w.id(id);
@ -953,8 +946,6 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
dcx.maps.mutbl_map.insert(id, ());
} else if tag == (c::tag_table_copy as uint) {
dcx.maps.copy_map.insert(id, ());
} else if tag == (c::tag_table_spill as uint) {
dcx.maps.spill_map.insert(id, ());
} else {
let val_doc = entry_doc[c::tag_table_val];
let val_dsr = ebml::ebml_deserializer(val_doc);

View File

@ -57,7 +57,6 @@ import capture::{cap_move, cap_drop, cap_copy, cap_ref};
export check_crate;
export last_use_map;
export spill_map;
// Maps from an expr id to a list of variable ids for which this expr
// is the last use. Typically, the expr is a path and the node id is
@ -66,13 +65,6 @@ export spill_map;
// list of closed over variables that can be moved into the closure.
type last_use_map = hashmap<node_id, @dvec<node_id>>;
// A set of variable ids which must be spilled (stored on the stack).
// We add in any variables or arguments where:
// (1) the variables are moved;
// (2) the address of the variable/argument is taken;
// or (3) we find a last use (as they may be moved).
type spill_map = hashmap<node_id, ()>;
enum variable = uint;
enum live_node = uint;
@ -85,7 +77,7 @@ enum live_node_kind {
fn check_crate(tcx: ty::ctxt,
method_map: typeck::method_map,
crate: @crate) -> (last_use_map, spill_map) {
crate: @crate) -> last_use_map {
let visitor = visit::mk_vt(@{
visit_fn: visit_fn,
visit_local: visit_local,
@ -94,12 +86,11 @@ fn check_crate(tcx: ty::ctxt,
});
let last_use_map = int_hash();
let spill_map = int_hash();
let initial_maps = @ir_maps(tcx, method_map,
last_use_map, spill_map);
last_use_map);
visit::visit_crate(*crate, initial_maps, visitor);
tcx.sess.abort_if_errors();
ret (last_use_map, spill_map);
ret last_use_map;
}
impl of to_str::to_str for live_node {
@ -162,7 +153,6 @@ class ir_maps {
let tcx: ty::ctxt;
let method_map: typeck::method_map;
let last_use_map: last_use_map;
let spill_map: spill_map;
let mut num_live_nodes: uint;
let mut num_vars: uint;
@ -174,11 +164,10 @@ class ir_maps {
let mut lnks: [live_node_kind];
new(tcx: ty::ctxt, method_map: typeck::method_map,
last_use_map: last_use_map, spill_map: spill_map) {
last_use_map: last_use_map) {
self.tcx = tcx;
self.method_map = method_map;
self.last_use_map = last_use_map;
self.spill_map = spill_map;
self.num_live_nodes = 0u;
self.num_vars = 0u;
@ -264,17 +253,6 @@ class ir_maps {
self.lnks[*ln]
}
fn add_spill(var: variable) {
let vk = self.var_kinds[*var];
alt vk {
vk_local(id, _) | vk_arg(id, _, by_val) {
#debug["adding spill for %?", vk];
self.spill_map.insert(id, ());
}
vk_arg(*) | vk_field(_) | vk_self | vk_implicit_ret {}
}
}
fn add_last_use(expr_id: node_id, var: variable) {
let vk = self.var_kinds[*var];
#debug["Node %d is a last use of variable %?", expr_id, vk];
@ -308,7 +286,7 @@ fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
// swap in a new set of IR maps for this function body:
let fn_maps = @ir_maps(self.tcx, self.method_map,
self.last_use_map, self.spill_map);
self.last_use_map);
#debug["creating fn_maps: %x", ptr::addr_of(*fn_maps) as uint];
@ -1407,11 +1385,7 @@ fn check_expr(expr: @expr, &&self: @liveness, vt: vt<@liveness>) {
vt.visit_expr(f, self, vt);
vec::iter2(args, targs) { |arg_expr, arg_ty|
alt ty::resolved_mode(self.tcx, arg_ty.mode) {
by_val | by_copy {
vt.visit_expr(arg_expr, self, vt);
}
by_ref | by_mutbl_ref {
self.spill_expr(arg_expr);
by_val | by_copy | by_ref | by_mutbl_ref{
vt.visit_expr(arg_expr, self, vt);
}
by_move {
@ -1421,10 +1395,6 @@ fn check_expr(expr: @expr, &&self: @liveness, vt: vt<@liveness>) {
}
}
expr_addr_of(_, arg_expr) {
self.spill_expr(arg_expr);
}
// no correctness conditions related to liveness
expr_if_check(*) | expr_if(*) | expr_alt(*) |
expr_while(*) | expr_loop(*) |
@ -1434,7 +1404,7 @@ fn check_expr(expr: @expr, &&self: @liveness, vt: vt<@liveness>) {
expr_assert(*) | expr_check(*) | expr_copy(*) |
expr_loop_body(*) | expr_cast(*) | expr_unary(*) | expr_fail(*) |
expr_ret(*) | expr_break | expr_cont | expr_lit(_) |
expr_block(*) | expr_swap(*) | expr_mac(*) {
expr_block(*) | expr_swap(*) | expr_mac(*) | expr_addr_of(*) {
visit::visit_expr(expr, self, vt);
}
}
@ -1501,10 +1471,7 @@ impl check_methods for @liveness {
ln.to_str(), var.to_str()];
alt (*self).live_on_exit(ln, var) {
none {
// update spill map to include this variable, as it is moved:
(*self.ir).add_spill(var);
}
none { }
some(lnk) {
self.report_illegal_move(span, lnk, var);
}
@ -1516,20 +1483,10 @@ impl check_methods for @liveness {
some(_) {}
none {
(*self.ir).add_last_use(expr.id, var);
// update spill map to include this variable, as it may be moved:
(*self.ir).add_spill(var);
}
}
}
fn spill_expr(expr: @expr) {
alt (*self).variable_from_path(expr) {
some(var) {(*self.ir).add_spill(var)}
none {}
}
}
fn check_move_from_expr(expr: @expr, vt: vt<@liveness>) {
#debug["check_move_from_expr(node %d: %s)",
expr.id, expr_to_str(expr)];
@ -1775,4 +1732,4 @@ impl check_methods for @liveness {
}
}
}
}
}