Auto merge of #6308 - pcwalton:debloat-partialeq, r=nox

This makes the difference between selector matching scaling on the ARM
Cortex-A9 and not, because the auto-derived `PartialEq` implementation
blows out the 32KB I-cache. With this change, there is a 2x improvement
in selector matching over sequential when using all 8 cores. (More work
needs to be done; this is a start.)

r? any DOM expert

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6308)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-06-12 21:04:05 -06:00
commit c3d242544e
4 changed files with 83 additions and 8 deletions

View file

@ -28,6 +28,7 @@ use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::collections::hash_state::DefaultState;
use std::default::Default;
use std::ffi::CString;
use std::intrinsics;
use std::ptr;
use url::Url;
@ -40,7 +41,7 @@ pub enum ListenerPhase {
Bubbling,
}
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone)]
#[jstraceable]
pub enum EventTargetTypeId {
Node(NodeTypeId),
@ -51,6 +52,42 @@ pub enum EventTargetTypeId {
XMLHttpRequestEventTarget(XMLHttpRequestEventTargetTypeId)
}
impl PartialEq for EventTargetTypeId {
#[inline]
fn eq(&self, other: &EventTargetTypeId) -> bool {
match (*self, *other) {
(EventTargetTypeId::Node(this_type), EventTargetTypeId::Node(other_type)) => {
this_type == other_type
}
_ => self.eq_slow(other)
}
}
}
impl EventTargetTypeId {
#[allow(unsafe_code)]
fn eq_slow(&self, other: &EventTargetTypeId) -> bool {
match (*self, *other) {
(EventTargetTypeId::Node(this_type), EventTargetTypeId::Node(other_type)) => {
this_type == other_type
}
(EventTargetTypeId::WorkerGlobalScope(this_type),
EventTargetTypeId::WorkerGlobalScope(other_type)) => {
this_type == other_type
}
(EventTargetTypeId::XMLHttpRequestEventTarget(this_type),
EventTargetTypeId::XMLHttpRequestEventTarget(other_type)) => {
this_type == other_type
}
(_, _) => {
unsafe {
intrinsics::discriminant_value(self) == intrinsics::discriminant_value(other)
}
}
}
}
}
#[derive(Copy, Clone, PartialEq)]
#[jstraceable]
pub enum EventListenerType {