about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-05-25 17:22:14 -0700
committerBrian Anderson <banderson@mozilla.com>2012-05-30 21:23:34 -0700
commita2bbdd3f52a71beabc1beb964772d30045cbe949 (patch)
treeca1f96956b6e304ba31456b9c5ac085dafe3b06b /src
parent80dc2e11a12c0a77447b74ef3fea3eb3ba44faaa (diff)
downloadrust-a2bbdd3f52a71beabc1beb964772d30045cbe949.tar.gz
rust-a2bbdd3f52a71beabc1beb964772d30045cbe949.zip
rt: Remove upcall_shared_malloc/free/realloc
Diffstat (limited to 'src')
-rw-r--r--src/rt/rust_task.cpp5
-rw-r--r--src/rt/rust_upcall.cpp75
-rw-r--r--src/rt/rust_upcall.h5
-rw-r--r--src/rt/rustrt.def.in4
-rw-r--r--src/rustc/back/upcall.rs10
-rw-r--r--src/rustc/middle/trans/base.rs16
-rw-r--r--src/rustc/middle/trans/common.rs2
-rw-r--r--src/rustc/middle/trans/tvec.rs4
8 files changed, 6 insertions, 115 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index 2331cccd590..5299de0ed34 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -7,7 +7,6 @@
 
 #include "rust_task.h"
 #include "rust_cc.h"
-#include "rust_upcall.h"
 #include "rust_env.h"
 #include "rust_port.h"
 
@@ -130,6 +129,8 @@ cleanup_task(cleanup_args *args) {
     }
 }
 
+extern "C" CDECL void upcall_exchange_free(void *ptr);
+
 // This runs on the Rust stack
 void task_start_wrapper(spawn_args *a)
 {
@@ -161,7 +162,7 @@ void task_start_wrapper(spawn_args *a)
         // free the environment (which should be a unique closure).
         const type_desc *td = env->td;
         td->drop_glue(NULL, NULL, td->first_param, box_body(env));
-        upcall_shared_free(env);
+        upcall_exchange_free(env);
     }
 
     // The cleanup work needs lots of stack
diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp
index 667a511debf..01606b37903 100644
--- a/src/rt/rust_upcall.cpp
+++ b/src/rt/rust_upcall.cpp
@@ -318,81 +318,6 @@ upcall_validate_box(rust_opaque_box* ptr) {
     }
 }
 
-/**********************************************************************
- * Allocate an object in the exchange heap.
- */
-
-struct s_shared_malloc_args {
-    uintptr_t retval;
-    size_t nbytes;
-};
-
-extern "C" CDECL void
-upcall_s_shared_malloc(s_shared_malloc_args *args) {
-    rust_task *task = rust_get_current_task();
-    LOG_UPCALL_ENTRY(task);
-
-    LOG(task, mem, "upcall shared_malloc(%" PRIdPTR ")", args->nbytes);
-    void *p = task->kernel->malloc(args->nbytes, "shared malloc");
-    memset(p, '\0', args->nbytes);
-    LOG(task, mem, "upcall shared_malloc(%" PRIdPTR ") = 0x%" PRIxPTR,
-        args->nbytes, (uintptr_t)p);
-    args->retval = (uintptr_t) p;
-}
-
-extern "C" CDECL uintptr_t
-upcall_shared_malloc(size_t nbytes) {
-    s_shared_malloc_args args = {0, nbytes};
-    UPCALL_SWITCH_STACK(&args, upcall_s_shared_malloc);
-    return args.retval;
-}
-
-/**********************************************************************
- * Called whenever an object in the exchange heap is freed.
- */
-
-struct s_shared_free_args {
-    void *ptr;
-};
-
-extern "C" CDECL void
-upcall_s_shared_free(s_shared_free_args *args) {
-    rust_task *task = rust_get_current_task();
-    LOG_UPCALL_ENTRY(task);
-
-    rust_sched_loop *sched_loop = task->sched_loop;
-    DLOG(sched_loop, mem,
-             "upcall shared_free(0x%" PRIxPTR")",
-             (uintptr_t)args->ptr);
-    task->kernel->free(args->ptr);
-}
-
-extern "C" CDECL void
-upcall_shared_free(void* ptr) {
-    s_shared_free_args args = {ptr};
-    UPCALL_SWITCH_STACK(&args, upcall_s_shared_free);
-}
-
-struct s_shared_realloc_args {
-    void *retval;
-    void *ptr;
-    size_t size;
-};
-
-extern "C" CDECL void
-upcall_s_shared_realloc(s_shared_realloc_args *args) {
-    rust_task *task = rust_get_current_task();
-    LOG_UPCALL_ENTRY(task);
-    args->retval = task->kernel->realloc(args->ptr, args->size);
-}
-
-extern "C" CDECL void *
-upcall_shared_realloc(void *ptr, size_t size) {
-    s_shared_realloc_args args = {NULL, ptr, size};
-    UPCALL_SWITCH_STACK(&args, upcall_s_shared_realloc);
-    return args.retval;
-}
-
 /**********************************************************************/
 
 struct s_str_new_uniq_args {
diff --git a/src/rt/rust_upcall.h b/src/rt/rust_upcall.h
index 0030ef19b36..b2b2db20674 100644
--- a/src/rt/rust_upcall.h
+++ b/src/rt/rust_upcall.h
@@ -1,9 +1,4 @@
-
 #ifndef RUST_UPCALL_H
 #define RUST_UPCALL_H
 
-// Upcalls used from C code on occasion:
-
-extern "C" CDECL void upcall_shared_free(void* ptr);
-
 #endif
diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in
index 7c04902de57..8a627795850 100644
--- a/src/rt/rustrt.def.in
+++ b/src/rt/rustrt.def.in
@@ -74,10 +74,6 @@ upcall_validate_box
 upcall_log_type
 upcall_malloc
 upcall_rust_personality
-upcall_s_shared_malloc
-upcall_shared_malloc
-upcall_shared_free
-upcall_shared_realloc
 upcall_vec_grow
 upcall_str_new
 upcall_str_new_uniq
diff --git a/src/rustc/back/upcall.rs b/src/rustc/back/upcall.rs
index 6430632d5c0..33fec5fab03 100644
--- a/src/rustc/back/upcall.rs
+++ b/src/rustc/back/upcall.rs
@@ -16,9 +16,6 @@ type upcalls =
      exchange_malloc_dyn: ValueRef,
      exchange_free: ValueRef,
      validate_box: ValueRef,
-     shared_malloc: ValueRef,
-     shared_free: ValueRef,
-     shared_realloc: ValueRef,
      mark: ValueRef,
      vec_grow: ValueRef,
      str_new_uniq: ValueRef,
@@ -75,13 +72,6 @@ fn declare_upcalls(targ_cfg: @session::config,
               nothrow(dv("exchange_free", [T_ptr(T_i8())])),
           validate_box:
               nothrow(dv("validate_box", [T_ptr(T_i8())])),
-          shared_malloc:
-              nothrow(d("shared_malloc", [size_t], T_ptr(T_i8()))),
-          shared_free:
-              nothrow(dv("shared_free", [T_ptr(T_i8())])),
-          shared_realloc:
-              nothrow(d("shared_realloc", [T_ptr(T_i8()), size_t],
-                        T_ptr(T_i8()))),
           mark:
               d("mark", [T_ptr(T_i8())], int_t),
           vec_grow:
diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs
index 8423aebd979..23884dd0375 100644
--- a/src/rustc/middle/trans/base.rs
+++ b/src/rustc/middle/trans/base.rs
@@ -236,13 +236,6 @@ fn trans_free(cx: block, v: ValueRef) -> block {
     cx
 }
 
-fn trans_shared_free(cx: block, v: ValueRef) -> block {
-    let _icx = cx.insn_ctxt("trans_shared_free");
-    Call(cx, cx.ccx().upcalls.shared_free,
-         [PointerCast(cx, v, T_ptr(T_i8()))]);
-    ret cx;
-}
-
 fn trans_unique_free(cx: block, v: ValueRef) -> block {
     let _icx = cx.insn_ctxt("trans_shared_free");
     Call(cx, cx.ccx().upcalls.exchange_free,
@@ -333,15 +326,6 @@ fn GEP_enum(bcx: block, llblobptr: ValueRef, enum_id: ast::def_id,
     GEPi(bcx, typed_blobptr, [0u, ix])
 }
 
-// trans_shared_malloc: expects a type indicating which pointer type we want
-// and a size indicating how much space we want malloc'd.
-fn shared_malloc(cx: block, llptr_ty: TypeRef, llsize: ValueRef)
-   -> ValueRef {
-    let _icx = cx.insn_ctxt("opaque_shared_malloc");
-    let rval = Call(cx, cx.ccx().upcalls.shared_malloc, [llsize]);
-    PointerCast(cx, rval, llptr_ty)
-}
-
 // Returns a pointer to the body for the box. The box may be an opaque
 // box. The result will be casted to the type of body_t, if it is statically
 // known.
diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs
index b49272e07b2..194a1993ce3 100644
--- a/src/rustc/middle/trans/common.rs
+++ b/src/rustc/middle/trans/common.rs
@@ -271,7 +271,7 @@ fn add_clean_temp_mem(cx: block, val: ValueRef, ty: ty::t) {
     }
 }
 fn add_clean_free(cx: block, ptr: ValueRef, shared: bool) {
-    let free_fn = if shared { bind base::trans_shared_free(_, ptr) }
+    let free_fn = if shared { bind base::trans_unique_free(_, ptr) }
                   else { bind base::trans_free(_, ptr) };
     in_scope_cx(cx) {|info|
         info.cleanups += [clean_temp(ptr, free_fn,
diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs
index a9b78918295..e37806dccf8 100644
--- a/src/rustc/middle/trans/tvec.rs
+++ b/src/rustc/middle/trans/tvec.rs
@@ -2,7 +2,7 @@ import syntax::ast;
 import driver::session::session;
 import lib::llvm::{ValueRef, TypeRef};
 import back::abi;
-import base::{call_memmove, shared_malloc,
+import base::{call_memmove,
                INIT, copy_val, load_if_immediate, get_tydesc,
                sub_block, do_spill_noroot,
                dest, bcx_icx};
@@ -115,7 +115,7 @@ fn make_free_glue(bcx: block, vptr: ValueRef, vec_ty: ty::t) ->
         let bcx = if ty::type_needs_drop(tcx, unit_ty) {
             iter_vec(bcx, vptr, vec_ty, base::drop_ty)
         } else { bcx };
-        base::trans_shared_free(bcx, vptr)
+        base::trans_unique_free(bcx, vptr)
     }
 }