Make build_environment and trans_bind_thunk GEP bound arguments the same

These functions both use GEP_tup_like to get at the arguments bound to the
environment, but they were starting from a different 'level' of the
environment-box structure. Frighteningly, this was leading to them having
different opinions of how the bound arguments were aligned in some cases.
This commit is contained in:
Brian Anderson 2011-10-12 12:03:30 -07:00
parent 306f7fb25f
commit 99f876e3a8
2 changed files with 22 additions and 5 deletions

View File

@ -2705,13 +2705,14 @@ fn build_environment(bcx: @block_ctxt, lltydescs: [ValueRef],
// Copy expr values into boxed bindings.
// Silly check
check type_is_tup_like(bcx, closure_ty);
let bindings = GEP_tup_like(bcx, closure_ty, closure,
[0, abi::closure_elt_bindings]);
bcx = bindings.bcx;
let closure_box = box;
let closure_box_ty = ty::mk_imm_box(bcx_tcx(bcx), closure_ty);
let i = 0u;
for bv in bound_values {
let bound =
GEP_tup_like_1(bcx, bindings_ty, bindings.val, [0, i as int]);
let bound = GEP_tup_like_1(bcx, closure_box_ty, closure_box,
[0, abi::box_rc_field_body,
abi::closure_elt_bindings,
i as int]);
bcx = bound.bcx;
alt bv {
env_expr(e) {

View File

@ -0,0 +1,16 @@
fn wrapper3<T>(i: T, j: int) {
log i;
log j;
// This is a regression test that the spawn3 thunk to wrapper3
// correctly finds the value of j
assert j == 123456789;
}
fn spawn3<T>(i: T, j: int) {
let wrapped = bind wrapper3(i, j);
wrapped();
}
fn main() {
spawn3(127u8, 123456789);
}