Skip to content

Commit f605db4

Browse files
committed
---
yaml --- r: 4398 b: refs/heads/master c: 6df7c04 h: refs/heads/master v: v3
1 parent 4558e57 commit f605db4

File tree

2 files changed

+9
-39
lines changed

2 files changed

+9
-39
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: 29ec2503db2b0c1e1b438dcb190d82ae3dfc4bec
2+
refs/heads/master: 6df7c041bc6bbc5218edb21145c8640799d0b4f1

trunk/src/comp/middle/trans.rs

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn type_of_fn_full(cx: &@crate_ctxt, sp: &span, proto: ast::proto,
122122

123123
// Arg 2: Env (closure-bindings / self-obj)
124124
if is_method {
125-
atys += ~[cx.rust_object_type];
125+
atys += ~[T_ptr(cx.rust_object_type)];
126126
} else { atys += ~[T_opaque_closure_ptr(*cx)]; }
127127

128128
// Args >3: ty params, if not acquired via capture...
@@ -4273,6 +4273,7 @@ fn trans_lval_gen(cx: &@block_ctxt, e: &@ast::expr) -> lval_result {
42734273
ast::expr_self_method(ident) {
42744274
alt { cx.fcx.llself } {
42754275
some(pair) {
4276+
// TODO: do we actually need cx.build.Load(pair.v)?
42764277
let r = pair.v;
42774278
let t = pair.t;
42784279
ret trans_field(cx, e.span, r, t, ident, e.id);
@@ -4752,16 +4753,7 @@ fn trans_args(cx: &@block_ctxt, llenv: ValueRef, llobj: &option::t[ValueRef],
47524753
llargs += ~[bcx.fcx.lltaskptr];
47534754

47544755
// Arg 2: Env (closure-bindings / self-obj)
4755-
alt llobj {
4756-
some(ob) {
4757-
// Every object is always found in memory,
4758-
// and not-yet-loaded (as part of an lval x.y
4759-
// doted method-call).
4760-
4761-
llargs += ~[bcx.build.Load(ob)];
4762-
}
4763-
_ { llargs += ~[llenv]; }
4764-
}
4756+
llargs += ~[llenv];
47654757

47664758
// Args >3: ty_params ...
47674759
llargs += lltydescs;
@@ -4812,9 +4804,10 @@ fn trans_call(cx: &@block_ctxt, f: &@ast::expr,
48124804
let faddr = f_res.res.val;
48134805
let llenv = C_null(T_opaque_closure_ptr(*bcx_ccx(cx)));
48144806
alt f_res.llobj {
4815-
some(_) {
4807+
some(ob) {
48164808
// It's a vtbl entry.
48174809
faddr = bcx.build.Load(faddr);
4810+
llenv = ob;
48184811
}
48194812
none. {
48204813
// It's a closure. We have to autoderef.
@@ -6238,22 +6231,6 @@ fn create_llargs_for_fn_args(cx: &@fn_ctxt, proto: ast::proto,
62386231
}
62396232
}
62406233

6241-
6242-
// Recommended LLVM style, strange though this is, is to copy from args to
6243-
// allocas immediately upon entry; this permits us to GEP into structures we
6244-
// were passed and whatnot. Apparently mem2reg will mop up.
6245-
fn copy_any_self_to_alloca(fcx: @fn_ctxt) {
6246-
let bcx = llstaticallocas_block_ctxt(fcx);
6247-
alt { fcx.llself } {
6248-
some(pair) {
6249-
let a = alloca(bcx, fcx.lcx.ccx.rust_object_type);
6250-
bcx.build.Store(pair.v, a);
6251-
fcx.llself = some[val_self_pair]({v: a, t: pair.t});
6252-
}
6253-
_ { }
6254-
}
6255-
}
6256-
62576234
fn copy_args_to_allocas(fcx: @fn_ctxt, args: &ast::arg[],
62586235
arg_tys: &ty::arg[]) {
62596236
let bcx = new_raw_block_ctxt(fcx, fcx.llcopyargs);
@@ -6384,7 +6361,6 @@ fn trans_closure(bcx_maybe: &option::t[@block_ctxt],
63846361
create_llargs_for_fn_args(fcx, f.proto, ty_self,
63856362
ty::ret_ty_of_fn(cx.ccx.tcx, id), f.decl.inputs,
63866363
ty_params);
6387-
copy_any_self_to_alloca(fcx);
63886364
alt { fcx.llself } {
63896365
some(llself) { populate_fn_ctxt_from_llself(fcx, llself); }
63906366
_ { }
@@ -6539,9 +6515,8 @@ fn process_fwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method,
65396515
let lltop = bcx.llbb;
65406516

65416517
// The outer object will arrive in the forwarding function via the llenv
6542-
// argument. Put it in an alloca so that we can GEP into it later.
6543-
let llself_obj_ptr = alloca(bcx, fcx.lcx.ccx.rust_object_type);
6544-
bcx.build.Store(fcx.llenv, llself_obj_ptr);
6518+
// argument.
6519+
let llself_obj_ptr = fcx.llenv;
65456520

65466521
// Do backwarding if necessary.
65476522
alt (backwarding_vtbl) {
@@ -6566,11 +6541,6 @@ fn process_fwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method,
65666541
}
65676542
}
65686543

6569-
// Grab hold of the outer object so we can pass it into the inner object,
6570-
// in case that inner object needs to make any self-calls. (Such calls
6571-
// will need to dispatch back through the outer object.)
6572-
let llself_obj = bcx.build.Load(llself_obj_ptr);
6573-
65746544
// The 'llretptr' that will arrive in the forwarding function we're
65756545
// creating also needs to be the correct type. Cast it to the method's
65766546
// return type, if necessary.
@@ -6681,7 +6651,7 @@ fn process_fwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method,
66816651

66826652
// Set up the three implicit arguments to the original method we'll need
66836653
// to call.
6684-
let self_arg = llself_obj;
6654+
let self_arg = llself_obj_ptr;
66856655
let llorig_mthd_args: ValueRef[] = ~[llretptr, fcx.lltaskptr, self_arg];
66866656

66876657
// Copy the explicit arguments that are being passed into the forwarding

0 commit comments

Comments
 (0)