Skip to content

Commit 9008406

Browse files
committed
---
yaml --- r: 913 b: refs/heads/master c: a352efa h: refs/heads/master i: 911: 098c6be v: v3
1 parent aed2d4b commit 9008406

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
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: 4cbef9d8a1f5d894325c252a70429116c24d5364
2+
refs/heads/master: a352efadad7271798848c6ef4a22d8de7c8eba3a

trunk/src/comp/back/x86.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,18 @@ fn upcall_glue(int n_args) -> vec[str] {
7070
/*
7171
* 0, 4, 8, 12 are callee-saves
7272
* 16 is retpc
73-
* 20 is taskptr
74-
* 24 is callee
75-
* 28 .. (7+i) * 4 are args
73+
* 20 .. (5+i) * 4 are args
74+
*
75+
* ecx is taskptr
76+
* edx is callee
77+
*
7678
*/
7779

7880
fn copy_arg(uint i) -> str {
79-
auto src_off = wstr(7 + (i as int));
81+
auto src_off = wstr(5 + (i as int));
8082
auto dst_off = wstr(1 + (i as int));
81-
auto m = vec("movl " + src_off + "(%ebp),%edx",
82-
"movl %edx," + dst_off + "(%esp)");
83+
auto m = vec("movl " + src_off + "(%ebp),%eax",
84+
"movl %eax," + dst_off + "(%esp)");
8385
ret _str.connect(m, "\n\t");
8486
}
8587

@@ -88,8 +90,7 @@ fn upcall_glue(int n_args) -> vec[str] {
8890
ret
8991
save_callee_saves()
9092

91-
+ vec("movl %esp, %ebp # ebp = rust_sp",
92-
"movl 20(%esp), %ecx # ecx = rust_task")
93+
+ vec("movl %esp, %ebp # ebp = rust_sp")
9394

9495
+ store_esp_to_rust_sp()
9596
+ load_esp_from_runtime_sp()
@@ -100,9 +101,9 @@ fn upcall_glue(int n_args) -> vec[str] {
100101

101102
+ _vec.init_fn[str](carg, n_args as uint)
102103

103-
+ vec("movl 24(%ebp), %edx # edx = callee",
104+
+ vec("movl %ecx, %edi # save task from ecx to edi",
104105
"call *%edx # call *%edx",
105-
"movl 20(%ebp), %ecx # edx = rust_task")
106+
"movl %edi, %ecx # restore edi-saved task to ecx")
106107

107108
+ load_esp_from_rust_sp()
108109
+ restore_callee_saves()

trunk/src/comp/lib/llvm.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,15 @@ obj builder(BuilderRef B) {
10261026
_str.buf(""));
10271027
}
10281028

1029+
fn FastCall(ValueRef Fn, vec[ValueRef] Args) -> ValueRef {
1030+
auto v = llvm.LLVMBuildCall(B, Fn,
1031+
_vec.buf[ValueRef](Args),
1032+
_vec.len[ValueRef](Args),
1033+
_str.buf(""));
1034+
llvm.LLVMSetInstructionCallConv(v, LLVMFastCallConv);
1035+
ret v;
1036+
}
1037+
10291038
fn Select(ValueRef If, ValueRef Then, ValueRef Else) -> ValueRef {
10301039
ret llvm.LLVMBuildSelect(B, If, Then, Else, _str.buf(""));
10311040
}

trunk/src/comp/middle/trans.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ fn decl_upcall(ModuleRef llmod, uint _n) -> ValueRef {
375375
T_int()) // callee
376376
+ _vec.init_elt[TypeRef](T_int(), n as uint);
377377

378-
ret decl_cdecl_fn(llmod, s, args, T_int());
378+
ret decl_fastcall_fn(llmod, s, args, T_int());
379379
}
380380

381381
fn get_upcall(@trans_ctxt cx, str name, int n_args) -> ValueRef {
@@ -400,8 +400,7 @@ fn trans_upcall(@block_ctxt cx, str name, vec[ValueRef] args) -> result {
400400
for (ValueRef a in args) {
401401
call_args += cx.build.ZExtOrBitCast(a, T_int());
402402
}
403-
404-
ret res(cx, cx.build.Call(llglue, call_args));
403+
ret res(cx, cx.build.FastCall(llglue, call_args));
405404
}
406405

407406
fn trans_non_gc_free(@block_ctxt cx, ValueRef v) -> result {
@@ -941,10 +940,8 @@ impure fn trans_expr(@block_ctxt cx, &ast.expr e) -> result {
941940
auto args_res = trans_exprs(f_res._0.bcx, args);
942941
auto llargs = vec(cx.fcx.lltaskptr);
943942
llargs += args_res._1;
944-
auto call_val = args_res._0.build.Call(f_res._0.val, llargs);
945-
llvm.LLVMSetInstructionCallConv(call_val,
946-
lib.llvm.LLVMFastCallConv);
947-
ret res(args_res._0, call_val);
943+
ret res(args_res._0,
944+
args_res._0.build.FastCall(f_res._0.val, llargs));
948945
}
949946

950947
}

0 commit comments

Comments
 (0)