@@ -242,7 +242,7 @@ fn trans_free(cx: block, v: ValueRef) -> block {
242
242
}
243
243
244
244
fn trans_unique_free ( cx : block , v : ValueRef ) -> block {
245
- let _icx = cx. insn_ctxt ( "trans_shared_free " ) ;
245
+ let _icx = cx. insn_ctxt ( "trans_unique_free " ) ;
246
246
Call ( cx, cx. ccx ( ) . upcalls . exchange_free ,
247
247
~[ PointerCast ( cx, v, T_ptr ( T_i8 ( ) ) ) ] ) ;
248
248
ret cx;
@@ -422,12 +422,12 @@ fn get_tydesc(ccx: @crate_ctxt, t: ty::t,
422
422
423
423
fn get_static_tydesc ( ccx : @crate_ctxt , t : ty:: t ) -> @tydesc_info {
424
424
alt ccx. tydescs . find ( t) {
425
- some ( inf) { ret inf; }
426
- none {
425
+ some ( inf) { inf }
426
+ _ {
427
427
ccx. stats . n_static_tydescs += 1 u;
428
428
let inf = declare_tydesc ( ccx, t) ;
429
429
ccx. tydescs . insert ( t, inf) ;
430
- ret inf;
430
+ inf
431
431
}
432
432
}
433
433
}
@@ -490,16 +490,15 @@ fn note_unique_llvm_symbol(ccx: @crate_ctxt, sym: str) {
490
490
// Generates the declaration for (but doesn't emit) a type descriptor.
491
491
fn declare_tydesc ( ccx : @crate_ctxt , t : ty:: t ) -> @tydesc_info {
492
492
let _icx = ccx. insn_ctxt ( "declare_tydesc" ) ;
493
- log ( debug, "+++ declare_tydesc " + ty_to_str ( ccx. tcx , t) ) ;
494
493
let llty = type_of ( ccx, t) ;
495
494
let llsize = llsize_of ( ccx, llty) ;
496
495
let llalign = llalign_of ( ccx, llty) ;
497
- let mut name;
498
496
//XXX this triggers duplicate LLVM symbols
499
- if false /*ccx.sess.opts.debuginfo*/ {
500
- name = mangle_internal_name_by_type_only ( ccx, t, @"tydesc") ;
501
- } else { name = mangle_internal_name_by_seq ( ccx, @"tydesc") ; }
497
+ let name = if false /*ccx.sess.opts.debuginfo*/ {
498
+ mangle_internal_name_by_type_only ( ccx, t, @"tydesc")
499
+ } else { mangle_internal_name_by_seq ( ccx, @"tydesc") } ;
502
500
note_unique_llvm_symbol ( ccx, name) ;
501
+ log ( debug, #fmt ( "+++ declare_tydesc %s %s" , ty_to_str ( ccx. tcx , t) , name) ) ;
503
502
let gvar = str:: as_c_str ( name, { |buf|
504
503
llvm:: LLVMAddGlobal ( ccx. llmod , ccx. tydesc_type , buf)
505
504
} ) ;
@@ -613,14 +612,14 @@ fn emit_tydescs(ccx: @crate_ctxt) {
613
612
drop_glue, // drop_glue
614
613
free_glue, // free_glue
615
614
visit_glue, // visit_glue
616
- C_int ( ccx, 0 ) , // ununsed
617
- C_int ( ccx, 0 ) , // ununsed
618
- C_int ( ccx, 0 ) , // ununsed
619
- C_int ( ccx, 0 ) , // ununsed
615
+ C_int ( ccx, 0 ) , // unused
616
+ C_int ( ccx, 0 ) , // unused
617
+ C_int ( ccx, 0 ) , // unused
618
+ C_int ( ccx, 0 ) , // unused
620
619
C_shape ( ccx, shape) , // shape
621
620
shape_tables, // shape_tables
622
- C_int ( ccx, 0 ) , // ununsed
623
- C_int ( ccx, 0 ) ] ) ; // unused
621
+ C_int ( ccx, 0 ) , // unused
622
+ C_int ( ccx, 0 ) ] /~ ) ; // unused
624
623
625
624
let gvar = ti. tydesc ;
626
625
llvm:: LLVMSetInitializer ( gvar, tydesc) ;
@@ -704,8 +703,10 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
704
703
}
705
704
ty:: ty_opaque_box {
706
705
let v = PointerCast ( bcx, v, type_of( ccx, t) ) ;
707
- let td = Load ( bcx, GEPi ( bcx, v, ~[ 0 u, abi:: box_field_tydesc] ) ) ;
708
- let valptr = GEPi ( bcx, v, ~[ 0 u, abi:: box_field_body] ) ;
706
+ let td = Load ( bcx, GEPi ( bcx, v, [ 0 u, abi:: box_field_tydesc] /~) ) ;
707
+ let valptr = GEPi ( bcx, v, [ 0 u, abi:: box_field_body] /~) ;
708
+ // Generate code that, dynamically, indexes into the
709
+ // tydesc and calls the drop glue that got set dynamically
709
710
call_tydesc_glue_full ( bcx, valptr, td, abi:: tydesc_field_drop_glue,
710
711
none) ;
711
712
trans_free ( bcx, v)
@@ -1194,6 +1195,7 @@ fn call_tydesc_glue_full(++cx: block, v: ValueRef, tydesc: ValueRef,
1194
1195
let llfn = {
1195
1196
alt static_glue_fn {
1196
1197
none {
1198
+ // Select out the glue function to call from the tydesc
1197
1199
let llfnptr = GEPi ( cx, tydesc, ~[ 0 u, field] ) ;
1198
1200
Load ( cx, llfnptr)
1199
1201
}
@@ -2136,11 +2138,6 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id,
2136
2138
}
2137
2139
} ) ;
2138
2140
2139
- #debug[ "monomorphic_fn(fn_id=%? (%s), real_substs=%?, substs=%?" ,
2140
- fn_id, ty:: item_path_str ( ccx. tcx , fn_id) ,
2141
- real_substs. map ( { |s| ty_to_str ( ccx. tcx , s) } ) ,
2142
- substs. map ( { |s| ty_to_str ( ccx. tcx , s) } ) ] ;
2143
-
2144
2141
for real_substs. each( ) { |s| assert !ty:: type_has_params( s) ; } ;
2145
2142
for substs. each( ) { |s| assert !ty:: type_has_params( s) ; } ;
2146
2143
@@ -2150,6 +2147,13 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id,
2150
2147
{ |p| alt p { mono_precise( _, _) { false } _ { true } } } ) {
2151
2148
must_cast = true ;
2152
2149
}
2150
+
2151
+ #debug[ "monomorphic_fn(fn_id=%? (%s), real_substs=%?, substs=%?, \
2152
+ hash_id = %?",
2153
+ fn_id, ty:: item_path_str ( ccx. tcx , fn_id) ,
2154
+ real_substs. map ( { |s| ty_to_str ( ccx. tcx , s) } ) ,
2155
+ substs. map ( { |s| ty_to_str ( ccx. tcx , s) } ) , hash_id] ;
2156
+
2153
2157
alt ccx. monomorphized . find ( hash_id) {
2154
2158
some ( val) {
2155
2159
ret { val : val, must_cast : must_cast} ;
0 commit comments