mirror of
https://github.com/servo/servo.git
synced 2025-10-08 20:49:24 +01:00
Revert #18668 - Add mprotect diagnostics for HashMap crash
This commit is contained in:
parent
e07c6f38a5
commit
15b866d8de
17 changed files with 9 additions and 448 deletions
|
@ -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() {
|
||||
|
||||
|
@ -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> {
|
||||
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue