Skip to content

Commit 3e291e2

Browse files
committed
---
yaml --- r: 66475 b: refs/heads/master c: b883d6a h: refs/heads/master i: 66473: fee584c 66471: e091959 v: v3
1 parent 8a6c68d commit 3e291e2

File tree

23 files changed

+196
-295
lines changed

23 files changed

+196
-295
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: b4bb36490d10a9d2613448215f2436f258e7fd28
2+
refs/heads/master: b883d6a54c460f8357b1107b3599108eb1f8580b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/src/etc/ctags.rust

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@
88
--regex-rust=/[ \t]*static[ \t]+([a-zA-Z0-9_]+)/\1/m,consts/
99
--regex-rust=/[ \t]*trait[ \t]+([a-zA-Z0-9_]+)/\1/m,traits/
1010
--regex-rust=/[ \t]*impl[ \t]+([a-zA-Z0-9_]+)/\1/m,impls/
11-
--regex-rust=/[ \t]*macro_rules![ \t]+([a-zA-Z0-9_]+)/\1/m,macros/

trunk/src/librust/rust.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,6 @@ fn usage() {
238238

239239
pub fn main() {
240240
let os_args = os::args();
241-
242-
if (os_args.len() > 1 && (os_args[1] == ~"-v" || os_args[1] == ~"--version")) {
243-
rustc::version(os_args[0]);
244-
unsafe { exit(0); }
245-
}
246-
247241
let args = os_args.tail();
248242

249243
if !args.is_empty() {

trunk/src/librustc/middle/trans/asm.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub fn trans_inline_asm(bcx: block, ia: &ast::inline_asm) -> block {
4141
callee::trans_arg_expr(bcx,
4242
expr_ty(bcx, out),
4343
ty::ByCopy,
44+
ast::sty_static,
4445
out,
4546
&mut cleanups,
4647
None,
@@ -56,6 +57,7 @@ pub fn trans_inline_asm(bcx: block, ia: &ast::inline_asm) -> block {
5657
callee::trans_arg_expr(bcx,
5758
expr_ty(bcx, e),
5859
ty::ByCopy,
60+
ast::sty_static,
5961
e,
6062
&mut cleanups,
6163
None,
@@ -77,6 +79,7 @@ pub fn trans_inline_asm(bcx: block, ia: &ast::inline_asm) -> block {
7779
callee::trans_arg_expr(bcx,
7880
expr_ty(bcx, in),
7981
ty::ByCopy,
82+
ast::sty_static,
8083
in,
8184
&mut cleanups,
8285
None,

trunk/src/librustc/middle/trans/base.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,11 +1626,18 @@ pub fn create_llargs_for_fn_args(cx: fn_ctxt,
16261626
let _icx = push_ctxt("create_llargs_for_fn_args");
16271627

16281628
match self_arg {
1629-
impl_self(tt, self_mode) => {
1629+
impl_self(tt) => {
16301630
cx.llself = Some(ValSelfData {
16311631
v: cx.llenv,
16321632
t: tt,
1633-
is_copy: self_mode == ty::ByCopy
1633+
is_owned: false
1634+
});
1635+
}
1636+
impl_owned_self(tt) => {
1637+
cx.llself = Some(ValSelfData {
1638+
v: cx.llenv,
1639+
t: tt,
1640+
is_owned: true
16341641
});
16351642
}
16361643
no_self => ()
@@ -1669,18 +1676,12 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt,
16691676

16701677
match fcx.llself {
16711678
Some(slf) => {
1672-
let self_val = if slf.is_copy
1673-
&& datum::appropriate_mode(slf.t).is_by_value() {
1674-
let tmp = BitCast(bcx, slf.v, type_of(bcx.ccx(), slf.t));
1675-
let alloc = alloc_ty(bcx, slf.t);
1676-
Store(bcx, tmp, alloc);
1677-
alloc
1678-
} else {
1679-
PointerCast(bcx, slf.v, type_of(bcx.ccx(), slf.t).ptr_to())
1680-
};
1681-
1679+
let self_val = PointerCast(bcx, slf.v, type_of(bcx.ccx(), slf.t).ptr_to());
16821680
fcx.llself = Some(ValSelfData {v: self_val, ..slf});
1683-
add_clean(bcx, self_val, slf.t);
1681+
1682+
if slf.is_owned {
1683+
add_clean(bcx, slf.v, slf.t);
1684+
}
16841685
}
16851686
_ => {}
16861687
}
@@ -1757,7 +1758,7 @@ pub fn tie_up_header_blocks(fcx: fn_ctxt, lltop: BasicBlockRef) {
17571758
}
17581759
}
17591760

1760-
pub enum self_arg { impl_self(ty::t, ty::SelfMode), no_self, }
1761+
pub enum self_arg { impl_self(ty::t), impl_owned_self(ty::t), no_self, }
17611762

17621763
// trans_closure: Builds an LLVM function out of a source function.
17631764
// If the function closes over its environment a closure will be

trunk/src/librustc/middle/trans/cabi_x86_64.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,11 @@ fn classify_ty(ty: Type) -> ~[RegClass] {
126126
Float => 4,
127127
Double => 8,
128128
Struct => {
129-
let str_tys = ty.field_types();
130129
if ty.is_packed() {
130+
let str_tys = ty.field_types();
131131
str_tys.iter().fold(0, |s, t| s + ty_size(*t))
132132
} else {
133+
let str_tys = ty.field_types();
133134
let size = str_tys.iter().fold(0, |s, t| align(s, *t) + ty_size(*t));
134135
align(size, ty)
135136
}
@@ -239,7 +240,9 @@ fn classify_ty(ty: Type) -> ~[RegClass] {
239240
let mut i = 0u;
240241
let ty_kind = ty.kind();
241242
let e = cls.len();
242-
if cls.len() > 2u && (ty_kind == Struct || ty_kind == Array) {
243+
if cls.len() > 2u &&
244+
(ty_kind == Struct ||
245+
ty_kind == Array) {
243246
if cls[i].is_sse() {
244247
i += 1u;
245248
while i < e {
@@ -266,7 +269,7 @@ fn classify_ty(ty: Type) -> ~[RegClass] {
266269
return;
267270
}
268271
if cls[i] == SSEUp {
269-
cls[i] = SSEDv;
272+
cls[i] = SSEInt;
270273
} else if cls[i].is_sse() {
271274
i += 1;
272275
while i != e && cls[i] == SSEUp { i += 1u; }
@@ -284,6 +287,7 @@ fn classify_ty(ty: Type) -> ~[RegClass] {
284287
let mut cls = vec::from_elem(words, NoClass);
285288
if words > 4 {
286289
all_mem(cls);
290+
let cls = cls;
287291
return cls;
288292
}
289293
classify(ty, cls, 0, 0);
@@ -312,8 +316,8 @@ fn llreg_ty(cls: &[RegClass]) -> Type {
312316
tys.push(Type::i64());
313317
}
314318
SSEFv => {
315-
let vec_len = llvec_len(cls.tailn(i + 1u));
316-
let vec_ty = Type::vector(&Type::f32(), (vec_len * 2u) as u64);
319+
let vec_len = llvec_len(cls.tailn(i + 1u)) * 2u;
320+
let vec_ty = Type::vector(&Type::f32(), vec_len as u64);
317321
tys.push(vec_ty);
318322
i += vec_len;
319323
loop;

trunk/src/librustc/middle/trans/callee.rs

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ pub struct FnData {
6262
pub struct MethodData {
6363
llfn: ValueRef,
6464
llself: ValueRef,
65-
temp_cleanup: Option<ValueRef>,
6665
self_ty: ty::t,
6766
self_mode: ty::SelfMode,
67+
explicit_self: ast::explicit_self_
6868
}
6969

7070
pub enum CalleeData {
@@ -615,7 +615,10 @@ pub fn trans_call_inner(in_cx: block,
615615
}
616616
Method(d) => {
617617
// Weird but true: we pass self in the *environment* slot!
618-
(d.llfn, d.llself)
618+
let llself = PointerCast(bcx,
619+
d.llself,
620+
Type::opaque_box(ccx).ptr_to());
621+
(d.llfn, llself)
619622
}
620623
Closure(d) => {
621624
// Closures are represented as (llfn, llclosure) pair:
@@ -644,12 +647,11 @@ pub fn trans_call_inner(in_cx: block,
644647

645648

646649
// Now that the arguments have finished evaluating, we need to revoke
647-
// the cleanup for the self argument
650+
// the cleanup for the self argument, if it exists
648651
match callee.data {
649-
Method(d) => {
650-
for d.temp_cleanup.iter().advance |&v| {
651-
revoke_clean(bcx, v);
652-
}
652+
Method(d) if d.self_mode == ty::ByCopy ||
653+
d.explicit_self == ast::sty_value => {
654+
revoke_clean(bcx, d.llself);
653655
}
654656
_ => {}
655657
}
@@ -770,6 +772,7 @@ pub fn trans_args(cx: block,
770772
trans_arg_expr(bcx,
771773
arg_tys[i],
772774
ty::ByCopy,
775+
ast::sty_static,
773776
*arg_expr,
774777
&mut temp_cleanups,
775778
if i == last { ret_flag } else { None },
@@ -803,16 +806,18 @@ pub enum AutorefArg {
803806
pub fn trans_arg_expr(bcx: block,
804807
formal_arg_ty: ty::t,
805808
self_mode: ty::SelfMode,
809+
ex_self: ast::explicit_self_,
806810
arg_expr: @ast::expr,
807811
temp_cleanups: &mut ~[ValueRef],
808812
ret_flag: Option<ValueRef>,
809813
autoref_arg: AutorefArg) -> Result {
810814
let _icx = push_ctxt("trans_arg_expr");
811815
let ccx = bcx.ccx();
812816

813-
debug!("trans_arg_expr(formal_arg_ty=(%s), self_mode=%?, arg_expr=%s, \
817+
debug!("trans_arg_expr(formal_arg_ty=(%s), explicit_self=%? self_mode=%?, arg_expr=%s, \
814818
ret_flag=%?)",
815819
formal_arg_ty.repr(bcx.tcx()),
820+
ex_self,
816821
self_mode,
817822
arg_expr.repr(bcx.tcx()),
818823
ret_flag.map(|v| bcx.val_to_str(*v)));
@@ -872,15 +877,9 @@ pub fn trans_arg_expr(bcx: block,
872877
val = arg_datum.to_ref_llval(bcx);
873878
}
874879
DontAutorefArg => {
875-
match self_mode {
876-
ty::ByRef => {
877-
// This assertion should really be valid, but because
878-
// the explicit self code currently passes by-ref, it
879-
// does not hold.
880-
//
881-
//assert !bcx.ccx().maps.moves_map.contains_key(
882-
// &arg_expr.id);
883-
debug!("by ref arg with type %s, storing to scratch",
880+
match (self_mode, ex_self) {
881+
(ty::ByRef, ast::sty_value) => {
882+
debug!("by value self with type %s, storing to scratch",
884883
bcx.ty_to_str(arg_datum.ty));
885884
let scratch = scratch_datum(bcx, arg_datum.ty, false);
886885

@@ -897,7 +896,18 @@ pub fn trans_arg_expr(bcx: block,
897896

898897
val = scratch.to_ref_llval(bcx);
899898
}
900-
ty::ByCopy => {
899+
(ty::ByRef, _) => {
900+
// This assertion should really be valid, but because
901+
// the explicit self code currently passes by-ref, it
902+
// does not hold.
903+
//
904+
//assert !bcx.ccx().maps.moves_map.contains_key(
905+
// &arg_expr.id);
906+
debug!("by ref arg with type %s",
907+
bcx.ty_to_str(arg_datum.ty));
908+
val = arg_datum.to_ref_llval(bcx);
909+
}
910+
(ty::ByCopy, _) => {
901911
if ty::type_needs_drop(bcx.tcx(), arg_datum.ty) ||
902912
arg_datum.appropriate_mode().is_by_ref() {
903913
debug!("by copy arg with type %s, storing to scratch",
@@ -920,7 +930,7 @@ pub fn trans_arg_expr(bcx: block,
920930
ByRef(_) => val = scratch.val,
921931
}
922932
} else {
923-
debug!("by copy arg with type %s", bcx.ty_to_str(arg_datum.ty));
933+
debug!("by copy arg with type %s");
924934
match arg_datum.mode {
925935
ByRef(_) => val = Load(bcx, arg_datum.val),
926936
ByValue => val = arg_datum.val,
@@ -934,6 +944,10 @@ pub fn trans_arg_expr(bcx: block,
934944
if formal_arg_ty != arg_datum.ty {
935945
// this could happen due to e.g. subtyping
936946
let llformal_arg_ty = type_of::type_of_explicit_arg(ccx, &formal_arg_ty);
947+
let llformal_arg_ty = match self_mode {
948+
ty::ByRef => llformal_arg_ty.ptr_to(),
949+
ty::ByCopy => llformal_arg_ty,
950+
};
937951
debug!("casting actual type (%s) to match formal (%s)",
938952
bcx.val_to_str(val), bcx.llty_str(llformal_arg_ty));
939953
val = PointerCast(bcx, val, llformal_arg_ty);

trunk/src/librustc/middle/trans/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub type ExternMap = HashMap<@str, ValueRef>;
125125
pub struct ValSelfData {
126126
v: ValueRef,
127127
t: ty::t,
128-
is_copy: bool,
128+
is_owned: bool
129129
}
130130

131131
// Here `self_ty` is the real type of the self parameter to this method. It

trunk/src/librustc/middle/trans/glue.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,12 @@ pub fn trans_struct_drop_flag(bcx: block, t: ty::t, v0: ValueRef, dtor_did: ast:
425425
// just consist of the environment (self)
426426
assert_eq!(params.len(), 1);
427427

428-
let self_arg = PointerCast(bcx, v0, params[0]);
428+
// Take a reference to the class (because it's using the Drop trait),
429+
// do so now.
430+
let llval = alloca(bcx, val_ty(v0));
431+
Store(bcx, v0, llval);
432+
433+
let self_arg = PointerCast(bcx, llval, params[0]);
429434
let args = ~[self_arg];
430435

431436
Call(bcx, dtor_addr, args);
@@ -460,7 +465,12 @@ pub fn trans_struct_drop(mut bcx: block, t: ty::t, v0: ValueRef, dtor_did: ast::
460465
// just consist of the environment (self)
461466
assert_eq!(params.len(), 1);
462467

463-
let self_arg = PointerCast(bcx, v0, params[0]);
468+
// Take a reference to the class (because it's using the Drop trait),
469+
// do so now.
470+
let llval = alloca(bcx, val_ty(v0));
471+
Store(bcx, v0, llval);
472+
473+
let self_arg = PointerCast(bcx, llval, params[0]);
464474
let args = ~[self_arg];
465475

466476
Call(bcx, dtor_addr, args);

trunk/src/librustc/middle/trans/inline.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use core::prelude::*;
1212

1313
use metadata::csearch;
1414
use middle::astencode;
15-
use middle::trans::base::{push_ctxt, impl_self, no_self};
15+
use middle::trans::base::{push_ctxt,impl_owned_self, impl_self, no_self};
1616
use middle::trans::base::{trans_item, get_item_val, trans_fn};
1717
use middle::trans::common::*;
1818
use middle::ty;
@@ -114,8 +114,8 @@ pub fn maybe_instantiate_inline(ccx: @mut CrateContext, fn_id: ast::def_id,
114114
debug!("calling inline trans_fn with self_ty %s",
115115
ty_to_str(ccx.tcx, self_ty));
116116
match mth.explicit_self.node {
117-
ast::sty_value => impl_self(self_ty, ty::ByRef),
118-
_ => impl_self(self_ty, ty::ByCopy),
117+
ast::sty_value => impl_owned_self(self_ty),
118+
_ => impl_self(self_ty),
119119
}
120120
}
121121
};

0 commit comments

Comments
 (0)