@@ -367,12 +367,11 @@ fn malloc_raw_dyn(bcx: block, t: ty::t, heap: heap,
367
367
let llty = type_of ( ccx, box_ptr_ty) ;
368
368
369
369
// Get the tydesc for the body:
370
- let mut static_ti = none;
371
- let lltydesc = get_tydesc ( ccx, t, static_ti) ;
372
- lazily_emit_all_tydesc_glue ( ccx, copy static_ti) ;
370
+ let static_ti = get_tydesc ( ccx, t) ;
371
+ lazily_emit_all_tydesc_glue ( ccx, static_ti) ;
373
372
374
373
// Allocate space:
375
- let rval = Call ( bcx, upcall, ~[ lltydesc , size] ) ;
374
+ let rval = Call ( bcx, upcall, ~[ static_ti . tydesc , size] ) ;
376
375
ret PointerCast ( bcx, rval, llty) ;
377
376
}
378
377
@@ -409,20 +408,10 @@ fn malloc_unique(bcx: block, t: ty::t) -> {box: ValueRef, body: ValueRef} {
409
408
// Type descriptor and type glue stuff
410
409
411
410
fn get_tydesc_simple ( ccx : @crate_ctxt , t : ty:: t ) -> ValueRef {
412
- let mut ti = none;
413
- get_tydesc ( ccx, t, ti)
411
+ get_tydesc ( ccx, t) . tydesc
414
412
}
415
413
416
- fn get_tydesc ( ccx : @crate_ctxt , t : ty:: t ,
417
- & static_ti: option < @tydesc_info > ) -> ValueRef {
418
- assert !ty:: type_has_params ( t) ;
419
- // Otherwise, generate a tydesc if necessary, and return it.
420
- let inf = get_static_tydesc ( ccx, t) ;
421
- static_ti = some ( inf) ;
422
- inf. tydesc
423
- }
424
-
425
- fn get_static_tydesc ( ccx : @crate_ctxt , t : ty:: t ) -> @tydesc_info {
414
+ fn get_tydesc ( ccx : @crate_ctxt , t : ty:: t ) -> @tydesc_info {
426
415
alt ccx. tydescs . find ( t) {
427
416
some ( inf) { inf }
428
417
_ {
@@ -1090,96 +1079,90 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
1090
1079
}
1091
1080
1092
1081
fn lazily_emit_all_tydesc_glue ( ccx : @crate_ctxt ,
1093
- static_ti : option < @tydesc_info > ) {
1082
+ static_ti : @tydesc_info ) {
1094
1083
lazily_emit_tydesc_glue ( ccx, abi:: tydesc_field_take_glue, static_ti) ;
1095
1084
lazily_emit_tydesc_glue ( ccx, abi:: tydesc_field_drop_glue, static_ti) ;
1096
1085
lazily_emit_tydesc_glue ( ccx, abi:: tydesc_field_free_glue, static_ti) ;
1097
1086
lazily_emit_tydesc_glue ( ccx, abi:: tydesc_field_visit_glue, static_ti) ;
1098
1087
}
1099
1088
1100
1089
fn lazily_emit_tydesc_glue ( ccx : @crate_ctxt , field : uint ,
1101
- static_ti : option < @tydesc_info > ) {
1090
+ ti : @tydesc_info ) {
1102
1091
let _icx = ccx. insn_ctxt ( "lazily_emit_tydesc_glue" ) ;
1103
- alt static_ti {
1104
- none { }
1105
- some( ti) {
1106
- if field == abi:: tydesc_field_take_glue {
1107
- alt ti. take_glue {
1108
- some ( _) { }
1109
- none {
1110
- #debug( "+++ lazily_emit_tydesc_glue TAKE %s" ,
1111
- ppaux:: ty_to_str ( ccx. tcx , ti. ty ) ) ;
1112
- let glue_fn = declare_generic_glue
1113
- ( ccx, ti. ty , T_glue_fn ( ccx) , "take" ) ;
1114
- ti. take_glue = some ( glue_fn) ;
1115
- make_generic_glue ( ccx, ti. ty , glue_fn,
1116
- make_take_glue, "take" ) ;
1117
- #debug ( "--- lazily_emit_tydesc_glue TAKE %s" ,
1118
- ppaux:: ty_to_str ( ccx. tcx , ti. ty ) ) ;
1119
- }
1120
- }
1121
- } else if field == abi:: tydesc_field_drop_glue {
1122
- alt ti. drop_glue {
1123
- some ( _) { }
1124
- none {
1125
- #debug( "+++ lazily_emit_tydesc_glue DROP %s" ,
1126
- ppaux:: ty_to_str ( ccx. tcx , ti. ty ) ) ;
1127
- let glue_fn =
1128
- declare_generic_glue ( ccx, ti. ty , T_glue_fn ( ccx) , "drop" ) ;
1129
- ti. drop_glue = some ( glue_fn) ;
1130
- make_generic_glue ( ccx, ti. ty , glue_fn,
1131
- make_drop_glue, "drop" ) ;
1132
- #debug ( "--- lazily_emit_tydesc_glue DROP %s" ,
1133
- ppaux:: ty_to_str ( ccx. tcx , ti. ty ) ) ;
1134
- }
1135
- }
1136
- } else if field == abi:: tydesc_field_free_glue {
1137
- alt ti. free_glue {
1138
- some ( _) { }
1139
- none {
1140
- #debug( "+++ lazily_emit_tydesc_glue FREE %s" ,
1141
- ppaux:: ty_to_str ( ccx. tcx , ti. ty ) ) ;
1142
- let glue_fn =
1143
- declare_generic_glue ( ccx, ti. ty , T_glue_fn ( ccx) , "free" ) ;
1144
- ti. free_glue = some ( glue_fn) ;
1145
- make_generic_glue ( ccx, ti. ty , glue_fn,
1146
- make_free_glue, "free" ) ;
1147
- #debug ( "--- lazily_emit_tydesc_glue FREE %s" ,
1148
- ppaux:: ty_to_str ( ccx. tcx , ti. ty ) ) ;
1149
- }
1150
- }
1151
- } else if field == abi:: tydesc_field_visit_glue {
1152
- alt ti. visit_glue {
1153
- some ( _) { }
1154
- none {
1155
- #debug( "+++ lazily_emit_tydesc_glue VISIT %s" ,
1156
- ppaux:: ty_to_str ( ccx. tcx , ti. ty ) ) ;
1157
- let glue_fn =
1158
- declare_generic_glue ( ccx, ti. ty , T_glue_fn ( ccx) , "visit" ) ;
1159
- ti. visit_glue = some ( glue_fn) ;
1160
- make_generic_glue ( ccx, ti. ty , glue_fn,
1161
- make_visit_glue, "visit" ) ;
1162
- #debug ( "--- lazily_emit_tydesc_glue VISIT %s" ,
1163
- ppaux:: ty_to_str ( ccx. tcx , ti. ty ) ) ;
1164
- }
1165
- }
1092
+ if field == abi:: tydesc_field_take_glue {
1093
+ alt ti. take_glue {
1094
+ some ( _) { }
1095
+ none {
1096
+ #debug( "+++ lazily_emit_tydesc_glue TAKE %s" ,
1097
+ ppaux:: ty_to_str ( ccx. tcx , ti. ty ) ) ;
1098
+ let glue_fn = declare_generic_glue
1099
+ ( ccx, ti. ty , T_glue_fn ( ccx) , "take" ) ;
1100
+ ti. take_glue = some ( glue_fn) ;
1101
+ make_generic_glue ( ccx, ti. ty , glue_fn,
1102
+ make_take_glue, "take" ) ;
1103
+ #debug ( "--- lazily_emit_tydesc_glue TAKE %s" ,
1104
+ ppaux:: ty_to_str ( ccx. tcx , ti. ty ) ) ;
1105
+ }
1106
+ }
1107
+ } else if field == abi:: tydesc_field_drop_glue {
1108
+ alt ti. drop_glue {
1109
+ some ( _) { }
1110
+ none {
1111
+ #debug( "+++ lazily_emit_tydesc_glue DROP %s" ,
1112
+ ppaux:: ty_to_str ( ccx. tcx , ti. ty ) ) ;
1113
+ let glue_fn =
1114
+ declare_generic_glue ( ccx, ti. ty , T_glue_fn ( ccx) , "drop" ) ;
1115
+ ti. drop_glue = some ( glue_fn) ;
1116
+ make_generic_glue ( ccx, ti. ty , glue_fn,
1117
+ make_drop_glue, "drop" ) ;
1118
+ #debug ( "--- lazily_emit_tydesc_glue DROP %s" ,
1119
+ ppaux:: ty_to_str ( ccx. tcx , ti. ty ) ) ;
1120
+ }
1121
+ }
1122
+ } else if field == abi:: tydesc_field_free_glue {
1123
+ alt ti. free_glue {
1124
+ some ( _) { }
1125
+ none {
1126
+ #debug( "+++ lazily_emit_tydesc_glue FREE %s" ,
1127
+ ppaux:: ty_to_str ( ccx. tcx , ti. ty ) ) ;
1128
+ let glue_fn =
1129
+ declare_generic_glue ( ccx, ti. ty , T_glue_fn ( ccx) , "free" ) ;
1130
+ ti. free_glue = some ( glue_fn) ;
1131
+ make_generic_glue ( ccx, ti. ty , glue_fn,
1132
+ make_free_glue, "free" ) ;
1133
+ #debug ( "--- lazily_emit_tydesc_glue FREE %s" ,
1134
+ ppaux:: ty_to_str ( ccx. tcx , ti. ty ) ) ;
1135
+ }
1136
+ }
1137
+ } else if field == abi:: tydesc_field_visit_glue {
1138
+ alt ti. visit_glue {
1139
+ some ( _) { }
1140
+ none {
1141
+ #debug( "+++ lazily_emit_tydesc_glue VISIT %s" ,
1142
+ ppaux:: ty_to_str ( ccx. tcx , ti. ty ) ) ;
1143
+ let glue_fn =
1144
+ declare_generic_glue ( ccx, ti. ty , T_glue_fn ( ccx) , "visit" ) ;
1145
+ ti. visit_glue = some ( glue_fn) ;
1146
+ make_generic_glue ( ccx, ti. ty , glue_fn,
1147
+ make_visit_glue, "visit" ) ;
1148
+ #debug ( "--- lazily_emit_tydesc_glue VISIT %s" ,
1149
+ ppaux:: ty_to_str ( ccx. tcx , ti. ty ) ) ;
1150
+ }
1166
1151
}
1167
-
1168
- }
1169
1152
}
1170
1153
}
1171
1154
1172
1155
// See [Note-arg-mode]
1173
1156
fn call_tydesc_glue_full ( ++cx : block , v : ValueRef , tydesc : ValueRef ,
1174
1157
field : uint , static_ti : option < @tydesc_info > ) {
1175
1158
let _icx = cx. insn_ctxt ( "call_tydesc_glue_full" ) ;
1176
- lazily_emit_tydesc_glue ( cx. ccx ( ) , field, static_ti) ;
1177
- if cx. unreachable { ret; }
1159
+ if cx. unreachable { ret; }
1178
1160
1179
1161
let mut static_glue_fn = none;
1180
1162
alt static_ti {
1181
1163
none { /* no-op */ }
1182
1164
some( sti) {
1165
+ lazily_emit_tydesc_glue ( cx. ccx ( ) , field, sti) ;
1183
1166
if field == abi:: tydesc_field_take_glue {
1184
1167
static_glue_fn = sti. take_glue ;
1185
1168
} else if field == abi:: tydesc_field_drop_glue {
@@ -1213,9 +1196,8 @@ fn call_tydesc_glue_full(++cx: block, v: ValueRef, tydesc: ValueRef,
1213
1196
fn call_tydesc_glue ( ++cx : block , v : ValueRef , t : ty:: t , field : uint )
1214
1197
-> block {
1215
1198
let _icx = cx. insn_ctxt ( "call_tydesc_glue" ) ;
1216
- let mut ti = none;
1217
- let td = get_tydesc ( cx. ccx ( ) , t, ti) ;
1218
- call_tydesc_glue_full ( cx, v, td, field, ti) ;
1199
+ let ti = get_tydesc ( cx. ccx ( ) , t) ;
1200
+ call_tydesc_glue_full ( cx, v, ti. tydesc , field, some ( ti) ) ;
1219
1201
ret cx;
1220
1202
}
1221
1203
0 commit comments