diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2014-05-06 22:03:14 -0400 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2014-05-10 19:58:17 -0400 |
| commit | 138437956c9ab78aede9bb698aa80f9367b3b75a (patch) | |
| tree | b1614baf6a134ee7e8a6f728c86ceb9f4996dd60 /src/libsync | |
| parent | aaf6e06b01c4f7490e71693d3c96f466032e80d0 (diff) | |
| download | rust-138437956c9ab78aede9bb698aa80f9367b3b75a.tar.gz rust-138437956c9ab78aede9bb698aa80f9367b3b75a.zip | |
initial port of the exchange allocator to jemalloc
In stage0, all allocations are 8-byte aligned. Passing a size and alignment to free is not yet implemented everywhere (0 size and 8 align are used as placeholders). Fixing this is part of #13994. Closes #13616
Diffstat (limited to 'src/libsync')
| -rw-r--r-- | src/libsync/arc.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libsync/arc.rs b/src/libsync/arc.rs index f5369ec862f..226eb7afb5f 100644 --- a/src/libsync/arc.rs +++ b/src/libsync/arc.rs @@ -15,8 +15,9 @@ use std::cast; use std::ptr; -use std::rt::global_heap; +use std::rt::heap::exchange_free; use std::sync::atomics; +use std::mem::{min_align_of, size_of}; /// An atomically reference counted wrapper for shared state. /// @@ -190,7 +191,8 @@ impl<T: Share + Send> Drop for Arc<T> { if self.inner().weak.fetch_sub(1, atomics::Release) == 1 { atomics::fence(atomics::Acquire); - unsafe { global_heap::exchange_free(self.x as *u8) } + unsafe { exchange_free(self.x as *mut u8, size_of::<ArcInner<T>>(), + min_align_of::<ArcInner<T>>()) } } } } @@ -240,7 +242,8 @@ impl<T: Share + Send> Drop for Weak<T> { // the memory orderings if self.inner().weak.fetch_sub(1, atomics::Release) == 1 { atomics::fence(atomics::Acquire); - unsafe { global_heap::exchange_free(self.x as *u8) } + unsafe { exchange_free(self.x as *mut u8, size_of::<ArcInner<T>>(), + min_align_of::<ArcInner<T>>()) } } } } |
