Skip to content

Commit aeca138

Browse files
committed
swap taskptr and callee in preparation for making taskptr optional.
1 parent 50da3ea commit aeca138

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/comp/back/x86.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,11 @@ fn upcall_glue(int n_args) -> vec[str] {
175175
*/
176176

177177
fn copy_arg(uint i) -> str {
178-
auto src_off = wstr(5 + (i as int));
179-
auto dst_off = wstr(1 + (i as int));
178+
if (i == 0u) {
179+
ret "movl %edx, (%esp)";
180+
}
181+
auto src_off = wstr(4 + (i as int));
182+
auto dst_off = wstr(0 + (i as int));
180183
auto m = vec("movl " + src_off + "(%ebp),%eax",
181184
"movl %eax," + dst_off + "(%esp)");
182185
ret _str.connect(m, "\n\t");
@@ -193,14 +196,13 @@ fn upcall_glue(int n_args) -> vec[str] {
193196
+ load_esp_from_runtime_sp()
194197

195198
+ vec("subl $" + wstr(n_args + 1) + ", %esp # esp -= args",
196-
"andl $~0xf, %esp # align esp down",
197-
"movl %ecx, (%esp) # arg[0] = rust_task ")
199+
"andl $~0xf, %esp # align esp down")
198200

199-
+ _vec.init_fn[str](carg, n_args as uint)
201+
+ _vec.init_fn[str](carg, (n_args + 1) as uint)
200202

201-
+ vec("movl %ecx, %edi # save task from ecx to edi",
202-
"call *%edx # call *%edx",
203-
"movl %edi, %ecx # restore edi-saved task to ecx")
203+
+ vec("movl %edx, %edi # save task from ecx to edi",
204+
"call *%ecx # call *%edx",
205+
"movl %edi, %edx # restore edi-saved task to ecx")
204206

205207
+ load_esp_from_rust_sp()
206208
+ restore_callee_saves()

src/comp/middle/trans.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,8 @@ fn decl_upcall_glue(ModuleRef llmod, type_names tn, uint _n) -> ValueRef {
831831
let int n = _n as int;
832832
let str s = abi.upcall_glue_name(n);
833833
let vec[TypeRef] args =
834-
vec(T_taskptr(tn), // taskptr
835-
T_int()) // callee
834+
vec(T_int(), // callee
835+
T_taskptr(tn)) // taskptr
836836
+ _vec.init_elt[TypeRef](T_int(), n as uint);
837837

838838
ret decl_fastcall_fn(llmod, s, T_fn(args, T_int()));
@@ -856,7 +856,7 @@ fn trans_upcall(@block_ctxt cx, str name, vec[ValueRef] args) -> result {
856856
llupcall = llvm.LLVMConstPointerCast(llupcall, T_int());
857857

858858
let ValueRef llglue = cx.fcx.ccx.glues.upcall_glues.(n);
859-
let vec[ValueRef] call_args = vec(cx.fcx.lltaskptr, llupcall);
859+
let vec[ValueRef] call_args = vec(llupcall, cx.fcx.lltaskptr);
860860

861861
for (ValueRef a in args) {
862862
call_args += cx.build.ZExtOrBitCast(a, T_int());

0 commit comments

Comments
 (0)