Skip to content

Commit 8ecc0c6

Browse files
committed
---
yaml --- r: 68415 b: refs/heads/auto c: 7673749 h: refs/heads/master i: 68413: a2cce7f 68411: 50fe544 68407: 7dda711 68399: 013270b 68383: 673ca9e 68351: 5ee3e9d v: v3
1 parent a6b89e8 commit 8ecc0c6

22 files changed

+146
-1351
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 927f454ac115c7d19f34951914b269ce356a1ca6
17+
refs/heads/auto: 767374976b71965415ada45cf8e7d9da5ddef43f
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/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,

branches/auto/src/librustc/middle/trans/base.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,23 +1680,15 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt,
16801680
let mut bcx = bcx;
16811681

16821682
match fcx.llself {
1683-
Some(slf) => {
1684-
let self_val = if slf.is_owned
1685-
&& datum::appropriate_mode(slf.t).is_by_value() {
1686-
let tmp = BitCast(bcx, slf.v, type_of(bcx.ccx(), slf.t));
1687-
let alloc = alloc_ty(bcx, slf.t);
1688-
Store(bcx, tmp, alloc);
1689-
alloc
1690-
} else {
1691-
PointerCast(bcx, slf.v, type_of(bcx.ccx(), slf.t).ptr_to())
1692-
};
1693-
1694-
fcx.llself = Some(ValSelfData {v: self_val, ..slf});
1695-
if slf.is_owned {
1696-
add_clean(bcx, self_val, slf.t);
1697-
}
1698-
}
1699-
_ => {}
1683+
Some(slf) => {
1684+
let self_val = PointerCast(bcx, slf.v, type_of(bcx.ccx(), slf.t).ptr_to());
1685+
fcx.llself = Some(ValSelfData {v: self_val, ..slf});
1686+
1687+
if slf.is_owned {
1688+
add_clean(bcx, slf.v, slf.t);
1689+
}
1690+
}
1691+
_ => {}
17001692
}
17011693

17021694
for uint::range(0, arg_tys.len()) |arg_n| {

branches/auto/src/librustc/middle/trans/callee.rs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ pub struct MethodData {
6363
llself: ValueRef,
6464
self_ty: ty::t,
6565
self_mode: ty::SelfMode,
66+
explicit_self: ast::explicit_self_
6667
}
6768

6869
pub enum CalleeData {
@@ -565,7 +566,8 @@ pub fn trans_call_inner(in_cx: block,
565566
// Now that the arguments have finished evaluating, we need to revoke
566567
// the cleanup for the self argument, if it exists
567568
match callee.data {
568-
Method(d) if d.self_mode == ty::ByCopy => {
569+
Method(d) if d.self_mode == ty::ByCopy ||
570+
d.explicit_self == ast::sty_value => {
569571
revoke_clean(bcx, d.llself);
570572
}
571573
_ => {}
@@ -687,6 +689,7 @@ pub fn trans_args(cx: block,
687689
trans_arg_expr(bcx,
688690
arg_tys[i],
689691
ty::ByCopy,
692+
ast::sty_static,
690693
*arg_expr,
691694
&mut temp_cleanups,
692695
if i == last { ret_flag } else { None },
@@ -720,16 +723,18 @@ pub enum AutorefArg {
720723
pub fn trans_arg_expr(bcx: block,
721724
formal_arg_ty: ty::t,
722725
self_mode: ty::SelfMode,
726+
ex_self: ast::explicit_self_,
723727
arg_expr: @ast::expr,
724728
temp_cleanups: &mut ~[ValueRef],
725729
ret_flag: Option<ValueRef>,
726730
autoref_arg: AutorefArg) -> Result {
727731
let _icx = push_ctxt("trans_arg_expr");
728732
let ccx = bcx.ccx();
729733

730-
debug!("trans_arg_expr(formal_arg_ty=(%s), self_mode=%?, arg_expr=%s, \
734+
debug!("trans_arg_expr(formal_arg_ty=(%s), explicit_self=%? self_mode=%?, arg_expr=%s, \
731735
ret_flag=%?)",
732736
formal_arg_ty.repr(bcx.tcx()),
737+
ex_self,
733738
self_mode,
734739
arg_expr.repr(bcx.tcx()),
735740
ret_flag.map(|v| bcx.val_to_str(*v)));
@@ -789,8 +794,26 @@ pub fn trans_arg_expr(bcx: block,
789794
val = arg_datum.to_ref_llval(bcx);
790795
}
791796
DontAutorefArg => {
792-
match self_mode {
793-
ty::ByRef => {
797+
match (self_mode, ex_self) {
798+
(ty::ByRef, ast::sty_value) => {
799+
debug!("by value self with type %s, storing to scratch",
800+
bcx.ty_to_str(arg_datum.ty));
801+
let scratch = scratch_datum(bcx, arg_datum.ty, false);
802+
803+
arg_datum.store_to_datum(bcx,
804+
arg_expr.id,
805+
INIT,
806+
scratch);
807+
808+
// Technically, ownership of val passes to the callee.
809+
// However, we must cleanup should we fail before the
810+
// callee is actually invoked.
811+
scratch.add_clean(bcx);
812+
temp_cleanups.push(scratch.val);
813+
814+
val = scratch.to_ref_llval(bcx);
815+
}
816+
(ty::ByRef, _) => {
794817
// This assertion should really be valid, but because
795818
// the explicit self code currently passes by-ref, it
796819
// does not hold.
@@ -801,7 +824,7 @@ pub fn trans_arg_expr(bcx: block,
801824
bcx.ty_to_str(arg_datum.ty));
802825
val = arg_datum.to_ref_llval(bcx);
803826
}
804-
ty::ByCopy => {
827+
(ty::ByCopy, _) => {
805828
if ty::type_needs_drop(bcx.tcx(), arg_datum.ty) ||
806829
arg_datum.appropriate_mode().is_by_ref() {
807830
debug!("by copy arg with type %s, storing to scratch",

0 commit comments

Comments
 (0)