@@ -1592,24 +1592,25 @@ fn linearize_ty_params(@block_ctxt cx, ty.t t) ->
1592
1592
}
1593
1593
1594
1594
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) ) ;
1597
1598
1598
1599
// 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 ) ) ) ) ;
1601
1600
llroottydesc = cx. build. Load ( llroottydesc) ;
1602
- cx. build. Store ( llroottydesc, lltydesc ) ;
1601
+ cx. build. Store ( llroottydesc, llmyroottydesc ) ;
1603
1602
1604
1603
// 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 ) ) ) ;
1606
1605
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 ) ) ) ) ;
1608
1607
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 ) ) ) ) ;
1611
1612
1612
- ret res( cx, lltydesc ) ;
1613
+ ret res( cx, llmyroottydesc ) ;
1613
1614
}
1614
1615
1615
1616
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 {
1621
1622
1622
1623
auto root = get_static_tydesc( cx, t, tys. _0) . tydesc;
1623
1624
1624
- auto tydescs = alloca( cx, T_array ( T_ptr ( T_tydesc ( cx. fcx. lcx. ccx. tn) ) ,
1625
- 1 u /* 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
-
1637
1625
auto bcx = cx;
1638
1626
auto sz = size_of( bcx, t) ;
1639
1627
bcx = sz. bcx;
@@ -1642,14 +1630,38 @@ fn mk_derived_tydesc(@block_ctxt cx, ty.t t, bool escapes) -> result {
1642
1630
1643
1631
auto v;
1644
1632
if ( escapes) {
1633
+ auto tydescs = alloca( cx, T_array ( T_ptr ( T_tydesc ( cx. fcx. lcx. ccx. tn) ) ,
1634
+ 1 u /* 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
+
1645
1646
v = trans_upcall( bcx, "upcall_get_type_desc" ,
1646
1647
vec( p2i( bcx. fcx. lcx. ccx. crate_ptr) ,
1647
1648
sz. val,
1648
1649
align. val,
1649
1650
C_int ( ( 1 u + n_params) as int) ,
1650
1651
vp2i( bcx, tydescs) ) , true ) ;
1651
1652
} 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) ;
1653
1665
}
1654
1666
1655
1667
ret res( v. bcx, vi2p( v. bcx, v. val, T_ptr ( T_tydesc ( cx. fcx. lcx. ccx. tn) ) ) ) ;
0 commit comments