зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1514121 - Remove unused rust OOM handling variant. r=froydnj
This removes the code added in bug 1458161, because the old versions of rust that required it can't be used to build Gecko anymore. The variant for newer versions of rust stays. Differential Revision: https://phabricator.services.mozilla.com/D14528 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a7360dc455
Коммит
cc31837126
|
@ -7,10 +7,7 @@ fn main() {
|
|||
let mut bootstrap = false;
|
||||
let max_oom_hook_version = Version::parse("1.33.0-alpha").unwrap();
|
||||
|
||||
if ver >= Version::parse("1.24.0").unwrap() && ver < Version::parse("1.27.0").unwrap() {
|
||||
println!("cargo:rustc-cfg=feature=\"oom_with_global_alloc\"");
|
||||
bootstrap = true;
|
||||
} else if ver >= Version::parse("1.28.0-alpha").unwrap() && ver < max_oom_hook_version {
|
||||
if ver >= Version::parse("1.28.0-alpha").unwrap() && ver < max_oom_hook_version {
|
||||
println!("cargo:rustc-cfg=feature=\"oom_with_hook\"");
|
||||
bootstrap = true;
|
||||
} else if std::env::var("MOZ_AUTOMATION").is_ok() {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#![cfg_attr(feature = "oom_with_global_alloc",
|
||||
feature(global_allocator, alloc, alloc_system, allocator_api))]
|
||||
#![cfg_attr(feature = "oom_with_hook", feature(alloc_error_hook))]
|
||||
|
||||
#[cfg(feature="servo")]
|
||||
|
@ -242,62 +240,6 @@ pub extern "C" fn install_rust_panic_hook() {
|
|||
panic::set_hook(Box::new(panic_hook));
|
||||
}
|
||||
|
||||
// Wrap the rust system allocator to override the OOM handler, redirecting
|
||||
// to Gecko's, which interacts with the crash reporter.
|
||||
// This relies on unstable APIs that have not changed between 1.24 and 1.27.
|
||||
// In 1.27, the API changed, so we'll need to adapt to those changes before
|
||||
// we can ship with 1.27. As of writing, there might still be further changes
|
||||
// to those APIs before 1.27 is released, so we wait for those.
|
||||
#[cfg(feature = "oom_with_global_alloc")]
|
||||
mod global_alloc {
|
||||
extern crate alloc;
|
||||
extern crate alloc_system;
|
||||
|
||||
use self::alloc::allocator::{Alloc, AllocErr, Layout};
|
||||
use self::alloc_system::System;
|
||||
|
||||
pub struct GeckoHeap;
|
||||
|
||||
extern "C" {
|
||||
fn GeckoHandleOOM(size: usize) -> !;
|
||||
}
|
||||
|
||||
unsafe impl<'a> Alloc for &'a GeckoHeap {
|
||||
unsafe fn alloc(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> {
|
||||
System.alloc(layout)
|
||||
}
|
||||
|
||||
unsafe fn dealloc(&mut self, ptr: *mut u8, layout: Layout) {
|
||||
System.dealloc(ptr, layout)
|
||||
}
|
||||
|
||||
fn oom(&mut self, e: AllocErr) -> ! {
|
||||
match e {
|
||||
AllocErr::Exhausted { request } => unsafe { GeckoHandleOOM(request.size()) },
|
||||
_ => System.oom(e),
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn realloc(
|
||||
&mut self,
|
||||
ptr: *mut u8,
|
||||
layout: Layout,
|
||||
new_layout: Layout,
|
||||
) -> Result<*mut u8, AllocErr> {
|
||||
System.realloc(ptr, layout, new_layout)
|
||||
}
|
||||
|
||||
unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> {
|
||||
System.alloc_zeroed(layout)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[cfg(feature = "oom_with_global_alloc")]
|
||||
#[global_allocator]
|
||||
static HEAP: global_alloc::GeckoHeap = global_alloc::GeckoHeap;
|
||||
|
||||
#[cfg(feature = "oom_with_hook")]
|
||||
mod oom_hook {
|
||||
use std::alloc::{Layout, set_alloc_error_hook};
|
||||
|
|
Загрузка…
Ссылка в новой задаче