mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Auto merge of #21046 - servo:stable-alloc, r=nox
Upgrade to rustc 1.28.0-nightly (b68432d56 2018-06-12) <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21046) <!-- Reviewable:end -->
This commit is contained in:
commit
98ac66d015
5 changed files with 21 additions and 49 deletions
9
Cargo.lock
generated
9
Cargo.lock
generated
|
@ -572,7 +572,7 @@ dependencies = [
|
|||
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"procedural-masquerade 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"procedural-masquerade 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -586,7 +586,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
dependencies = [
|
||||
"phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"procedural-masquerade 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"procedural-masquerade 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -2224,7 +2224,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "procedural-masquerade"
|
||||
version = "0.1.2"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
|
@ -2789,7 +2789,6 @@ version = "0.0.1"
|
|||
dependencies = [
|
||||
"jemalloc-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3893,7 +3892,7 @@ dependencies = [
|
|||
"checksum png 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f0b0cabbbd20c2d7f06dbf015e06aad59b6ca3d9ed14848783e98af9aaf19925"
|
||||
"checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
|
||||
"checksum proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "77997c53ae6edd6d187fec07ec41b207063b5ee6f33680e9fa86d405cdd313d4"
|
||||
"checksum procedural-masquerade 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c93cdc1fb30af9ddf3debc4afbdb0f35126cbd99daa229dd76cdd5349b41d989"
|
||||
"checksum procedural-masquerade 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9a1574a51c3fd37b26d2c0032b649d08a7d51d4cca9c41bbc5bf7118fa4509d0"
|
||||
"checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4"
|
||||
"checksum quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7b0ff51282f28dc1b53fd154298feaa2e77c5ea0dba68e1fd8b03b72fbe13d2a"
|
||||
"checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1"
|
||||
|
|
|
@ -8,14 +8,8 @@ publish = false
|
|||
[lib]
|
||||
path = "lib.rs"
|
||||
|
||||
[features]
|
||||
unstable = ["kernel32-sys", "jemalloc-sys"]
|
||||
|
||||
[dependencies]
|
||||
libc = "0.2" # Only used when 'unstable' is disabled, but looks like Cargo cannot express that.
|
||||
|
||||
[target.'cfg(not(windows))'.dependencies]
|
||||
jemalloc-sys = { version = "0.1.4", optional = true }
|
||||
jemalloc-sys = { version = "0.1.4" }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
kernel32-sys = { version = "0.2.1", optional = true }
|
||||
kernel32-sys = { version = "0.2.1" }
|
||||
|
|
|
@ -4,20 +4,17 @@
|
|||
|
||||
//! Selecting the default global allocator for Servo
|
||||
|
||||
#![cfg_attr(feature = "unstable", feature(global_allocator, allocator_api, alloc_system))]
|
||||
|
||||
#[cfg(feature = "unstable")]
|
||||
#[global_allocator]
|
||||
static ALLOC: Allocator = Allocator;
|
||||
|
||||
pub use platform::*;
|
||||
|
||||
|
||||
#[cfg(all(feature = "unstable", not(windows)))]
|
||||
#[cfg(not(windows))]
|
||||
mod platform {
|
||||
extern crate jemalloc_sys as ffi;
|
||||
|
||||
use std::alloc::{GlobalAlloc, Layout, Opaque};
|
||||
use std::alloc::{GlobalAlloc, Layout};
|
||||
use std::os::raw::{c_int, c_void};
|
||||
|
||||
/// Get the size of a heap block.
|
||||
|
@ -65,44 +62,43 @@ mod platform {
|
|||
|
||||
unsafe impl GlobalAlloc for Allocator {
|
||||
#[inline]
|
||||
unsafe fn alloc(&self, layout: Layout) -> *mut Opaque {
|
||||
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
||||
let flags = layout_to_flags(layout.align(), layout.size());
|
||||
ffi::mallocx(layout.size(), flags) as *mut Opaque
|
||||
ffi::mallocx(layout.size(), flags) as *mut u8
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut Opaque {
|
||||
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
|
||||
if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() {
|
||||
ffi::calloc(1, layout.size()) as *mut Opaque
|
||||
ffi::calloc(1, layout.size()) as *mut u8
|
||||
} else {
|
||||
let flags = layout_to_flags(layout.align(), layout.size()) | ffi::MALLOCX_ZERO;
|
||||
ffi::mallocx(layout.size(), flags) as *mut Opaque
|
||||
ffi::mallocx(layout.size(), flags) as *mut u8
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn dealloc(&self, ptr: *mut Opaque, layout: Layout) {
|
||||
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
|
||||
let flags = layout_to_flags(layout.align(), layout.size());
|
||||
ffi::sdallocx(ptr as *mut _, layout.size(), flags)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn realloc(&self,
|
||||
ptr: *mut Opaque,
|
||||
ptr: *mut u8,
|
||||
layout: Layout,
|
||||
new_size: usize) -> *mut Opaque {
|
||||
new_size: usize) -> *mut u8 {
|
||||
let flags = layout_to_flags(layout.align(), new_size);
|
||||
ffi::rallocx(ptr as *mut _, new_size, flags) as *mut Opaque
|
||||
ffi::rallocx(ptr as *mut _, new_size, flags) as *mut u8
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "unstable", windows))]
|
||||
#[cfg(windows)]
|
||||
mod platform {
|
||||
extern crate alloc_system;
|
||||
extern crate kernel32;
|
||||
|
||||
pub use self::alloc_system::System as Allocator;
|
||||
pub use std::alloc::System as Allocator;
|
||||
use self::kernel32::{GetProcessHeap, HeapSize, HeapValidate};
|
||||
use std::os::raw::c_void;
|
||||
|
||||
|
@ -117,20 +113,3 @@ mod platform {
|
|||
HeapSize(heap, 0, ptr) as usize
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "unstable"))]
|
||||
mod platform {
|
||||
use std::os::raw::c_void;
|
||||
|
||||
/// Without `#[global_allocator]` we cannot be certain of what allocator is used
|
||||
/// or how it is linked. We therefore disable memory reporting. (Return zero.)
|
||||
pub unsafe extern "C" fn usable_size(_ptr: *const c_void) -> usize {
|
||||
0
|
||||
}
|
||||
|
||||
/// Memory allocation APIs compatible with libc
|
||||
pub mod libc_compat {
|
||||
extern crate libc;
|
||||
pub use self::libc::{malloc, realloc, free};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ path = "lib.rs"
|
|||
|
||||
[features]
|
||||
debugmozjs = ['mozjs/debugmozjs']
|
||||
unstable = ["servo_allocator/unstable"]
|
||||
unstable = []
|
||||
unrooted_must_root_lint = ["script_plugins/unrooted_must_root_lint"]
|
||||
default = ["unrooted_must_root_lint"]
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
nightly-2018-05-30
|
||||
nightly-2018-06-13
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue