about summary refs log tree commit diff
path: root/src/rt/rust_upcall.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-02-16 21:48:28 -0800
committerBrian Anderson <banderson@mozilla.com>2012-02-17 11:37:17 -0800
commite0b2fd84173c87d01b73ff38b8d353595207af56 (patch)
tree33f146ca4338e9e76e1015ae68b7c34368d124ca /src/rt/rust_upcall.cpp
parent853e2003b8383749596e5b7b153186e2eef32455 (diff)
downloadrust-e0b2fd84173c87d01b73ff38b8d353595207af56.tar.gz
rust-e0b2fd84173c87d01b73ff38b8d353595207af56.zip
rt: Simplify upcall_vec_push
Diffstat (limited to 'src/rt/rust_upcall.cpp')
-rw-r--r--src/rt/rust_upcall.cpp34
1 files changed, 11 insertions, 23 deletions
diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp
index 2eefe02aa2e..f4f9ab8b327 100644
--- a/src/rt/rust_upcall.cpp
+++ b/src/rt/rust_upcall.cpp
@@ -450,35 +450,23 @@ copy_elements(rust_task *task, type_desc *elem_t,
     }
 }
 
-/**********************************************************************/
-
-struct s_vec_push_args {
-    rust_vec** vp;
-    type_desc* elt_ty;
-    void* elt;
-};
-
 extern "C" CDECL void
-upcall_s_vec_push(s_vec_push_args *args) {
+upcall_vec_push(rust_vec** vp, type_desc* elt_ty, void* elt) {
+    // NB: This runs entirely on the Rust stack because it invokes take glue
+
     rust_task *task = rust_task_thread::get_task();
+
     LOG_UPCALL_ENTRY(task);
-    size_t new_sz = (*args->vp)->fill + args->elt_ty->size;
-    reserve_vec(task, args->vp, new_sz);
-    rust_vec* v = *args->vp;
-    copy_elements(task, args->elt_ty, &v->data[0] + v->fill, 
-                  args->elt, args->elt_ty->size);
-    v->fill += args->elt_ty->size;
-}
 
-extern "C" CDECL void
-upcall_vec_push(rust_vec** vp, type_desc* elt_ty, void* elt) {
-    // FIXME: Switching stacks here causes crashes, probably
-    // because this upcall calls take glue
-    s_vec_push_args args = {vp, elt_ty, elt};
-    upcall_s_vec_push(&args);
+    size_t new_sz = (*vp)->fill + elt_ty->size;
+    reserve_vec(task, vp, new_sz);
+    rust_vec* v = *vp;
+    copy_elements(task, elt_ty, &v->data[0] + v->fill,
+                  elt, elt_ty->size);
+    v->fill += elt_ty->size;
+
 
     // Do the stack check to make sure this op, on the Rust stack, is behaving
-    rust_task *task = rust_task_thread::get_task();
     task->check_stack_canary();
 }