script: Make PartialEq on element type IDs generate a lot less code.

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.)
This commit is contained in:
Patrick Walton 2015-06-08 17:39:13 -07:00
parent 41095c01a7
commit 8c210e1a27
4 changed files with 83 additions and 8 deletions

View file

@ -36,6 +36,7 @@ use string_cache::Atom;
use std::borrow::ToOwned;
use std::default::Default;
use std::intrinsics;
#[dom_struct]
pub struct HTMLElement {
@ -303,7 +304,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLElement> {
}
}
#[derive(Copy, Clone, PartialEq, Debug)]
#[derive(Copy, Clone, Debug)]
#[jstraceable]
pub enum HTMLElementTypeId {
HTMLElement,
@ -374,3 +375,25 @@ pub enum HTMLElementTypeId {
HTMLUnknownElement,
}
impl PartialEq for HTMLElementTypeId {
#[inline]
#[allow(unsafe_code)]
fn eq(&self, other: &HTMLElementTypeId) -> bool {
match (*self, *other) {
(HTMLElementTypeId::HTMLMediaElement(this_type),
HTMLElementTypeId::HTMLMediaElement(other_type)) => {
this_type == other_type
}
(HTMLElementTypeId::HTMLTableCellElement(this_type),
HTMLElementTypeId::HTMLTableCellElement(other_type)) => {
this_type == other_type
}
(_, _) => {
unsafe {
intrinsics::discriminant_value(self) == intrinsics::discriminant_value(other)
}
}
}
}
}