From af4d6ae76b05d4edb9d7074b971600a447c9c9a4 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 22 Feb 2011 16:37:01 -0800 Subject: Add ABI tagging to crates, adjust rustc output and runtime stack-frame setup so access to argv works. --- src/comp/back/abi.rs | 3 +++ src/comp/back/x86.rs | 4 ++-- src/comp/middle/trans.rs | 13 +++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src/comp') diff --git a/src/comp/back/abi.rs b/src/comp/back/abi.rs index 82a85a6c..f41f6e20 100644 --- a/src/comp/back/abi.rs +++ b/src/comp/back/abi.rs @@ -60,6 +60,9 @@ const int worst_case_glue_call_args = 7; const int n_upcall_glues = 7; +const int abi_x86_rustboot_cdecl = 1; +const int abi_x86_rustc_fastcall = 2; + fn memcpy_glue_name() -> str { ret "rust_memcpy_glue"; } diff --git a/src/comp/back/x86.rs b/src/comp/back/x86.rs index 907cb32e..10227df7 100644 --- a/src/comp/back/x86.rs +++ b/src/comp/back/x86.rs @@ -98,12 +98,12 @@ fn rust_activate_glue() -> vec[str] { * | esi | * | ebx | <-- current task->rust_sp == current esp * - * + * * This is a problem. If we return to "esp <- task->rust_sp" it * will push esp back down by 5 words. This manifests as a rust * stack that grows by 5 words on each yield/reactivate. Not * good. - * + * * So what we do here is just adjust task->rust_sp up 5 words as * well, to mirror the movement in esp we're about to * perform. That way the "esp <- task->rust_sp" we 'ret' to below diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 9da7e009..4a672f49 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -345,7 +345,8 @@ fn T_crate(type_names tn) -> TypeRef { T_int(), // size_t main_exit_task_glue_off T_int(), // int n_rust_syms T_int(), // int n_c_syms - T_int() // int n_libs + T_int(), // int n_libs + T_int() // uintptr_t abi_tag )); tn.associate(s, t); ret t; @@ -4545,7 +4546,7 @@ fn trans_exit_task_glue(@crate_ctxt cx) { let vec[ValueRef] V_args = vec(); auto llfn = cx.glues.exit_task_glue; - let ValueRef lltaskptr = llvm.LLVMGetParam(llfn, 0u); + let ValueRef lltaskptr = llvm.LLVMGetParam(llfn, 3u); auto fcx = @rec(llfn=llfn, lltaskptr=lltaskptr, llenv=C_null(T_opaque_closure_ptr(cx.tn)), @@ -4596,7 +4597,8 @@ fn create_crate_constant(@crate_ctxt cx) { exit_task_glue_off, // size_t main_exit_task_glue_off C_null(T_int()), // int n_rust_syms C_null(T_int()), // int n_c_syms - C_null(T_int()) // int n_libs + C_null(T_int()), // int n_libs + C_int(abi.abi_x86_rustc_fastcall) // uintptr_t abi_tag )); llvm.LLVMSetInitializer(cx.crate_ptr, crate_val); @@ -4810,7 +4812,10 @@ fn make_glues(ModuleRef llmod, type_names tn) -> @glue_fns { * this is the signature required to retrieve it. */ exit_task_glue = decl_cdecl_fn(llmod, abi.exit_task_glue_name(), - T_fn(vec(T_taskptr(tn)), + T_fn(vec(T_int(), + T_int(), + T_int(), + T_taskptr(tn)), T_void())), upcall_glues = -- cgit v1.2.3