Skip to content

Commit fa5b916

Browse files
committed
---
yaml --- r: 2405 b: refs/heads/master c: 5e2088f h: refs/heads/master i: 2403: 826bce4 v: v3
1 parent 5c0b117 commit fa5b916

File tree

2 files changed

+37
-25
lines changed

2 files changed

+37
-25
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: 57a5c3ac9f7091c8a2f52a7fd2cab86d8a103858
2+
refs/heads/master: 5e2088f2faf5e53ebf8af52d9bd7e034c5fc61c2

trunk/src/comp/middle/trans.rs

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,24 +1592,25 @@ fn linearize_ty_params(@block_ctxt cx, ty.t t) ->
15921592
}
15931593

15941594
fn trans_stack_local_derived_tydesc(@block_ctxt cx, ValueRef llsz,
1595-
ValueRef llalign, ValueRef lltydescs) -> result {
1596-
auto lltydesc = alloca(cx, T_tydesc(cx.fcx.lcx.ccx.tn));
1595+
ValueRef llalign, ValueRef llroottydesc, ValueRef llparamtydescs)
1596+
-> result {
1597+
auto llmyroottydesc = alloca(cx, T_tydesc(cx.fcx.lcx.ccx.tn));
15971598

15981599
// By convention, desc 0 is the root descriptor.
1599-
auto llroottydesc = cx.build.Load(cx.build.GEP(lltydescs,
1600-
vec(C_int(0), C_int(0))));
16011600
llroottydesc = cx.build.Load(llroottydesc);
1602-
cx.build.Store(llroottydesc, lltydesc);
1601+
cx.build.Store(llroottydesc, llmyroottydesc);
16031602

16041603
// Store a pointer to the rest of the descriptors.
1605-
auto llfirstparam = cx.build.GEP(lltydescs, vec(C_int(0), C_int(1)));
1604+
auto llfirstparam = cx.build.GEP(llparamtydescs, vec(C_int(0), C_int(0)));
16061605
cx.build.Store(llfirstparam,
1607-
cx.build.GEP(lltydesc, vec(C_int(0), C_int(0))));
1606+
cx.build.GEP(llmyroottydesc, vec(C_int(0), C_int(0))));
16081607

1609-
cx.build.Store(llsz, cx.build.GEP(lltydesc, vec(C_int(0), C_int(1))));
1610-
cx.build.Store(llalign, cx.build.GEP(lltydesc, vec(C_int(0), C_int(2))));
1608+
cx.build.Store(llsz,
1609+
cx.build.GEP(llmyroottydesc, vec(C_int(0), C_int(1))));
1610+
cx.build.Store(llalign,
1611+
cx.build.GEP(llmyroottydesc, vec(C_int(0), C_int(2))));
16111612

1612-
ret res(cx, lltydesc);
1613+
ret res(cx, llmyroottydesc);
16131614
}
16141615

16151616
fn mk_derived_tydesc(@block_ctxt cx, ty.t t, bool escapes) -> result {
@@ -1621,19 +1622,6 @@ fn mk_derived_tydesc(@block_ctxt cx, ty.t t, bool escapes) -> result {
16211622

16221623
auto root = get_static_tydesc(cx, t, tys._0).tydesc;
16231624

1624-
auto tydescs = alloca(cx, T_array(T_ptr(T_tydesc(cx.fcx.lcx.ccx.tn)),
1625-
1u /* for root*/ + n_params));
1626-
1627-
auto i = 0;
1628-
auto tdp = cx.build.GEP(tydescs, vec(C_int(0), C_int(i)));
1629-
cx.build.Store(root, tdp);
1630-
i += 1;
1631-
for (ValueRef td in tys._1) {
1632-
auto tdp = cx.build.GEP(tydescs, vec(C_int(0), C_int(i)));
1633-
cx.build.Store(td, tdp);
1634-
i += 1;
1635-
}
1636-
16371625
auto bcx = cx;
16381626
auto sz = size_of(bcx, t);
16391627
bcx = sz.bcx;
@@ -1642,14 +1630,38 @@ fn mk_derived_tydesc(@block_ctxt cx, ty.t t, bool escapes) -> result {
16421630

16431631
auto v;
16441632
if (escapes) {
1633+
auto tydescs = alloca(cx, T_array(T_ptr(T_tydesc(cx.fcx.lcx.ccx.tn)),
1634+
1u /* for root*/ + n_params));
1635+
1636+
auto i = 0;
1637+
auto tdp = cx.build.GEP(tydescs, vec(C_int(0), C_int(i)));
1638+
cx.build.Store(root, tdp);
1639+
i += 1;
1640+
for (ValueRef td in tys._1) {
1641+
auto tdp = cx.build.GEP(tydescs, vec(C_int(0), C_int(i)));
1642+
cx.build.Store(td, tdp);
1643+
i += 1;
1644+
}
1645+
16451646
v = trans_upcall(bcx, "upcall_get_type_desc",
16461647
vec(p2i(bcx.fcx.lcx.ccx.crate_ptr),
16471648
sz.val,
16481649
align.val,
16491650
C_int((1u + n_params) as int),
16501651
vp2i(bcx, tydescs)), true);
16511652
} else {
1652-
v = trans_stack_local_derived_tydesc(bcx, sz.val, align.val, tydescs);
1653+
auto llparamtydescs = alloca(cx,
1654+
T_array(T_ptr(T_tydesc(cx.fcx.lcx.ccx.tn)), n_params));
1655+
1656+
auto i = 0;
1657+
for (ValueRef td in tys._1) {
1658+
auto tdp = cx.build.GEP(llparamtydescs, vec(C_int(0), C_int(i)));
1659+
cx.build.Store(td, tdp);
1660+
i += 1;
1661+
}
1662+
1663+
v = trans_stack_local_derived_tydesc(bcx, sz.val, align.val, root,
1664+
llparamtydescs);
16531665
}
16541666

16551667
ret res(v.bcx, vi2p(v.bcx, v.val, T_ptr(T_tydesc(cx.fcx.lcx.ccx.tn))));

0 commit comments

Comments
 (0)