about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-10-14 20:54:11 +0200
committerMarijn Haverbeke <marijnh@gmail.com>2011-10-20 13:15:09 +0200
commite927df17f7f9c150fcbfd566927ad29ff5eb6f15 (patch)
tree0811b3951844240012eac5d08a59298474b86334 /src
parent243c5c34790eaba815c2786009b10c31bc04c63d (diff)
downloadrust-e927df17f7f9c150fcbfd566927ad29ff5eb6f15.tar.gz
rust-e927df17f7f9c150fcbfd566927ad29ff5eb6f15.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/comp/middle/trans.rs2
-rw-r--r--src/rt/main.ll.in23
-rw-r--r--src/rt/rust_builtin.cpp9
-rw-r--r--src/rt/rust_task.cpp16
-rw-r--r--src/rt/rustrt.def.in1
5 files changed, 10 insertions, 41 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 7b7926a8300..e750b79fda6 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 6b0454cc31f..a953ef90444 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 314e85eecc4..bfa598b5152 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 97d68e6be39..a764856343b 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 d7caebe41a1..69dda53b8bf 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