From e249e77144f0919eae609cb8ab833f576fec91a5 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Wed, 2 Oct 2019 02:45:44 +0000 Subject: [PATCH] =?UTF-8?q?servo:=20Merge=20#18944=20-=20Stop=20relying=20?= =?UTF-8?q?on=20linking=20details=20of=20std=E2=80=99s=20default=20allocat?= =?UTF-8?q?or=20(from=20servo:jemallocator2);=20r=3Dnox?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We’ve been bitten before by symbol names changing: https://github.com/servo/heapsize/pull/46, and upstream is planning to stop using jemalloc by default: https://github.com/rust-lang/rust/issues/33082#issuecomment-309781465 So use the (relatively) new `#[global_allocator]` attribute to explicitly select the system allocator on Windows and jemalloc (now in an external crate) on other platforms. This choice matches current defaults. Source-Repo: https://github.com/servo/servo Source-Revision: 07e9794306d597afe5d90d192fd32a99572c3cc3 UltraBlame original commit: 921526150768f9a2e9ba1586a350583f9ad025c9 --- servo/Cargo.lock | 34 +++++++++- servo/components/allocator/Cargo.toml | 18 ++++++ servo/components/allocator/lib.rs | 62 +++++++++++++++++++ servo/components/gfx/Cargo.toml | 1 + servo/components/gfx/lib.rs | 4 +- .../gfx/platform/freetype/font_context.rs | 16 ++--- servo/components/layout_thread/Cargo.toml | 1 + servo/components/layout_thread/lib.rs | 5 +- servo/components/malloc_size_of/Cargo.toml | 3 - servo/components/malloc_size_of/lib.rs | 31 ---------- servo/components/profile/Cargo.toml | 3 +- servo/components/profile/lib.rs | 7 +-- servo/components/profile/mem.rs | 8 +-- servo/components/script/Cargo.toml | 3 +- servo/components/script/lib.rs | 1 + servo/components/script/script_thread.rs | 4 +- servo/ports/servo/Cargo.toml | 2 +- servo/python/tidy/servo_tidy/tidy.py | 4 ++ servo/tests/unit/profile/Cargo.toml | 6 ++ servo/tests/unit/profile/lib.rs | 1 + 20 files changed, 152 insertions(+), 62 deletions(-) create mode 100644 servo/components/allocator/Cargo.toml create mode 100644 servo/components/allocator/lib.rs diff --git a/servo/Cargo.lock b/servo/Cargo.lock index b80eadd755346..ea877271f0faf 100644 --- a/servo/Cargo.lock +++ b/servo/Cargo.lock @@ -1115,6 +1115,7 @@ dependencies = [ "range 0.0.1", "serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", "servo-fontconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "servo_allocator 0.0.1", "servo_arc 0.0.1", "servo_atoms 0.0.1", "servo_geometry 0.0.1", @@ -1444,6 +1445,24 @@ name = "itoa" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "jemalloc-sys" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "jemallocator" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "jemalloc-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "jpeg-decoder" version = "0.1.13" @@ -1576,6 +1595,7 @@ dependencies = [ "script_traits 0.0.1", "selectors 0.19.0", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "servo_allocator 0.0.1", "servo_arc 0.0.1", "servo_atoms 0.0.1", "servo_config 0.0.1", @@ -1738,7 +1758,6 @@ dependencies = [ "euclid 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)", "hashglobe 0.1.0", "js 0.1.6 (git+https://github.com/servo/rust-mozjs)", - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "servo_arc 0.0.1", "smallbitvec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2368,6 +2387,7 @@ dependencies = [ "heartbeats-simple 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "influent 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jemalloc-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "profile_traits 0.0.1", @@ -2386,6 +2406,7 @@ dependencies = [ "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "profile 0.0.1", "profile_traits 0.0.1", + "servo_allocator 0.0.1", ] [[package]] @@ -2635,6 +2656,7 @@ dependencies = [ "selectors 0.19.0", "serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "servo_allocator 0.0.1", "servo_arc 0.0.1", "servo_atoms 0.0.1", "servo_config 0.0.1", @@ -2926,6 +2948,14 @@ dependencies = [ "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "servo_allocator" +version = "0.0.1" +dependencies = [ + "jemallocator 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "servo_arc" version = "0.0.1" @@ -3879,6 +3909,8 @@ dependencies = [ "checksum ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c10ed089b1921b01ef342c736a37ee0788eeb9a5f373bb2df1ba88d01125064f" "checksum itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4833d6978da405305126af4ac88569b5d71ff758581ce5a987dbfa3755f694fc" "checksum itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2f404fbc66fd9aac13e998248505e7ecb2ad8e44ab6388684c5fb11c6c251c" +"checksum jemalloc-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94fb624d7e8345e5c42caab8d1db6ec925fdadff3fd0cb7dd781b41be8442828" +"checksum jemallocator 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1850725977c344d63af66e8fd00857646e3ec936c490cd63667860b7b03ab5c1" "checksum jpeg-decoder 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2805ccb10ffe4d10e06ef68a158ff94c255211ecbae848fbde2146b098f93ce7" "checksum js 0.1.6 (git+https://github.com/servo/rust-mozjs)" = "" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" diff --git a/servo/components/allocator/Cargo.toml b/servo/components/allocator/Cargo.toml new file mode 100644 index 0000000000000..fccec48a5e902 --- /dev/null +++ b/servo/components/allocator/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "servo_allocator" +version = "0.0.1" +authors = ["The Servo Project Developers"] +license = "MPL-2.0" +publish = false + +[lib] +path = "lib.rs" + +[features] +unstable = ["kernel32-sys", "jemallocator"] + +[target.'cfg(not(windows))'.dependencies] +jemallocator = { version = "0.1.3", optional = true } + +[target.'cfg(windows)'.dependencies] +kernel32-sys = { version = "0.2.1", optional = true } diff --git a/servo/components/allocator/lib.rs b/servo/components/allocator/lib.rs new file mode 100644 index 0000000000000..482122279a09b --- /dev/null +++ b/servo/components/allocator/lib.rs @@ -0,0 +1,62 @@ + + + + + + +#![cfg_attr(all(feature = "unstable", windows), feature(alloc_system, allocator_api))] +#![cfg_attr(feature = "unstable", feature(global_allocator))] + +#[cfg(feature = "unstable")] +#[global_allocator] +static ALLOC: platform::Allocator = platform::Allocator; + +pub use platform::usable_size; + + +#[cfg(all(feature = "unstable", not(windows)))] +mod platform { + extern crate jemallocator; + + pub use self::jemallocator::Jemalloc as Allocator; + use std::os::raw::c_void; + + + pub unsafe extern "C" fn usable_size(ptr: *const c_void) -> usize { + jemallocator::usable_size(ptr) + } +} + +#[cfg(all(feature = "unstable", windows))] +mod platform { + extern crate alloc_system; + extern crate kernel32; + + pub use self::alloc_system::System as Allocator; + use self::kernel32::{GetProcessHeap, HeapSize, HeapValidate}; + use std::os::raw::c_void; + + + pub unsafe extern "C" fn usable_size(mut ptr: *const c_void) -> usize { + let heap = GetProcessHeap(); + + if HeapValidate(heap, 0, ptr) == 0 { + ptr = *(ptr as *const *const c_void).offset(-1); + } + + HeapSize(heap, 0, ptr) as usize + } +} + +#[cfg(not(feature = "unstable"))] +mod platform { + use std::os::raw::c_void; + + + + pub unsafe extern "C" fn usable_size(_ptr: *const c_void) -> usize { + 0 + } +} + + diff --git a/servo/components/gfx/Cargo.toml b/servo/components/gfx/Cargo.toml index 606d17c290858..d28c7b8f44a8e 100644 --- a/servo/components/gfx/Cargo.toml +++ b/servo/components/gfx/Cargo.toml @@ -53,6 +53,7 @@ core-text = "7.0" [target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies] freetype = "0.3" +servo_allocator = {path = "../allocator"} [target.'cfg(target_os = "linux")'.dependencies] servo-fontconfig = "0.2.1" diff --git a/servo/components/gfx/lib.rs b/servo/components/gfx/lib.rs index c28a787057420..b6f8f1a745729 100644 --- a/servo/components/gfx/lib.rs +++ b/servo/components/gfx/lib.rs @@ -27,8 +27,8 @@ extern crate fnv; #[cfg(target_os = "linux")] extern crate fontconfig; extern crate fontsan; -#[cfg(any(target_os = "linux", target_os = "android"))] -extern crate freetype; +#[cfg(any(target_os = "linux", target_os = "android"))] extern crate freetype; +#[cfg(any(target_os = "linux", target_os = "android"))] extern crate servo_allocator; extern crate gfx_traits; diff --git a/servo/components/gfx/platform/freetype/font_context.rs b/servo/components/gfx/platform/freetype/font_context.rs index 0d1a8cf7ea3b1..0030f36aae99e 100644 --- a/servo/components/gfx/platform/freetype/font_context.rs +++ b/servo/components/gfx/platform/freetype/font_context.rs @@ -8,7 +8,8 @@ use freetype::freetype::FT_Library; use freetype::freetype::FT_Memory; use freetype::freetype::FT_MemoryRec_; use freetype::freetype::FT_New_Library; -use malloc_size_of::{malloc_size_of, MallocSizeOf, MallocSizeOfOps}; +use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; +use servo_allocator::usable_size; use std::mem; use std::os::raw::{c_long, c_void}; use std::ptr; @@ -31,7 +32,7 @@ extern fn ft_alloc(mem: FT_Memory, req_size: c_long) -> *mut c_void { mem::forget(vec); unsafe { - let actual_size = malloc_size_of(ptr as *const _); + let actual_size = usable_size(ptr as *const _); let user = (*mem).user as *mut User; (*user).size += actual_size; } @@ -41,7 +42,7 @@ extern fn ft_alloc(mem: FT_Memory, req_size: c_long) -> *mut c_void { extern fn ft_free(mem: FT_Memory, ptr: *mut c_void) { unsafe { - let actual_size = malloc_size_of(ptr as *const _); + let actual_size = usable_size(ptr as *const _); let user = (*mem).user as *mut User; (*user).size -= actual_size; @@ -50,13 +51,14 @@ extern fn ft_free(mem: FT_Memory, ptr: *mut c_void) { } } -extern fn ft_realloc(mem: FT_Memory, _cur_size: c_long, new_req_size: c_long, +extern fn ft_realloc(mem: FT_Memory, old_size: c_long, new_req_size: c_long, old_ptr: *mut c_void) -> *mut c_void { let old_actual_size; let mut vec; unsafe { - old_actual_size = malloc_size_of(old_ptr as *const _); - vec = Vec::::from_raw_parts(old_ptr as *mut u8, old_actual_size, old_actual_size); + old_actual_size = usable_size(old_ptr as *const _); + let old_size = old_size as usize; + vec = Vec::::from_raw_parts(old_ptr as *mut u8, old_size, old_size); }; let new_req_size = new_req_size as usize; @@ -71,7 +73,7 @@ extern fn ft_realloc(mem: FT_Memory, _cur_size: c_long, new_req_size: c_long, mem::forget(vec); unsafe { - let new_actual_size = malloc_size_of(new_ptr as *const _); + let new_actual_size = usable_size(new_ptr as *const _); let user = (*mem).user as *mut User; (*user).size += new_actual_size; (*user).size -= old_actual_size; diff --git a/servo/components/layout_thread/Cargo.toml b/servo/components/layout_thread/Cargo.toml index 35336e133ca5f..8683ad609424c 100644 --- a/servo/components/layout_thread/Cargo.toml +++ b/servo/components/layout_thread/Cargo.toml @@ -40,6 +40,7 @@ script_layout_interface = {path = "../script_layout_interface"} script_traits = {path = "../script_traits"} selectors = { path = "../selectors" } serde_json = "1.0" +servo_allocator = {path = "../allocator"} servo_arc = {path = "../servo_arc"} servo_atoms = {path = "../atoms"} servo_config = {path = "../config"} diff --git a/servo/components/layout_thread/lib.rs b/servo/components/layout_thread/lib.rs index ad62bf06e10d2..21fb0d8653fe6 100644 --- a/servo/components/layout_thread/lib.rs +++ b/servo/components/layout_thread/lib.rs @@ -39,6 +39,7 @@ extern crate script_layout_interface; extern crate script_traits; extern crate selectors; extern crate serde_json; +extern crate servo_allocator; extern crate servo_arc; extern crate servo_atoms; extern crate servo_config; @@ -84,7 +85,7 @@ use layout::webrender_helpers::WebRenderDisplayListConverter; use layout::wrapper::LayoutNodeLayoutData; use layout_traits::LayoutThreadFactory; use libc::c_void; -use malloc_size_of::{malloc_size_of, MallocSizeOf, MallocSizeOfOps}; +use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use metrics::{PaintTimeMetrics, ProfilerMetadataFactory}; use msg::constellation_msg::PipelineId; use msg::constellation_msg::TopLevelBrowsingContextId; @@ -775,7 +776,7 @@ impl LayoutThread { let mut reports = vec![]; - let mut ops = MallocSizeOfOps::new(malloc_size_of, None, None); + let mut ops = MallocSizeOfOps::new(::servo_allocator::usable_size, None, None); let rw_data = possibly_locked_rw_data.lock(); diff --git a/servo/components/malloc_size_of/Cargo.toml b/servo/components/malloc_size_of/Cargo.toml index afc92cf53a983..05a8f4f4810a5 100644 --- a/servo/components/malloc_size_of/Cargo.toml +++ b/servo/components/malloc_size_of/Cargo.toml @@ -8,9 +8,6 @@ publish = false [lib] path = "lib.rs" -[target.'cfg(windows)'.dependencies] -kernel32-sys = "0.2.1" - [features] servo = ["js", "string_cache", "url", "webrender_api", "xml5ever"] diff --git a/servo/components/malloc_size_of/lib.rs b/servo/components/malloc_size_of/lib.rs index dee414cf39c26..a0f75b5b2ec0c 100644 --- a/servo/components/malloc_size_of/lib.rs +++ b/servo/components/malloc_size_of/lib.rs @@ -49,8 +49,6 @@ extern crate euclid; extern crate hashglobe; #[cfg(feature = "servo")] extern crate js; -#[cfg(target_os = "windows")] -extern crate kernel32; extern crate servo_arc; extern crate smallbitvec; extern crate smallvec; @@ -63,8 +61,6 @@ extern crate webrender_api; #[cfg(feature = "servo")] extern crate xml5ever; -#[cfg(target_os = "windows")] -use kernel32::{GetProcessHeap, HeapSize, HeapValidate}; use std::hash::{BuildHasher, Hash}; use std::mem::size_of; use std::ops::Range; @@ -147,33 +143,6 @@ impl MallocSizeOfOps { } -#[cfg(not(target_os = "windows"))] -pub unsafe extern "C" fn malloc_size_of(ptr: *const c_void) -> usize { - - - - - extern "C" { - #[cfg_attr(any(prefixed_jemalloc, target_os = "macos", target_os = "ios", target_os = "android"), - link_name = "je_malloc_usable_size")] - fn malloc_usable_size(ptr: *const c_void) -> usize; - } - malloc_usable_size(ptr) -} - - -#[cfg(target_os = "windows")] -pub unsafe extern "C" fn malloc_size_of(mut ptr: *const c_void) -> usize { - let heap = GetProcessHeap(); - - if HeapValidate(heap, 0, ptr) == 0 { - ptr = *(ptr as *const *const c_void).offset(-1); - } - - HeapSize(heap, 0, ptr) as usize -} - - pub trait MallocSizeOf { diff --git a/servo/components/profile/Cargo.toml b/servo/components/profile/Cargo.toml index d00c0f5000dc3..6923b0540cf98 100644 --- a/servo/components/profile/Cargo.toml +++ b/servo/components/profile/Cargo.toml @@ -10,7 +10,7 @@ name = "profile" path = "lib.rs" [features] -unstable = [] +unstable = ["jemalloc-sys"] [dependencies] profile_traits = {path = "../profile_traits"} @@ -31,3 +31,4 @@ regex = "0.2" [target.'cfg(not(target_os = "windows"))'.dependencies] libc = "0.2" +jemalloc-sys = {version = "0.1.3", optional = true} diff --git a/servo/components/profile/lib.rs b/servo/components/profile/lib.rs index bf3a7525518e1..4173ca3fe8b1f 100644 --- a/servo/components/profile/lib.rs +++ b/servo/components/profile/lib.rs @@ -2,17 +2,14 @@ -#![cfg_attr(all(feature = "unstable", not(target_os = "windows")), feature(alloc_jemalloc))] - #![deny(unsafe_code)] #[allow(unused_extern_crates)] -#[cfg(all(feature = "unstable", not(target_os = "windows")))] -extern crate alloc_jemalloc; extern crate heartbeats_simple; extern crate influent; extern crate ipc_channel; -#[allow(unused_extern_crates)] +#[cfg(all(feature = "unstable", not(target_os = "windows")))] +extern crate jemalloc_sys; #[cfg(not(target_os = "windows"))] extern crate libc; #[macro_use] diff --git a/servo/components/profile/mem.rs b/servo/components/profile/mem.rs index 70bab086f9ed2..8fa9384bbbcf8 100644 --- a/servo/components/profile/mem.rs +++ b/servo/components/profile/mem.rs @@ -354,7 +354,7 @@ impl ReportsForest { mod system_reporter { #[cfg(all(feature = "unstable", not(target_os = "windows")))] - use libc::{c_char, c_void, size_t}; + use libc::{c_void, size_t}; #[cfg(target_os = "linux")] use libc::c_int; use profile_traits::mem::{Report, ReportKind, ReporterRequest}; @@ -460,11 +460,7 @@ mod system_reporter { } #[cfg(all(feature = "unstable", not(target_os = "windows")))] - extern { - #[cfg_attr(any(target_os = "macos", target_os = "android"), link_name = "je_mallctl")] - fn mallctl(name: *const c_char, oldp: *mut c_void, oldlenp: *mut size_t, - newp: *mut c_void, newlen: size_t) -> ::libc::c_int; - } + use jemalloc_sys::mallctl; #[cfg(all(feature = "unstable", not(target_os = "windows")))] fn jemalloc_stat(value_name: &str) -> Option { diff --git a/servo/components/script/Cargo.toml b/servo/components/script/Cargo.toml index 8c9e9613ede4d..191a325f60a0e 100644 --- a/servo/components/script/Cargo.toml +++ b/servo/components/script/Cargo.toml @@ -13,7 +13,7 @@ path = "lib.rs" [features] debugmozjs = ['js/debugmozjs'] -unstable = [] +unstable = ["servo_allocator/unstable"] [build-dependencies] cmake = "0.1" @@ -77,6 +77,7 @@ script_plugins = {path = "../script_plugins"} script_traits = {path = "../script_traits"} selectors = { path = "../selectors" } serde = "1.0" +servo_allocator = {path = "../allocator"} servo_arc = {path = "../servo_arc"} servo_atoms = {path = "../atoms"} servo_config = {path = "../config"} diff --git a/servo/components/script/lib.rs b/servo/components/script/lib.rs index 37611fcdc39fe..725cdc5b971d9 100644 --- a/servo/components/script/lib.rs +++ b/servo/components/script/lib.rs @@ -78,6 +78,7 @@ extern crate script_layout_interface; extern crate script_traits; extern crate selectors; extern crate serde; +extern crate servo_allocator; extern crate servo_arc; #[macro_use] extern crate servo_atoms; extern crate servo_config; diff --git a/servo/components/script/script_thread.rs b/servo/components/script/script_thread.rs index 8138dbc696745..d57f86ae26c70 100644 --- a/servo/components/script/script_thread.rs +++ b/servo/components/script/script_thread.rs @@ -73,7 +73,7 @@ use js::jsapi::{JSAutoCompartment, JSContext, JS_SetWrapObjectCallbacks}; use js::jsapi::{JSTracer, SetWindowProxyClass}; use js::jsval::UndefinedValue; use js::rust::Runtime; -use malloc_size_of::{malloc_size_of, MallocSizeOfOps}; +use malloc_size_of::MallocSizeOfOps; use mem::malloc_size_of_including_self; use metrics::PaintTimeMetrics; use microtask::{MicrotaskQueue, Microtask}; @@ -1506,7 +1506,7 @@ impl ScriptThread { let mut reports = vec![]; - let mut ops = MallocSizeOfOps::new(malloc_size_of, None, None); + let mut ops = MallocSizeOfOps::new(::servo_allocator::usable_size, None, None); for (_, document) in self.documents.borrow().iter() { let current_url = document.url(); diff --git a/servo/ports/servo/Cargo.toml b/servo/ports/servo/Cargo.toml index 63803a90f5885..4376a0accd076 100644 --- a/servo/ports/servo/Cargo.toml +++ b/servo/ports/servo/Cargo.toml @@ -37,7 +37,7 @@ energy-profiling = ["libservo/energy-profiling"] debugmozjs = ["libservo/debugmozjs"] googlevr = ["libservo/googlevr"] oculusvr = ["libservo/oculusvr"] -unstable = ["libservo/unstable"] +unstable = ["libservo/unstable", "profile_tests/unstable"] [dependencies] backtrace = "0.3" diff --git a/servo/python/tidy/servo_tidy/tidy.py b/servo/python/tidy/servo_tidy/tidy.py index 35860af9de010..12a2fc3b03175 100644 --- a/servo/python/tidy/servo_tidy/tidy.py +++ b/servo/python/tidy/servo_tidy/tidy.py @@ -626,6 +626,10 @@ def check_rust(file_name, lines): + decl_found.format(crate_name)) prev_crate[indent] = crate_name + if line == "}": + for i in [i for i in prev_crate.keys() if i > indent]: + del prev_crate[i] + if is_lib_rs_file: match = re.search(r"#!\[feature\((.*)\)\]", line) diff --git a/servo/tests/unit/profile/Cargo.toml b/servo/tests/unit/profile/Cargo.toml index 36dbeb8ffb148..0d04fba813f26 100644 --- a/servo/tests/unit/profile/Cargo.toml +++ b/servo/tests/unit/profile/Cargo.toml @@ -9,7 +9,13 @@ name = "profile_tests" path = "lib.rs" doctest = false +[features] +unstable = ["servo_allocator/unstable"] + [dependencies] ipc-channel = "0.9" profile = {path = "../../../components/profile"} profile_traits = {path = "../../../components/profile_traits"} + +# Work around https://github.com/alexcrichton/jemallocator/issues/19 +servo_allocator = {path = "../../../components/allocator"} diff --git a/servo/tests/unit/profile/lib.rs b/servo/tests/unit/profile/lib.rs index 8be7a34903dec..c3a6959ccb3b5 100644 --- a/servo/tests/unit/profile/lib.rs +++ b/servo/tests/unit/profile/lib.rs @@ -5,6 +5,7 @@ extern crate ipc_channel; extern crate profile; extern crate profile_traits; +extern crate servo_allocator; #[cfg(test)] mod time;