mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Upgrade rustc to d3c49d2140fc65e8bb7d7cf25bfe74dda6ce5ecf/rustc-1.0.0-dev.
This commit is contained in:
parent
65d4b12bf2
commit
5f15eb5fbf
140 changed files with 1420 additions and 1222 deletions
|
@ -36,7 +36,7 @@ path = "../../support/rust-task_info"
|
|||
[dependencies.string_cache]
|
||||
git = "https://github.com/servo/string-cache"
|
||||
|
||||
[dependencies.string_cache_macros]
|
||||
[dependencies.string_cache_plugin]
|
||||
git = "https://github.com/servo/string-cache"
|
||||
|
||||
[dependencies.lazy_static]
|
||||
|
@ -47,7 +47,7 @@ bitflags = "*"
|
|||
libc = "*"
|
||||
rand = "*"
|
||||
regex = "0.1.14"
|
||||
rustc-serialize = "0.2"
|
||||
rustc-serialize = "0.3"
|
||||
text_writer = "0.1.1"
|
||||
time = "0.1.12"
|
||||
url = "0.2.16"
|
||||
|
|
|
@ -12,6 +12,7 @@ use std::hash::{Hash, Hasher, SipHasher};
|
|||
use std::iter::repeat;
|
||||
use rand;
|
||||
use std::slice::Iter;
|
||||
use std::default::Default;
|
||||
|
||||
#[cfg(test)]
|
||||
use std::cell::Cell;
|
||||
|
@ -21,12 +22,12 @@ pub struct HashCache<K, V> {
|
|||
}
|
||||
|
||||
impl<K, V> HashCache<K,V>
|
||||
where K: Clone + PartialEq + Eq + Hash<SipHasher>,
|
||||
where K: Clone + PartialEq + Eq + Hash,
|
||||
V: Clone,
|
||||
{
|
||||
pub fn new() -> HashCache<K,V> {
|
||||
HashCache {
|
||||
entries: HashMap::with_hash_state(DefaultState),
|
||||
entries: HashMap::with_hash_state(<DefaultState<SipHasher> as Default>::default()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,7 +134,7 @@ pub struct SimpleHashCache<K,V> {
|
|||
k1: u64,
|
||||
}
|
||||
|
||||
impl<K:Clone+Eq+Hash<SipHasher>,V:Clone> SimpleHashCache<K,V> {
|
||||
impl<K:Clone+Eq+Hash,V:Clone> SimpleHashCache<K,V> {
|
||||
pub fn new(cache_size: usize) -> SimpleHashCache<K,V> {
|
||||
let mut r = rand::thread_rng();
|
||||
SimpleHashCache {
|
||||
|
@ -149,7 +150,7 @@ impl<K:Clone+Eq+Hash<SipHasher>,V:Clone> SimpleHashCache<K,V> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn bucket_for_key<Q:Hash<SipHasher>>(&self, key: &Q) -> usize {
|
||||
fn bucket_for_key<Q:Hash>(&self, key: &Q) -> usize {
|
||||
let mut hasher = SipHasher::new_with_keys(self.k0, self.k1);
|
||||
key.hash(&mut hasher);
|
||||
self.to_bucket(hasher.finish() as usize)
|
||||
|
@ -160,7 +161,7 @@ impl<K:Clone+Eq+Hash<SipHasher>,V:Clone> SimpleHashCache<K,V> {
|
|||
self.entries[bucket_index] = Some((key, value));
|
||||
}
|
||||
|
||||
pub fn find<Q>(&self, key: &Q) -> Option<V> where Q: PartialEq<K> + Hash<SipHasher> + Eq {
|
||||
pub fn find<Q>(&self, key: &Q) -> Option<V> where Q: PartialEq<K> + Hash + Eq {
|
||||
let bucket_index = self.bucket_for_key(key);
|
||||
match self.entries[bucket_index] {
|
||||
Some((ref existing_key, ref value)) if key == existing_key => Some((*value).clone()),
|
||||
|
|
|
@ -78,6 +78,8 @@ struct Deque<T> {
|
|||
pool: BufferPool<T>,
|
||||
}
|
||||
|
||||
unsafe impl<T> Send for Deque<T> {}
|
||||
|
||||
/// Worker half of the work-stealing deque. This worker has exclusive access to
|
||||
/// one side of the deque, and uses `push` and `pop` method to manipulate it.
|
||||
///
|
||||
|
@ -144,7 +146,7 @@ struct Buffer<T> {
|
|||
|
||||
unsafe impl<T: 'static> Send for Buffer<T> { }
|
||||
|
||||
impl<T: Send> BufferPool<T> {
|
||||
impl<T: Send + 'static> BufferPool<T> {
|
||||
/// Allocates a new buffer pool which in turn can be used to allocate new
|
||||
/// deques.
|
||||
pub fn new() -> BufferPool<T> {
|
||||
|
@ -182,7 +184,7 @@ impl<T: Send> Clone for BufferPool<T> {
|
|||
fn clone(&self) -> BufferPool<T> { BufferPool { pool: self.pool.clone() } }
|
||||
}
|
||||
|
||||
impl<T: Send> Worker<T> {
|
||||
impl<T: Send + 'static> Worker<T> {
|
||||
/// Pushes data onto the front of this work queue.
|
||||
pub fn push(&self, t: T) {
|
||||
unsafe { self.deque.push(t) }
|
||||
|
@ -201,7 +203,7 @@ impl<T: Send> Worker<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: Send> Stealer<T> {
|
||||
impl<T: Send + 'static> Stealer<T> {
|
||||
/// Steals work off the end of the queue (opposite of the worker's end)
|
||||
pub fn steal(&self) -> Stolen<T> {
|
||||
unsafe { self.deque.steal() }
|
||||
|
@ -224,7 +226,7 @@ impl<T: Send> Clone for Stealer<T> {
|
|||
// Almost all of this code can be found directly in the paper so I'm not
|
||||
// personally going to heavily comment what's going on here.
|
||||
|
||||
impl<T: Send> Deque<T> {
|
||||
impl<T: Send + 'static> Deque<T> {
|
||||
fn new(mut pool: BufferPool<T>) -> Deque<T> {
|
||||
let buf = pool.alloc(MIN_BITS);
|
||||
Deque {
|
||||
|
@ -330,7 +332,7 @@ impl<T: Send> Deque<T> {
|
|||
|
||||
|
||||
#[unsafe_destructor]
|
||||
impl<T: Send> Drop for Deque<T> {
|
||||
impl<T: Send + 'static> Drop for Deque<T> {
|
||||
fn drop(&mut self) {
|
||||
let t = self.top.load(SeqCst);
|
||||
let b = self.bottom.load(SeqCst);
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
|
||||
//! Utility functions for doubly-linked lists.
|
||||
|
||||
use std::collections::DList;
|
||||
use std::collections::LinkedList;
|
||||
use std::mem;
|
||||
|
||||
/// Splits the head off a list in O(1) time, and returns the head.
|
||||
pub fn split_off_head<T>(list: &mut DList<T>) -> DList<T> {
|
||||
pub fn split_off_head<T>(list: &mut LinkedList<T>) -> LinkedList<T> {
|
||||
// FIXME: Work around https://github.com/rust-lang/rust/issues/22244
|
||||
if list.len() == 1 {
|
||||
return mem::replace(list, DList::new());
|
||||
return mem::replace(list, LinkedList::new());
|
||||
}
|
||||
let tail = list.split_off(1);
|
||||
mem::replace(list, tail)
|
||||
|
@ -19,7 +19,7 @@ pub fn split_off_head<T>(list: &mut DList<T>) -> DList<T> {
|
|||
|
||||
/// Prepends the items in the other list to this one, leaving the other list empty.
|
||||
#[inline]
|
||||
pub fn prepend_from<T>(this: &mut DList<T>, other: &mut DList<T>) {
|
||||
pub fn prepend_from<T>(this: &mut LinkedList<T>, other: &mut LinkedList<T>) {
|
||||
other.append(this);
|
||||
mem::swap(this, other);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
//! This file stolen wholesale from rustc/src/librustc/util/nodemap.rs
|
||||
|
||||
use std::default::Default;
|
||||
use std::hash::{Hasher, Writer};
|
||||
use std::hash::Hasher;
|
||||
use std::num::wrapping::WrappingOps;
|
||||
|
||||
/// A speedy hash algorithm for node ids and def ids. The hashmap in
|
||||
/// libcollections by default uses SipHash which isn't quite as speedy as we
|
||||
|
@ -22,17 +23,12 @@ impl Default for FnvHasher {
|
|||
}
|
||||
|
||||
impl Hasher for FnvHasher {
|
||||
type Output = u64;
|
||||
fn reset(&mut self) { *self = Default::default(); }
|
||||
fn finish(&self) -> u64 { self.0 }
|
||||
}
|
||||
|
||||
impl Writer for FnvHasher {
|
||||
fn write(&mut self, bytes: &[u8]) {
|
||||
let FnvHasher(mut hash) = *self;
|
||||
for byte in bytes.iter() {
|
||||
hash = hash ^ (*byte as u64);
|
||||
hash = hash * 0x100000001b3;
|
||||
hash = hash.wrapping_mul(0x100000001b3);
|
||||
}
|
||||
*self = FnvHasher(hash);
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ impl Add for Au {
|
|||
fn add(self, other: Au) -> Au {
|
||||
let Au(s) = self;
|
||||
let Au(o) = other;
|
||||
Au(s + o)
|
||||
Au(s.wrapping_add(o))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ impl Sub for Au {
|
|||
fn sub(self, other: Au) -> Au {
|
||||
let Au(s) = self;
|
||||
let Au(o) = other;
|
||||
Au(s - o)
|
||||
Au(s.wrapping_sub(o))
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ impl Mul<i32> for Au {
|
|||
#[inline]
|
||||
fn mul(self, other: i32) -> Au {
|
||||
let Au(s) = self;
|
||||
Au(s * other)
|
||||
Au(s.wrapping_mul(other))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#![feature(unicode)]
|
||||
#![feature(unsafe_destructor)]
|
||||
|
||||
#![allow(missing_copy_implementations)]
|
||||
#![plugin(string_cache_plugin)]
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
|
||||
|
@ -44,8 +44,6 @@ extern crate string_cache;
|
|||
extern crate unicode;
|
||||
extern crate url;
|
||||
|
||||
#[no_link] #[macro_use] #[plugin]
|
||||
extern crate string_cache_macros;
|
||||
extern crate lazy_static;
|
||||
|
||||
pub use selectors::smallvec;
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
use libc::{c_char,c_int,c_void,size_t};
|
||||
use std::borrow::ToOwned;
|
||||
use std::collections::{DList, HashMap};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::LinkedList as DList;
|
||||
use std::ffi::CString;
|
||||
#[cfg(target_os = "linux")]
|
||||
use std::iter::AdditiveIterator;
|
||||
|
|
|
@ -271,7 +271,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
|
|||
};
|
||||
|
||||
let device_pixels_per_px = opt_match.opt_str("device-pixel-ratio").map(|dppx_str|
|
||||
ScaleFactor(dppx_str.parse().unwrap())
|
||||
ScaleFactor::new(dppx_str.parse().unwrap())
|
||||
);
|
||||
|
||||
let mut paint_threads: usize = match opt_match.opt_str("t") {
|
||||
|
|
|
@ -74,7 +74,7 @@ pub struct PersistentListIterator<'a,T> where T: 'a + Send + Sync {
|
|||
entry: Option<&'a PersistentListEntry<T>>,
|
||||
}
|
||||
|
||||
impl<'a,T> Iterator for PersistentListIterator<'a,T> where T: Send + Sync {
|
||||
impl<'a,T> Iterator for PersistentListIterator<'a,T> where T: Send + Sync + 'static {
|
||||
type Item = &'a T;
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -7,6 +7,7 @@ use std::iter;
|
|||
use std::fmt;
|
||||
use std::num;
|
||||
use std::num::Int;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
/// An index type to be used by a `Range`
|
||||
pub trait RangeIndex: Int + fmt::Debug {
|
||||
|
@ -27,93 +28,93 @@ impl RangeIndex for int {
|
|||
/// Implements a range index type with operator overloads
|
||||
#[macro_export]
|
||||
macro_rules! int_range_index {
|
||||
($(#[$attr:meta])* struct $Self:ident($T:ty)) => (
|
||||
($(#[$attr:meta])* struct $Self_:ident($T:ty)) => (
|
||||
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Debug, Copy)]
|
||||
$(#[$attr])*
|
||||
pub struct $Self(pub $T);
|
||||
pub struct $Self_(pub $T);
|
||||
|
||||
impl $Self {
|
||||
impl $Self_ {
|
||||
#[inline]
|
||||
pub fn to_uint(self) -> uint {
|
||||
self.get() as uint
|
||||
}
|
||||
}
|
||||
|
||||
impl RangeIndex for $Self {
|
||||
impl RangeIndex for $Self_ {
|
||||
type Index = $T;
|
||||
#[inline]
|
||||
fn new(x: $T) -> $Self {
|
||||
$Self(x)
|
||||
fn new(x: $T) -> $Self_ {
|
||||
$Self_(x)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get(self) -> $T {
|
||||
match self { $Self(x) => x }
|
||||
match self { $Self_(x) => x }
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::num::Int for $Self {
|
||||
fn zero() -> $Self { $Self(0) }
|
||||
fn one() -> $Self { $Self(1) }
|
||||
fn min_value() -> $Self { $Self(::std::num::Int::min_value()) }
|
||||
fn max_value() -> $Self { $Self(::std::num::Int::max_value()) }
|
||||
fn count_ones(self) -> uint { self.get().count_ones() }
|
||||
fn leading_zeros(self) -> uint { self.get().leading_zeros() }
|
||||
fn trailing_zeros(self) -> uint { self.get().trailing_zeros() }
|
||||
fn rotate_left(self, n: uint) -> $Self { $Self(self.get().rotate_left(n)) }
|
||||
fn rotate_right(self, n: uint) -> $Self { $Self(self.get().rotate_right(n)) }
|
||||
fn swap_bytes(self) -> $Self { $Self(self.get().swap_bytes()) }
|
||||
fn checked_add(self, other: $Self) -> Option<$Self> {
|
||||
self.get().checked_add(other.get()).map($Self)
|
||||
impl ::std::num::Int for $Self_ {
|
||||
fn zero() -> $Self_ { $Self_(0) }
|
||||
fn one() -> $Self_ { $Self_(1) }
|
||||
fn min_value() -> $Self_ { $Self_(::std::num::Int::min_value()) }
|
||||
fn max_value() -> $Self_ { $Self_(::std::num::Int::max_value()) }
|
||||
fn count_ones(self) -> u32 { self.get().count_ones() }
|
||||
fn leading_zeros(self) -> u32 { self.get().leading_zeros() }
|
||||
fn trailing_zeros(self) -> u32 { self.get().trailing_zeros() }
|
||||
fn rotate_left(self, n: u32) -> $Self_ { $Self_(self.get().rotate_left(n)) }
|
||||
fn rotate_right(self, n: u32) -> $Self_ { $Self_(self.get().rotate_right(n)) }
|
||||
fn swap_bytes(self) -> $Self_ { $Self_(self.get().swap_bytes()) }
|
||||
fn checked_add(self, other: $Self_) -> Option<$Self_> {
|
||||
self.get().checked_add(other.get()).map($Self_)
|
||||
}
|
||||
fn checked_sub(self, other: $Self) -> Option<$Self> {
|
||||
self.get().checked_sub(other.get()).map($Self)
|
||||
fn checked_sub(self, other: $Self_) -> Option<$Self_> {
|
||||
self.get().checked_sub(other.get()).map($Self_)
|
||||
}
|
||||
fn checked_mul(self, other: $Self) -> Option<$Self> {
|
||||
self.get().checked_mul(other.get()).map($Self)
|
||||
fn checked_mul(self, other: $Self_) -> Option<$Self_> {
|
||||
self.get().checked_mul(other.get()).map($Self_)
|
||||
}
|
||||
fn checked_div(self, other: $Self) -> Option<$Self> {
|
||||
self.get().checked_div(other.get()).map($Self)
|
||||
fn checked_div(self, other: $Self_) -> Option<$Self_> {
|
||||
self.get().checked_div(other.get()).map($Self_)
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<$Self> for $Self {
|
||||
type Output = $Self;
|
||||
impl Add<$Self_> for $Self_ {
|
||||
type Output = $Self_;
|
||||
|
||||
#[inline]
|
||||
fn add(self, other: $Self) -> $Self {
|
||||
$Self(self.get() + other.get())
|
||||
fn add(self, other: $Self_) -> $Self_ {
|
||||
$Self_(self.get() + other.get())
|
||||
}
|
||||
}
|
||||
|
||||
impl Sub<$Self> for $Self {
|
||||
type Output = $Self;
|
||||
impl Sub<$Self_> for $Self_ {
|
||||
type Output = $Self_;
|
||||
|
||||
#[inline]
|
||||
fn sub(self, other: $Self) -> $Self {
|
||||
$Self(self.get() - other.get())
|
||||
fn sub(self, other: $Self_) -> $Self_ {
|
||||
$Self_(self.get() - other.get())
|
||||
}
|
||||
}
|
||||
|
||||
impl Mul<$Self> for $Self {
|
||||
type Output = $Self;
|
||||
impl Mul<$Self_> for $Self_ {
|
||||
type Output = $Self_;
|
||||
|
||||
#[inline]
|
||||
fn mul(self, other: $Self) -> $Self {
|
||||
$Self(self.get() * other.get())
|
||||
fn mul(self, other: $Self_) -> $Self_ {
|
||||
$Self_(self.get() * other.get())
|
||||
}
|
||||
}
|
||||
|
||||
impl Neg for $Self {
|
||||
type Output = $Self;
|
||||
impl Neg for $Self_ {
|
||||
type Output = $Self_;
|
||||
|
||||
#[inline]
|
||||
fn neg(self) -> $Self {
|
||||
$Self(-self.get())
|
||||
fn neg(self) -> $Self_ {
|
||||
$Self_(-self.get())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPrimitive for $Self {
|
||||
impl ToPrimitive for $Self_ {
|
||||
fn to_i64(&self) -> Option<i64> {
|
||||
Some(self.get() as i64)
|
||||
}
|
||||
|
@ -123,65 +124,92 @@ macro_rules! int_range_index {
|
|||
}
|
||||
}
|
||||
|
||||
impl ::std::num::NumCast for $Self {
|
||||
fn from<T: ToPrimitive>(n: T) -> Option<$Self> {
|
||||
n.to_int().map($Self)
|
||||
impl ::std::num::NumCast for $Self_ {
|
||||
fn from<T: ToPrimitive>(n: T) -> Option<$Self_> {
|
||||
n.to_int().map($Self_)
|
||||
}
|
||||
}
|
||||
|
||||
impl Div<$Self> for $Self {
|
||||
type Output = $Self;
|
||||
fn div(self, other: $Self) -> $Self {
|
||||
$Self(self.get() / other.get())
|
||||
impl Div<$Self_> for $Self_ {
|
||||
type Output = $Self_;
|
||||
fn div(self, other: $Self_) -> $Self_ {
|
||||
$Self_(self.get() / other.get())
|
||||
}
|
||||
}
|
||||
|
||||
impl Rem<$Self> for $Self {
|
||||
type Output = $Self;
|
||||
fn rem(self, other: $Self) -> $Self {
|
||||
$Self(self.get() % other.get())
|
||||
impl Rem<$Self_> for $Self_ {
|
||||
type Output = $Self_;
|
||||
fn rem(self, other: $Self_) -> $Self_ {
|
||||
$Self_(self.get() % other.get())
|
||||
}
|
||||
}
|
||||
|
||||
impl Not for $Self {
|
||||
type Output = $Self;
|
||||
fn not(self) -> $Self {
|
||||
$Self(!self.get())
|
||||
impl Not for $Self_ {
|
||||
type Output = $Self_;
|
||||
fn not(self) -> $Self_ {
|
||||
$Self_(!self.get())
|
||||
}
|
||||
}
|
||||
|
||||
impl BitAnd<$Self> for $Self {
|
||||
type Output = $Self;
|
||||
fn bitand(self, other: $Self) -> $Self {
|
||||
$Self(self.get() & other.get())
|
||||
impl BitAnd<$Self_> for $Self_ {
|
||||
type Output = $Self_;
|
||||
fn bitand(self, other: $Self_) -> $Self_ {
|
||||
$Self_(self.get() & other.get())
|
||||
}
|
||||
}
|
||||
|
||||
impl BitOr<$Self> for $Self {
|
||||
type Output = $Self;
|
||||
fn bitor(self, other: $Self) -> $Self {
|
||||
$Self(self.get() | other.get())
|
||||
impl BitOr<$Self_> for $Self_ {
|
||||
type Output = $Self_;
|
||||
fn bitor(self, other: $Self_) -> $Self_ {
|
||||
$Self_(self.get() | other.get())
|
||||
}
|
||||
}
|
||||
|
||||
impl BitXor<$Self> for $Self {
|
||||
type Output = $Self;
|
||||
fn bitxor(self, other: $Self) -> $Self {
|
||||
$Self(self.get() ^ other.get())
|
||||
impl BitXor<$Self_> for $Self_ {
|
||||
type Output = $Self_;
|
||||
fn bitxor(self, other: $Self_) -> $Self_ {
|
||||
$Self_(self.get() ^ other.get())
|
||||
}
|
||||
}
|
||||
|
||||
impl Shl<uint> for $Self {
|
||||
type Output = $Self;
|
||||
fn shl(self, n: uint) -> $Self {
|
||||
$Self(self.get() << n)
|
||||
impl Shl<uint> for $Self_ {
|
||||
type Output = $Self_;
|
||||
fn shl(self, n: uint) -> $Self_ {
|
||||
$Self_(self.get() << n)
|
||||
}
|
||||
}
|
||||
|
||||
impl Shr<uint> for $Self {
|
||||
type Output = $Self;
|
||||
fn shr(self, n: uint) -> $Self {
|
||||
$Self(self.get() >> n)
|
||||
impl Shr<uint> for $Self_ {
|
||||
type Output = $Self_;
|
||||
fn shr(self, n: uint) -> $Self_ {
|
||||
$Self_(self.get() >> n)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::num::wrapping::WrappingOps for $Self_ {
|
||||
fn wrapping_add(self, rhs: $Self_) -> $Self_ {
|
||||
$Self_(self.get().wrapping_add(rhs.get()))
|
||||
}
|
||||
fn wrapping_sub(self, rhs: $Self_) -> $Self_ {
|
||||
$Self_(self.get().wrapping_sub(rhs.get()))
|
||||
}
|
||||
fn wrapping_mul(self, rhs: $Self_) -> $Self_ {
|
||||
$Self_(self.get().wrapping_mul(rhs.get()))
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::num::wrapping::OverflowingOps for $Self_ {
|
||||
fn overflowing_add(self, rhs: $Self_) -> ($Self_, bool) {
|
||||
let (x, b) = self.get().overflowing_add(rhs.get());
|
||||
($Self_(x), b)
|
||||
}
|
||||
fn overflowing_sub(self, rhs: $Self_) -> ($Self_, bool) {
|
||||
let (x, b) = self.get().overflowing_sub(rhs.get());
|
||||
($Self_(x), b)
|
||||
}
|
||||
fn overflowing_mul(self, rhs: $Self_) -> ($Self_, bool) {
|
||||
let (x, b) = self.get().overflowing_mul(rhs.get());
|
||||
($Self_(x), b)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -203,10 +231,11 @@ impl<I: RangeIndex> fmt::Debug for Range<I> {
|
|||
/// An iterator over each index in a range
|
||||
pub struct EachIndex<T, I> {
|
||||
it: iter::Range<T>,
|
||||
phantom: PhantomData<I>,
|
||||
}
|
||||
|
||||
pub fn each_index<T: Int, I: RangeIndex<Index=T>>(start: I, stop: I) -> EachIndex<T, I> {
|
||||
EachIndex { it: iter::range(start.get(), stop.get()) }
|
||||
EachIndex { it: iter::range(start.get(), stop.get()), phantom: PhantomData }
|
||||
}
|
||||
|
||||
impl<T: Int, I: RangeIndex<Index=T>> Iterator for EachIndex<T, I> {
|
||||
|
|
|
@ -2,22 +2,22 @@
|
|||
* 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/. */
|
||||
|
||||
use std::old_io::{File, IoResult};
|
||||
use std::old_path::Path;
|
||||
use std::fs::{File, PathExt};
|
||||
use std::io::{self, Read};
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
pub fn resources_dir_path() -> Path {
|
||||
Path::new("/sdcard/servo/")
|
||||
pub fn resources_dir_path() -> PathBuf {
|
||||
PathBuf::new("/sdcard/servo/")
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
pub fn resources_dir_path() -> Path {
|
||||
pub fn resources_dir_path() -> PathBuf {
|
||||
use opts;
|
||||
use std::env;
|
||||
use std::old_io::fs::PathExtensions;
|
||||
|
||||
match opts::get().resources_path {
|
||||
Some(ref path) => Path::new(path),
|
||||
Some(ref path) => PathBuf::new(path),
|
||||
None => {
|
||||
// FIXME: Find a way to not rely on the executable being
|
||||
// under `<servo source>/components/servo/target`
|
||||
|
@ -39,9 +39,13 @@ pub fn resources_dir_path() -> Path {
|
|||
}
|
||||
|
||||
|
||||
pub fn read_resource_file(relative_path_components: &[&str]) -> IoResult<Vec<u8>> {
|
||||
pub fn read_resource_file(relative_path_components: &[&str]) -> io::Result<Vec<u8>> {
|
||||
let mut path = resources_dir_path();
|
||||
path.push_many(relative_path_components);
|
||||
for component in relative_path_components {
|
||||
path.push(component);
|
||||
}
|
||||
let mut file = try!(File::open(&path));
|
||||
file.read_to_end()
|
||||
let mut data = Vec::new();
|
||||
try!(file.read_to_end(&mut data));
|
||||
Ok(data)
|
||||
}
|
||||
|
|
|
@ -35,25 +35,11 @@ pub fn null_str_as_empty_ref<'a>(s: &'a Option<DOMString>) -> &'a str {
|
|||
}
|
||||
|
||||
/// Whitespace as defined by HTML5 § 2.4.1.
|
||||
struct Whitespace;
|
||||
|
||||
impl CharEq for Whitespace {
|
||||
#[inline]
|
||||
fn matches(&mut self, ch: char) -> bool {
|
||||
match ch {
|
||||
' ' | '\t' | '\x0a' | '\x0c' | '\x0d' => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn only_ascii(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
// TODO(SimonSapin) Maybe a custom Pattern can be more efficient?
|
||||
const WHITESPACE: &'static [char] = &[' ', '\t', '\x0a', '\x0c', '\x0d'];
|
||||
|
||||
pub fn is_whitespace(s: &str) -> bool {
|
||||
s.chars().all(|c| Whitespace.matches(c))
|
||||
s.chars().all(|c| WHITESPACE.contains(&c))
|
||||
}
|
||||
|
||||
/// A "space character" according to:
|
||||
|
@ -144,7 +130,7 @@ pub enum LengthOrPercentageOrAuto {
|
|||
|
||||
/// Parses a length per HTML5 § 2.4.4.4. If unparseable, `Auto` is returned.
|
||||
pub fn parse_length(mut value: &str) -> LengthOrPercentageOrAuto {
|
||||
value = value.trim_left_matches(Whitespace);
|
||||
value = value.trim_left_matches(WHITESPACE);
|
||||
if value.len() == 0 {
|
||||
return LengthOrPercentageOrAuto::Auto
|
||||
}
|
||||
|
@ -200,7 +186,7 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA,()> {
|
|||
}
|
||||
|
||||
// Step 3.
|
||||
input = input.trim_left_matches(Whitespace).trim_right_matches(Whitespace);
|
||||
input = input.trim_matches(WHITESPACE);
|
||||
|
||||
// Step 4.
|
||||
if input.eq_ignore_ascii_case("transparent") {
|
||||
|
|
|
@ -9,7 +9,7 @@ use std::sync::mpsc::Sender;
|
|||
use std::thread::Builder;
|
||||
|
||||
pub fn spawn_named<F>(name: String, f: F)
|
||||
where F: FnOnce() + Send
|
||||
where F: FnOnce() + Send + 'static
|
||||
{
|
||||
let builder = thread::Builder::new().name(name);
|
||||
builder.spawn(move || {
|
||||
|
@ -23,13 +23,13 @@ pub fn spawn_named_with_send_on_failure<F, T>(name: &'static str,
|
|||
f: F,
|
||||
msg: T,
|
||||
dest: Sender<T>)
|
||||
where F: FnOnce() + Send,
|
||||
T: Send
|
||||
where F: FnOnce() + Send + 'static,
|
||||
T: Send + 'static
|
||||
{
|
||||
let future_handle = thread::Builder::new().name(name.to_owned()).scoped(move || {
|
||||
let future_handle = thread::Builder::new().name(name.to_owned()).spawn(move || {
|
||||
task_state::initialize(state);
|
||||
f()
|
||||
});
|
||||
}).unwrap();
|
||||
|
||||
let watcher_name = format!("{}Watcher", name);
|
||||
Builder::new().name(watcher_name).spawn(move || {
|
||||
|
|
|
@ -21,7 +21,7 @@ use std::sync::mpsc::{channel, Sender, Receiver};
|
|||
use std::thunk::Thunk;
|
||||
|
||||
pub struct TaskPool {
|
||||
tx: Sender<Thunk<()>>,
|
||||
tx: Sender<Thunk<'static, ()>>,
|
||||
}
|
||||
|
||||
impl TaskPool {
|
||||
|
@ -52,7 +52,7 @@ impl TaskPool {
|
|||
}
|
||||
|
||||
pub fn execute<F>(&self, job: F)
|
||||
where F: FnOnce() + Send
|
||||
where F: FnOnce() + Send + 'static
|
||||
{
|
||||
self.tx.send(Thunk::new(job)).unwrap();
|
||||
}
|
||||
|
|
|
@ -7,15 +7,15 @@
|
|||
//! Data associated with queues is simply a pair of unsigned integers. It is expected that a
|
||||
//! higher-level API on top of this could allow safe fork-join parallelism.
|
||||
|
||||
use deque::{Abort, BufferPool, Data, Empty, Stealer, Worker};
|
||||
use task::spawn_named;
|
||||
use task_state;
|
||||
|
||||
use libc::funcs::posix88::unistd::usleep;
|
||||
use std::mem;
|
||||
use rand::{Rng, weak_rng, XorShiftRng};
|
||||
use std::mem;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::mpsc::{channel, Sender, Receiver};
|
||||
use deque::{Abort, BufferPool, Data, Empty, Stealer, Worker};
|
||||
|
||||
/// A unit of work.
|
||||
///
|
||||
|
@ -184,7 +184,7 @@ pub struct WorkerProxy<'a, QueueData: 'a, WorkData: 'a> {
|
|||
worker_index: u8,
|
||||
}
|
||||
|
||||
impl<'a, QueueData: 'static, WorkData: Send> WorkerProxy<'a, QueueData, WorkData> {
|
||||
impl<'a, QueueData: 'static, WorkData: Send + 'static> WorkerProxy<'a, QueueData, WorkData> {
|
||||
/// Enqueues a block into the work queue.
|
||||
#[inline]
|
||||
pub fn push(&mut self, work_unit: WorkUnit<QueueData, WorkData>) {
|
||||
|
@ -297,7 +297,9 @@ impl<QueueData: Send, WorkData: Send> WorkQueue<QueueData, WorkData> {
|
|||
// Tell the workers to start.
|
||||
let mut work_count = AtomicUsize::new(self.work_count);
|
||||
for worker in self.workers.iter_mut() {
|
||||
worker.chan.send(WorkerMsg::Start(worker.deque.take().unwrap(), &mut work_count, &self.data)).unwrap()
|
||||
worker.chan.send(WorkerMsg::Start(worker.deque.take().unwrap(),
|
||||
&mut work_count,
|
||||
&self.data)).unwrap()
|
||||
}
|
||||
|
||||
// Wait for the work to finish.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue