Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format gfx_traits and hashglobe #21373 #21648

Merged
merged 2 commits into from Sep 9, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -4,13 +4,15 @@

#![crate_name = "gfx_traits"]
#![crate_type = "rlib"]

#![deny(unsafe_code)]

extern crate malloc_size_of;
#[macro_use] extern crate malloc_size_of_derive;
#[macro_use] extern crate range;
#[macro_use] extern crate serde;
#[macro_use]
extern crate malloc_size_of_derive;
#[macro_use]
extern crate range;
#[macro_use]
extern crate serde;

pub mod print_tree;

@@ -32,7 +34,7 @@ impl Epoch {
pub struct StackingContextId(
/// The identifier for this StackingContext, derived from the Flow's memory address
/// and fragment type. As a space optimization, these are combined into a single word.
pub u64
pub u64,
);

impl StackingContextId {
@@ -87,7 +89,7 @@ fn next_special_id() -> usize {
SPECIAL_SCROLL_ROOT_ID_MASK
}

pub fn combine_id_with_fragment_type(id: usize, fragment_type: FragmentType) -> usize {
pub fn combine_id_with_fragment_type(id: usize, fragment_type: FragmentType) -> usize {
debug_assert_eq!(id & (fragment_type as usize), 0);
if fragment_type == FragmentType::FragmentBody {
id
@@ -1,25 +1,26 @@
// FORK NOTE: Copied from liballoc_system, removed unnecessary APIs,
// APIs take size/align directly instead of Layout




// The minimum alignment guaranteed by the architecture. This value is used to
// add fast paths for low alignment values. In practice, the alignment is a
// constant at the call site and the branch will be optimized out.
#[cfg(all(any(target_arch = "x86",
target_arch = "arm",
target_arch = "mips",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "asmjs",
target_arch = "wasm32")))]
#[cfg(all(any(
target_arch = "x86",
target_arch = "arm",
target_arch = "mips",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "asmjs",
target_arch = "wasm32"
)))]
const MIN_ALIGN: usize = 8;
#[cfg(all(any(target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "mips64",
target_arch = "s390x",
target_arch = "sparc64")))]
#[cfg(all(any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "mips64",
target_arch = "s390x",
target_arch = "sparc64"
)))]
const MIN_ALIGN: usize = 16;

pub use self::platform::{alloc, dealloc, realloc};
@@ -100,7 +101,6 @@ mod platform {
type DWORD = u32;
type BOOL = i32;


extern "system" {
fn GetProcessHeap() -> HANDLE;
fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID;
@@ -123,8 +123,7 @@ mod platform {
}

#[inline]
unsafe fn allocate_with_flags(size: usize, align: usize, flags: DWORD) -> *mut u8
{
unsafe fn allocate_with_flags(size: usize, align: usize, flags: DWORD) -> *mut u8 {
if align <= MIN_ALIGN {
HeapAlloc(GetProcessHeap(), flags, size)
} else {
@@ -147,21 +146,16 @@ mod platform {
pub unsafe fn dealloc(ptr: *mut u8, align: usize) {
if align <= MIN_ALIGN {
let err = HeapFree(GetProcessHeap(), 0, ptr as LPVOID);
debug_assert!(err != 0, "Failed to free heap memory: {}",
GetLastError());
debug_assert!(err != 0, "Failed to free heap memory: {}", GetLastError());
} else {
let header = get_header(ptr);
let err = HeapFree(GetProcessHeap(), 0, header.0 as LPVOID);
debug_assert!(err != 0, "Failed to free heap memory: {}",
GetLastError());
debug_assert!(err != 0, "Failed to free heap memory: {}", GetLastError());
}
}

#[inline]
pub unsafe fn realloc(ptr: *mut u8, new_size: usize) -> *mut u8 {
HeapReAlloc(GetProcessHeap(),
0,
ptr as LPVOID,
new_size) as *mut u8
HeapReAlloc(GetProcessHeap(), 0, ptr as LPVOID, new_size) as *mut u8
}
}
@@ -26,7 +26,6 @@ pub use std::collections::hash_set::{Iter as SetIter, IntoIter as SetIntoIter};
#[derive(Clone)]
pub struct HashMap<K, V, S = RandomState>(StdMap<K, V, S>);


use FailedAllocationError;

impl<K, V, S> Deref for HashMap<K, V, S> {
@@ -43,26 +42,30 @@ impl<K, V, S> DerefMut for HashMap<K, V, S> {
}

impl<K, V, S> HashMap<K, V, S>
where K: Eq + Hash,
S: BuildHasher
where
K: Eq + Hash,
S: BuildHasher,
{
#[inline]
pub fn try_with_hasher(hash_builder: S) -> Result<HashMap<K, V, S>, FailedAllocationError> {
Ok(HashMap(StdMap::with_hasher(hash_builder)))
}

#[inline]
pub fn try_with_capacity_and_hasher(capacity: usize,
hash_builder: S)
-> Result<HashMap<K, V, S>, FailedAllocationError> {
Ok(HashMap(StdMap::with_capacity_and_hasher(capacity, hash_builder)))
pub fn try_with_capacity_and_hasher(
capacity: usize,
hash_builder: S,
) -> Result<HashMap<K, V, S>, FailedAllocationError> {
Ok(HashMap(StdMap::with_capacity_and_hasher(
capacity,
hash_builder,
)))
}

pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> HashMap<K, V, S> {
HashMap(StdMap::with_capacity_and_hasher(capacity, hash_builder))
}


#[inline]
pub fn try_reserve(&mut self, additional: usize) -> Result<(), FailedAllocationError> {
Ok(self.reserve(additional))
@@ -85,7 +88,6 @@ impl<K, V, S> HashMap<K, V, S>
#[derive(Clone)]
pub struct HashSet<T, S = RandomState>(StdSet<T, S>);


impl<T, S> Deref for HashSet<T, S> {
type Target = StdSet<T, S>;
fn deref(&self) -> &Self::Target {
@@ -111,17 +113,16 @@ impl<T: Hash + Eq> HashSet<T, RandomState> {
}
}


impl<T, S> HashSet<T, S>
where T: Eq + Hash,
S: BuildHasher
where
T: Eq + Hash,
S: BuildHasher,
{
#[inline]
pub fn with_hasher(hasher: S) -> HashSet<T, S> {
HashSet(StdSet::with_hasher(hasher))
}


#[inline]
pub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashSet<T, S> {
HashSet(StdSet::with_capacity_and_hasher(capacity, hasher))
@@ -153,34 +154,39 @@ impl<K: Hash + Eq, V, S: BuildHasher + Default> Default for HashMap<K, V, S> {
}

impl<K, V, S> fmt::Debug for HashMap<K, V, S>
where K: Eq + Hash + fmt::Debug,
V: fmt::Debug,
S: BuildHasher {
where
K: Eq + Hash + fmt::Debug,
V: fmt::Debug,
S: BuildHasher,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.0.fmt(f)
}
}

impl<K, V, S> PartialEq for HashMap<K, V, S>
where K: Eq + Hash,
V: PartialEq,
S: BuildHasher
where
K: Eq + Hash,
V: PartialEq,
S: BuildHasher,
{
fn eq(&self, other: &HashMap<K, V, S>) -> bool {
self.0.eq(&other.0)
}
}

impl<K, V, S> Eq for HashMap<K, V, S>
where K: Eq + Hash,
V: Eq,
S: BuildHasher
where
K: Eq + Hash,
V: Eq,
S: BuildHasher,
{
}

impl<'a, K, V, S> IntoIterator for &'a HashMap<K, V, S>
where K: Eq + Hash,
S: BuildHasher
where
K: Eq + Hash,
S: BuildHasher,
{
type Item = (&'a K, &'a V);
type IntoIter = MapIter<'a, K, V>;
@@ -191,8 +197,9 @@ impl<'a, K, V, S> IntoIterator for &'a HashMap<K, V, S>
}

impl<'a, K, V, S> IntoIterator for &'a mut HashMap<K, V, S>
where K: Eq + Hash,
S: BuildHasher
where
K: Eq + Hash,
S: BuildHasher,
{
type Item = (&'a K, &'a mut V);
type IntoIter = MapIterMut<'a, K, V>;
@@ -209,32 +216,36 @@ impl<T: Eq + Hash, S: BuildHasher + Default> Default for HashSet<T, S> {
}

impl<T, S> fmt::Debug for HashSet<T, S>
where T: Eq + Hash + fmt::Debug,
S: BuildHasher
where
T: Eq + Hash + fmt::Debug,
S: BuildHasher,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.0.fmt(f)
}
}

impl<T, S> PartialEq for HashSet<T, S>
where T: Eq + Hash,
S: BuildHasher
where
T: Eq + Hash,
S: BuildHasher,
{
fn eq(&self, other: &HashSet<T, S>) -> bool {
self.0.eq(&other.0)
}
}

impl<T, S> Eq for HashSet<T, S>
where T: Eq + Hash,
S: BuildHasher
where
T: Eq + Hash,
S: BuildHasher,
{
}

impl<'a, T, S> IntoIterator for &'a HashSet<T, S>
where T: Eq + Hash,
S: BuildHasher
where
T: Eq + Hash,
S: BuildHasher,
{
type Item = &'a T;
type IntoIter = SetIter<'a, T>;
@@ -245,16 +256,14 @@ impl<'a, T, S> IntoIterator for &'a HashSet<T, S>
}

impl<T, S> IntoIterator for HashSet<T, S>
where T: Eq + Hash,
S: BuildHasher
where
T: Eq + Hash,
S: BuildHasher,
{
type Item = T;
type IntoIter = SetIntoIter<T>;


fn into_iter(self) -> SetIntoIter<T> {
self.0.into_iter()
}
}


ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.