Rename misleading contains_managed to owns_managed
This commit is contained in:
parent
f3191a450c
commit
3d1f3f4de0
15 changed files with 44 additions and 26 deletions
|
@ -1600,7 +1600,7 @@ fn compile_submatch_continue(mut bcx: @mut Block,
|
||||||
let pat_ty = node_id_type(bcx, pat_id);
|
let pat_ty = node_id_type(bcx, pat_id);
|
||||||
let llbox = Load(bcx, val);
|
let llbox = Load(bcx, val);
|
||||||
let unboxed = match ty::get(pat_ty).sty {
|
let unboxed = match ty::get(pat_ty).sty {
|
||||||
ty::ty_uniq(*) if !ty::type_contents(bcx.tcx(), pat_ty).contains_managed() => llbox,
|
ty::ty_uniq(*) if !ty::type_contents(bcx.tcx(), pat_ty).owns_managed() => llbox,
|
||||||
_ => GEPi(bcx, llbox, [0u, abi::box_field_body])
|
_ => GEPi(bcx, llbox, [0u, abi::box_field_body])
|
||||||
};
|
};
|
||||||
compile_submatch(bcx, enter_uniq(bcx, dm, m, col, val),
|
compile_submatch(bcx, enter_uniq(bcx, dm, m, col, val),
|
||||||
|
@ -2220,7 +2220,7 @@ fn bind_irrefutable_pat(bcx: @mut Block,
|
||||||
let pat_ty = node_id_type(bcx, pat.id);
|
let pat_ty = node_id_type(bcx, pat.id);
|
||||||
let llbox = Load(bcx, val);
|
let llbox = Load(bcx, val);
|
||||||
let unboxed = match ty::get(pat_ty).sty {
|
let unboxed = match ty::get(pat_ty).sty {
|
||||||
ty::ty_uniq(*) if !ty::type_contents(bcx.tcx(), pat_ty).contains_managed() => llbox,
|
ty::ty_uniq(*) if !ty::type_contents(bcx.tcx(), pat_ty).owns_managed() => llbox,
|
||||||
_ => GEPi(bcx, llbox, [0u, abi::box_field_body])
|
_ => GEPi(bcx, llbox, [0u, abi::box_field_body])
|
||||||
};
|
};
|
||||||
bcx = bind_irrefutable_pat(bcx, inner, unboxed, binding_mode);
|
bcx = bind_irrefutable_pat(bcx, inner, unboxed, binding_mode);
|
||||||
|
|
|
@ -409,7 +409,7 @@ pub fn malloc_general(bcx: @mut Block, t: ty::t, heap: heap) -> MallocResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn heap_for_unique(bcx: @mut Block, t: ty::t) -> heap {
|
pub fn heap_for_unique(bcx: @mut Block, t: ty::t) -> heap {
|
||||||
if ty::type_contents(bcx.tcx(), t).contains_managed() {
|
if ty::type_contents(bcx.tcx(), t).owns_managed() {
|
||||||
heap_managed_unique
|
heap_managed_unique
|
||||||
} else {
|
} else {
|
||||||
heap_exchange
|
heap_exchange
|
||||||
|
|
|
@ -156,7 +156,7 @@ pub fn mk_closure_tys(tcx: ty::ctxt,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn heap_for_unique_closure(bcx: @mut Block, t: ty::t) -> heap {
|
fn heap_for_unique_closure(bcx: @mut Block, t: ty::t) -> heap {
|
||||||
if ty::type_contents(bcx.tcx(), t).contains_managed() {
|
if ty::type_contents(bcx.tcx(), t).owns_managed() {
|
||||||
heap_managed_unique
|
heap_managed_unique
|
||||||
} else {
|
} else {
|
||||||
heap_exchange_closure
|
heap_exchange_closure
|
||||||
|
|
|
@ -566,7 +566,7 @@ impl Datum {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if !header && !ty::type_contents(bcx.tcx(), content_ty).contains_managed() {
|
if !header && !ty::type_contents(bcx.tcx(), content_ty).owns_managed() {
|
||||||
let ptr = self.to_value_llval(bcx);
|
let ptr = self.to_value_llval(bcx);
|
||||||
let ty = type_of::type_of(bcx.ccx(), content_ty);
|
let ty = type_of::type_of(bcx.ccx(), content_ty);
|
||||||
let body = PointerCast(bcx, ptr, ty.ptr_to());
|
let body = PointerCast(bcx, ptr, ty.ptr_to());
|
||||||
|
|
|
@ -2060,7 +2060,7 @@ fn type_metadata(cx: &mut CrateContext,
|
||||||
ty::vstore_fixed(len) => {
|
ty::vstore_fixed(len) => {
|
||||||
fixed_vec_metadata(cx, mt.ty, len, usage_site_span)
|
fixed_vec_metadata(cx, mt.ty, len, usage_site_span)
|
||||||
}
|
}
|
||||||
ty::vstore_uniq if ty::type_contents(cx.tcx, mt.ty).contains_managed() => {
|
ty::vstore_uniq if ty::type_contents(cx.tcx, mt.ty).owns_managed() => {
|
||||||
let boxed_vec_metadata = boxed_vec_metadata(cx, mt.ty, usage_site_span);
|
let boxed_vec_metadata = boxed_vec_metadata(cx, mt.ty, usage_site_span);
|
||||||
pointer_type_metadata(cx, t, boxed_vec_metadata)
|
pointer_type_metadata(cx, t, boxed_vec_metadata)
|
||||||
}
|
}
|
||||||
|
@ -2077,7 +2077,7 @@ fn type_metadata(cx: &mut CrateContext,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ty::ty_uniq(ref mt) if ty::type_contents(cx.tcx, mt.ty).contains_managed() => {
|
ty::ty_uniq(ref mt) if ty::type_contents(cx.tcx, mt.ty).owns_managed() => {
|
||||||
create_pointer_to_box_metadata(cx, t, mt.ty)
|
create_pointer_to_box_metadata(cx, t, mt.ty)
|
||||||
},
|
},
|
||||||
ty::ty_uniq(ref mt) |
|
ty::ty_uniq(ref mt) |
|
||||||
|
|
|
@ -603,7 +603,7 @@ pub fn declare_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info {
|
||||||
|
|
||||||
let has_header = match ty::get(t).sty {
|
let has_header = match ty::get(t).sty {
|
||||||
ty::ty_box(*) => true,
|
ty::ty_box(*) => true,
|
||||||
ty::ty_uniq(*) => ty::type_contents(ccx.tcx, t).contains_managed(),
|
ty::ty_uniq(*) => ty::type_contents(ccx.tcx, t).owns_managed(),
|
||||||
_ => false
|
_ => false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -387,9 +387,9 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
|
||||||
let tp_ty = substs.tys[0];
|
let tp_ty = substs.tys[0];
|
||||||
Ret(bcx, C_bool(ty::type_needs_drop(ccx.tcx, tp_ty)));
|
Ret(bcx, C_bool(ty::type_needs_drop(ccx.tcx, tp_ty)));
|
||||||
}
|
}
|
||||||
"contains_managed" => {
|
"owns_managed" => {
|
||||||
let tp_ty = substs.tys[0];
|
let tp_ty = substs.tys[0];
|
||||||
Ret(bcx, C_bool(ty::type_contents(ccx.tcx, tp_ty).contains_managed()));
|
Ret(bcx, C_bool(ty::type_contents(ccx.tcx, tp_ty).owns_managed()));
|
||||||
}
|
}
|
||||||
"visit_tydesc" => {
|
"visit_tydesc" => {
|
||||||
let td = get_param(decl, first_real_arg);
|
let td = get_param(decl, first_real_arg);
|
||||||
|
|
|
@ -183,7 +183,7 @@ impl Reflector {
|
||||||
ty::ty_evec(ref mt, vst) => {
|
ty::ty_evec(ref mt, vst) => {
|
||||||
let (name, extra) = self.vstore_name_and_extra(t, vst);
|
let (name, extra) = self.vstore_name_and_extra(t, vst);
|
||||||
let extra = extra + self.c_mt(mt);
|
let extra = extra + self.c_mt(mt);
|
||||||
if "uniq" == name && ty::type_contents(bcx.tcx(), t).contains_managed() {
|
if "uniq" == name && ty::type_contents(bcx.tcx(), t).owns_managed() {
|
||||||
self.visit("evec_uniq_managed", extra)
|
self.visit("evec_uniq_managed", extra)
|
||||||
} else {
|
} else {
|
||||||
self.visit(~"evec_" + name, extra)
|
self.visit(~"evec_" + name, extra)
|
||||||
|
@ -195,7 +195,7 @@ impl Reflector {
|
||||||
}
|
}
|
||||||
ty::ty_uniq(ref mt) => {
|
ty::ty_uniq(ref mt) => {
|
||||||
let extra = self.c_mt(mt);
|
let extra = self.c_mt(mt);
|
||||||
if ty::type_contents(bcx.tcx(), t).contains_managed() {
|
if ty::type_contents(bcx.tcx(), t).owns_managed() {
|
||||||
self.visit("uniq_managed", extra)
|
self.visit("uniq_managed", extra)
|
||||||
} else {
|
} else {
|
||||||
self.visit("uniq", extra)
|
self.visit("uniq", extra)
|
||||||
|
|
|
@ -65,7 +65,7 @@ pub fn get_alloc(bcx: @mut Block, vptr: ValueRef) -> ValueRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_bodyptr(bcx: @mut Block, vptr: ValueRef, t: ty::t) -> ValueRef {
|
pub fn get_bodyptr(bcx: @mut Block, vptr: ValueRef, t: ty::t) -> ValueRef {
|
||||||
if ty::type_contents(bcx.tcx(), t).contains_managed() {
|
if ty::type_contents(bcx.tcx(), t).owns_managed() {
|
||||||
GEPi(bcx, vptr, [0u, abi::box_field_body])
|
GEPi(bcx, vptr, [0u, abi::box_field_body])
|
||||||
} else {
|
} else {
|
||||||
vptr
|
vptr
|
||||||
|
|
|
@ -226,7 +226,7 @@ pub fn type_of(cx: &mut CrateContext, t: ty::t) -> Type {
|
||||||
ty::ty_opaque_box => Type::opaque_box(cx).ptr_to(),
|
ty::ty_opaque_box => Type::opaque_box(cx).ptr_to(),
|
||||||
ty::ty_uniq(ref mt) => {
|
ty::ty_uniq(ref mt) => {
|
||||||
let ty = type_of(cx, mt.ty);
|
let ty = type_of(cx, mt.ty);
|
||||||
if ty::type_contents(cx.tcx, mt.ty).contains_managed() {
|
if ty::type_contents(cx.tcx, mt.ty).owns_managed() {
|
||||||
Type::unique(cx, &ty).ptr_to()
|
Type::unique(cx, &ty).ptr_to()
|
||||||
} else {
|
} else {
|
||||||
ty.ptr_to()
|
ty.ptr_to()
|
||||||
|
@ -235,7 +235,7 @@ pub fn type_of(cx: &mut CrateContext, t: ty::t) -> Type {
|
||||||
ty::ty_evec(ref mt, ty::vstore_uniq) => {
|
ty::ty_evec(ref mt, ty::vstore_uniq) => {
|
||||||
let ty = type_of(cx, mt.ty);
|
let ty = type_of(cx, mt.ty);
|
||||||
let ty = Type::vec(cx.sess.targ_cfg.arch, &ty);
|
let ty = Type::vec(cx.sess.targ_cfg.arch, &ty);
|
||||||
if ty::type_contents(cx.tcx, mt.ty).contains_managed() {
|
if ty::type_contents(cx.tcx, mt.ty).owns_managed() {
|
||||||
Type::unique(cx, &ty).ptr_to()
|
Type::unique(cx, &ty).ptr_to()
|
||||||
} else {
|
} else {
|
||||||
ty.ptr_to()
|
ty.ptr_to()
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub fn make_free_glue(bcx: @mut Block, vptrptr: ValueRef, box_ty: ty::t)
|
||||||
let body_datum = box_datum.box_body(bcx);
|
let body_datum = box_datum.box_body(bcx);
|
||||||
let bcx = glue::drop_ty(bcx, body_datum.to_ref_llval(bcx),
|
let bcx = glue::drop_ty(bcx, body_datum.to_ref_llval(bcx),
|
||||||
body_datum.ty);
|
body_datum.ty);
|
||||||
if ty::type_contents(bcx.tcx(), box_ty).contains_managed() {
|
if ty::type_contents(bcx.tcx(), box_ty).owns_managed() {
|
||||||
glue::trans_free(bcx, box_datum.val)
|
glue::trans_free(bcx, box_datum.val)
|
||||||
} else {
|
} else {
|
||||||
glue::trans_exchange_free(bcx, box_datum.val)
|
glue::trans_exchange_free(bcx, box_datum.val)
|
||||||
|
|
|
@ -1954,7 +1954,7 @@ impl TypeContents {
|
||||||
!self.intersects(TC::Nonsendable)
|
!self.intersects(TC::Nonsendable)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn contains_managed(&self) -> bool {
|
pub fn owns_managed(&self) -> bool {
|
||||||
self.intersects(TC::OwnsManaged)
|
self.intersects(TC::OwnsManaged)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3732,7 +3732,7 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {
|
||||||
ty::mk_nil())
|
ty::mk_nil())
|
||||||
}
|
}
|
||||||
"needs_drop" => (1u, ~[], ty::mk_bool()),
|
"needs_drop" => (1u, ~[], ty::mk_bool()),
|
||||||
"contains_managed" => (1u, ~[], ty::mk_bool()),
|
"owns_managed" => (1u, ~[], ty::mk_bool()),
|
||||||
"atomic_xchg" | "atomic_xadd" | "atomic_xsub" |
|
"atomic_xchg" | "atomic_xadd" | "atomic_xsub" |
|
||||||
"atomic_xchg_acq" | "atomic_xadd_acq" | "atomic_xsub_acq" |
|
"atomic_xchg_acq" | "atomic_xadd_acq" | "atomic_xsub_acq" |
|
||||||
"atomic_xchg_rel" | "atomic_xadd_rel" | "atomic_xsub_rel" => {
|
"atomic_xchg_rel" | "atomic_xadd_rel" | "atomic_xsub_rel" => {
|
||||||
|
|
|
@ -337,8 +337,13 @@ extern "rust-intrinsic" {
|
||||||
pub fn needs_drop<T>() -> bool;
|
pub fn needs_drop<T>() -> bool;
|
||||||
|
|
||||||
/// Returns `true` if a type is managed (will be allocated on the local heap)
|
/// Returns `true` if a type is managed (will be allocated on the local heap)
|
||||||
|
#[cfg(stage0)]
|
||||||
pub fn contains_managed<T>() -> bool;
|
pub fn contains_managed<T>() -> bool;
|
||||||
|
|
||||||
|
/// Returns `true` if a type is managed (will be allocated on the local heap)
|
||||||
|
#[cfg(not(stage0))]
|
||||||
|
pub fn owns_managed<T>() -> bool;
|
||||||
|
|
||||||
pub fn visit_tydesc(td: *TyDesc, tv: &mut TyVisitor);
|
pub fn visit_tydesc(td: *TyDesc, tv: &mut TyVisitor);
|
||||||
|
|
||||||
/// Get the address of the `__morestack` stack growth function.
|
/// Get the address of the `__morestack` stack growth function.
|
||||||
|
|
|
@ -121,11 +121,19 @@ use mem::size_of;
|
||||||
use uint;
|
use uint;
|
||||||
use unstable::finally::Finally;
|
use unstable::finally::Finally;
|
||||||
use unstable::intrinsics;
|
use unstable::intrinsics;
|
||||||
use unstable::intrinsics::{get_tydesc, contains_managed};
|
use unstable::intrinsics::{get_tydesc};
|
||||||
use unstable::raw::{Box, Repr, Slice, Vec};
|
use unstable::raw::{Box, Repr, Slice, Vec};
|
||||||
use vec;
|
use vec;
|
||||||
use util;
|
use util;
|
||||||
|
|
||||||
|
#[cfg(not(stage0))]
|
||||||
|
use unstable::intrinsics::owns_managed;
|
||||||
|
|
||||||
|
#[cfg(stage0)]
|
||||||
|
unsafe fn owns_managed<T>() -> bool {
|
||||||
|
intrinsics::contains_managed::<T>()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and initializes an owned vector.
|
* Creates and initializes an owned vector.
|
||||||
*
|
*
|
||||||
|
@ -180,7 +188,7 @@ pub fn from_elem<T:Clone>(n_elts: uint, t: T) -> ~[T] {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn with_capacity<T>(capacity: uint) -> ~[T] {
|
pub fn with_capacity<T>(capacity: uint) -> ~[T] {
|
||||||
unsafe {
|
unsafe {
|
||||||
if contains_managed::<T>() {
|
if owns_managed::<T>() {
|
||||||
let mut vec = ~[];
|
let mut vec = ~[];
|
||||||
vec.reserve(capacity);
|
vec.reserve(capacity);
|
||||||
vec
|
vec
|
||||||
|
@ -1401,7 +1409,7 @@ impl<T> OwnedVector<T> for ~[T] {
|
||||||
if self.capacity() < n {
|
if self.capacity() < n {
|
||||||
unsafe {
|
unsafe {
|
||||||
let td = get_tydesc::<T>();
|
let td = get_tydesc::<T>();
|
||||||
if contains_managed::<T>() {
|
if owns_managed::<T>() {
|
||||||
let ptr: *mut *mut Box<Vec<()>> = cast::transmute(self);
|
let ptr: *mut *mut Box<Vec<()>> = cast::transmute(self);
|
||||||
::at_vec::raw::reserve_raw(td, ptr, n);
|
::at_vec::raw::reserve_raw(td, ptr, n);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1437,7 +1445,7 @@ impl<T> OwnedVector<T> for ~[T] {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn capacity(&self) -> uint {
|
fn capacity(&self) -> uint {
|
||||||
unsafe {
|
unsafe {
|
||||||
if contains_managed::<T>() {
|
if owns_managed::<T>() {
|
||||||
let repr: **Box<Vec<()>> = cast::transmute(self);
|
let repr: **Box<Vec<()>> = cast::transmute(self);
|
||||||
(**repr).data.alloc / mem::nonzero_size_of::<T>()
|
(**repr).data.alloc / mem::nonzero_size_of::<T>()
|
||||||
} else {
|
} else {
|
||||||
|
@ -1460,7 +1468,7 @@ impl<T> OwnedVector<T> for ~[T] {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn push(&mut self, t: T) {
|
fn push(&mut self, t: T) {
|
||||||
unsafe {
|
unsafe {
|
||||||
if contains_managed::<T>() {
|
if owns_managed::<T>() {
|
||||||
let repr: **Box<Vec<()>> = cast::transmute(&mut *self);
|
let repr: **Box<Vec<()>> = cast::transmute(&mut *self);
|
||||||
let fill = (**repr).data.fill;
|
let fill = (**repr).data.fill;
|
||||||
if (**repr).data.alloc <= fill {
|
if (**repr).data.alloc <= fill {
|
||||||
|
@ -1482,7 +1490,7 @@ impl<T> OwnedVector<T> for ~[T] {
|
||||||
// This doesn't bother to make sure we have space.
|
// This doesn't bother to make sure we have space.
|
||||||
#[inline] // really pretty please
|
#[inline] // really pretty please
|
||||||
unsafe fn push_fast<T>(this: &mut ~[T], t: T) {
|
unsafe fn push_fast<T>(this: &mut ~[T], t: T) {
|
||||||
if contains_managed::<T>() {
|
if owns_managed::<T>() {
|
||||||
let repr: **mut Box<Vec<u8>> = cast::transmute(this);
|
let repr: **mut Box<Vec<u8>> = cast::transmute(this);
|
||||||
let fill = (**repr).data.fill;
|
let fill = (**repr).data.fill;
|
||||||
(**repr).data.fill += mem::nonzero_size_of::<T>();
|
(**repr).data.fill += mem::nonzero_size_of::<T>();
|
||||||
|
@ -2057,9 +2065,14 @@ pub mod raw {
|
||||||
use mem;
|
use mem;
|
||||||
use unstable::intrinsics;
|
use unstable::intrinsics;
|
||||||
use vec::{with_capacity, ImmutableVector, MutableVector};
|
use vec::{with_capacity, ImmutableVector, MutableVector};
|
||||||
use unstable::intrinsics::contains_managed;
|
|
||||||
use unstable::raw::{Box, Vec, Slice};
|
use unstable::raw::{Box, Vec, Slice};
|
||||||
|
|
||||||
|
#[cfg(not(stage0))]
|
||||||
|
use unstable::intrinsics::owns_managed;
|
||||||
|
|
||||||
|
#[cfg(stage0)]
|
||||||
|
use vec::owns_managed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the length of a vector
|
* Sets the length of a vector
|
||||||
*
|
*
|
||||||
|
@ -2069,7 +2082,7 @@ pub mod raw {
|
||||||
*/
|
*/
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn set_len<T>(v: &mut ~[T], new_len: uint) {
|
pub unsafe fn set_len<T>(v: &mut ~[T], new_len: uint) {
|
||||||
if contains_managed::<T>() {
|
if owns_managed::<T>() {
|
||||||
let repr: **mut Box<Vec<()>> = cast::transmute(v);
|
let repr: **mut Box<Vec<()>> = cast::transmute(v);
|
||||||
(**repr).data.fill = new_len * mem::nonzero_size_of::<T>();
|
(**repr).data.fill = new_len * mem::nonzero_size_of::<T>();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue