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
This commit is contained in:
Marijn Haverbeke 2011-10-14 20:54:11 +02:00
parent 243c5c3479
commit e927df17f7
5 changed files with 10 additions and 41 deletions

View File

@ -5662,7 +5662,7 @@ fn create_main(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
let llfty = type_of_fn(ccx, sp, ast::proto_fn, false, false, let llfty = type_of_fn(ccx, sp, ast::proto_fn, false, false,
[vecarg_ty], nt, 0u); [vecarg_ty], nt, 0u);
let llfdecl = decl_fn(ccx.llmod, "_rust_main", 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); let fcx = new_fn_ctxt(new_local_ctxt(ccx), sp, llfdecl);

View File

@ -16,28 +16,9 @@
declare i32 @rust_start(i32, i32, i32, i32) declare i32 @rust_start(i32, i32, i32, i32)
declare external fastcc void @_rust_main(i1* nocapture, %task*, %2* nocapture, %vec*) declare external 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*)*);
define i32 @"MAIN"(i32, i32) { 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 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_wrap to i32), i32 %0, i32 %1, i32 ptrtoint (%0* @_rust_crate_map_toplevel to i32))
ret i32 %result ret i32 %result
} }

View File

@ -472,13 +472,18 @@ struct fn_env_pair {
intptr_t env; 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 extern "C" CDECL void
start_task(void *unused_task, rust_task_id id, fn_env_pair *f) { start_task(void *unused_task, rust_task_id id, fn_env_pair *f) {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
rust_task *target = task->kernel->get_task_by_id(id); 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(); target->deref();
} }

View File

@ -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 void
rust_task::start(uintptr_t spawnee_fn, rust_task::start(uintptr_t spawnee_fn,
uintptr_t args, uintptr_t args,

View File

@ -54,7 +54,6 @@ rust_run_program
rust_start rust_start
rust_getcwd rust_getcwd
set_min_stack set_min_stack
set_spawn_wrapper
sched_threads sched_threads
size_of size_of
squareroot squareroot