@@ -147,7 +147,8 @@ type crate_ctxt =
147
147
ty:: ctxt tcx,
148
148
stats stats,
149
149
@upcall:: upcalls upcalls,
150
- TypeRef tydesc_type ) ;
150
+ TypeRef tydesc_type ,
151
+ TypeRef task_type ) ;
151
152
152
153
type local_ctxt =
153
154
rec( str[ ] path,
@@ -477,9 +478,8 @@ fn T_struct(&TypeRef[] elts) -> TypeRef {
477
478
478
479
fn T_opaque ( ) -> TypeRef { ret llvm:: LLVMOpaqueType ( ) ; }
479
480
480
- fn T_task ( & type_names tn ) -> TypeRef {
481
+ fn T_task2 ( ) -> TypeRef {
481
482
auto s = "task" ;
482
- if ( tn. name_has_type ( s) ) { ret tn. get_type ( s) ; }
483
483
auto t =
484
484
T_struct ( ~[ T_int ( ) , // Refcount
485
485
T_int ( ) , // Delegate pointer
@@ -491,7 +491,6 @@ fn T_task(&type_names tn) -> TypeRef {
491
491
T_int ( ) , // Domain pointer
492
492
// Crate cache pointer
493
493
T_int ( ) ] ) ;
494
- tn. associate ( s, t) ;
495
494
ret t;
496
495
}
497
496
@@ -527,16 +526,16 @@ fn T_cmp_glue_fn(&crate_ctxt cx) -> TypeRef {
527
526
ret t;
528
527
}
529
528
530
- fn T_tydesc ( & type_names tn ) -> TypeRef {
529
+ fn T_tydesc ( TypeRef taskptr_type ) -> TypeRef {
531
530
auto th = mk_type_handle ( ) ;
532
531
auto abs_tydesc = llvm:: LLVMResolveTypeHandle ( th. llth ) ;
533
532
auto tydescpp = T_ptr ( T_ptr ( abs_tydesc) ) ;
534
533
auto pvoid = T_ptr ( T_i8 ( ) ) ;
535
534
auto glue_fn_ty =
536
- T_ptr ( T_fn ( ~[ T_ptr ( T_nil ( ) ) , T_taskptr ( tn ) , T_ptr ( T_nil ( ) ) , tydescpp,
535
+ T_ptr ( T_fn ( ~[ T_ptr ( T_nil ( ) ) , taskptr_type , T_ptr ( T_nil ( ) ) , tydescpp,
537
536
pvoid] , T_void ( ) ) ) ;
538
537
auto cmp_glue_fn_ty =
539
- T_ptr ( T_fn ( ~[ T_ptr ( T_i1 ( ) ) , T_taskptr ( tn ) , T_ptr ( T_nil ( ) ) , tydescpp,
538
+ T_ptr ( T_fn ( ~[ T_ptr ( T_i1 ( ) ) , taskptr_type , T_ptr ( T_nil ( ) ) , tydescpp,
540
539
pvoid, pvoid, T_i8 ( ) ] , T_void ( ) ) ) ;
541
540
auto tydesc =
542
541
T_struct ( ~[ tydescpp, // first_param
@@ -633,7 +632,7 @@ fn T_chan(TypeRef t) -> TypeRef {
633
632
634
633
}
635
634
636
- fn T_taskptr ( & type_names tn ) -> TypeRef { ret T_ptr ( T_task ( tn ) ) ; }
635
+ fn T_taskptr ( & crate_ctxt cx ) -> TypeRef { ret T_ptr ( cx . task_type ) ; }
637
636
638
637
639
638
// This type must never be used directly; it must always be cast away.
@@ -766,7 +765,7 @@ fn type_of_fn_full(&@crate_ctxt cx, &span sp, ast::proto proto,
766
765
}
767
766
768
767
// Arg 1: task pointer.
769
- atys += ~[ T_taskptr ( cx . tn ) ] ;
768
+ atys += ~[ T_taskptr ( * cx ) ] ;
770
769
771
770
// Arg 2: Env (closure-bindings / self-obj)
772
771
alt ( obj_self) {
@@ -811,7 +810,7 @@ fn type_of_native_fn(&@crate_ctxt cx, &span sp, ast::native_abi abi,
811
810
-> TypeRef {
812
811
let TypeRef [ ] atys = ~[ ] ;
813
812
if ( abi == ast:: native_abi_rust) {
814
- atys += ~[ T_taskptr ( cx . tn ) ] ;
813
+ atys += ~[ T_taskptr ( * cx ) ] ;
815
814
auto i = 0 u;
816
815
while ( i < ty_param_count) {
817
816
atys += ~[ T_ptr ( cx. tydesc_type ) ] ;
@@ -874,7 +873,7 @@ fn type_of_inner(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef {
874
873
case ( ty:: ty_chan ( ?t) ) {
875
874
llty = T_ptr ( T_chan ( type_of_inner ( cx, sp, t) ) ) ;
876
875
}
877
- case ( ty:: ty_task) { llty = T_taskptr ( cx . tn ) ; }
876
+ case ( ty:: ty_task) { llty = T_taskptr ( * cx ) ; }
878
877
case ( ty:: ty_tup ( ?elts) ) {
879
878
let TypeRef [ ] tys = ~[ ] ;
880
879
for ( ty:: mt elt in elts) {
@@ -1136,8 +1135,8 @@ fn decl_internal_fastcall_fn(ModuleRef llmod, &str name, TypeRef llty) ->
1136
1135
ret llfn;
1137
1136
}
1138
1137
1139
- fn decl_glue( ModuleRef llmod, type_names tn , & str s) -> ValueRef {
1140
- ret decl_cdecl_fn( llmod, s, T_fn ( ~[ T_taskptr ( tn ) ] , T_void ( ) ) ) ;
1138
+ fn decl_glue( ModuleRef llmod, & crate_ctxt cx , & str s) -> ValueRef {
1139
+ ret decl_cdecl_fn( llmod, s, T_fn ( ~[ T_taskptr ( cx ) ] , T_void ( ) ) ) ;
1141
1140
}
1142
1141
1143
1142
fn get_extern_fn( & hashmap[ str, ValueRef ] externs, ModuleRef llmod, & str name,
@@ -8999,7 +8998,7 @@ fn i2p(ValueRef v, TypeRef t) -> ValueRef {
8999
8998
}
9000
8999
9001
9000
fn create_typedefs( & @crate_ctxt cx) {
9002
- llvm:: LLVMAddTypeName ( cx. llmod, str :: buf( "task") , T_task ( cx. tn ) ) ;
9001
+ llvm:: LLVMAddTypeName ( cx. llmod, str :: buf( "task") , cx. task_type ) ;
9003
9002
llvm:: LLVMAddTypeName ( cx. llmod, str :: buf( "tydesc") , cx. tydesc_type) ;
9004
9003
}
9005
9004
@@ -9057,8 +9056,8 @@ fn trap(&@block_ctxt bcx) {
9057
9056
}
9058
9057
}
9059
9058
9060
- fn decl_no_op_type_glue( ModuleRef llmod, type_names tn ) -> ValueRef {
9061
- auto ty = T_fn ( ~[ T_taskptr ( tn ) , T_ptr ( T_i8 ( ) ) ] , T_void ( ) ) ;
9059
+ fn decl_no_op_type_glue( ModuleRef llmod, TypeRef taskptr_type ) -> ValueRef {
9060
+ auto ty = T_fn ( ~[ taskptr_type , T_ptr ( T_i8 ( ) ) ] , T_void ( ) ) ;
9062
9061
ret decl_fastcall_fn( llmod, abi:: no_op_type_glue_name( ) , ty) ;
9063
9062
}
9064
9063
@@ -9078,24 +9077,26 @@ fn vec_p0(&@block_ctxt bcx, ValueRef v) -> ValueRef {
9078
9077
ret bcx. build. PointerCast ( p, T_ptr ( T_i8 ( ) ) ) ;
9079
9078
}
9080
9079
9081
- fn make_glues( ModuleRef llmod, & type_names tn ) -> @glue_fns {
9082
- ret @rec( no_op_type_glue=decl_no_op_type_glue( llmod, tn ) ) ;
9080
+ fn make_glues( ModuleRef llmod, TypeRef taskptr_type ) -> @glue_fns {
9081
+ ret @rec( no_op_type_glue=decl_no_op_type_glue( llmod, taskptr_type ) ) ;
9083
9082
}
9084
9083
9085
9084
fn make_common_glue( & session:: session sess, & str output) {
9086
9085
// FIXME: part of this is repetitive and is probably a good idea
9087
9086
// to autogen it.
9088
9087
9088
+ auto task_type = T_task2 ( ) ;
9089
+ auto taskptr_type = T_ptr ( task_type) ;
9090
+
9089
9091
auto llmod =
9090
9092
llvm:: LLVMModuleCreateWithNameInContext ( str :: buf( "rust_out") ,
9091
9093
llvm:: LLVMGetGlobalContext ( ) ) ;
9092
9094
llvm:: LLVMSetDataLayout ( llmod, str :: buf( x86:: get_data_layout( ) ) ) ;
9093
9095
llvm:: LLVMSetTarget ( llmod, str :: buf( x86:: get_target_triple( ) ) ) ;
9094
9096
mk_target_data( x86:: get_data_layout( ) ) ;
9095
- auto tn = mk_type_names( ) ;
9096
9097
declare_intrinsics( llmod) ;
9097
9098
llvm:: LLVMSetModuleInlineAsm ( llmod, str :: buf( x86:: get_module_asm( ) ) ) ;
9098
- make_glues( llmod, tn ) ;
9099
+ make_glues( llmod, taskptr_type ) ;
9099
9100
link:: write:: run_passes( sess, llmod, output) ;
9100
9101
}
9101
9102
@@ -9170,7 +9171,10 @@ fn trans_crate(&session::session sess, &@ast::crate crate, &ty::ctxt tcx,
9170
9171
auto td = mk_target_data( x86:: get_data_layout( ) ) ;
9171
9172
auto tn = mk_type_names( ) ;
9172
9173
auto intrinsics = declare_intrinsics( llmod) ;
9173
- auto glues = make_glues( llmod, tn) ;
9174
+ auto task_type = T_task2 ( ) ;
9175
+ auto taskptr_type = T_ptr ( task_type) ;
9176
+ auto tydesc_type = T_tydesc ( taskptr_type) ;
9177
+ auto glues = make_glues( llmod, taskptr_type) ;
9174
9178
auto hasher = ty:: hash_ty;
9175
9179
auto eqer = ty:: eq_ty;
9176
9180
auto tag_sizes = map:: mk_hashmap[ ty:: t, uint] ( hasher, eqer) ;
@@ -9179,7 +9183,6 @@ fn trans_crate(&session::session sess, &@ast::crate crate, &ty::ctxt tcx,
9179
9183
auto sha1s = map:: mk_hashmap[ ty:: t, str ] ( hasher, eqer) ;
9180
9184
auto short_names = map:: mk_hashmap[ ty:: t, str ] ( hasher, eqer) ;
9181
9185
auto sha = std:: sha1:: mk_sha1( ) ;
9182
- auto tydesc_type = T_tydesc ( tn) ;
9183
9186
auto ccx =
9184
9187
@rec( sess=sess,
9185
9188
llmod=llmod,
@@ -9212,8 +9215,10 @@ fn trans_crate(&session::session sess, &@ast::crate crate, &ty::ctxt tcx,
9212
9215
mutable n_glues_created=0 u,
9213
9216
mutable n_null_glues=0 u,
9214
9217
mutable n_real_glues=0 u) ,
9215
- upcalls=upcall:: declare_upcalls( tn, tydesc_type, llmod) ,
9216
- tydesc_type=tydesc_type) ;
9218
+ upcalls=upcall:: declare_upcalls( tn, tydesc_type, taskptr_type,
9219
+ llmod) ,
9220
+ tydesc_type=tydesc_type,
9221
+ task_type=task_type) ;
9217
9222
auto cx = new_local_ctxt( ccx) ;
9218
9223
create_typedefs( ccx) ;
9219
9224
collect_items( ccx, crate ) ;
0 commit comments