Skip to content

Commit 634f93d

Browse files
committed
---
yaml --- r: 1115 b: refs/heads/master c: 9b56b79 h: refs/heads/master i: 1113: 40dc929 1111: 492ba6a v: v3
1 parent 2e6b91b commit 634f93d

File tree

2 files changed

+35
-25
lines changed

2 files changed

+35
-25
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 01bcb1d10eac97d27b3324125f7d5f3e0045a7ab
2+
refs/heads/master: 9b56b7929613e5aa98a2e8b74951e69c593e5cdd

trunk/src/comp/middle/trans.rs

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ state obj namegen(mutable int i) {
4949
type glue_fns = rec(ValueRef activate_glue,
5050
ValueRef yield_glue,
5151
ValueRef exit_task_glue,
52-
vec[ValueRef] upcall_glues);
52+
vec[ValueRef] upcall_glues,
53+
ValueRef no_op_type_glue);
5354

5455
tag arity { nullary; n_ary; }
5556
type tag_info = rec(type_handle th,
@@ -2785,6 +2786,37 @@ fn check_module(ModuleRef llmod) {
27852786
// TODO: run the linter here also, once there are llvm-c bindings for it.
27862787
}
27872788

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+
27882820
fn trans_crate(session.session sess, @ast.crate crate, str output) {
27892821
auto llmod =
27902822
llvm.LLVMModuleCreateWithNameInContext(_str.buf("rust_out"),
@@ -2798,29 +2830,7 @@ fn trans_crate(session.session sess, @ast.crate crate, str output) {
27982830

27992831
auto intrinsics = declare_intrinsics(llmod);
28002832

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);
28242834
auto hasher = typeck.hash_ty;
28252835
auto eqer = typeck.eq_ty;
28262836
auto types = map.mk_hashmap[@typeck.ty,@ty_info](hasher, eqer);

0 commit comments

Comments
 (0)