Remove unused TyDesc parameter from the glue functions
To remove the environment pointer, support for function pointers without an environment argument is needed (i.e. a fixed version of #6661).
This commit is contained in:
parent
1b76bac41d
commit
e2f1049bd5
9 changed files with 66 additions and 37 deletions
|
|
@ -115,6 +115,19 @@ fn round_up_to(base: uint, align: uint) -> uint {
|
|||
(base + (align - 1)) & !(align - 1)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
|
||||
// This function should be inlined when stage0 is gone
|
||||
((*tydesc).drop_glue)(data);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(stage0)]
|
||||
unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
|
||||
((*tydesc).drop_glue)(0 as **TyDesc, data);
|
||||
}
|
||||
|
||||
// Walk down a chunk, running the destructors for any objects stored
|
||||
// in it.
|
||||
unsafe fn destroy_chunk(chunk: &Chunk) {
|
||||
|
|
@ -134,8 +147,7 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
|
|||
//debug!("freeing object: idx = %u, size = %u, align = %u, done = %b",
|
||||
// start, size, align, is_done);
|
||||
if is_done {
|
||||
((*tydesc).drop_glue)(&tydesc as **TyDesc,
|
||||
ptr::offset(buf, start) as *i8);
|
||||
call_drop_glue(tydesc, ptr::offset(buf, start) as *i8);
|
||||
}
|
||||
|
||||
// Find where the next tydesc lives
|
||||
|
|
|
|||
|
|
@ -8,9 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
|
||||
|
||||
pub static rc_base_field_refcnt: uint = 0u;
|
||||
|
||||
pub static task_field_refcnt: uint = 0u;
|
||||
|
|
@ -69,14 +66,4 @@ pub static vec_elt_elems: uint = 2u;
|
|||
pub static slice_elt_base: uint = 0u;
|
||||
pub static slice_elt_len: uint = 1u;
|
||||
|
||||
pub static worst_case_glue_call_args: uint = 7u;
|
||||
|
||||
pub static abi_version: uint = 1u;
|
||||
|
||||
pub fn memcpy_glue_name() -> ~str { return ~"rust_memcpy_glue"; }
|
||||
|
||||
pub fn bzero_glue_name() -> ~str { return ~"rust_bzero_glue"; }
|
||||
|
||||
pub fn yield_glue_name() -> ~str { return ~"rust_yield_glue"; }
|
||||
|
||||
pub fn no_op_type_glue_name() -> ~str { return ~"rust_no_op_type_glue"; }
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ pub fn lazily_emit_tydesc_glue(ccx: @mut CrateContext,
|
|||
field: uint,
|
||||
ti: @mut tydesc_info) {
|
||||
let _icx = push_ctxt("lazily_emit_tydesc_glue");
|
||||
let llfnty = type_of_glue_fn(ccx);
|
||||
let llfnty = Type::glue_fn();
|
||||
|
||||
if lazily_emit_simplified_tydesc_glue(ccx, field, ti) {
|
||||
return;
|
||||
|
|
@ -338,9 +338,7 @@ pub fn call_tydesc_glue_full(bcx: block,
|
|||
}
|
||||
};
|
||||
|
||||
Call(bcx, llfn, [C_null(Type::nil().ptr_to()),
|
||||
C_null(bcx.ccx().tydesc_type.ptr_to().ptr_to()),
|
||||
llrawptr]);
|
||||
Call(bcx, llfn, [C_null(Type::nil().ptr_to()), llrawptr]);
|
||||
}
|
||||
|
||||
// See [Note-arg-mode]
|
||||
|
|
@ -680,7 +678,7 @@ pub fn make_generic_glue_inner(ccx: @mut CrateContext,
|
|||
|
||||
let bcx = top_scope_block(fcx, None);
|
||||
let lltop = bcx.llbb;
|
||||
let rawptr0_arg = fcx.arg_pos(1u);
|
||||
let rawptr0_arg = fcx.arg_pos(0u);
|
||||
let llrawptr0 = unsafe { llvm::LLVMGetParam(llfn, rawptr0_arg as c_uint) };
|
||||
let llty = type_of(ccx, t);
|
||||
let llrawptr0 = PointerCast(bcx, llrawptr0, llty.ptr_to());
|
||||
|
|
@ -715,7 +713,7 @@ pub fn emit_tydescs(ccx: &mut CrateContext) {
|
|||
let _icx = push_ctxt("emit_tydescs");
|
||||
// As of this point, allow no more tydescs to be created.
|
||||
ccx.finished_tydescs = true;
|
||||
let glue_fn_ty = Type::generic_glue_fn(ccx);
|
||||
let glue_fn_ty = Type::generic_glue_fn(ccx).ptr_to();
|
||||
let tyds = &mut ccx.tydescs;
|
||||
for tyds.each_value |&val| {
|
||||
let ti = val;
|
||||
|
|
@ -782,7 +780,3 @@ pub fn emit_tydescs(ccx: &mut CrateContext) {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub fn type_of_glue_fn(ccx: &CrateContext) -> Type {
|
||||
Type::glue_fn(ccx.tydesc_type)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ use middle::trans::base;
|
|||
|
||||
use syntax::ast;
|
||||
use syntax::abi::{Architecture, X86, X86_64, Arm, Mips};
|
||||
use back::abi;
|
||||
|
||||
use core::vec;
|
||||
use core::cast;
|
||||
|
|
@ -189,22 +188,20 @@ impl Type {
|
|||
None => ()
|
||||
}
|
||||
|
||||
let ty = Type::glue_fn(cx.tydesc_type).ptr_to();
|
||||
let ty = Type::glue_fn();
|
||||
cx.tn.associate_type("glue_fn", &ty);
|
||||
|
||||
return ty;
|
||||
}
|
||||
|
||||
pub fn glue_fn(tydesc: Type) -> Type {
|
||||
let tydescpp = tydesc.ptr_to().ptr_to();
|
||||
Type::func([ Type::nil().ptr_to(), tydescpp, Type::i8p() ],
|
||||
pub fn glue_fn() -> Type {
|
||||
Type::func([ Type::nil().ptr_to(), Type::i8p() ],
|
||||
&Type::void())
|
||||
}
|
||||
|
||||
pub fn tydesc(arch: Architecture) -> Type {
|
||||
let mut tydesc = Type::named_struct("tydesc");
|
||||
let pvoid = Type::i8p();
|
||||
let glue_fn_ty = Type::glue_fn(tydesc).ptr_to();
|
||||
let glue_fn_ty = Type::glue_fn().ptr_to();
|
||||
|
||||
let int_ty = Type::int(arch);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,10 @@
|
|||
#[doc(hidden)];
|
||||
|
||||
use libc::{c_char, intptr_t, uintptr_t};
|
||||
use ptr::{mut_null, to_unsafe_ptr};
|
||||
use ptr::{mut_null};
|
||||
use repr::BoxRepr;
|
||||
use cast::transmute;
|
||||
use unstable::intrinsics::TyDesc;
|
||||
#[cfg(not(test))] use unstable::lang::clear_task_borrow_list;
|
||||
|
||||
/**
|
||||
|
|
@ -158,6 +159,19 @@ fn debug_mem() -> bool {
|
|||
false
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
|
||||
// This function should be inlined when stage0 is gone
|
||||
((*tydesc).drop_glue)(data);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(stage0)]
|
||||
unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
|
||||
((*tydesc).drop_glue)(0 as **TyDesc, data);
|
||||
}
|
||||
|
||||
/// Destroys all managed memory (i.e. @ boxes) held by the current task.
|
||||
#[cfg(not(test))]
|
||||
#[lang="annihilate"]
|
||||
|
|
@ -201,7 +215,7 @@ pub unsafe fn annihilate() {
|
|||
if !uniq {
|
||||
let tydesc = (*box).header.type_desc;
|
||||
let data = transmute(&(*box).data);
|
||||
((*tydesc).drop_glue)(to_unsafe_ptr(&tydesc), data);
|
||||
call_drop_glue(tydesc, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -316,6 +316,19 @@ fn expect_sentinel() -> bool { true }
|
|||
#[cfg(nogc)]
|
||||
fn expect_sentinel() -> bool { false }
|
||||
|
||||
#[inline]
|
||||
#[cfg(not(stage0))]
|
||||
unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
|
||||
// This function should be inlined when stage0 is gone
|
||||
((*tydesc).drop_glue)(data);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(stage0)]
|
||||
unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
|
||||
((*tydesc).drop_glue)(0 as **TyDesc, data);
|
||||
}
|
||||
|
||||
// Entry point for GC-based cleanup. Walks stack looking for exchange
|
||||
// heap and stack allocations requiring drop, and runs all
|
||||
// destructors.
|
||||
|
|
@ -359,7 +372,7 @@ pub fn cleanup_stack_for_failure() {
|
|||
// FIXME #4420: Destroy this box
|
||||
// FIXME #4330: Destroy this box
|
||||
} else {
|
||||
((*tydesc).drop_glue)(&tydesc as **TyDesc, *root as *i8);
|
||||
call_drop_glue(tydesc, *root as *i8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@ A quick refresher on memory ordering:
|
|||
#[cfg(test)]
|
||||
pub use realstd::unstable::intrinsics::{TyDesc, Opaque, TyVisitor};
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
pub type GlueFn = extern "Rust" fn(*i8);
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub type GlueFn = extern "Rust" fn(**TyDesc, *i8);
|
||||
|
||||
// NB: this has to be kept in sync with the Rust ABI.
|
||||
|
|
|
|||
|
|
@ -183,7 +183,11 @@ void task_start_wrapper(spawn_args *a)
|
|||
if(env) {
|
||||
// free the environment (which should be a unique closure).
|
||||
const type_desc *td = env->td;
|
||||
td->drop_glue(NULL, NULL, box_body(env));
|
||||
td->drop_glue(NULL,
|
||||
#ifdef _RUST_STAGE0
|
||||
NULL,
|
||||
#endif
|
||||
box_body(env));
|
||||
task->kernel->region()->free(env);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,11 @@ typedef void (*CDECL spawn_fn)(rust_opaque_box*, void *);
|
|||
|
||||
struct type_desc;
|
||||
|
||||
typedef void CDECL (glue_fn)(void *, const type_desc **, void *);
|
||||
typedef void CDECL (glue_fn)(void *,
|
||||
#ifdef _RUST_STAGE0
|
||||
const type_desc **,
|
||||
#endif
|
||||
void *);
|
||||
|
||||
// Corresponds to the boxed data in the @ region. The body follows the
|
||||
// header; you can obtain a ptr via box_body() below.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue