@@ -49,7 +49,8 @@ state obj namegen(mutable int i) {
49
49
type glue_fns = rec ( ValueRef activate_glue ,
50
50
ValueRef yield_glue ,
51
51
ValueRef exit_task_glue ,
52
- vec[ ValueRef ] upcall_glues ) ;
52
+ vec[ ValueRef ] upcall_glues ,
53
+ ValueRef no_op_type_glue ) ;
53
54
54
55
tag arity { nullary; n_ary; }
55
56
type tag_info = rec ( type_handle th,
@@ -2785,6 +2786,37 @@ fn check_module(ModuleRef llmod) {
2785
2786
// TODO: run the linter here also, once there are llvm-c bindings for it.
2786
2787
}
2787
2788
2789
+ fn make_no_op_type_glue ( ModuleRef llmod) -> ValueRef {
2790
+ auto ty = T_fn ( vec ( T_taskptr ( ) , T_ptr ( T_i8 ( ) ) ) , T_void ( ) ) ;
2791
+ auto fun = decl_fastcall_fn ( llmod, "_rust_no_op_type_glue" , ty) ;
2792
+ auto bb_name = _str. buf ( "_rust_no_op_type_glue_bb" ) ;
2793
+ auto llbb = llvm. LLVMAppendBasicBlock ( fun, bb_name) ;
2794
+ new_builder ( llbb, "builder" ) . RetVoid ( ) ;
2795
+ ret fun;
2796
+ }
2797
+
2798
+ fn make_glues ( ModuleRef llmod) -> @glue_fns {
2799
+ ret @rec( activate_glue = decl_glue ( llmod, abi. activate_glue_name ( ) ) ,
2800
+ yield_glue = decl_glue ( llmod, abi. yield_glue_name ( ) ) ,
2801
+ /*
2802
+ * Note: the signature passed to decl_cdecl_fn here looks unusual
2803
+ * because it is. It corresponds neither to an upcall signature
2804
+ * nor a normal rust-ABI signature. In fact it is a fake
2805
+ * signature, that exists solely to acquire the task pointer as
2806
+ * an argument to the upcall. It so happens that the runtime sets
2807
+ * up the task pointer as the sole incoming argument to the frame
2808
+ * that we return into when returning to the exit task glue. So
2809
+ * this is the signature required to retrieve it.
2810
+ */
2811
+ exit_task_glue = decl_cdecl_fn ( llmod, abi. exit_task_glue_name ( ) ,
2812
+ T_fn ( vec ( T_taskptr ( ) ) , T_void ( ) ) ) ,
2813
+
2814
+ upcall_glues =
2815
+ _vec. init_fn [ ValueRef ] ( bind decl_upcall ( llmod, _) ,
2816
+ abi. n_upcall_glues as uint ) ,
2817
+ no_op_type_glue = make_no_op_type_glue ( llmod) ) ;
2818
+ }
2819
+
2788
2820
fn trans_crate ( session . session sess, @ast. crate crate, str output ) {
2789
2821
auto llmod =
2790
2822
llvm. LLVMModuleCreateWithNameInContext ( _str. buf ( "rust_out" ) ,
@@ -2798,29 +2830,7 @@ fn trans_crate(session.session sess, @ast.crate crate, str output) {
2798
2830
2799
2831
auto intrinsics = declare_intrinsics ( llmod) ;
2800
2832
2801
- auto glues = @rec ( activate_glue = decl_glue ( llmod,
2802
- abi. activate_glue_name ( ) ) ,
2803
- yield_glue = decl_glue ( llmod, abi. yield_glue_name ( ) ) ,
2804
- /*
2805
- * Note: the signature passed to decl_cdecl_fn here
2806
- * looks unusual because it is. It corresponds neither
2807
- * to an upcall signature nor a normal rust-ABI
2808
- * signature. In fact it is a fake signature, that
2809
- * exists solely to acquire the task pointer as an
2810
- * argument to the upcall. It so happens that the
2811
- * runtime sets up the task pointer as the sole incoming
2812
- * argument to the frame that we return into when
2813
- * returning to the exit task glue. So this is the
2814
- * signature required to retrieve it.
2815
- */
2816
- exit_task_glue =
2817
- decl_cdecl_fn ( llmod, abi. exit_task_glue_name ( ) ,
2818
- T_fn ( vec ( T_taskptr ( ) ) , T_void ( ) ) ) ,
2819
-
2820
- upcall_glues =
2821
- _vec. init_fn [ ValueRef ] ( bind decl_upcall ( llmod, _) ,
2822
- abi. n_upcall_glues as uint ) ) ;
2823
-
2833
+ auto glues = make_glues ( llmod) ;
2824
2834
auto hasher = typeck. hash_ty ;
2825
2835
auto eqer = typeck. eq_ty ;
2826
2836
auto types = map. mk_hashmap [ @typeck. ty , @ty_info] ( hasher, eqer) ;
0 commit comments