diff --git a/src/comp/back/x86.rs b/src/comp/back/x86.rs index 0ed79db453c..345603bb710 100644 --- a/src/comp/back/x86.rs +++ b/src/comp/back/x86.rs @@ -212,10 +212,10 @@ fn upcall_glue(int n_args) -> vec[str] { + store_esp_to_rust_sp_second_arg() + load_esp_from_runtime_sp_second_arg() - + vec("subl $" + wstr(n_args + 1) + ", %esp # esp -= args", + + vec("subl $" + wstr(n_args) + ", %esp # esp -= args", "andl $~0xf, %esp # align esp down") - + _vec.init_fn[str](carg, (n_args + 1) as uint) + + _vec.init_fn[str](carg, (n_args) as uint) + vec("movl %edx, %edi # save task from edx to edi", "call *%ecx # call *%ecx", @@ -268,7 +268,7 @@ fn get_module_asm() -> str { rust_yield_glue())) + _vec.init_fn[str](bind decl_upcall_glue(align, prefix, _), - abi.n_upcall_glues as uint); + (abi.n_upcall_glues + 1) as uint); ret _str.connect(glues, "\n\n"); } diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 7bea575f9be..f119681b0c2 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -832,8 +832,7 @@ fn decl_upcall_glue(ModuleRef llmod, type_names tn, uint _n) -> ValueRef { let int n = _n as int; let str s = abi.upcall_glue_name(n); let vec[TypeRef] args = - vec(T_int(), // callee - T_int()) // taskptr + vec(T_int()) // callee + _vec.init_elt[TypeRef](T_int(), n as uint); ret decl_fastcall_fn(llmod, s, T_fn(args, T_int())); @@ -864,7 +863,7 @@ fn trans_upcall2(builder b, @glue_fns glues, ValueRef lltaskptr, &hashmap[str, ValueRef] upcalls, type_names tn, ModuleRef llmod, str name, vec[ValueRef] args) -> ValueRef { - let int n = _vec.len[ValueRef](args) as int; + let int n = (_vec.len[ValueRef](args) as int) + 1; let ValueRef llupcall = get_upcall(upcalls, tn, llmod, name, n); llupcall = llvm.LLVMConstPointerCast(llupcall, T_int()); @@ -6098,7 +6097,7 @@ fn make_glues(ModuleRef llmod, type_names tn) -> @glue_fns { upcall_glues = _vec.init_fn[ValueRef](bind decl_upcall_glue(llmod, tn, _), - abi.n_upcall_glues as uint), + abi.n_upcall_glues + 1 as uint), no_op_type_glue = decl_no_op_type_glue(llmod, tn), memcpy_glue = decl_memcpy_glue(llmod), bzero_glue = decl_bzero_glue(llmod),