diff options
| author | bors <bors@rust-lang.org> | 2013-07-08 02:52:56 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-07-08 02:52:56 -0700 |
| commit | 48ad726f2abc90fe62cdf239bc1c9318261a6926 (patch) | |
| tree | fb48c49be09efe99d543e18e1dd711d444521639 /src/libstd | |
| parent | 44770ae3a8001de38b33e449889c6444808941fc (diff) | |
| parent | 90f1db10fa29eb6b91e22037f13130f854da1401 (diff) | |
| download | rust-48ad726f2abc90fe62cdf239bc1c9318261a6926.tar.gz rust-48ad726f2abc90fe62cdf239bc1c9318261a6926.zip | |
auto merge of #7605 : thestinger/rust/vec, r=Aatch
This is work continued from the now landed #7495 and #7521 pulls. Removing the headers from unique vectors is another project, so I've separated the allocator.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/reflect.rs | 8 | ||||
| -rw-r--r-- | src/libstd/repr.rs | 9 | ||||
| -rw-r--r-- | src/libstd/rt/global_heap.rs | 9 | ||||
| -rw-r--r-- | src/libstd/unstable/intrinsics.rs | 1 | ||||
| -rw-r--r-- | src/libstd/vec.rs | 27 |
5 files changed, 33 insertions, 21 deletions
diff --git a/src/libstd/reflect.rs b/src/libstd/reflect.rs index 16ab4771d0d..9075133b086 100644 --- a/src/libstd/reflect.rs +++ b/src/libstd/reflect.rs @@ -248,6 +248,14 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> { true } + #[cfg(not(stage0))] + fn visit_uniq_managed(&self, mtbl: uint, inner: *TyDesc) -> bool { + self.align_to::<~u8>(); + if ! self.inner.visit_uniq_managed(mtbl, inner) { return false; } + self.bump_past::<~u8>(); + true + } + fn visit_ptr(&self, mtbl: uint, inner: *TyDesc) -> bool { self.align_to::<*u8>(); if ! self.inner.visit_ptr(mtbl, inner) { return false; } diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index fdda65d3e95..dd5075f8e66 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -302,6 +302,15 @@ impl TyVisitor for ReprVisitor { fn visit_uniq(&self, mtbl: uint, inner: *TyDesc) -> bool { self.writer.write_char('~'); self.write_mut_qualifier(mtbl); + do self.get::<*c_void> |b| { + self.visit_ptr_inner(*b, inner); + } + } + + #[cfg(not(stage0))] + fn visit_uniq_managed(&self, mtbl: uint, inner: *TyDesc) -> bool { + self.writer.write_char('~'); + self.write_mut_qualifier(mtbl); do self.get::<&managed::raw::BoxRepr> |b| { let p = ptr::to_unsafe_ptr(&b.data) as *c_void; self.visit_ptr_inner(p, inner); diff --git a/src/libstd/rt/global_heap.rs b/src/libstd/rt/global_heap.rs index 1020580d52c..54deb8924f5 100644 --- a/src/libstd/rt/global_heap.rs +++ b/src/libstd/rt/global_heap.rs @@ -80,7 +80,14 @@ pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char { #[cfg(not(stage0), not(test))] #[lang="exchange_malloc"] #[inline] -pub unsafe fn exchange_malloc(align: u32, size: uintptr_t) -> *c_char { +pub unsafe fn exchange_malloc(_align: u32, size: uintptr_t) -> *c_char { + malloc_raw(size as uint) as *c_char +} + +#[cfg(not(test))] +#[lang="vector_exchange_malloc"] +#[inline] +pub unsafe fn vector_exchange_malloc(align: u32, size: uintptr_t) -> *c_char { let total_size = get_box_size(size as uint, align as uint); malloc_raw(total_size as uint) as *c_char } diff --git a/src/libstd/unstable/intrinsics.rs b/src/libstd/unstable/intrinsics.rs index 97e3cba92db..ce5ccf2401d 100644 --- a/src/libstd/unstable/intrinsics.rs +++ b/src/libstd/unstable/intrinsics.rs @@ -91,6 +91,7 @@ pub trait TyVisitor { fn visit_box(&self, mtbl: uint, inner: *TyDesc) -> bool; fn visit_uniq(&self, mtbl: uint, inner: *TyDesc) -> bool; + fn visit_uniq_managed(&self, mtbl: uint, inner: *TyDesc) -> bool; fn visit_ptr(&self, mtbl: uint, inner: *TyDesc) -> bool; fn visit_rptr(&self, mtbl: uint, inner: *TyDesc) -> bool; diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 84e4358a496..33857556548 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -33,28 +33,15 @@ use sys::size_of; use uint; use unstable::intrinsics; #[cfg(stage0)] -use intrinsic::{get_tydesc}; +use intrinsic::{get_tydesc, TyDesc}; #[cfg(not(stage0))] -use unstable::intrinsics::{get_tydesc, contains_managed}; +use unstable::intrinsics::{get_tydesc, contains_managed, TyDesc}; use vec; use util; -#[doc(hidden)] -pub mod rustrt { - use libc; - use vec::raw; - #[cfg(stage0)] - use intrinsic::{TyDesc}; - #[cfg(not(stage0))] - use unstable::intrinsics::{TyDesc}; - - #[abi = "cdecl"] - pub extern { - #[fast_ffi] - unsafe fn vec_reserve_shared_actual(t: *TyDesc, - v: **raw::VecRepr, - n: libc::size_t); - } +extern { + #[fast_ffi] + unsafe fn vec_reserve_shared_actual(t: *TyDesc, v: **raw::VecRepr, n: libc::size_t); } /// Returns true if two vectors have the same length @@ -1152,7 +1139,7 @@ impl<T> OwnedVector<T> for ~[T] { let td = get_tydesc::<T>(); if ((**ptr).box_header.ref_count == managed::raw::RC_MANAGED_UNIQUE) { - rustrt::vec_reserve_shared_actual(td, ptr as **raw::VecRepr, n as libc::size_t); + vec_reserve_shared_actual(td, ptr as **raw::VecRepr, n as libc::size_t); } else { let alloc = n * sys::nonzero_size_of::<T>(); *ptr = realloc_raw(*ptr as *mut c_void, alloc + size_of::<raw::VecRepr>()) @@ -1182,7 +1169,7 @@ impl<T> OwnedVector<T> for ~[T] { let ptr: *mut *mut raw::VecRepr = cast::transmute(self); let td = get_tydesc::<T>(); if contains_managed::<T>() { - rustrt::vec_reserve_shared_actual(td, ptr as **raw::VecRepr, n as libc::size_t); + vec_reserve_shared_actual(td, ptr as **raw::VecRepr, n as libc::size_t); } else { let alloc = n * sys::nonzero_size_of::<T>(); *ptr = realloc_raw(*ptr as *mut c_void, alloc + size_of::<raw::VecRepr>()) |
