Skip to content

Commit

Permalink
Auto merge of #18732 - bholley:revert_mprotect_diagnostics, r=bholley
Browse files Browse the repository at this point in the history
Revert #18668 - Add mprotect diagnostics for HashMap crash (except for round-up-to-page behavior).

These diagnostics have served their purpose, time to remove them.

https://bugzilla.mozilla.org/show_bug.cgi?id=1403397

<!-- 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/18732)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Oct 3, 2017
2 parents 3dc4614 + 15b866d commit 0b69887
Show file tree
Hide file tree
Showing 17 changed files with 9 additions and 448 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions components/hashglobe/src/hash_map.rs
Expand Up @@ -1027,12 +1027,6 @@ impl<K, V, S> HashMap<K, V, S>
self.table.size()
}

/// Access to the raw buffer backing this hashmap.
pub fn raw_buffer(&self) -> (*const (), usize) {
assert!(self.raw_capacity() != 0);
self.table.raw_buffer()
}

/// Returns true if the map contains no elements.
///
/// # Examples
Expand Down
4 changes: 0 additions & 4 deletions components/hashglobe/src/lib.rs
Expand Up @@ -13,7 +13,6 @@ extern crate heapsize;
pub mod alloc;
pub mod hash_map;
pub mod hash_set;
pub mod protected;
mod shim;
mod table;

Expand Down Expand Up @@ -52,6 +51,3 @@ impl fmt::Display for FailedAllocationError {
self.reason.fmt(f)
}
}

// The size of memory pages on this system. Set when initializing geckolib.
pub static SYSTEM_PAGE_SIZE: ::std::sync::atomic::AtomicUsize = ::std::sync::atomic::ATOMIC_USIZE_INIT;
235 changes: 0 additions & 235 deletions components/hashglobe/src/protected.rs

This file was deleted.

36 changes: 1 addition & 35 deletions components/hashglobe/src/table.rs
Expand Up @@ -777,7 +777,7 @@ impl<K, V> RawTable<K, V> {


// FORK NOTE: Uses alloc shim instead of Heap.alloc
let buffer = alloc(round_up_to_page_size(size), alignment);
let buffer = alloc(size, alignment);

if buffer.is_null() {

Expand Down Expand Up @@ -813,24 +813,6 @@ impl<K, V> RawTable<K, V> {
}
}

/// Access to the raw buffer backing this table.
pub fn raw_buffer(&self) -> (*const (), usize) {
debug_assert!(self.capacity() != 0);

let buffer = self.hashes.ptr() as *const ();
let size = {
let hashes_size = self.capacity() * size_of::<HashUint>();
let pairs_size = self.capacity() * size_of::<(K, V)>();
let (_, _, size, _) = calculate_allocation(hashes_size,
align_of::<HashUint>(),
pairs_size,
align_of::<(K, V)>());
round_up_to_page_size(size)
};
(buffer, size)
}


/// Creates a new raw table from a given capacity. All buckets are
/// initially empty.
pub fn new(capacity: usize) -> Result<RawTable<K, V>, FailedAllocationError> {
Expand Down Expand Up @@ -1219,19 +1201,3 @@ impl<K, V> Drop for RawTable<K, V> {
}
}
}

// Force all allocations to fill their pages for the duration of the mprotect
// experiment.
#[inline]
fn round_up_to_page_size(size: usize) -> usize {
let page_size = ::SYSTEM_PAGE_SIZE.load(::std::sync::atomic::Ordering::Relaxed);
debug_assert!(page_size != 0);
let mut result = size;
let remainder = size % page_size;
if remainder != 0 {
result += page_size - remainder;
}
debug_assert!(result % page_size == 0);
debug_assert!(result - size < page_size);
result
}
19 changes: 0 additions & 19 deletions components/malloc_size_of/lib.rs
Expand Up @@ -339,25 +339,6 @@ impl<K, V, S> MallocSizeOf for hashglobe::hash_map::HashMap<K, V, S>
}
}

impl<K, V, S> MallocShallowSizeOf for hashglobe::protected::ProtectedHashMap<K, V, S>
where K: Eq + Hash,
S: BuildHasher
{
fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
self.inner().shallow_size_of(ops)
}
}

impl<K, V, S> MallocSizeOf for hashglobe::protected::ProtectedHashMap<K, V, S>
where K: Eq + Hash + MallocSizeOf,
V: MallocSizeOf,
S: BuildHasher,
{
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
self.inner().size_of(ops)
}
}

// XXX: we don't want MallocSizeOf to be defined for Rc and Arc. If negative
// trait bounds are ever allowed, this code should be uncommented.
// (We do have a compile-fail test for this:
Expand Down
12 changes: 0 additions & 12 deletions components/style/gecko/generated/bindings.rs
Expand Up @@ -1562,14 +1562,6 @@ extern "C" {
extern "C" {
pub fn Gecko_GetSystemPageSize() -> usize;
}
extern "C" {
pub fn Gecko_ProtectBuffer(buffer: *mut ::std::os::raw::c_void,
size: usize);
}
extern "C" {
pub fn Gecko_UnprotectBuffer(buffer: *mut ::std::os::raw::c_void,
size: usize);
}
extern "C" {
pub fn Gecko_Construct_Default_nsStyleFont(ptr: *mut nsStyleFont,
pres_context:
Expand Down Expand Up @@ -2999,10 +2991,6 @@ extern "C" {
*const ServoRawOffsetArc<RustString>)
-> ServoRawOffsetArc<RustString>;
}
extern "C" {
pub fn Servo_CorruptRuleHashAndCrash(set: RawServoStyleSetBorrowed,
index: usize);
}
extern "C" {
pub fn Gecko_CreateCSSErrorReporter(sheet: *mut ServoStyleSheet,
loader: *mut Loader, uri: *mut nsIURI)
Expand Down

0 comments on commit 0b69887

Please sign in to comment.