@@ -895,7 +895,8 @@ fn linearize_ty_params(cx: &@block_ctxt, t: &ty::t) ->
895
895
896
896
fn trans_stack_local_derived_tydesc ( cx : & @block_ctxt , llsz : ValueRef ,
897
897
llalign : ValueRef , llroottydesc : ValueRef ,
898
- llparamtydescs : ValueRef ) -> ValueRef {
898
+ llparamtydescs : ValueRef ,
899
+ n_params : uint ) -> ValueRef {
899
900
let llmyroottydesc = alloca ( cx, bcx_ccx ( cx) . tydesc_type ) ;
900
901
// By convention, desc 0 is the root descriptor.
901
902
@@ -904,11 +905,14 @@ fn trans_stack_local_derived_tydesc(cx: &@block_ctxt, llsz: ValueRef,
904
905
// Store a pointer to the rest of the descriptors.
905
906
906
907
let llfirstparam = cx. build . GEP ( llparamtydescs, ~[ C_int ( 0 ) , C_int ( 0 ) ] ) ;
907
- cx. build . Store ( llfirstparam,
908
- cx. build . GEP ( llmyroottydesc, ~[ C_int ( 0 ) , C_int ( 0 ) ] ) ) ;
909
- cx. build . Store ( llsz, cx. build . GEP ( llmyroottydesc, ~[ C_int ( 0 ) , C_int ( 1 ) ] ) ) ;
910
- cx. build . Store ( llalign,
911
- cx. build . GEP ( llmyroottydesc, ~[ C_int ( 0 ) , C_int ( 2 ) ] ) ) ;
908
+ store_inbounds ( cx, llfirstparam, llmyroottydesc,
909
+ ~[ C_int ( 0 ) , C_int ( abi:: tydesc_field_first_param) ] ) ;
910
+ store_inbounds ( cx, C_uint ( n_params) , llmyroottydesc,
911
+ ~[ C_int ( 0 ) , C_int ( abi:: tydesc_field_n_params) ] ) ;
912
+ store_inbounds ( cx, llsz, llmyroottydesc,
913
+ ~[ C_int ( 0 ) , C_int ( abi:: tydesc_field_size) ] ) ;
914
+ store_inbounds ( cx, llalign, llmyroottydesc,
915
+ ~[ C_int ( 0 ) , C_int ( abi:: tydesc_field_align) ] ) ;
912
916
ret llmyroottydesc;
913
917
}
914
918
@@ -964,7 +968,8 @@ fn get_derived_tydesc(cx: &@block_ctxt, t: &ty::t, escapes: bool,
964
968
v = td_val;
965
969
} else {
966
970
let llparamtydescs =
967
- alloca ( bcx, T_array ( T_ptr ( bcx_ccx ( bcx) . tydesc_type ) , n_params) ) ;
971
+ alloca ( bcx, T_array ( T_ptr ( bcx_ccx ( bcx) . tydesc_type ) ,
972
+ n_params + 1 u) ) ;
968
973
let i = 0 ;
969
974
for td: ValueRef in tys. descs {
970
975
let tdp = bcx. build . GEP ( llparamtydescs, ~[ C_int ( 0 ) , C_int ( i) ] ) ;
@@ -973,7 +978,7 @@ fn get_derived_tydesc(cx: &@block_ctxt, t: &ty::t, escapes: bool,
973
978
}
974
979
v =
975
980
trans_stack_local_derived_tydesc ( bcx, sz. val , align. val , root,
976
- llparamtydescs) ;
981
+ llparamtydescs, n_params ) ;
977
982
}
978
983
bcx. fcx . derived_tydescs . insert ( t, { lltydesc: v, escapes: escapes} ) ;
979
984
ret rslt( cx, v) ;
@@ -1191,20 +1196,28 @@ fn emit_tydescs(ccx: &@crate_ctxt) {
1191
1196
none. { ccx . stats . n_null_glues += 1 u; C_null ( cmp_fn_ty) }
1192
1197
some ( v) { ccx. stats . n_real_glues += 1 u; v }
1193
1198
} ;
1194
- let // copy_glue
1195
- // drop_glue
1196
- // free_glue
1197
- // sever_glue
1198
- // mark_glue
1199
- // obj_drop_glue
1200
- // is_stateful
1201
- tydesc =
1199
+
1200
+ let shape = shape:: shape_of ( ccx, pair. key ) ;
1201
+ let shape_tables =
1202
+ llvm:: LLVMConstPointerCast ( ccx. shape_cx . llshapetables ,
1203
+ T_ptr ( T_i8 ( ) ) ) ;
1204
+
1205
+ let tydesc =
1202
1206
C_named_struct ( ccx. tydesc_type ,
1203
- ~[ C_null ( T_ptr ( T_ptr ( ccx. tydesc_type ) ) ) , ti. size ,
1204
- ti. align , copy_glue, drop_glue, free_glue,
1205
- C_null ( glue_fn_ty) , C_null ( glue_fn_ty) ,
1206
- C_null ( glue_fn_ty) , C_null ( glue_fn_ty) ,
1207
- cmp_glue] ) ; // cmp_glue
1207
+ ~[ C_null ( T_ptr ( T_ptr ( ccx. tydesc_type ) ) ) ,
1208
+ ti. size , // size
1209
+ ti. align , // align
1210
+ copy_glue, // copy_glue
1211
+ drop_glue, // drop_glue
1212
+ free_glue, // free_glue
1213
+ C_null ( glue_fn_ty) , // sever_glue
1214
+ C_null ( glue_fn_ty) , // mark_glue
1215
+ C_null ( glue_fn_ty) , // obj_drop_glue
1216
+ C_null ( glue_fn_ty) , // is_stateful
1217
+ cmp_glue, // cmp_glue
1218
+ C_shape ( ccx, shape) , // shape
1219
+ shape_tables, // shape_tables
1220
+ C_int ( 0 ) ] ) ; // n_params
1208
1221
1209
1222
let gvar = ti. tydesc ;
1210
1223
llvm:: LLVMSetInitializer ( gvar, tydesc) ;
@@ -2288,16 +2301,17 @@ fn call_cmp_glue(cx: &@block_ctxt, lhs: ValueRef, rhs: ValueRef, t: &ty::t,
2288
2301
let ti = none[ @tydesc_info] ;
2289
2302
let r = get_tydesc ( cx, t, false , ti) ;
2290
2303
lazily_emit_tydesc_glue ( cx, abi:: tydesc_field_cmp_glue, ti) ;
2304
+ let lltydesc = r. val ;
2291
2305
let lltydescs =
2292
- r. bcx . build . GEP ( r . val ,
2306
+ r. bcx . build . GEP ( lltydesc ,
2293
2307
~[ C_int ( 0 ) , C_int ( abi:: tydesc_field_first_param) ] ) ;
2294
2308
lltydescs = r. bcx . build . Load ( lltydescs) ;
2295
2309
2296
2310
let llfn;
2297
2311
alt ti {
2298
2312
none. {
2299
2313
let llfnptr =
2300
- r. bcx . build . GEP ( r . val ,
2314
+ r. bcx . build . GEP ( lltydesc ,
2301
2315
~[ C_int ( 0 ) , C_int ( abi:: tydesc_field_cmp_glue) ] ) ;
2302
2316
llfn = r. bcx . build . Load ( llfnptr) ;
2303
2317
}
@@ -2306,7 +2320,7 @@ fn call_cmp_glue(cx: &@block_ctxt, lhs: ValueRef, rhs: ValueRef, t: &ty::t,
2306
2320
2307
2321
let llcmpresultptr = alloca ( r. bcx , T_i1 ( ) ) ;
2308
2322
let llargs: ValueRef [ ] =
2309
- ~[ llcmpresultptr, r. bcx . fcx . lltaskptr , C_null ( T_ptr ( T_nil ( ) ) ) ,
2323
+ ~[ llcmpresultptr, r. bcx . fcx . lltaskptr , lltydesc ,
2310
2324
lltydescs, llrawlhsptr, llrawrhsptr, llop] ;
2311
2325
r. bcx . build . Call ( llfn, llargs) ;
2312
2326
ret rslt( r. bcx , r. bcx . build . Load ( llcmpresultptr) ) ;
@@ -8000,8 +8014,9 @@ fn trans_crate(sess: &session::session, crate: &@ast::crate, tcx: &ty::ctxt,
8000
8014
trans_mod ( cx, crate . node. module ) ;
8001
8015
create_crate_map ( ccx) ;
8002
8016
emit_tydescs ( ccx) ;
8003
- // Translate the metadata:
8017
+ shape :: gen_shape_tables ( ccx ) ;
8004
8018
8019
+ // Translate the metadata.
8005
8020
write_metadata ( cx. ccx , crate ) ;
8006
8021
if ccx. sess . get_opts ( ) . stats {
8007
8022
log_err "--- trans stats ---" ;
0 commit comments