Skip to content

Commit a78ec25

Browse files
committed
---
yaml --- r: 7131 b: refs/heads/master c: 47cfeba h: refs/heads/master i: 7129: 3e02701 7127: fc86010 v: v3
1 parent ca09705 commit a78ec25

28 files changed

+373
-223
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: ba694775f5ea61c9b29e318bbe2e4d942adb39ad
2+
refs/heads/master: 47cfeba4675906dceb92e0a6b2846146ff888581

trunk/AUTHORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Paul Stansifer <[email protected]>
4141
Peter Hull <[email protected]>
4242
Ralph Giles <[email protected]>
4343
Rafael Ávila de Espíndola <[email protected]>
44+
Reuben Morais <[email protected]>
4445
Rob Arnold <[email protected]>
4546
Roy Frostig <[email protected]>
4647
Stefan Plantikow <[email protected]>

trunk/LICENSE.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ The remaining code and documentation in the collective work
250250
presented here, as well as the collective work itslf, is
251251
distributed under the following terms ("The Rust License"):
252252

253-
Copyright (c) 2006-2011 Graydon Hoare
254-
Copyright (c) 2009-2011 Mozilla Foundation
253+
Copyright (c) 2006-2012 Graydon Hoare
254+
Copyright (c) 2009-2012 Mozilla Foundation
255255

256256
Permission is hereby granted, free of charge, to any
257257
person obtaining a copy of this software and associated

trunk/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ then
324324
| cut -d ' ' -f 3)
325325

326326
case $CFG_CLANG_VERSION in
327-
(3.0svn | 3.0)
327+
(3.0svn | 3.0 | 3.1)
328328
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
329329
CFG_C_COMPILER="clang"
330330
;;

trunk/src/comp/middle/last_use.rs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
136136
v.visit_expr(dest, cx, v);
137137
clear_if_path(cx, dest, v, true);
138138
}
139+
expr_fn(_, _, _, cap_clause) {
140+
// n.b.: safe to ignore copies, as if they are unused
141+
// then they are ignored, otherwise they will show up
142+
// as freevars in the body.
143+
144+
vec::iter(cap_clause.moves) {|ci|
145+
clear_def_if_path(cx, cx.def_map.get(ci.id), true);
146+
}
147+
visit::visit_expr(ex, cx, v);
148+
}
139149
expr_call(f, args, _) {
140150
v.visit_expr(f, cx, v);
141151
let i = 0u, fns = [];
@@ -263,18 +273,25 @@ fn clear_in_current(cx: ctx, my_def: node_id, to: bool) {
263273
}
264274
}
265275

276+
fn clear_def_if_path(cx: ctx, d: def, to: bool)
277+
-> option<node_id> {
278+
alt d {
279+
def_local(def_id, let_copy.) | def_arg(def_id, by_copy.) |
280+
def_arg(def_id, by_move.) {
281+
clear_in_current(cx, def_id.node, to);
282+
some(def_id.node)
283+
}
284+
_ {
285+
none
286+
}
287+
}
288+
}
289+
266290
fn clear_if_path(cx: ctx, ex: @expr, v: visit::vt<ctx>, to: bool)
267291
-> option::t<node_id> {
268292
alt ex.node {
269293
expr_path(_) {
270-
alt cx.def_map.get(ex.id) {
271-
def_local(def_id, let_copy.) | def_arg(def_id, by_copy.) |
272-
def_arg(def_id, by_move.) {
273-
clear_in_current(cx, def_id.node, to);
274-
ret option::some(def_id.node);
275-
}
276-
_ {}
277-
}
294+
ret clear_def_if_path(cx, cx.def_map.get(ex.id), to);
278295
}
279296
_ { v.visit_expr(ex, cx, v); }
280297
}

trunk/src/comp/middle/resolve.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,9 @@ fn visit_fn_with_scope(e: @env, fk: visit::fn_kind, decl: ast::fn_decl,
486486
for c: @ast::constr in decl.constraints { resolve_constr(e, c, sc, v); }
487487
let scope = alt fk {
488488
visit::fk_item_fn(_, tps) | visit::fk_res(_, tps) |
489-
visit::fk_method(_, tps) {
490-
scope_bare_fn(decl, id, tps)
491-
}
492-
visit::fk_anon(_) | visit::fk_fn_block. {
493-
scope_fn_expr(decl, id, [])
494-
}
489+
visit::fk_method(_, tps) { scope_bare_fn(decl, id, tps) }
490+
visit::fk_anon(ast::proto_bare.) { scope_bare_fn(decl, id, []) }
491+
visit::fk_anon(_) | visit::fk_fn_block. { scope_fn_expr(decl, id, []) }
495492
};
496493

497494
visit::visit_fn(fk, decl, body, sp, id, cons(scope, @sc), v);

trunk/src/comp/middle/shape.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const shape_res: u8 = 20u8;
5252
const shape_var: u8 = 21u8;
5353
const shape_uniq: u8 = 22u8;
5454
const shape_opaque_closure_ptr: u8 = 23u8; // the closure itself.
55+
const shape_iface: u8 = 24u8;
5556

5657
// FIXME: This is a bad API in trans_common.
5758
fn C_u8(n: u8) -> ValueRef { ret trans_common::C_u8(n as uint); }
@@ -387,6 +388,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint],
387388
}
388389
ty::ty_native_fn(_, _) { s += [shape_u32]; }
389390
ty::ty_obj(_) { s += [shape_obj]; }
391+
ty::ty_iface(_, _) { s += [shape_iface]; }
390392
ty::ty_res(did, raw_subt, tps) {
391393
let subt = ty::substitute_type_params(ccx.tcx, tps, raw_subt);
392394
let ri = {did: did, t: subt};

trunk/src/comp/middle/trans.rs

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ fn type_of_inner(cx: @crate_ctxt, sp: span, t: ty::t)
178178
let nft = native_fn_wrapper_type(cx, sp, [], t);
179179
T_fn_pair(cx, nft)
180180
}
181-
ty::ty_obj(meths) { cx.rust_object_type }
181+
ty::ty_obj(_) { cx.rust_object_type }
182+
ty::ty_iface(_, _) { T_opaque_iface_ptr(cx) }
182183
ty::ty_res(_, sub, tps) {
183184
let sub1 = ty::substitute_type_params(cx.tcx, tps, sub);
184185
check non_ty_var(cx, sub1);
@@ -483,7 +484,9 @@ fn mk_obstack_token(ccx: @crate_ctxt, fcx: @fn_ctxt) ->
483484
fn simplify_type(ccx: @crate_ctxt, typ: ty::t) -> ty::t {
484485
fn simplifier(ccx: @crate_ctxt, typ: ty::t) -> ty::t {
485486
alt ty::struct(ccx.tcx, typ) {
486-
ty::ty_box(_) { ret ty::mk_imm_box(ccx.tcx, ty::mk_nil(ccx.tcx)); }
487+
ty::ty_box(_) | ty::ty_iface(_, _) {
488+
ret ty::mk_imm_box(ccx.tcx, ty::mk_nil(ccx.tcx));
489+
}
487490
ty::ty_uniq(_) {
488491
ret ty::mk_imm_uniq(ccx.tcx, ty::mk_nil(ccx.tcx));
489492
}
@@ -1386,9 +1389,10 @@ fn make_free_glue(bcx: @block_ctxt, v: ValueRef, t: ty::t) {
13861389
ty::ty_vec(_) | ty::ty_str. {
13871390
tvec::make_free_glue(bcx, PointerCast(bcx, v, type_of_1(bcx, t)), t)
13881391
}
1389-
ty::ty_obj(_) {
1392+
ty::ty_obj(_) | ty::ty_iface(_, _) {
13901393
// Call through the obj's own fields-drop glue first.
13911394
// Then free the body.
1395+
// (Same code of ifaces, whose layout is similar)
13921396
let ccx = bcx_ccx(bcx);
13931397
let llbox_ty = T_opaque_obj_ptr(ccx);
13941398
let b = PointerCast(bcx, v, llbox_ty);
@@ -1425,13 +1429,14 @@ fn make_drop_glue(bcx: @block_ctxt, v0: ValueRef, t: ty::t) {
14251429
let ccx = bcx_ccx(bcx);
14261430
let bcx =
14271431
alt ty::struct(ccx.tcx, t) {
1428-
ty::ty_box(_) { decr_refcnt_maybe_free(bcx, Load(bcx, v0), t) }
1432+
ty::ty_box(_) | ty::ty_iface(_, _) {
1433+
decr_refcnt_maybe_free(bcx, Load(bcx, v0), t)
1434+
}
14291435
ty::ty_uniq(_) | ty::ty_vec(_) | ty::ty_str. | ty::ty_send_type. {
14301436
free_ty(bcx, Load(bcx, v0), t)
14311437
}
14321438
ty::ty_obj(_) {
1433-
let box_cell =
1434-
GEPi(bcx, v0, [0, abi::obj_field_box]);
1439+
let box_cell = GEPi(bcx, v0, [0, abi::obj_field_box]);
14351440
decr_refcnt_maybe_free(bcx, Load(bcx, box_cell), t)
14361441
}
14371442
ty::ty_res(did, inner, tps) {
@@ -1935,22 +1940,22 @@ fn drop_ty(cx: @block_ctxt, v: ValueRef, t: ty::t) -> @block_ctxt {
19351940

19361941
fn drop_ty_immediate(bcx: @block_ctxt, v: ValueRef, t: ty::t) -> @block_ctxt {
19371942
alt ty::struct(bcx_tcx(bcx), t) {
1938-
ty::ty_uniq(_) | ty::ty_vec(_) | ty::ty_str. {
1939-
ret free_ty(bcx, v, t);
1940-
}
1941-
ty::ty_box(_) { ret decr_refcnt_maybe_free(bcx, v, t); }
1943+
ty::ty_uniq(_) | ty::ty_vec(_) | ty::ty_str. { free_ty(bcx, v, t) }
1944+
ty::ty_box(_) | ty::ty_iface(_, _) { decr_refcnt_maybe_free(bcx, v, t) }
19421945
}
19431946
}
19441947

19451948
fn take_ty_immediate(bcx: @block_ctxt, v: ValueRef, t: ty::t) -> result {
19461949
alt ty::struct(bcx_tcx(bcx), t) {
1947-
ty::ty_box(_) { ret rslt(incr_refcnt_of_boxed(bcx, v), v); }
1950+
ty::ty_box(_) | ty::ty_iface(_, _) {
1951+
rslt(incr_refcnt_of_boxed(bcx, v), v)
1952+
}
19481953
ty::ty_uniq(_) {
19491954
check trans_uniq::type_is_unique_box(bcx, t);
1950-
ret trans_uniq::duplicate(bcx, v, t);
1955+
trans_uniq::duplicate(bcx, v, t)
19511956
}
1952-
ty::ty_str. | ty::ty_vec(_) { ret tvec::duplicate(bcx, v, t); }
1953-
_ { ret rslt(bcx, v); }
1957+
ty::ty_str. | ty::ty_vec(_) { tvec::duplicate(bcx, v, t) }
1958+
_ { rslt(bcx, v) }
19541959
}
19551960
}
19561961

@@ -2873,9 +2878,12 @@ fn trans_callee(bcx: @block_ctxt, e: @ast::expr) -> lval_maybe_callee {
28732878
ret trans_impl::trans_static_callee(bcx, e, base, did);
28742879
}
28752880
some(typeck::method_param(iid, off, p, b)) {
2876-
ret trans_impl::trans_dict_callee(
2881+
ret trans_impl::trans_param_callee(
28772882
bcx, e, base, iid, off, p, b);
28782883
}
2884+
some(typeck::method_iface(off)) {
2885+
ret trans_impl::trans_iface_callee(bcx, e, base, off);
2886+
}
28792887
none. { // An object method
28802888
let of = trans_object_field(bcx, base, ident);
28812889
ret {bcx: of.bcx, val: of.mthptr, kind: owned,
@@ -3001,10 +3009,14 @@ fn float_cast(bcx: @block_ctxt, lldsttype: TypeRef, llsrctype: TypeRef,
30013009
fn trans_cast(cx: @block_ctxt, e: @ast::expr, id: ast::node_id,
30023010
dest: dest) -> @block_ctxt {
30033011
let ccx = bcx_ccx(cx);
3012+
let t_out = node_id_type(ccx, id);
3013+
alt ty::struct(ccx.tcx, t_out) {
3014+
ty::ty_iface(_, _) { ret trans_impl::trans_cast(cx, e, id, dest); }
3015+
_ {}
3016+
}
30043017
let e_res = trans_temp_expr(cx, e);
30053018
let ll_t_in = val_ty(e_res.val);
30063019
let t_in = ty::expr_ty(ccx.tcx, e);
3007-
let t_out = node_id_type(ccx, id);
30083020
// Check should be avoidable because it's a cast.
30093021
// FIXME: Constrain types so as to avoid this check.
30103022
check (type_has_static_size(ccx, t_out));

trunk/src/comp/middle/trans_closure.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import middle::freevars::{get_freevars, freevar_info};
99
import option::{some, none};
1010
import back::abi;
1111
import syntax::codemap::span;
12+
import syntax::print::pprust::expr_to_str;
1213
import back::link::{
1314
mangle_internal_name_by_path,
1415
mangle_internal_name_by_path_and_seq};
@@ -121,6 +122,18 @@ tag environment_value {
121122
env_ref(ValueRef, ty::t, lval_kind);
122123
}
123124

125+
fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> str {
126+
alt ev {
127+
env_expr(ex) { expr_to_str(ex) }
128+
env_copy(v, t, lk) { #fmt("copy(%s,%s)", val_str(ccx.tn, v),
129+
ty_to_str(ccx.tcx, t)) }
130+
env_move(v, t, lk) { #fmt("move(%s,%s)", val_str(ccx.tn, v),
131+
ty_to_str(ccx.tcx, t)) }
132+
env_ref(v, t, lk) { #fmt("ref(%s,%s)", val_str(ccx.tn, v),
133+
ty_to_str(ccx.tcx, t)) }
134+
}
135+
}
136+
124137
fn mk_tydesc_ty(tcx: ty::ctxt, ck: ty::closure_kind) -> ty::t {
125138
ret alt ck {
126139
ty::closure_block. | ty::closure_shared. { ty::mk_type(tcx) }
@@ -284,7 +297,7 @@ fn store_environment(
284297
};
285298
}
286299

287-
//let ccx = bcx_ccx(bcx);
300+
let ccx = bcx_ccx(bcx);
288301
let tcx = bcx_tcx(bcx);
289302

290303
// compute the shape of the closure
@@ -351,6 +364,11 @@ fn store_environment(
351364
let {bcx: bcx, val:bindings_slot} =
352365
GEP_tup_like_1(bcx, cboxptr_ty, llbox, [0, abi::cbox_elt_bindings]);
353366
vec::iteri(bound_values) { |i, bv|
367+
if (!ccx.sess.get_opts().no_asm_comments) {
368+
add_comment(bcx, #fmt("Copy %s into closure",
369+
ev_to_str(ccx, bv)));
370+
}
371+
354372
let bound_data = GEPi(bcx, bindings_slot, [0, i as int]);
355373
alt bv {
356374
env_expr(e) {

trunk/src/comp/middle/trans_common.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,11 @@ fn T_obj_ptr(cx: @crate_ctxt, n_captured_tydescs: uint) -> TypeRef {
754754

755755
fn T_opaque_obj_ptr(cx: @crate_ctxt) -> TypeRef { ret T_obj_ptr(cx, 0u); }
756756

757+
fn T_opaque_iface_ptr(cx: @crate_ctxt) -> TypeRef {
758+
let tdptr = T_ptr(cx.tydesc_type);
759+
T_ptr(T_box(cx, T_struct([tdptr, tdptr, T_i8()])))
760+
}
761+
757762
fn T_opaque_port_ptr() -> TypeRef { ret T_ptr(T_i8()); }
758763

759764
fn T_opaque_chan_ptr() -> TypeRef { ret T_ptr(T_i8()); }

0 commit comments

Comments
 (0)