@@ -122,7 +122,7 @@ fn type_of_fn_full(cx: &@crate_ctxt, sp: &span, proto: ast::proto,
122
122
123
123
// Arg 2: Env (closure-bindings / self-obj)
124
124
if is_method {
125
- atys += ~[ cx. rust_object_type ] ;
125
+ atys += ~[ T_ptr ( cx. rust_object_type ) ] ;
126
126
} else { atys += ~[ T_opaque_closure_ptr ( * cx) ] ; }
127
127
128
128
// 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 {
4273
4273
ast:: expr_self_method ( ident) {
4274
4274
alt { cx. fcx . llself } {
4275
4275
some ( pair) {
4276
+ // TODO: do we actually need cx.build.Load(pair.v)?
4276
4277
let r = pair. v ;
4277
4278
let t = pair. t ;
4278
4279
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],
4752
4753
llargs += ~[ bcx. fcx . lltaskptr ] ;
4753
4754
4754
4755
// 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] ;
4765
4757
4766
4758
// Args >3: ty_params ...
4767
4759
llargs += lltydescs;
@@ -4812,9 +4804,10 @@ fn trans_call(cx: &@block_ctxt, f: &@ast::expr,
4812
4804
let faddr = f_res. res . val ;
4813
4805
let llenv = C_null ( T_opaque_closure_ptr ( * bcx_ccx ( cx) ) ) ;
4814
4806
alt f_res. llobj {
4815
- some ( _ ) {
4807
+ some ( ob ) {
4816
4808
// It's a vtbl entry.
4817
4809
faddr = bcx. build . Load ( faddr) ;
4810
+ llenv = ob;
4818
4811
}
4819
4812
none. {
4820
4813
// It's a closure. We have to autoderef.
@@ -6238,22 +6231,6 @@ fn create_llargs_for_fn_args(cx: &@fn_ctxt, proto: ast::proto,
6238
6231
}
6239
6232
}
6240
6233
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
-
6257
6234
fn copy_args_to_allocas ( fcx : @fn_ctxt , args : & ast:: arg [ ] ,
6258
6235
arg_tys : & ty:: arg [ ] ) {
6259
6236
let bcx = new_raw_block_ctxt ( fcx, fcx. llcopyargs ) ;
@@ -6384,7 +6361,6 @@ fn trans_closure(bcx_maybe: &option::t[@block_ctxt],
6384
6361
create_llargs_for_fn_args ( fcx, f. proto , ty_self,
6385
6362
ty:: ret_ty_of_fn ( cx. ccx . tcx , id) , f. decl . inputs ,
6386
6363
ty_params) ;
6387
- copy_any_self_to_alloca ( fcx) ;
6388
6364
alt { fcx. llself } {
6389
6365
some ( llself) { populate_fn_ctxt_from_llself ( fcx, llself) ; }
6390
6366
_ { }
@@ -6539,9 +6515,8 @@ fn process_fwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method,
6539
6515
let lltop = bcx. llbb ;
6540
6516
6541
6517
// 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 ;
6545
6520
6546
6521
// Do backwarding if necessary.
6547
6522
alt ( backwarding_vtbl) {
@@ -6566,11 +6541,6 @@ fn process_fwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method,
6566
6541
}
6567
6542
}
6568
6543
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
-
6574
6544
// The 'llretptr' that will arrive in the forwarding function we're
6575
6545
// creating also needs to be the correct type. Cast it to the method's
6576
6546
// return type, if necessary.
@@ -6681,7 +6651,7 @@ fn process_fwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method,
6681
6651
6682
6652
// Set up the three implicit arguments to the original method we'll need
6683
6653
// to call.
6684
- let self_arg = llself_obj ;
6654
+ let self_arg = llself_obj_ptr ;
6685
6655
let llorig_mthd_args: ValueRef [ ] = ~[ llretptr, fcx. lltaskptr , self_arg] ;
6686
6656
6687
6657
// Copy the explicit arguments that are being passed into the forwarding
0 commit comments