From e927df17f7f9c150fcbfd566927ad29ff5eb6f15 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 14 Oct 2011 20:54:11 +0200 Subject: [PATCH] Remove spawn_wrap and main_wrap kludges This isn't needed now that our functions are cdecl (and was apparently only still working by accident). Issue #992 --- src/comp/middle/trans.rs | 2 +- src/rt/main.ll.in | 23 ++--------------------- src/rt/rust_builtin.cpp | 9 +++++++-- src/rt/rust_task.cpp | 16 ---------------- src/rt/rustrt.def.in | 1 - 5 files changed, 10 insertions(+), 41 deletions(-) diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 7b7926a8300f..e750b79fda66 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -5662,7 +5662,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, let llfty = type_of_fn(ccx, sp, ast::proto_fn, false, false, [vecarg_ty], nt, 0u); let llfdecl = decl_fn(ccx.llmod, "_rust_main", - lib::llvm::LLVMFastCallConv, llfty); + lib::llvm::LLVMCCallConv, llfty); let fcx = new_fn_ctxt(new_local_ctxt(ccx), sp, llfdecl); diff --git a/src/rt/main.ll.in b/src/rt/main.ll.in index 6b0454cc31fc..a953ef904448 100644 --- a/src/rt/main.ll.in +++ b/src/rt/main.ll.in @@ -16,28 +16,9 @@ declare i32 @rust_start(i32, i32, i32, i32) -declare external fastcc void @_rust_main(i1* nocapture, %task*, %2* nocapture, %vec*) - -define void @_rust_main_wrap(i1* nocapture, %task *, %2* nocapture, %vec *) -{ - tail call fastcc void @_rust_main(i1* %0, %task *%1, %2* nocapture %2, %vec* %3) - ret void -} - -%nullary_fn = type void (i1*, %task*, %2*) - -define void @_rust_spawn_wrap( - i1* nocapture, %task*, %2* nocapture, %nullary_fn* %f) -{ - call void %f(i1* %0, %task *%1, %2* nocapture %2) - ret void -} - -declare external void @set_spawn_wrapper(void (i1*, %task*, %2*, %nullary_fn*)*); +declare external void @_rust_main(i1* nocapture, %task*, %2* nocapture, %vec*) define i32 @"MAIN"(i32, i32) { - call void @set_spawn_wrapper(void (i1*, %task*, %2*, %nullary_fn*)* @_rust_spawn_wrap) - - %result = tail call i32 @rust_start(i32 ptrtoint (void (i1*, %task*, %2*, %vec*)* @_rust_main_wrap to i32), i32 %0, i32 %1, i32 ptrtoint (%0* @_rust_crate_map_toplevel to i32)) + %result = tail call i32 @rust_start(i32 ptrtoint (void (i1*, %task*, %2*, %vec*)* @_rust_main to i32), i32 %0, i32 %1, i32 ptrtoint (%0* @_rust_crate_map_toplevel to i32)) ret i32 %result } diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 314e85eecc48..bfa598b51520 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -472,13 +472,18 @@ struct fn_env_pair { intptr_t env; }; -extern "C" CDECL uintptr_t get_spawn_wrapper(); +// FIXME This is probably not needed at all anymore. Have to rearrange some +// argument passing to remove it. +void rust_spawn_wrapper(void* retptr, rust_task* taskptr, void* envptr, + void(*func)(void*, rust_task*, void*)) { + func(retptr, taskptr, envptr); +} extern "C" CDECL void start_task(void *unused_task, rust_task_id id, fn_env_pair *f) { rust_task *task = rust_scheduler::get_task(); rust_task *target = task->kernel->get_task_by_id(id); - target->start(get_spawn_wrapper(), f->f, f->env); + target->start((uintptr_t)rust_spawn_wrapper, f->f, f->env); target->deref(); } diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 97d68e6be391..a764856343b2 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -180,22 +180,6 @@ void task_start_wrapper(spawn_args *a) } } -/* We spawn a rust (fastcc) function through a CDECL function - defined in main.ll, which is built as part of each crate. These accessors - allow each rust program to install that function at startup */ - -uintptr_t spawn_wrapper; - -extern "C" CDECL void -set_spawn_wrapper(uintptr_t f) { - spawn_wrapper = f; -} - -extern "C" CDECL uintptr_t -get_spawn_wrapper() { - return spawn_wrapper; -} - void rust_task::start(uintptr_t spawnee_fn, uintptr_t args, diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index d7caebe41a16..69dda53b8bf7 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -54,7 +54,6 @@ rust_run_program rust_start rust_getcwd set_min_stack -set_spawn_wrapper sched_threads size_of squareroot