@@ -66,29 +66,18 @@ pub fn new_namegen(intr: @ident_interner) -> namegen {
66
66
f
67
67
}
68
68
69
- pub type addrspace = c_uint ;
70
69
71
- // Address spaces communicate to LLVM which destructors need to run for
72
- // specific types.
73
- // 0 is ignored by the GC, and is used for all non-GC'd pointers.
74
- // 1 is for opaque GC'd boxes.
75
- // >= 2 are for specific types (e.g. resources).
70
+ // Multiple address spaces were at one time used to encode
71
+ // GC information. They may be again someday. In the meantime
72
+ // we only support a single addrspace.
73
+ pub type addrspace = c_uint ;
76
74
pub static default_addrspace: addrspace = 0 ;
77
- pub static gc_box_addrspace: addrspace = 1 ;
78
-
79
- pub type addrspace_gen = @fn ( ) -> addrspace ;
80
- pub fn new_addrspace_gen ( ) -> addrspace_gen {
81
- let i = @mut 1 ;
82
- let result: addrspace_gen = || { * i += 1 ; * i } ;
83
- result
84
- }
85
75
86
76
pub struct tydesc_info {
87
77
ty : ty:: t ,
88
78
tydesc : ValueRef ,
89
79
size : ValueRef ,
90
80
align : ValueRef ,
91
- addrspace : addrspace ,
92
81
take_glue : Option < ValueRef > ,
93
82
drop_glue : Option < ValueRef > ,
94
83
free_glue : Option < ValueRef > ,
@@ -208,7 +197,6 @@ pub struct CrateContext {
208
197
llsizingtypes : @mut HashMap < ty:: t , TypeRef > ,
209
198
adt_reprs : @mut HashMap < ty:: t , @adt:: Repr > ,
210
199
names : namegen ,
211
- next_addrspace : addrspace_gen ,
212
200
symbol_hasher : @mut hash:: State ,
213
201
type_hashcodes : @mut HashMap < ty:: t , @str > ,
214
202
type_short_names : @mut HashMap < ty:: t , ~str > ,
@@ -224,10 +212,6 @@ pub struct CrateContext {
224
212
builder : BuilderRef_res ,
225
213
shape_cx : shape:: Ctxt ,
226
214
crate_map : ValueRef ,
227
- // Set when at least one function uses GC. Needed so that
228
- // decl_gc_metadata knows whether to link to the module metadata, which
229
- // is not emitted by LLVM's GC pass when no functions use GC.
230
- uses_gc : @mut bool ,
231
215
dbg_cx : Option < debuginfo:: DebugContext > ,
232
216
do_not_commit_warning_issued : @mut bool
233
217
}
@@ -426,38 +410,16 @@ pub fn cleanup_type(cx: ty::ctxt, ty: ty::t) -> cleantype {
426
410
}
427
411
}
428
412
429
- // This is not the same as datum::Datum::root(), which is used to keep copies
430
- // of @ values live for as long as a borrowed pointer to the interior exists.
431
- // In the new GC, we can identify immediates on the stack without difficulty,
432
- // but have trouble knowing where non-immediates are on the stack. For
433
- // non-immediates, we must add an additional level of indirection, which
434
- // allows us to alloca a pointer with the right addrspace.
435
- pub fn root_for_cleanup ( bcx : block , v : ValueRef , t : ty:: t )
436
- -> ( ValueRef , bool ) {
437
- let ccx = bcx. ccx ( ) ;
438
-
439
- let addrspace = base:: get_tydesc ( ccx, t) . addrspace ;
440
- if addrspace > gc_box_addrspace {
441
- let llty = type_of:: type_of_rooted ( ccx, t) ;
442
- let root = base:: alloca ( bcx, llty) ;
443
- build:: Store ( bcx, build:: PointerCast ( bcx, v, llty) , root) ;
444
- ( root, true )
445
- } else {
446
- ( v, false )
447
- }
448
- }
449
-
450
413
pub fn add_clean ( bcx : block , val : ValueRef , t : ty:: t ) {
451
414
if !ty:: type_needs_drop ( bcx. tcx ( ) , t) { return ; }
452
415
debug ! ( "add_clean(%s, %s, %s)" ,
453
416
bcx. to_str( ) ,
454
417
val_str( bcx. ccx( ) . tn, val) ,
455
418
t. repr( bcx. tcx( ) ) ) ;
456
- let ( root, rooted) = root_for_cleanup ( bcx, val, t) ;
457
419
let cleanup_type = cleanup_type ( bcx. tcx ( ) , t) ;
458
420
do in_scope_cx ( bcx) |scope_info| {
459
421
scope_info. cleanups . push (
460
- clean ( |a| glue:: drop_ty_root ( a, root , rooted , t) ,
422
+ clean ( |a| glue:: drop_ty ( a, val , t) ,
461
423
cleanup_type) ) ;
462
424
scope_clean_changed ( scope_info) ;
463
425
}
@@ -481,11 +443,10 @@ pub fn add_clean_temp_mem(bcx: block, val: ValueRef, t: ty::t) {
481
443
debug ! ( "add_clean_temp_mem(%s, %s, %s)" ,
482
444
bcx. to_str( ) , val_str( bcx. ccx( ) . tn, val) ,
483
445
t. repr( bcx. tcx( ) ) ) ;
484
- let ( root, rooted) = root_for_cleanup ( bcx, val, t) ;
485
446
let cleanup_type = cleanup_type ( bcx. tcx ( ) , t) ;
486
447
do in_scope_cx ( bcx) |scope_info| {
487
448
scope_info. cleanups . push (
488
- clean_temp ( val, |a| glue:: drop_ty_root ( a, root , rooted , t) ,
449
+ clean_temp ( val, |a| glue:: drop_ty ( a, val , t) ,
489
450
cleanup_type) ) ;
490
451
scope_clean_changed ( scope_info) ;
491
452
}
@@ -895,12 +856,6 @@ pub fn T_ptr(t: TypeRef) -> TypeRef {
895
856
}
896
857
}
897
858
898
- pub fn T_root ( t : TypeRef , addrspace : addrspace ) -> TypeRef {
899
- unsafe {
900
- return llvm:: LLVMPointerType ( t, addrspace) ;
901
- }
902
- }
903
-
904
859
pub fn T_struct ( elts : & [ TypeRef ] , packed : bool ) -> TypeRef {
905
860
unsafe {
906
861
return llvm:: LLVMStructType ( to_ptr ( elts) ,
@@ -1054,7 +1009,7 @@ pub fn T_box(cx: @CrateContext, t: TypeRef) -> TypeRef {
1054
1009
1055
1010
pub fn T_box_ptr ( t : TypeRef ) -> TypeRef {
1056
1011
unsafe {
1057
- return llvm:: LLVMPointerType ( t, gc_box_addrspace ) ;
1012
+ return llvm:: LLVMPointerType ( t, default_addrspace ) ;
1058
1013
}
1059
1014
}
1060
1015
@@ -1072,7 +1027,7 @@ pub fn T_unique(cx: @CrateContext, t: TypeRef) -> TypeRef {
1072
1027
1073
1028
pub fn T_unique_ptr ( t : TypeRef ) -> TypeRef {
1074
1029
unsafe {
1075
- return llvm:: LLVMPointerType ( t, gc_box_addrspace ) ;
1030
+ return llvm:: LLVMPointerType ( t, default_addrspace ) ;
1076
1031
}
1077
1032
}
1078
1033
0 commit comments