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
This commit is contained in:
@@ -26,6 +26,23 @@ use slice::ImmutableVector;
|
||||
// FIXME: Once the runtime matures remove the `true` below to turn off rtassert, etc.
|
||||
pub static ENFORCE_SANITY: bool = true || !cfg!(rtopt) || cfg!(rtdebug) || cfg!(rtassert);
|
||||
|
||||
#[deprecated]
|
||||
#[doc(hidden)]
|
||||
#[inline]
|
||||
pub fn get_box_size(body_size: uint, body_align: uint) -> uint {
|
||||
let header_size = ::mem::size_of::<::raw::Box<()>>();
|
||||
let total_size = align_to(header_size, body_align) + body_size;
|
||||
total_size
|
||||
}
|
||||
|
||||
// Rounds |size| to the nearest |alignment|. Invariant: |alignment| is a power
|
||||
// of two.
|
||||
#[inline]
|
||||
fn align_to(size: uint, align: uint) -> uint {
|
||||
assert!(align != 0);
|
||||
(size + align - 1) & !(align - 1)
|
||||
}
|
||||
|
||||
/// Get the number of cores available
|
||||
pub fn num_cpus() -> uint {
|
||||
unsafe {
|
||||
|
||||
Reference in New Issue
Block a user