rt: Remove upcall_shared_malloc/free/realloc
This commit is contained in:
parent
80dc2e11a1
commit
a2bbdd3f52
src
rt
rustc
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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.
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user