mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Format component allocator #21373
This commit is contained in:
parent
89ab110357
commit
b25a01f492
1 changed files with 25 additions and 17 deletions
|
@ -9,7 +9,6 @@ static ALLOC: Allocator = Allocator;
|
|||
|
||||
pub use platform::*;
|
||||
|
||||
|
||||
#[cfg(not(windows))]
|
||||
mod platform {
|
||||
extern crate jemalloc_sys as ffi;
|
||||
|
@ -31,19 +30,31 @@ mod platform {
|
|||
|
||||
// The minimum alignment guaranteed by the architecture. This value is used to
|
||||
// add fast paths for low alignment values.
|
||||
#[cfg(all(any(target_arch = "arm",
|
||||
target_arch = "mips",
|
||||
target_arch = "mipsel",
|
||||
target_arch = "powerpc")))]
|
||||
#[cfg(
|
||||
all(
|
||||
any(
|
||||
target_arch = "arm",
|
||||
target_arch = "mips",
|
||||
target_arch = "mipsel",
|
||||
target_arch = "powerpc"
|
||||
)
|
||||
)
|
||||
)]
|
||||
const MIN_ALIGN: usize = 8;
|
||||
#[cfg(all(any(target_arch = "x86",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "aarch64",
|
||||
target_arch = "powerpc64",
|
||||
target_arch = "powerpc64le",
|
||||
target_arch = "mips64",
|
||||
target_arch = "s390x",
|
||||
target_arch = "sparc64")))]
|
||||
#[cfg(
|
||||
all(
|
||||
any(
|
||||
target_arch = "x86",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "aarch64",
|
||||
target_arch = "powerpc64",
|
||||
target_arch = "powerpc64le",
|
||||
target_arch = "mips64",
|
||||
target_arch = "s390x",
|
||||
target_arch = "sparc64"
|
||||
)
|
||||
)
|
||||
)]
|
||||
const MIN_ALIGN: usize = 16;
|
||||
|
||||
fn layout_to_flags(align: usize, size: usize) -> c_int {
|
||||
|
@ -84,10 +95,7 @@ mod platform {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn realloc(&self,
|
||||
ptr: *mut u8,
|
||||
layout: Layout,
|
||||
new_size: usize) -> *mut u8 {
|
||||
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
|
||||
let flags = layout_to_flags(layout.align(), new_size);
|
||||
ffi::rallocx(ptr as *mut _, new_size, flags) as *mut u8
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue