mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
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:
commit
c3d242544e
4 changed files with 83 additions and 8 deletions
|
@ -28,6 +28,7 @@ use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||||
use std::collections::hash_state::DefaultState;
|
use std::collections::hash_state::DefaultState;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
|
use std::intrinsics;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ pub enum ListenerPhase {
|
||||||
Bubbling,
|
Bubbling,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone)]
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
pub enum EventTargetTypeId {
|
pub enum EventTargetTypeId {
|
||||||
Node(NodeTypeId),
|
Node(NodeTypeId),
|
||||||
|
@ -51,6 +52,42 @@ pub enum EventTargetTypeId {
|
||||||
XMLHttpRequestEventTarget(XMLHttpRequestEventTargetTypeId)
|
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)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
pub enum EventListenerType {
|
pub enum EventListenerType {
|
||||||
|
|
|
@ -36,6 +36,7 @@ use string_cache::Atom;
|
||||||
|
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
use std::intrinsics;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct HTMLElement {
|
pub struct HTMLElement {
|
||||||
|
@ -303,7 +304,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLElement> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
pub enum HTMLElementTypeId {
|
pub enum HTMLElementTypeId {
|
||||||
HTMLElement,
|
HTMLElement,
|
||||||
|
@ -374,3 +375,25 @@ pub enum HTMLElementTypeId {
|
||||||
HTMLUnknownElement,
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,10 +42,17 @@ impl HTMLMediaElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
pub enum HTMLMediaElementTypeId {
|
pub enum HTMLMediaElementTypeId {
|
||||||
HTMLAudioElement,
|
HTMLAudioElement = 0,
|
||||||
HTMLVideoElement,
|
HTMLVideoElement = 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq for HTMLMediaElementTypeId {
|
||||||
|
#[inline]
|
||||||
|
fn eq(&self, other: &HTMLMediaElementTypeId) -> bool {
|
||||||
|
(*self as u8) == (*other as u8)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,18 @@ use std::cmp::max;
|
||||||
|
|
||||||
const DEFAULT_COLSPAN: u32 = 1;
|
const DEFAULT_COLSPAN: u32 = 1;
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
pub enum HTMLTableCellElementTypeId {
|
pub enum HTMLTableCellElementTypeId {
|
||||||
HTMLTableDataCellElement,
|
HTMLTableDataCellElement = 0,
|
||||||
HTMLTableHeaderCellElement,
|
HTMLTableHeaderCellElement = 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq for HTMLTableCellElementTypeId {
|
||||||
|
#[inline]
|
||||||
|
fn eq(&self, other: &HTMLTableCellElementTypeId) -> bool {
|
||||||
|
(*self as u8) == (*other as u8)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -143,3 +150,4 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTableCellElement> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue