Switch upcall glues to fastcall as well.

This commit is contained in:
Graydon Hoare 2010-11-14 13:41:10 -08:00
parent 4cbef9d8a1
commit a352efadad
3 changed files with 24 additions and 17 deletions

View File

@ -70,16 +70,18 @@ fn upcall_glue(int n_args) -> vec[str] {
/*
* 0, 4, 8, 12 are callee-saves
* 16 is retpc
* 20 is taskptr
* 24 is callee
* 28 .. (7+i) * 4 are args
* 20 .. (5+i) * 4 are args
*
* ecx is taskptr
* edx is callee
*
*/
fn copy_arg(uint i) -> str {
auto src_off = wstr(7 + (i as int));
auto src_off = wstr(5 + (i as int));
auto dst_off = wstr(1 + (i as int));
auto m = vec("movl " + src_off + "(%ebp),%edx",
"movl %edx," + dst_off + "(%esp)");
auto m = vec("movl " + src_off + "(%ebp),%eax",
"movl %eax," + dst_off + "(%esp)");
ret _str.connect(m, "\n\t");
}
@ -88,8 +90,7 @@ fn upcall_glue(int n_args) -> vec[str] {
ret
save_callee_saves()
+ vec("movl %esp, %ebp # ebp = rust_sp",
"movl 20(%esp), %ecx # ecx = rust_task")
+ vec("movl %esp, %ebp # ebp = rust_sp")
+ store_esp_to_rust_sp()
+ load_esp_from_runtime_sp()
@ -100,9 +101,9 @@ fn upcall_glue(int n_args) -> vec[str] {
+ _vec.init_fn[str](carg, n_args as uint)
+ vec("movl 24(%ebp), %edx # edx = callee",
+ vec("movl %ecx, %edi # save task from ecx to edi",
"call *%edx # call *%edx",
"movl 20(%ebp), %ecx # edx = rust_task")
"movl %edi, %ecx # restore edi-saved task to ecx")
+ load_esp_from_rust_sp()
+ restore_callee_saves()

View File

@ -1026,6 +1026,15 @@ obj builder(BuilderRef B) {
_str.buf(""));
}
fn FastCall(ValueRef Fn, vec[ValueRef] Args) -> ValueRef {
auto v = llvm.LLVMBuildCall(B, Fn,
_vec.buf[ValueRef](Args),
_vec.len[ValueRef](Args),
_str.buf(""));
llvm.LLVMSetInstructionCallConv(v, LLVMFastCallConv);
ret v;
}
fn Select(ValueRef If, ValueRef Then, ValueRef Else) -> ValueRef {
ret llvm.LLVMBuildSelect(B, If, Then, Else, _str.buf(""));
}

View File

@ -375,7 +375,7 @@ fn decl_upcall(ModuleRef llmod, uint _n) -> ValueRef {
T_int()) // callee
+ _vec.init_elt[TypeRef](T_int(), n as uint);
ret decl_cdecl_fn(llmod, s, args, T_int());
ret decl_fastcall_fn(llmod, s, args, T_int());
}
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 {
for (ValueRef a in args) {
call_args += cx.build.ZExtOrBitCast(a, T_int());
}
ret res(cx, cx.build.Call(llglue, call_args));
ret res(cx, cx.build.FastCall(llglue, call_args));
}
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 {
auto args_res = trans_exprs(f_res._0.bcx, args);
auto llargs = vec(cx.fcx.lltaskptr);
llargs += args_res._1;
auto call_val = args_res._0.build.Call(f_res._0.val, llargs);
llvm.LLVMSetInstructionCallConv(call_val,
lib.llvm.LLVMFastCallConv);
ret res(args_res._0, call_val);
ret res(args_res._0,
args_res._0.build.FastCall(f_res._0.val, llargs));
}
}