diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2023-06-06 23:25:18 +0200 |
---|---|---|
committer | Oriol Brufau <obrufau@igalia.com> | 2023-06-09 10:22:25 +0200 |
commit | 5b62f66f6e60e57d025f3a8709469227832b3bc1 (patch) | |
tree | fbbe549ac0ef8c40243ec01df7da93dda5cd4407 | |
parent | fc4d185079ea17cfc973e37e6f871c4927071b32 (diff) | |
download | servo-5b62f66f6e60e57d025f3a8709469227832b3bc1.tar.gz servo-5b62f66f6e60e57d025f3a8709469227832b3bc1.zip |
style: Remove ThinBoxedSlice
The only remaining consumers are ::-moz-tree pseudo-elements (we used to
use ThinBoxedSlice for other data structures in the past).
Those are not particularly performance sensitive so I think just
double-boxing is fine. In the future, if we wanted to avoid the double
indirection, we could probably use the "thin" crate
(https://docs.rs/thin) or similar, which stores the length of the slice
along with the allocation, making the pointer thin in all
configurations, much like "ThinArc" does:
https://searchfox.org/mozilla-central/rev/1ce2eea39442190a71a1f8f650d098f286bf4a01/servo/components/servo_arc/lib.rs#891
In practice though, I don't think it's particularly worth it for this
specific case.
Differential Revision: https://phabricator.services.mozilla.com/D134672
-rw-r--r-- | components/malloc_size_of/Cargo.toml | 1 | ||||
-rw-r--r-- | components/malloc_size_of/lib.rs | 18 | ||||
-rw-r--r-- | components/style/Cargo.toml | 4 | ||||
-rw-r--r-- | components/style/gecko/pseudo_element.rs | 1 | ||||
-rw-r--r-- | components/style/gecko/pseudo_element_definition.mako.rs | 5 | ||||
-rw-r--r-- | components/to_shmem/Cargo.toml | 1 | ||||
-rw-r--r-- | components/to_shmem/lib.rs | 18 |
7 files changed, 5 insertions, 43 deletions
diff --git a/components/malloc_size_of/Cargo.toml b/components/malloc_size_of/Cargo.toml index 43a82c9ed8d..23d7a79d371 100644 --- a/components/malloc_size_of/Cargo.toml +++ b/components/malloc_size_of/Cargo.toml @@ -44,7 +44,6 @@ servo_arc = { path = "../servo_arc" } smallbitvec = { workspace = true } smallvec = { workspace = true } string_cache = { workspace = true, optional = true } -thin-slice = { workspace = true } time = { workspace = true, optional = true } tokio = { workspace = true } url = { workspace = true, optional = true } diff --git a/components/malloc_size_of/lib.rs b/components/malloc_size_of/lib.rs index fa5a9b1e0ce..2a684ac73d1 100644 --- a/components/malloc_size_of/lib.rs +++ b/components/malloc_size_of/lib.rs @@ -213,24 +213,6 @@ impl<T: MallocSizeOf + ?Sized> MallocSizeOf for Box<T> { } } -impl<T> MallocShallowSizeOf for thin_slice::ThinBoxedSlice<T> { - fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - let mut n = 0; - unsafe { - n += thin_slice::ThinBoxedSlice::spilled_storage(self) - .map_or(0, |ptr| ops.malloc_size_of(ptr)); - n += ops.malloc_size_of(&**self); - } - n - } -} - -impl<T: MallocSizeOf> MallocSizeOf for thin_slice::ThinBoxedSlice<T> { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.shallow_size_of(ops) + (**self).size_of(ops) - } -} - impl MallocSizeOf for () { fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { 0 diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 6c49fcf5889..17af89e9e34 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -17,8 +17,7 @@ path = "lib.rs" doctest = false [features] -gecko = ["style_traits/gecko", "bindgen", "regex", "toml", - "num_cpus", "thin-slice"] +gecko = ["style_traits/gecko", "bindgen", "regex", "toml", "num_cpus"] servo = ["serde", "style_traits/servo", "servo_atoms", "servo_config", "html5ever", "cssparser/serde", "encoding_rs", "malloc_size_of/servo", "servo_url", "string_cache", "to_shmem/servo", @@ -68,7 +67,6 @@ smallvec = "1.0" string_cache = { version = "0.8", optional = true } style_derive = { path = "../style_derive" } style_traits = { path = "../style_traits" } -thin-slice = { version = "0.1.0", optional = true } time = "0.1" to_shmem = { path = "../to_shmem" } to_shmem_derive = { path = "../to_shmem_derive" } diff --git a/components/style/gecko/pseudo_element.rs b/components/style/gecko/pseudo_element.rs index be8d0def121..855fed9a0d8 100644 --- a/components/style/gecko/pseudo_element.rs +++ b/components/style/gecko/pseudo_element.rs @@ -17,7 +17,6 @@ use crate::string_cache::Atom; use crate::values::serialize_atom_identifier; use cssparser::ToCss; use std::fmt; -use thin_slice::ThinBoxedSlice; include!(concat!( env!("OUT_DIR"), diff --git a/components/style/gecko/pseudo_element_definition.mako.rs b/components/style/gecko/pseudo_element_definition.mako.rs index 41dff1a9468..dd6d1aad227 100644 --- a/components/style/gecko/pseudo_element_definition.mako.rs +++ b/components/style/gecko/pseudo_element_definition.mako.rs @@ -3,12 +3,15 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ /// Gecko's pseudo-element definition. +/// +/// We intentionally double-box legacy ::-moz-tree pseudo-elements to keep the +/// size of PseudoElement (and thus selector components) small. #[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToShmem)] pub enum PseudoElement { % for pseudo in PSEUDOS: /// ${pseudo.value} % if pseudo.is_tree_pseudo_element(): - ${pseudo.capitalized_pseudo()}(ThinBoxedSlice<Atom>), + ${pseudo.capitalized_pseudo()}(Box<Box<[Atom]>>), % else: ${pseudo.capitalized_pseudo()}, % endif diff --git a/components/to_shmem/Cargo.toml b/components/to_shmem/Cargo.toml index a87b441fa10..9ef2cefe112 100644 --- a/components/to_shmem/Cargo.toml +++ b/components/to_shmem/Cargo.toml @@ -20,4 +20,3 @@ servo_arc = { path = "../servo_arc" } smallbitvec = { workspace = true } smallvec = { workspace = true } string_cache = { workspace = true, optional = true } -thin-slice = { workspace = true } diff --git a/components/to_shmem/lib.rs b/components/to_shmem/lib.rs index 9188346eb59..6de65ff440e 100644 --- a/components/to_shmem/lib.rs +++ b/components/to_shmem/lib.rs @@ -32,7 +32,6 @@ use std::os::raw::c_void; use std::ptr::{self, NonNull}; use std::slice; use std::str; -use thin_slice::ThinBoxedSlice; /// Result type for ToShmem::to_shmem. /// @@ -334,23 +333,6 @@ impl<T: ToShmem> ToShmem for Box<[T]> { } } -impl<T: ToShmem> ToShmem for ThinBoxedSlice<T> { - fn to_shmem(&self, builder: &mut SharedMemoryBuilder) -> Result<Self> { - // We could support this if we needed but in practice we will never - // need to handle such big ThinBoxedSlices. - assert!( - self.spilled_storage().is_none(), - "ToShmem failed for ThinBoxedSlice: too many entries ({})", - self.len(), - ); - - unsafe { - let dest = to_shmem_slice(self.iter(), builder)?; - Ok(ManuallyDrop::new(ThinBoxedSlice::from_raw(dest))) - } - } -} - impl ToShmem for Box<str> { fn to_shmem(&self, builder: &mut SharedMemoryBuilder) -> Result<Self> { // Reserve space for the string bytes. |