Skip to content

Commit

Permalink
will not copy trait_callee on stack if it's source expr is a plain bo…
Browse files Browse the repository at this point in the history
…rrowed ref
  • Loading branch information
U-NOV2010\eugals authored and Evgeny Sologubov committed Sep 19, 2013
1 parent dfa3f5f commit 0c3b6ad
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/librustc/middle/trans/expr.rs
Expand Up @@ -343,7 +343,6 @@ pub fn trans_to_datum(bcx: @mut Block, expr: @ast::Expr) -> DatumBlock {
_ => {}
}


let scratch = scratch_datum(bcx, target_obj_ty,
"__auto_borrow_obj", false);

Expand Down
19 changes: 14 additions & 5 deletions src/librustc/middle/trans/meth.rs
Expand Up @@ -434,13 +434,22 @@ pub fn trans_trait_callee(bcx: @mut Block,
let _icx = push_ctxt("impl::trans_trait_callee");
let mut bcx = bcx;

// make a local copy for trait if needed
let self_ty = expr_ty_adjusted(bcx, self_expr);
let self_scratch = scratch_datum(bcx, self_ty, "__trait_callee", false);
bcx = expr::trans_into(bcx, self_expr, expr::SaveIn(self_scratch.val));
let self_scratch = match ty::get(self_ty).sty {
ty::ty_trait(_, _, ty::RegionTraitStore(*), _, _) => {
unpack_datum!(bcx, expr::trans_to_datum(bcx, self_expr))
}
_ => {
let d = scratch_datum(bcx, self_ty, "__trait_callee", false);
bcx = expr::trans_into(bcx, self_expr, expr::SaveIn(d.val));
// Arrange a temporary cleanup for the object in case something
// should go wrong before the method is actually *invoked*.
d.add_clean(bcx);
d
}
};

// Arrange a temporary cleanup for the object in case something
// should go wrong before the method is actually *invoked*.
self_scratch.add_clean(bcx);

let callee_ty = node_id_type(bcx, callee_id);
trans_trait_callee_from_llval(bcx,
Expand Down

0 comments on commit 0c3b6ad

Please sign in to comment.