mirror of
https://github.com/servo/servo.git
synced 2025-09-17 02:18:23 +01:00
Replace Hash Algorithm in HashMap/Set with FxHashMap/Set for simple types (#39166)
FxHash is faster than FnvHash and SipHash for simple types up to at least 64 bytes. The cryptographic guarantees are not needed for any types changed here because they are simple ids. This changes the types in script and net crates. In a future PR we will change the remaining Fnv to be also Fx unless there is a reason to keep them as Fnv. Testing: Should not change functionality but unit test and wpt will find it. Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This commit is contained in:
parent
1deb7b5957
commit
177f6d6502
46 changed files with 226 additions and 215 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1629,6 +1629,7 @@ dependencies = [
|
||||||
"net_traits",
|
"net_traits",
|
||||||
"pixels",
|
"pixels",
|
||||||
"profile_traits",
|
"profile_traits",
|
||||||
|
"rustc-hash 2.1.1",
|
||||||
"serde",
|
"serde",
|
||||||
"servo_config",
|
"servo_config",
|
||||||
"servo_malloc_size_of",
|
"servo_malloc_size_of",
|
||||||
|
@ -5566,6 +5567,7 @@ dependencies = [
|
||||||
"rayon",
|
"rayon",
|
||||||
"resvg",
|
"resvg",
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
|
"rustc-hash 2.1.1",
|
||||||
"rustls",
|
"rustls",
|
||||||
"rustls-pemfile",
|
"rustls-pemfile",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
|
|
|
@ -31,6 +31,7 @@ data-url = { workspace = true }
|
||||||
devtools_traits = { workspace = true }
|
devtools_traits = { workspace = true }
|
||||||
embedder_traits = { workspace = true }
|
embedder_traits = { workspace = true }
|
||||||
fst = "0.4"
|
fst = "0.4"
|
||||||
|
rustc-hash = { workspace = true }
|
||||||
futures = { version = "0.3", package = "futures" }
|
futures = { version = "0.3", package = "futures" }
|
||||||
futures-core = { version = "0.3.30", default-features = false }
|
futures-core = { version = "0.3.30", default-features = false }
|
||||||
futures-util = { version = "0.3.30", default-features = false }
|
futures-util = { version = "0.3.30", default-features = false }
|
||||||
|
|
|
@ -59,6 +59,7 @@ use net_traits::{
|
||||||
};
|
};
|
||||||
use profile_traits::mem::{Report, ReportKind};
|
use profile_traits::mem::{Report, ReportKind};
|
||||||
use profile_traits::path;
|
use profile_traits::path;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use servo_url::{Host, ImmutableOrigin, ServoUrl};
|
use servo_url::{Host, ImmutableOrigin, ServoUrl};
|
||||||
use tokio::sync::mpsc::{
|
use tokio::sync::mpsc::{
|
||||||
|
@ -102,7 +103,7 @@ pub struct HttpState {
|
||||||
/// or whether a concurrent pending store should be awaited.
|
/// or whether a concurrent pending store should be awaited.
|
||||||
pub http_cache_state: HttpCacheState,
|
pub http_cache_state: HttpCacheState,
|
||||||
pub auth_cache: RwLock<AuthCache>,
|
pub auth_cache: RwLock<AuthCache>,
|
||||||
pub history_states: RwLock<HashMap<HistoryStateId, Vec<u8>>>,
|
pub history_states: RwLock<FxHashMap<HistoryStateId, Vec<u8>>>,
|
||||||
pub client: Client<Connector, crate::connector::BoxedBody>,
|
pub client: Client<Connector, crate::connector::BoxedBody>,
|
||||||
pub override_manager: CertificateErrorOverrideManager,
|
pub override_manager: CertificateErrorOverrideManager,
|
||||||
pub embedder_proxy: Mutex<EmbedderProxy>,
|
pub embedder_proxy: Mutex<EmbedderProxy>,
|
||||||
|
|
|
@ -27,6 +27,7 @@ use pixels::{CorsStatus, ImageFrame, ImageMetadata, PixelFormat, RasterImage, lo
|
||||||
use profile_traits::mem::{Report, ReportKind};
|
use profile_traits::mem::{Report, ReportKind};
|
||||||
use profile_traits::path;
|
use profile_traits::path;
|
||||||
use resvg::{tiny_skia, usvg};
|
use resvg::{tiny_skia, usvg};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use servo_config::pref;
|
use servo_config::pref;
|
||||||
use servo_url::{ImmutableOrigin, ServoUrl};
|
use servo_url::{ImmutableOrigin, ServoUrl};
|
||||||
use webrender_api::units::DeviceIntSize;
|
use webrender_api::units::DeviceIntSize;
|
||||||
|
@ -185,7 +186,7 @@ type ImageKey = (ServoUrl, ImmutableOrigin, Option<CorsSettings>);
|
||||||
struct AllPendingLoads {
|
struct AllPendingLoads {
|
||||||
// The loads, indexed by a load key. Used during most operations,
|
// The loads, indexed by a load key. Used during most operations,
|
||||||
// for performance reasons.
|
// for performance reasons.
|
||||||
loads: HashMap<LoadKey, PendingLoad>,
|
loads: FxHashMap<LoadKey, PendingLoad>,
|
||||||
|
|
||||||
// Get a load key from its url and requesting origin. Used ony when starting and
|
// Get a load key from its url and requesting origin. Used ony when starting and
|
||||||
// finishing a load or when adding a new listener.
|
// finishing a load or when adding a new listener.
|
||||||
|
@ -198,8 +199,8 @@ struct AllPendingLoads {
|
||||||
impl AllPendingLoads {
|
impl AllPendingLoads {
|
||||||
fn new() -> AllPendingLoads {
|
fn new() -> AllPendingLoads {
|
||||||
AllPendingLoads {
|
AllPendingLoads {
|
||||||
loads: HashMap::new(),
|
loads: FxHashMap::default(),
|
||||||
url_to_load_key: HashMap::new(),
|
url_to_load_key: HashMap::default(),
|
||||||
keygen: LoadKeyGenerator::new(),
|
keygen: LoadKeyGenerator::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ use net_traits::indexeddb_thread::{
|
||||||
AsyncOperation, BackendError, BackendResult, CreateObjectResult, DbResult, IndexedDBThreadMsg,
|
AsyncOperation, BackendError, BackendResult, CreateObjectResult, DbResult, IndexedDBThreadMsg,
|
||||||
IndexedDBTxnMode, KeyPath, SyncOperation,
|
IndexedDBTxnMode, KeyPath, SyncOperation,
|
||||||
};
|
};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use servo_config::pref;
|
use servo_config::pref;
|
||||||
use servo_url::origin::ImmutableOrigin;
|
use servo_url::origin::ImmutableOrigin;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
@ -78,7 +79,7 @@ impl IndexedDBDescription {
|
||||||
|
|
||||||
struct IndexedDBEnvironment<E: KvsEngine> {
|
struct IndexedDBEnvironment<E: KvsEngine> {
|
||||||
engine: E,
|
engine: E,
|
||||||
transactions: HashMap<u64, KvsTransaction>,
|
transactions: FxHashMap<u64, KvsTransaction>,
|
||||||
serial_number_counter: u64,
|
serial_number_counter: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ impl<E: KvsEngine> IndexedDBEnvironment<E> {
|
||||||
fn new(engine: E) -> IndexedDBEnvironment<E> {
|
fn new(engine: E) -> IndexedDBEnvironment<E> {
|
||||||
IndexedDBEnvironment {
|
IndexedDBEnvironment {
|
||||||
engine,
|
engine,
|
||||||
transactions: HashMap::new(),
|
transactions: FxHashMap::default(),
|
||||||
serial_number_counter: 0,
|
serial_number_counter: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ use profile_traits::mem::{
|
||||||
};
|
};
|
||||||
use profile_traits::path;
|
use profile_traits::path;
|
||||||
use profile_traits::time::ProfilerChan;
|
use profile_traits::time::ProfilerChan;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use rustls::RootCertStore;
|
use rustls::RootCertStore;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use servo_arc::Arc as ServoArc;
|
use servo_arc::Arc as ServoArc;
|
||||||
|
@ -182,8 +183,8 @@ struct ResourceChannelManager {
|
||||||
config_dir: Option<PathBuf>,
|
config_dir: Option<PathBuf>,
|
||||||
ca_certificates: CACertificates,
|
ca_certificates: CACertificates,
|
||||||
ignore_certificate_errors: bool,
|
ignore_certificate_errors: bool,
|
||||||
cancellation_listeners: HashMap<RequestId, Weak<CancellationListener>>,
|
cancellation_listeners: FxHashMap<RequestId, Weak<CancellationListener>>,
|
||||||
cookie_listeners: HashMap<CookieStoreId, IpcSender<CookieAsyncResponse>>,
|
cookie_listeners: FxHashMap<CookieStoreId, IpcSender<CookieAsyncResponse>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_http_states(
|
fn create_http_states(
|
||||||
|
@ -207,7 +208,7 @@ fn create_http_states(
|
||||||
hsts_list: RwLock::new(hsts_list),
|
hsts_list: RwLock::new(hsts_list),
|
||||||
cookie_jar: RwLock::new(cookie_jar),
|
cookie_jar: RwLock::new(cookie_jar),
|
||||||
auth_cache: RwLock::new(auth_cache),
|
auth_cache: RwLock::new(auth_cache),
|
||||||
history_states: RwLock::new(HashMap::new()),
|
history_states: RwLock::new(FxHashMap::default()),
|
||||||
http_cache: RwLock::new(http_cache),
|
http_cache: RwLock::new(http_cache),
|
||||||
http_cache_state: Mutex::new(HashMap::new()),
|
http_cache_state: Mutex::new(HashMap::new()),
|
||||||
client: create_http_client(create_tls_config(
|
client: create_http_client(create_tls_config(
|
||||||
|
@ -224,7 +225,7 @@ fn create_http_states(
|
||||||
hsts_list: RwLock::new(HstsList::default()),
|
hsts_list: RwLock::new(HstsList::default()),
|
||||||
cookie_jar: RwLock::new(CookieStorage::new(150)),
|
cookie_jar: RwLock::new(CookieStorage::new(150)),
|
||||||
auth_cache: RwLock::new(AuthCache::default()),
|
auth_cache: RwLock::new(AuthCache::default()),
|
||||||
history_states: RwLock::new(HashMap::new()),
|
history_states: RwLock::new(FxHashMap::default()),
|
||||||
http_cache: RwLock::new(HttpCache::default()),
|
http_cache: RwLock::new(HttpCache::default()),
|
||||||
http_cache_state: Mutex::new(HashMap::new()),
|
http_cache_state: Mutex::new(HashMap::new()),
|
||||||
client: create_http_client(create_tls_config(
|
client: create_http_client(create_tls_config(
|
||||||
|
|
|
@ -15,6 +15,7 @@ use profile_traits::mem::{
|
||||||
ProcessReports, ProfilerChan as MemProfilerChan, Report, ReportKind, perform_memory_report,
|
ProcessReports, ProfilerChan as MemProfilerChan, Report, ReportKind, perform_memory_report,
|
||||||
};
|
};
|
||||||
use profile_traits::path;
|
use profile_traits::path;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
|
|
||||||
use crate::resource_thread;
|
use crate::resource_thread;
|
||||||
|
@ -52,7 +53,7 @@ type OriginEntry = (usize, BTreeMap<String, String>);
|
||||||
|
|
||||||
struct StorageManager {
|
struct StorageManager {
|
||||||
port: GenericReceiver<StorageThreadMsg>,
|
port: GenericReceiver<StorageThreadMsg>,
|
||||||
session_data: HashMap<WebViewId, HashMap<String, OriginEntry>>,
|
session_data: FxHashMap<WebViewId, HashMap<String, OriginEntry>>,
|
||||||
local_data: HashMap<String, OriginEntry>,
|
local_data: HashMap<String, OriginEntry>,
|
||||||
config_dir: Option<PathBuf>,
|
config_dir: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
@ -65,7 +66,7 @@ impl StorageManager {
|
||||||
}
|
}
|
||||||
StorageManager {
|
StorageManager {
|
||||||
port,
|
port,
|
||||||
session_data: HashMap::new(),
|
session_data: FxHashMap::default(),
|
||||||
local_data,
|
local_data,
|
||||||
config_dir,
|
config_dir,
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ use net_traits::filemanager_thread::FileTokenCheck;
|
||||||
use net_traits::request::Request;
|
use net_traits::request::Request;
|
||||||
use net_traits::response::Response;
|
use net_traits::response::Response;
|
||||||
use net_traits::{AsyncRuntime, FetchTaskTarget, ResourceFetchTiming, ResourceTimingType};
|
use net_traits::{AsyncRuntime, FetchTaskTarget, ResourceFetchTiming, ResourceTimingType};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use rustls_pemfile::{certs, pkcs8_private_keys};
|
use rustls_pemfile::{certs, pkcs8_private_keys};
|
||||||
use rustls_pki_types::{CertificateDer, PrivateKeyDer};
|
use rustls_pki_types::{CertificateDer, PrivateKeyDer};
|
||||||
use servo_arc::Arc as ServoArc;
|
use servo_arc::Arc as ServoArc;
|
||||||
|
@ -146,7 +147,7 @@ fn create_http_state(fc: Option<EmbedderProxy>) -> HttpState {
|
||||||
hsts_list: RwLock::new(net::hsts::HstsList::default()),
|
hsts_list: RwLock::new(net::hsts::HstsList::default()),
|
||||||
cookie_jar: RwLock::new(net::cookie_storage::CookieStorage::new(150)),
|
cookie_jar: RwLock::new(net::cookie_storage::CookieStorage::new(150)),
|
||||||
auth_cache: RwLock::new(net::resource_thread::AuthCache::default()),
|
auth_cache: RwLock::new(net::resource_thread::AuthCache::default()),
|
||||||
history_states: RwLock::new(HashMap::new()),
|
history_states: RwLock::new(FxHashMap::default()),
|
||||||
http_cache: RwLock::new(net::http_cache::HttpCache::default()),
|
http_cache: RwLock::new(net::http_cache::HttpCache::default()),
|
||||||
http_cache_state: Mutex::new(HashMap::new()),
|
http_cache_state: Mutex::new(HashMap::new()),
|
||||||
client: create_http_client(create_tls_config(
|
client: create_http_client(create_tls_config(
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::collections::{HashMap, hash_map};
|
use std::collections::hash_map;
|
||||||
|
|
||||||
use base::id::{BrowsingContextId, PipelineId};
|
use base::id::{BrowsingContextId, PipelineId};
|
||||||
|
use rustc_hash::{FxBuildHasher, FxHashMap};
|
||||||
|
|
||||||
use crate::dom::bindings::inheritance::Castable;
|
use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
|
@ -20,7 +21,7 @@ use crate::dom::window::Window;
|
||||||
#[derive(JSTraceable)]
|
#[derive(JSTraceable)]
|
||||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||||
pub(crate) struct DocumentCollection {
|
pub(crate) struct DocumentCollection {
|
||||||
map: HashMapTracedValues<PipelineId, Dom<Document>>,
|
map: HashMapTracedValues<PipelineId, Dom<Document>, FxBuildHasher>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DocumentCollection {
|
impl DocumentCollection {
|
||||||
|
@ -95,7 +96,7 @@ impl Default for DocumentCollection {
|
||||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
map: HashMapTracedValues::new(),
|
map: HashMapTracedValues::new_fx(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +134,7 @@ struct DocumentTreeNode {
|
||||||
/// [st]: crate::script_thread::ScriptThread
|
/// [st]: crate::script_thread::ScriptThread
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct DocumentTree {
|
struct DocumentTree {
|
||||||
tree: HashMap<PipelineId, DocumentTreeNode>,
|
tree: FxHashMap<PipelineId, DocumentTreeNode>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DocumentTree {
|
impl DocumentTree {
|
||||||
|
|
|
@ -2,10 +2,9 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::collections::HashSet;
|
|
||||||
|
|
||||||
use crossbeam_channel::{Receiver, select};
|
use crossbeam_channel::{Receiver, select};
|
||||||
use devtools_traits::DevtoolScriptControlMsg;
|
use devtools_traits::DevtoolScriptControlMsg;
|
||||||
|
use rustc_hash::FxHashSet;
|
||||||
|
|
||||||
use crate::dom::bindings::conversions::DerivedFrom;
|
use crate::dom::bindings::conversions::DerivedFrom;
|
||||||
use crate::dom::bindings::reflector::DomObject;
|
use crate::dom::bindings::reflector::DomObject;
|
||||||
|
@ -55,7 +54,7 @@ pub(crate) fn run_worker_event_loop<T, WorkerMsg, Event>(
|
||||||
let event = select! {
|
let event = select! {
|
||||||
recv(worker_scope.control_receiver()) -> msg => T::from_control_msg(msg.unwrap()),
|
recv(worker_scope.control_receiver()) -> msg => T::from_control_msg(msg.unwrap()),
|
||||||
recv(task_queue.select()) -> msg => {
|
recv(task_queue.select()) -> msg => {
|
||||||
task_queue.take_tasks(msg.unwrap(), &HashSet::new());
|
task_queue.take_tasks(msg.unwrap(), &FxHashSet::default());
|
||||||
T::from_worker_msg(task_queue.recv().unwrap())
|
T::from_worker_msg(task_queue.recv().unwrap())
|
||||||
},
|
},
|
||||||
recv(devtools_receiver) -> msg => T::from_devtools_msg(msg.unwrap()),
|
recv(devtools_receiver) -> msg => T::from_devtools_msg(msg.unwrap()),
|
||||||
|
@ -74,7 +73,7 @@ pub(crate) fn run_worker_event_loop<T, WorkerMsg, Event>(
|
||||||
while !scope.is_closing() {
|
while !scope.is_closing() {
|
||||||
// Batch all events that are ready.
|
// Batch all events that are ready.
|
||||||
// The task queue will throttle non-priority tasks if necessary.
|
// The task queue will throttle non-priority tasks if necessary.
|
||||||
match task_queue.take_tasks_and_recv(&HashSet::new()) {
|
match task_queue.take_tasks_and_recv(&FxHashSet::default()) {
|
||||||
Err(_) => match devtools_receiver.try_recv() {
|
Err(_) => match devtools_receiver.try_recv() {
|
||||||
Ok(message) => sequential.push(T::from_devtools_msg(message)),
|
Ok(message) => sequential.push(T::from_devtools_msg(message)),
|
||||||
Err(_) => break,
|
Err(_) => break,
|
||||||
|
|
|
@ -5,9 +5,8 @@
|
||||||
//! Trait representing the concept of [serializable objects]
|
//! Trait representing the concept of [serializable objects]
|
||||||
//! (<https://html.spec.whatwg.org/multipage/#serializable-objects>).
|
//! (<https://html.spec.whatwg.org/multipage/#serializable-objects>).
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use base::id::{Index, NamespaceIndex, PipelineNamespaceId};
|
use base::id::{Index, NamespaceIndex, PipelineNamespaceId};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use script_bindings::structuredclone::MarkedAsSerializableInIdl;
|
use script_bindings::structuredclone::MarkedAsSerializableInIdl;
|
||||||
|
|
||||||
use crate::dom::bindings::reflector::DomObject;
|
use crate::dom::bindings::reflector::DomObject;
|
||||||
|
@ -68,7 +67,7 @@ where
|
||||||
/// should be used to read/store serialized instances of this type.
|
/// should be used to read/store serialized instances of this type.
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<NamespaceIndex<Self::Index>, Self::Data>>;
|
) -> &'a mut Option<FxHashMap<NamespaceIndex<Self::Index>, Self::Data>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn assert_serializable<T: Serializable>() {}
|
pub(crate) fn assert_serializable<T: Serializable>() {}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
//! This module implements structured cloning, as defined by [HTML](https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data).
|
//! This module implements structured cloning, as defined by [HTML](https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data).
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::os::raw;
|
use std::os::raw;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
@ -34,6 +33,7 @@ use js::rust::wrappers::{JS_ReadStructuredClone, JS_WriteStructuredClone};
|
||||||
use js::rust::{
|
use js::rust::{
|
||||||
CustomAutoRooterGuard, HandleValue, JSAutoStructuredCloneBufferWrapper, MutableHandleValue,
|
CustomAutoRooterGuard, HandleValue, JSAutoStructuredCloneBufferWrapper, MutableHandleValue,
|
||||||
};
|
};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use script_bindings::conversions::{IDLInterface, SafeToJSValConvertible};
|
use script_bindings::conversions::{IDLInterface, SafeToJSValConvertible};
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ unsafe fn write_object<T: Serializable>(
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if let Ok((new_id, serialized)) = object.serialize() {
|
if let Ok((new_id, serialized)) = object.serialize() {
|
||||||
let objects = T::serialized_storage(StructuredData::Writer(sc_writer))
|
let objects = T::serialized_storage(StructuredData::Writer(sc_writer))
|
||||||
.get_or_insert_with(HashMap::new);
|
.get_or_insert(FxHashMap::default());
|
||||||
objects.insert(new_id, serialized);
|
objects.insert(new_id, serialized);
|
||||||
let storage_key = StorageKey::new(new_id);
|
let storage_key = StorageKey::new(new_id);
|
||||||
|
|
||||||
|
@ -416,8 +416,8 @@ unsafe fn try_transfer<T: Transferable + IDLInterface>(
|
||||||
let (id, object) = object.transfer().map_err(OperationError::Exception)?;
|
let (id, object) = object.transfer().map_err(OperationError::Exception)?;
|
||||||
|
|
||||||
// 2. Store the transferred object at a given key.
|
// 2. Store the transferred object at a given key.
|
||||||
let objects =
|
let objects = T::serialized_storage(StructuredData::Writer(sc_writer))
|
||||||
T::serialized_storage(StructuredData::Writer(sc_writer)).get_or_insert_with(HashMap::new);
|
.get_or_insert(FxHashMap::default());
|
||||||
objects.insert(id, object);
|
objects.insert(id, object);
|
||||||
|
|
||||||
let index = id.index.0.get();
|
let index = id.index.0.get();
|
||||||
|
@ -587,32 +587,33 @@ pub(crate) struct StructuredDataReader<'a> {
|
||||||
/// A map of port implementations,
|
/// A map of port implementations,
|
||||||
/// used as part of the "transfer-receiving" steps of ports,
|
/// used as part of the "transfer-receiving" steps of ports,
|
||||||
/// to produce the DOM ports stored in `message_ports` above.
|
/// to produce the DOM ports stored in `message_ports` above.
|
||||||
pub(crate) port_impls: Option<HashMap<MessagePortId, MessagePortImpl>>,
|
pub(crate) port_impls: Option<FxHashMap<MessagePortId, MessagePortImpl>>,
|
||||||
/// A map of transform stream implementations,
|
/// A map of transform stream implementations,
|
||||||
pub(crate) transform_streams_port_impls: Option<HashMap<MessagePortId, TransformStreamData>>,
|
pub(crate) transform_streams_port_impls: Option<FxHashMap<MessagePortId, TransformStreamData>>,
|
||||||
/// A map of blob implementations,
|
/// A map of blob implementations,
|
||||||
/// used as part of the "deserialize" steps of blobs,
|
/// used as part of the "deserialize" steps of blobs,
|
||||||
/// to produce the DOM blobs stored in `blobs` above.
|
/// to produce the DOM blobs stored in `blobs` above.
|
||||||
pub(crate) blob_impls: Option<HashMap<BlobId, BlobImpl>>,
|
pub(crate) blob_impls: Option<FxHashMap<BlobId, BlobImpl>>,
|
||||||
/// A map of serialized points.
|
/// A map of serialized points.
|
||||||
pub(crate) points: Option<HashMap<DomPointId, DomPoint>>,
|
pub(crate) points: Option<FxHashMap<DomPointId, DomPoint>>,
|
||||||
/// A map of serialized rects.
|
/// A map of serialized rects.
|
||||||
pub(crate) rects: Option<HashMap<DomRectId, DomRect>>,
|
pub(crate) rects: Option<FxHashMap<DomRectId, DomRect>>,
|
||||||
/// A map of serialized quads.
|
/// A map of serialized quads.
|
||||||
pub(crate) quads: Option<HashMap<DomQuadId, DomQuad>>,
|
pub(crate) quads: Option<FxHashMap<DomQuadId, DomQuad>>,
|
||||||
/// A map of serialized matrices.
|
/// A map of serialized matrices.
|
||||||
pub(crate) matrices: Option<HashMap<DomMatrixId, DomMatrix>>,
|
pub(crate) matrices: Option<FxHashMap<DomMatrixId, DomMatrix>>,
|
||||||
/// A map of serialized exceptions.
|
/// A map of serialized exceptions.
|
||||||
pub(crate) exceptions: Option<HashMap<DomExceptionId, DomException>>,
|
pub(crate) exceptions: Option<FxHashMap<DomExceptionId, DomException>>,
|
||||||
/// A map of serialized quota exceeded errors.
|
/// A map of serialized quota exceeded errors.
|
||||||
pub(crate) quota_exceeded_errors:
|
pub(crate) quota_exceeded_errors:
|
||||||
Option<HashMap<QuotaExceededErrorId, SerializableQuotaExceededError>>,
|
Option<FxHashMap<QuotaExceededErrorId, SerializableQuotaExceededError>>,
|
||||||
// A map of serialized image bitmaps.
|
// A map of serialized image bitmaps.
|
||||||
pub(crate) image_bitmaps: Option<HashMap<ImageBitmapId, SerializableImageBitmap>>,
|
pub(crate) image_bitmaps: Option<FxHashMap<ImageBitmapId, SerializableImageBitmap>>,
|
||||||
/// A map of transferred image bitmaps.
|
/// A map of transferred image bitmaps.
|
||||||
pub(crate) transferred_image_bitmaps: Option<HashMap<ImageBitmapId, SerializableImageBitmap>>,
|
pub(crate) transferred_image_bitmaps: Option<FxHashMap<ImageBitmapId, SerializableImageBitmap>>,
|
||||||
/// A map of transferred offscreen canvases.
|
/// A map of transferred offscreen canvases.
|
||||||
pub(crate) offscreen_canvases: Option<HashMap<OffscreenCanvasId, TransferableOffscreenCanvas>>,
|
pub(crate) offscreen_canvases:
|
||||||
|
Option<FxHashMap<OffscreenCanvasId, TransferableOffscreenCanvas>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A data holder for transferred and serialized objects.
|
/// A data holder for transferred and serialized objects.
|
||||||
|
@ -622,30 +623,31 @@ pub(crate) struct StructuredDataWriter {
|
||||||
/// Error record.
|
/// Error record.
|
||||||
pub(crate) error: Option<Error>,
|
pub(crate) error: Option<Error>,
|
||||||
/// Transferred ports.
|
/// Transferred ports.
|
||||||
pub(crate) ports: Option<HashMap<MessagePortId, MessagePortImpl>>,
|
pub(crate) ports: Option<FxHashMap<MessagePortId, MessagePortImpl>>,
|
||||||
/// Transferred transform streams.
|
/// Transferred transform streams.
|
||||||
pub(crate) transform_streams_port: Option<HashMap<MessagePortId, TransformStreamData>>,
|
pub(crate) transform_streams_port: Option<FxHashMap<MessagePortId, TransformStreamData>>,
|
||||||
/// Serialized points.
|
/// Serialized points.
|
||||||
pub(crate) points: Option<HashMap<DomPointId, DomPoint>>,
|
pub(crate) points: Option<FxHashMap<DomPointId, DomPoint>>,
|
||||||
/// Serialized rects.
|
/// Serialized rects.
|
||||||
pub(crate) rects: Option<HashMap<DomRectId, DomRect>>,
|
pub(crate) rects: Option<FxHashMap<DomRectId, DomRect>>,
|
||||||
/// Serialized quads.
|
/// Serialized quads.
|
||||||
pub(crate) quads: Option<HashMap<DomQuadId, DomQuad>>,
|
pub(crate) quads: Option<FxHashMap<DomQuadId, DomQuad>>,
|
||||||
/// Serialized matrices.
|
/// Serialized matrices.
|
||||||
pub(crate) matrices: Option<HashMap<DomMatrixId, DomMatrix>>,
|
pub(crate) matrices: Option<FxHashMap<DomMatrixId, DomMatrix>>,
|
||||||
/// Serialized exceptions.
|
/// Serialized exceptions.
|
||||||
pub(crate) exceptions: Option<HashMap<DomExceptionId, DomException>>,
|
pub(crate) exceptions: Option<FxHashMap<DomExceptionId, DomException>>,
|
||||||
/// Serialized quota exceeded errors.
|
/// Serialized quota exceeded errors.
|
||||||
pub(crate) quota_exceeded_errors:
|
pub(crate) quota_exceeded_errors:
|
||||||
Option<HashMap<QuotaExceededErrorId, SerializableQuotaExceededError>>,
|
Option<FxHashMap<QuotaExceededErrorId, SerializableQuotaExceededError>>,
|
||||||
/// Serialized blobs.
|
/// Serialized blobs.
|
||||||
pub(crate) blobs: Option<HashMap<BlobId, BlobImpl>>,
|
pub(crate) blobs: Option<FxHashMap<BlobId, BlobImpl>>,
|
||||||
/// Serialized image bitmaps.
|
/// Serialized image bitmaps.
|
||||||
pub(crate) image_bitmaps: Option<HashMap<ImageBitmapId, SerializableImageBitmap>>,
|
pub(crate) image_bitmaps: Option<FxHashMap<ImageBitmapId, SerializableImageBitmap>>,
|
||||||
/// Transferred image bitmaps.
|
/// Transferred image bitmaps.
|
||||||
pub(crate) transferred_image_bitmaps: Option<HashMap<ImageBitmapId, SerializableImageBitmap>>,
|
pub(crate) transferred_image_bitmaps: Option<FxHashMap<ImageBitmapId, SerializableImageBitmap>>,
|
||||||
/// Transferred offscreen canvases.
|
/// Transferred offscreen canvases.
|
||||||
pub(crate) offscreen_canvases: Option<HashMap<OffscreenCanvasId, TransferableOffscreenCanvas>>,
|
pub(crate) offscreen_canvases:
|
||||||
|
Option<FxHashMap<OffscreenCanvasId, TransferableOffscreenCanvas>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Writes a structured clone. Returns a `DataClone` error if that fails.
|
/// Writes a structured clone. Returns a `DataClone` error if that fails.
|
||||||
|
|
|
@ -40,6 +40,7 @@ use js::glue::{CallScriptTracer, CallStringTracer, CallValueTracer};
|
||||||
use js::jsapi::{GCTraceKindToAscii, Heap, JSScript, JSString, JSTracer, TraceKind};
|
use js::jsapi::{GCTraceKindToAscii, Heap, JSScript, JSString, JSTracer, TraceKind};
|
||||||
use js::jsval::JSVal;
|
use js::jsval::JSVal;
|
||||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||||
|
use rustc_hash::FxBuildHasher;
|
||||||
pub(crate) use script_bindings::trace::*;
|
pub(crate) use script_bindings::trace::*;
|
||||||
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
|
@ -92,6 +93,9 @@ impl<T: MallocSizeOf> MallocSizeOf for NoTrace<T> {
|
||||||
/// HashMap wrapper, that has non-jsmanaged keys
|
/// HashMap wrapper, that has non-jsmanaged keys
|
||||||
///
|
///
|
||||||
/// Not all methods are reexposed, but you can access inner type via .0
|
/// Not all methods are reexposed, but you can access inner type via .0
|
||||||
|
/// If you need cryptographic secure hashs, or your keys are arbitrary large inputs
|
||||||
|
/// stick with the default hasher. Otherwise, stronlgy think about using FxHashBuilder
|
||||||
|
/// with `new_fx()`
|
||||||
#[cfg_attr(crown, crown::trace_in_no_trace_lint::must_not_have_traceable(0))]
|
#[cfg_attr(crown, crown::trace_in_no_trace_lint::must_not_have_traceable(0))]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) struct HashMapTracedValues<K, V, S = RandomState>(pub(crate) HashMap<K, V, S>);
|
pub(crate) struct HashMapTracedValues<K, V, S = RandomState>(pub(crate) HashMap<K, V, S>);
|
||||||
|
@ -111,6 +115,14 @@ impl<K, V> HashMapTracedValues<K, V, RandomState> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<K, V> HashMapTracedValues<K, V, FxBuildHasher> {
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
|
pub(crate) fn new_fx() -> HashMapTracedValues<K, V, FxBuildHasher> {
|
||||||
|
Self(HashMap::with_hasher(FxBuildHasher))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<K, V, S> HashMapTracedValues<K, V, S> {
|
impl<K, V, S> HashMapTracedValues<K, V, S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn iter(&self) -> std::collections::hash_map::Iter<'_, K, V> {
|
pub(crate) fn iter(&self) -> std::collections::hash_map::Iter<'_, K, V> {
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
//! Trait representing the concept of [transferable objects]
|
//! Trait representing the concept of [transferable objects]
|
||||||
//! (<https://html.spec.whatwg.org/multipage/#transferable-objects>).
|
//! (<https://html.spec.whatwg.org/multipage/#transferable-objects>).
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
use base::id::NamespaceIndex;
|
use base::id::NamespaceIndex;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use script_bindings::structuredclone::MarkedAsTransferableInIdl;
|
use script_bindings::structuredclone::MarkedAsTransferableInIdl;
|
||||||
|
|
||||||
use crate::dom::bindings::error::Fallible;
|
use crate::dom::bindings::error::Fallible;
|
||||||
|
@ -40,7 +40,7 @@ where
|
||||||
|
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<NamespaceIndex<Self::Index>, Self::Data>>;
|
) -> &'a mut Option<FxHashMap<NamespaceIndex<Self::Index>, Self::Data>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn assert_transferable<T: Transferable>() {}
|
pub(crate) fn assert_transferable<T: Transferable>() {}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
@ -14,6 +13,7 @@ use js::jsapi::JSObject;
|
||||||
use js::rust::HandleObject;
|
use js::rust::HandleObject;
|
||||||
use js::typedarray::{ArrayBufferU8, Uint8};
|
use js::typedarray::{ArrayBufferU8, Uint8};
|
||||||
use net_traits::filemanager_thread::RelativePos;
|
use net_traits::filemanager_thread::RelativePos;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::dom::bindings::buffer_source::create_buffer_source;
|
use crate::dom::bindings::buffer_source::create_buffer_source;
|
||||||
|
@ -120,7 +120,7 @@ impl Serializable for Blob {
|
||||||
|
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
reader: StructuredData<'a, '_>,
|
reader: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<BlobId, Self::Data>> {
|
) -> &'a mut Option<FxHashMap<BlobId, Self::Data>> {
|
||||||
match reader {
|
match reader {
|
||||||
StructuredData::Reader(r) => &mut r.blob_impls,
|
StructuredData::Reader(r) => &mut r.blob_impls,
|
||||||
StructuredData::Writer(w) => &mut w.blobs,
|
StructuredData::Writer(w) => &mut w.blobs,
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::cell::{Cell, Ref};
|
use std::cell::{Cell, Ref};
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use base::id::{ImageBitmapId, ImageBitmapIndex};
|
use base::id::{ImageBitmapId, ImageBitmapIndex};
|
||||||
|
@ -11,6 +10,7 @@ use constellation_traits::SerializableImageBitmap;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use euclid::default::{Point2D, Rect, Size2D};
|
use euclid::default::{Point2D, Rect, Size2D};
|
||||||
use pixels::{CorsStatus, PixelFormat, Snapshot, SnapshotAlphaMode, SnapshotPixelFormat};
|
use pixels::{CorsStatus, PixelFormat, Snapshot, SnapshotAlphaMode, SnapshotPixelFormat};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use script_bindings::error::{Error, Fallible};
|
use script_bindings::error::{Error, Fallible};
|
||||||
use script_bindings::realms::{AlreadyInRealm, InRealm};
|
use script_bindings::realms::{AlreadyInRealm, InRealm};
|
||||||
|
|
||||||
|
@ -663,7 +663,7 @@ impl Serializable for ImageBitmap {
|
||||||
|
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<ImageBitmapId, Self::Data>> {
|
) -> &'a mut Option<FxHashMap<ImageBitmapId, Self::Data>> {
|
||||||
match data {
|
match data {
|
||||||
StructuredData::Reader(r) => &mut r.image_bitmaps,
|
StructuredData::Reader(r) => &mut r.image_bitmaps,
|
||||||
StructuredData::Writer(w) => &mut w.image_bitmaps,
|
StructuredData::Writer(w) => &mut w.image_bitmaps,
|
||||||
|
@ -716,7 +716,7 @@ impl Transferable for ImageBitmap {
|
||||||
|
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<ImageBitmapId, Self::Data>> {
|
) -> &'a mut Option<FxHashMap<ImageBitmapId, Self::Data>> {
|
||||||
match data {
|
match data {
|
||||||
StructuredData::Reader(r) => &mut r.transferred_image_bitmaps,
|
StructuredData::Reader(r) => &mut r.transferred_image_bitmaps,
|
||||||
StructuredData::Writer(w) => &mut w.transferred_image_bitmaps,
|
StructuredData::Writer(w) => &mut w.transferred_image_bitmaps,
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use base::id::{OffscreenCanvasId, OffscreenCanvasIndex};
|
use base::id::{OffscreenCanvasId, OffscreenCanvasIndex};
|
||||||
|
@ -12,6 +11,7 @@ use dom_struct::dom_struct;
|
||||||
use euclid::default::Size2D;
|
use euclid::default::Size2D;
|
||||||
use js::rust::{HandleObject, HandleValue};
|
use js::rust::{HandleObject, HandleValue};
|
||||||
use pixels::{EncodedImageType, Snapshot};
|
use pixels::{EncodedImageType, Snapshot};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use script_bindings::weakref::WeakRef;
|
use script_bindings::weakref::WeakRef;
|
||||||
|
|
||||||
use crate::canvas_context::{CanvasContext, OffscreenRenderingContext};
|
use crate::canvas_context::{CanvasContext, OffscreenRenderingContext};
|
||||||
|
@ -261,7 +261,7 @@ impl Transferable for OffscreenCanvas {
|
||||||
|
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<OffscreenCanvasId, Self::Data>> {
|
) -> &'a mut Option<FxHashMap<OffscreenCanvasId, Self::Data>> {
|
||||||
match data {
|
match data {
|
||||||
StructuredData::Reader(r) => &mut r.offscreen_canvases,
|
StructuredData::Reader(r) => &mut r.offscreen_canvases,
|
||||||
StructuredData::Writer(w) => &mut w.offscreen_canvases,
|
StructuredData::Writer(w) => &mut w.offscreen_canvases,
|
||||||
|
|
|
@ -47,6 +47,7 @@ use percent_encoding::percent_decode;
|
||||||
use profile_traits::ipc as profile_ipc;
|
use profile_traits::ipc as profile_ipc;
|
||||||
use profile_traits::time::TimerMetadataFrameType;
|
use profile_traits::time::TimerMetadataFrameType;
|
||||||
use regex::bytes::Regex;
|
use regex::bytes::Regex;
|
||||||
|
use rustc_hash::FxBuildHasher;
|
||||||
use script_bindings::codegen::GenericBindings::ElementBinding::ElementMethods;
|
use script_bindings::codegen::GenericBindings::ElementBinding::ElementMethods;
|
||||||
use script_bindings::interfaces::DocumentHelpers;
|
use script_bindings::interfaces::DocumentHelpers;
|
||||||
use script_bindings::script_runtime::JSContext;
|
use script_bindings::script_runtime::JSContext;
|
||||||
|
@ -474,15 +475,17 @@ pub(crate) struct Document {
|
||||||
/// hosting the media controls UI.
|
/// hosting the media controls UI.
|
||||||
media_controls: DomRefCell<HashMap<String, Dom<ShadowRoot>>>,
|
media_controls: DomRefCell<HashMap<String, Dom<ShadowRoot>>>,
|
||||||
/// List of all context 2d IDs that need flushing.
|
/// List of all context 2d IDs that need flushing.
|
||||||
dirty_2d_contexts: DomRefCell<HashMapTracedValues<CanvasId, Dom<CanvasRenderingContext2D>>>,
|
dirty_2d_contexts:
|
||||||
|
DomRefCell<HashMapTracedValues<CanvasId, Dom<CanvasRenderingContext2D>, FxBuildHasher>>,
|
||||||
/// List of all WebGL context IDs that need flushing.
|
/// List of all WebGL context IDs that need flushing.
|
||||||
dirty_webgl_contexts:
|
dirty_webgl_contexts:
|
||||||
DomRefCell<HashMapTracedValues<WebGLContextId, Dom<WebGLRenderingContext>>>,
|
DomRefCell<HashMapTracedValues<WebGLContextId, Dom<WebGLRenderingContext>, FxBuildHasher>>,
|
||||||
/// Whether or not animated images need to have their contents updated.
|
/// Whether or not animated images need to have their contents updated.
|
||||||
has_pending_animated_image_update: Cell<bool>,
|
has_pending_animated_image_update: Cell<bool>,
|
||||||
/// List of all WebGPU contexts that need flushing.
|
/// List of all WebGPU contexts that need flushing.
|
||||||
#[cfg(feature = "webgpu")]
|
#[cfg(feature = "webgpu")]
|
||||||
dirty_webgpu_contexts: DomRefCell<HashMapTracedValues<WebGPUContextId, Dom<GPUCanvasContext>>>,
|
dirty_webgpu_contexts:
|
||||||
|
DomRefCell<HashMapTracedValues<WebGPUContextId, Dom<GPUCanvasContext>, FxBuildHasher>>,
|
||||||
/// <https://w3c.github.io/slection-api/#dfn-selection>
|
/// <https://w3c.github.io/slection-api/#dfn-selection>
|
||||||
selection: MutNullableDom<Selection>,
|
selection: MutNullableDom<Selection>,
|
||||||
/// A timeline for animations which is used for synchronizing animations.
|
/// A timeline for animations which is used for synchronizing animations.
|
||||||
|
@ -3418,11 +3421,11 @@ impl Document {
|
||||||
shadow_roots: DomRefCell::new(HashSet::new()),
|
shadow_roots: DomRefCell::new(HashSet::new()),
|
||||||
shadow_roots_styles_changed: Cell::new(false),
|
shadow_roots_styles_changed: Cell::new(false),
|
||||||
media_controls: DomRefCell::new(HashMap::new()),
|
media_controls: DomRefCell::new(HashMap::new()),
|
||||||
dirty_2d_contexts: DomRefCell::new(HashMapTracedValues::new()),
|
dirty_2d_contexts: DomRefCell::new(HashMapTracedValues::new_fx()),
|
||||||
dirty_webgl_contexts: DomRefCell::new(HashMapTracedValues::new()),
|
dirty_webgl_contexts: DomRefCell::new(HashMapTracedValues::new_fx()),
|
||||||
has_pending_animated_image_update: Cell::new(false),
|
has_pending_animated_image_update: Cell::new(false),
|
||||||
#[cfg(feature = "webgpu")]
|
#[cfg(feature = "webgpu")]
|
||||||
dirty_webgpu_contexts: DomRefCell::new(HashMapTracedValues::new()),
|
dirty_webgpu_contexts: DomRefCell::new(HashMapTracedValues::new_fx()),
|
||||||
selection: MutNullableDom::new(None),
|
selection: MutNullableDom::new(None),
|
||||||
animation_timeline: if pref!(layout_animations_test_enabled) {
|
animation_timeline: if pref!(layout_animations_test_enabled) {
|
||||||
DomRefCell::new(AnimationTimeline::new_for_testing())
|
DomRefCell::new(AnimationTimeline::new_for_testing())
|
||||||
|
|
|
@ -2,12 +2,11 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use base::id::{DomExceptionId, DomExceptionIndex};
|
use base::id::{DomExceptionId, DomExceptionIndex};
|
||||||
use constellation_traits::DomException;
|
use constellation_traits::DomException;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::rust::HandleObject;
|
use js::rust::HandleObject;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use crate::dom::bindings::codegen::Bindings::DOMExceptionBinding::{
|
use crate::dom::bindings::codegen::Bindings::DOMExceptionBinding::{
|
||||||
DOMExceptionConstants, DOMExceptionMethods,
|
DOMExceptionConstants, DOMExceptionMethods,
|
||||||
|
@ -280,7 +279,7 @@ impl Serializable for DOMException {
|
||||||
|
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<DomExceptionId, Self::Data>> {
|
) -> &'a mut Option<FxHashMap<DomExceptionId, Self::Data>> {
|
||||||
match data {
|
match data {
|
||||||
StructuredData::Reader(reader) => &mut reader.exceptions,
|
StructuredData::Reader(reader) => &mut reader.exceptions,
|
||||||
StructuredData::Writer(writer) => &mut writer.exceptions,
|
StructuredData::Writer(writer) => &mut writer.exceptions,
|
||||||
|
|
|
@ -2,14 +2,13 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use base::id::{DomMatrixId, DomMatrixIndex};
|
use base::id::{DomMatrixId, DomMatrixIndex};
|
||||||
use constellation_traits::DomMatrix;
|
use constellation_traits::DomMatrix;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use euclid::default::Transform3D;
|
use euclid::default::Transform3D;
|
||||||
use js::rust::{CustomAutoRooterGuard, HandleObject};
|
use js::rust::{CustomAutoRooterGuard, HandleObject};
|
||||||
use js::typedarray::{Float32Array, Float64Array};
|
use js::typedarray::{Float32Array, Float64Array};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use script_bindings::str::DOMString;
|
use script_bindings::str::DOMString;
|
||||||
|
|
||||||
use crate::dom::bindings::codegen::Bindings::DOMMatrixBinding::{DOMMatrixInit, DOMMatrixMethods};
|
use crate::dom::bindings::codegen::Bindings::DOMMatrixBinding::{DOMMatrixInit, DOMMatrixMethods};
|
||||||
|
@ -574,7 +573,7 @@ impl Serializable for DOMMatrix {
|
||||||
|
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<DomMatrixId, Self::Data>> {
|
) -> &'a mut Option<FxHashMap<DomMatrixId, Self::Data>> {
|
||||||
match data {
|
match data {
|
||||||
StructuredData::Reader(reader) => &mut reader.matrices,
|
StructuredData::Reader(reader) => &mut reader.matrices,
|
||||||
StructuredData::Writer(writer) => &mut writer.matrices,
|
StructuredData::Writer(writer) => &mut writer.matrices,
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::{f64, ptr};
|
use std::{f64, ptr};
|
||||||
|
|
||||||
use base::id::{DomMatrixId, DomMatrixIndex};
|
use base::id::{DomMatrixId, DomMatrixIndex};
|
||||||
|
@ -17,6 +16,7 @@ use js::jsapi::JSObject;
|
||||||
use js::jsval;
|
use js::jsval;
|
||||||
use js::rust::{CustomAutoRooterGuard, HandleObject, ToString};
|
use js::rust::{CustomAutoRooterGuard, HandleObject, ToString};
|
||||||
use js::typedarray::{Float32Array, Float64Array};
|
use js::typedarray::{Float32Array, Float64Array};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
@ -1033,7 +1033,7 @@ impl Serializable for DOMMatrixReadOnly {
|
||||||
|
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<DomMatrixId, Self::Data>> {
|
) -> &'a mut Option<FxHashMap<DomMatrixId, Self::Data>> {
|
||||||
match data {
|
match data {
|
||||||
StructuredData::Reader(reader) => &mut reader.matrices,
|
StructuredData::Reader(reader) => &mut reader.matrices,
|
||||||
StructuredData::Writer(writer) => &mut writer.matrices,
|
StructuredData::Writer(writer) => &mut writer.matrices,
|
||||||
|
|
|
@ -2,12 +2,11 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use base::id::{DomPointId, DomPointIndex};
|
use base::id::{DomPointId, DomPointIndex};
|
||||||
use constellation_traits::DomPoint;
|
use constellation_traits::DomPoint;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::rust::HandleObject;
|
use js::rust::HandleObject;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMethods};
|
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMethods};
|
||||||
use crate::dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::DOMPointReadOnlyMethods;
|
use crate::dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::DOMPointReadOnlyMethods;
|
||||||
|
@ -165,7 +164,7 @@ impl Serializable for DOMPoint {
|
||||||
|
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<DomPointId, Self::Data>> {
|
) -> &'a mut Option<FxHashMap<DomPointId, Self::Data>> {
|
||||||
match data {
|
match data {
|
||||||
StructuredData::Reader(reader) => &mut reader.points,
|
StructuredData::Reader(reader) => &mut reader.points,
|
||||||
StructuredData::Writer(writer) => &mut writer.points,
|
StructuredData::Writer(writer) => &mut writer.points,
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use base::id::{DomPointId, DomPointIndex};
|
use base::id::{DomPointId, DomPointIndex};
|
||||||
use constellation_traits::DomPoint;
|
use constellation_traits::DomPoint;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::rust::HandleObject;
|
use js::rust::HandleObject;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use crate::dom::bindings::codegen::Bindings::DOMMatrixBinding::DOMMatrixInit;
|
use crate::dom::bindings::codegen::Bindings::DOMMatrixBinding::DOMMatrixInit;
|
||||||
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
|
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
|
||||||
|
@ -213,7 +213,7 @@ impl Serializable for DOMPointReadOnly {
|
||||||
|
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<DomPointId, Self::Data>> {
|
) -> &'a mut Option<FxHashMap<DomPointId, Self::Data>> {
|
||||||
match data {
|
match data {
|
||||||
StructuredData::Reader(r) => &mut r.points,
|
StructuredData::Reader(r) => &mut r.points,
|
||||||
StructuredData::Writer(w) => &mut w.points,
|
StructuredData::Writer(w) => &mut w.points,
|
||||||
|
|
|
@ -2,12 +2,11 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use base::id::{DomQuadId, DomQuadIndex};
|
use base::id::{DomQuadId, DomQuadIndex};
|
||||||
use constellation_traits::{DomPoint, DomQuad};
|
use constellation_traits::{DomPoint, DomQuad};
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::rust::HandleObject;
|
use js::rust::HandleObject;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMethods};
|
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMethods};
|
||||||
use crate::dom::bindings::codegen::Bindings::DOMQuadBinding::{DOMQuadInit, DOMQuadMethods};
|
use crate::dom::bindings::codegen::Bindings::DOMQuadBinding::{DOMQuadInit, DOMQuadMethods};
|
||||||
|
@ -255,7 +254,7 @@ impl Serializable for DOMQuad {
|
||||||
|
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<DomQuadId, Self::Data>> {
|
) -> &'a mut Option<FxHashMap<DomQuadId, Self::Data>> {
|
||||||
match data {
|
match data {
|
||||||
StructuredData::Reader(reader) => &mut reader.quads,
|
StructuredData::Reader(reader) => &mut reader.quads,
|
||||||
StructuredData::Writer(writer) => &mut writer.quads,
|
StructuredData::Writer(writer) => &mut writer.quads,
|
||||||
|
|
|
@ -2,12 +2,11 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use base::id::{DomRectId, DomRectIndex};
|
use base::id::{DomRectId, DomRectIndex};
|
||||||
use constellation_traits::DomRect;
|
use constellation_traits::DomRect;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::rust::HandleObject;
|
use js::rust::HandleObject;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use crate::dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods;
|
use crate::dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::{
|
use crate::dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::{
|
||||||
|
@ -162,7 +161,7 @@ impl Serializable for DOMRect {
|
||||||
|
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<DomRectId, Self::Data>> {
|
) -> &'a mut Option<FxHashMap<DomRectId, Self::Data>> {
|
||||||
match data {
|
match data {
|
||||||
StructuredData::Reader(reader) => &mut reader.rects,
|
StructuredData::Reader(reader) => &mut reader.rects,
|
||||||
StructuredData::Writer(writer) => &mut writer.rects,
|
StructuredData::Writer(writer) => &mut writer.rects,
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use base::id::{DomRectId, DomRectIndex};
|
use base::id::{DomRectId, DomRectIndex};
|
||||||
use constellation_traits::DomRect;
|
use constellation_traits::DomRect;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::rust::HandleObject;
|
use js::rust::HandleObject;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use crate::dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::{
|
use crate::dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::{
|
||||||
DOMRectInit, DOMRectReadOnlyMethods,
|
DOMRectInit, DOMRectReadOnlyMethods,
|
||||||
|
@ -239,7 +239,7 @@ impl Serializable for DOMRectReadOnly {
|
||||||
|
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<Type, Self::Data>> {
|
) -> &'a mut Option<FxHashMap<Type, Self::Data>> {
|
||||||
match data {
|
match data {
|
||||||
StructuredData::Reader(reader) => &mut reader.rects,
|
StructuredData::Reader(reader) => &mut reader.rects,
|
||||||
StructuredData::Writer(writer) => &mut writer.rects,
|
StructuredData::Writer(writer) => &mut writer.rects,
|
||||||
|
|
|
@ -57,6 +57,7 @@ use net_traits::{
|
||||||
ResourceThreads, fetch_async,
|
ResourceThreads, fetch_async,
|
||||||
};
|
};
|
||||||
use profile_traits::{ipc as profile_ipc, mem as profile_mem, time as profile_time};
|
use profile_traits::{ipc as profile_ipc, mem as profile_mem, time as profile_time};
|
||||||
|
use rustc_hash::{FxBuildHasher, FxHashMap};
|
||||||
use script_bindings::interfaces::GlobalScopeHelpers;
|
use script_bindings::interfaces::GlobalScopeHelpers;
|
||||||
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
||||||
use timers::{TimerEventRequest, TimerId};
|
use timers::{TimerEventRequest, TimerId};
|
||||||
|
@ -204,18 +205,22 @@ pub(crate) struct GlobalScope {
|
||||||
broadcast_channel_state: DomRefCell<BroadcastChannelState>,
|
broadcast_channel_state: DomRefCell<BroadcastChannelState>,
|
||||||
|
|
||||||
/// The blobs managed by this global, if any.
|
/// The blobs managed by this global, if any.
|
||||||
blob_state: DomRefCell<HashMapTracedValues<BlobId, BlobInfo>>,
|
blob_state: DomRefCell<HashMapTracedValues<BlobId, BlobInfo, FxBuildHasher>>,
|
||||||
|
|
||||||
/// <https://w3c.github.io/ServiceWorker/#environment-settings-object-service-worker-registration-object-map>
|
/// <https://w3c.github.io/ServiceWorker/#environment-settings-object-service-worker-registration-object-map>
|
||||||
registration_map: DomRefCell<
|
registration_map: DomRefCell<
|
||||||
HashMapTracedValues<ServiceWorkerRegistrationId, Dom<ServiceWorkerRegistration>>,
|
HashMapTracedValues<
|
||||||
|
ServiceWorkerRegistrationId,
|
||||||
|
Dom<ServiceWorkerRegistration>,
|
||||||
|
FxBuildHasher,
|
||||||
|
>,
|
||||||
>,
|
>,
|
||||||
|
|
||||||
/// <https://cookiestore.spec.whatwg.org/#globals>
|
/// <https://cookiestore.spec.whatwg.org/#globals>
|
||||||
cookie_store: MutNullableDom<CookieStore>,
|
cookie_store: MutNullableDom<CookieStore>,
|
||||||
|
|
||||||
/// <https://w3c.github.io/ServiceWorker/#environment-settings-object-service-worker-object-map>
|
/// <https://w3c.github.io/ServiceWorker/#environment-settings-object-service-worker-object-map>
|
||||||
worker_map: DomRefCell<HashMapTracedValues<ServiceWorkerId, Dom<ServiceWorker>>>,
|
worker_map: DomRefCell<HashMapTracedValues<ServiceWorkerId, Dom<ServiceWorker>, FxBuildHasher>>,
|
||||||
|
|
||||||
/// Pipeline id associated with this global.
|
/// Pipeline id associated with this global.
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
|
@ -234,7 +239,7 @@ pub(crate) struct GlobalScope {
|
||||||
module_map: DomRefCell<HashMapTracedValues<ServoUrl, Rc<ModuleTree>>>,
|
module_map: DomRefCell<HashMapTracedValues<ServoUrl, Rc<ModuleTree>>>,
|
||||||
|
|
||||||
#[ignore_malloc_size_of = "mozjs"]
|
#[ignore_malloc_size_of = "mozjs"]
|
||||||
inline_module_map: DomRefCell<HashMap<ScriptId, Rc<ModuleTree>>>,
|
inline_module_map: DomRefCell<FxHashMap<ScriptId, Rc<ModuleTree>>>,
|
||||||
|
|
||||||
/// For providing instructions to an optional devtools server.
|
/// For providing instructions to an optional devtools server.
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
|
@ -336,7 +341,7 @@ pub(crate) struct GlobalScope {
|
||||||
|
|
||||||
/// WebGPU devices
|
/// WebGPU devices
|
||||||
#[cfg(feature = "webgpu")]
|
#[cfg(feature = "webgpu")]
|
||||||
gpu_devices: DomRefCell<HashMapTracedValues<WebGPUDevice, WeakRef<GPUDevice>>>,
|
gpu_devices: DomRefCell<HashMapTracedValues<WebGPUDevice, WeakRef<GPUDevice>, FxBuildHasher>>,
|
||||||
|
|
||||||
// https://w3c.github.io/performance-timeline/#supportedentrytypes-attribute
|
// https://w3c.github.io/performance-timeline/#supportedentrytypes-attribute
|
||||||
#[ignore_malloc_size_of = "mozjs"]
|
#[ignore_malloc_size_of = "mozjs"]
|
||||||
|
@ -510,7 +515,7 @@ pub(crate) enum MessagePortState {
|
||||||
/// The message-port router id for this global, and a map of managed ports.
|
/// The message-port router id for this global, and a map of managed ports.
|
||||||
Managed(
|
Managed(
|
||||||
#[no_trace] MessagePortRouterId,
|
#[no_trace] MessagePortRouterId,
|
||||||
HashMapTracedValues<MessagePortId, ManagedMessagePort>,
|
HashMapTracedValues<MessagePortId, ManagedMessagePort, FxBuildHasher>,
|
||||||
),
|
),
|
||||||
/// This global is not managing any ports at this time.
|
/// This global is not managing any ports at this time.
|
||||||
UnManaged,
|
UnManaged,
|
||||||
|
@ -765,9 +770,9 @@ impl GlobalScope {
|
||||||
blob_state: Default::default(),
|
blob_state: Default::default(),
|
||||||
eventtarget: EventTarget::new_inherited(),
|
eventtarget: EventTarget::new_inherited(),
|
||||||
crypto: Default::default(),
|
crypto: Default::default(),
|
||||||
registration_map: DomRefCell::new(HashMapTracedValues::new()),
|
registration_map: DomRefCell::new(HashMapTracedValues::new_fx()),
|
||||||
cookie_store: Default::default(),
|
cookie_store: Default::default(),
|
||||||
worker_map: DomRefCell::new(HashMapTracedValues::new()),
|
worker_map: DomRefCell::new(HashMapTracedValues::new_fx()),
|
||||||
pipeline_id,
|
pipeline_id,
|
||||||
devtools_wants_updates: Default::default(),
|
devtools_wants_updates: Default::default(),
|
||||||
console_timers: DomRefCell::new(Default::default()),
|
console_timers: DomRefCell::new(Default::default()),
|
||||||
|
@ -793,7 +798,7 @@ impl GlobalScope {
|
||||||
#[cfg(feature = "webgpu")]
|
#[cfg(feature = "webgpu")]
|
||||||
gpu_id_hub,
|
gpu_id_hub,
|
||||||
#[cfg(feature = "webgpu")]
|
#[cfg(feature = "webgpu")]
|
||||||
gpu_devices: DomRefCell::new(HashMapTracedValues::new()),
|
gpu_devices: DomRefCell::new(HashMapTracedValues::new_fx()),
|
||||||
frozen_supported_performance_entry_types: CachedFrozenArray::new(),
|
frozen_supported_performance_entry_types: CachedFrozenArray::new(),
|
||||||
https_state: Cell::new(HttpsState::None),
|
https_state: Cell::new(HttpsState::None),
|
||||||
console_group_stack: DomRefCell::new(Vec::new()),
|
console_group_stack: DomRefCell::new(Vec::new()),
|
||||||
|
@ -1703,7 +1708,7 @@ impl GlobalScope {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
let router_id = MessagePortRouterId::new();
|
let router_id = MessagePortRouterId::new();
|
||||||
*current_state = MessagePortState::Managed(router_id, HashMapTracedValues::new());
|
*current_state = MessagePortState::Managed(router_id, HashMapTracedValues::new_fx());
|
||||||
let _ = self.script_to_constellation_chan().send(
|
let _ = self.script_to_constellation_chan().send(
|
||||||
ScriptToConstellationMessage::NewMessagePortRouter(router_id, port_control_sender),
|
ScriptToConstellationMessage::NewMessagePortRouter(router_id, port_control_sender),
|
||||||
);
|
);
|
||||||
|
@ -2373,7 +2378,7 @@ impl GlobalScope {
|
||||||
.insert(script_id, Rc::new(module));
|
.insert(script_id, Rc::new(module));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_inline_module_map(&self) -> &DomRefCell<HashMap<ScriptId, Rc<ModuleTree>>> {
|
pub(crate) fn get_inline_module_map(&self) -> &DomRefCell<FxHashMap<ScriptId, Rc<ModuleTree>>> {
|
||||||
&self.inline_module_map
|
&self.inline_module_map
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use canvas_traits::webgl::{GLContextAttributes, WebGLVersion};
|
use canvas_traits::webgl::{GLContextAttributes, WebGLVersion};
|
||||||
|
@ -19,6 +18,7 @@ use js::error::throw_type_error;
|
||||||
use js::rust::{HandleObject, HandleValue};
|
use js::rust::{HandleObject, HandleValue};
|
||||||
use layout_api::HTMLCanvasData;
|
use layout_api::HTMLCanvasData;
|
||||||
use pixels::{EncodedImageType, Snapshot};
|
use pixels::{EncodedImageType, Snapshot};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use script_bindings::weakref::WeakRef;
|
use script_bindings::weakref::WeakRef;
|
||||||
use servo_media::streams::MediaStreamType;
|
use servo_media::streams::MediaStreamType;
|
||||||
use servo_media::streams::registry::MediaStreamId;
|
use servo_media::streams::registry::MediaStreamId;
|
||||||
|
@ -77,7 +77,7 @@ pub(crate) struct HTMLCanvasElement {
|
||||||
// This id and hashmap are used to keep track of ongoing toBlob() calls.
|
// This id and hashmap are used to keep track of ongoing toBlob() calls.
|
||||||
callback_id: Cell<u32>,
|
callback_id: Cell<u32>,
|
||||||
#[ignore_malloc_size_of = "not implemented for webidl callbacks"]
|
#[ignore_malloc_size_of = "not implemented for webidl callbacks"]
|
||||||
blob_callbacks: RefCell<HashMap<u32, Rc<BlobCallback>>>,
|
blob_callbacks: RefCell<FxHashMap<u32, Rc<BlobCallback>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLCanvasElement {
|
impl HTMLCanvasElement {
|
||||||
|
@ -90,7 +90,7 @@ impl HTMLCanvasElement {
|
||||||
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
|
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
|
||||||
context_mode: DomRefCell::new(None),
|
context_mode: DomRefCell::new(None),
|
||||||
callback_id: Cell::new(0),
|
callback_id: Cell::new(0),
|
||||||
blob_callbacks: RefCell::new(HashMap::new()),
|
blob_callbacks: RefCell::new(FxHashMap::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ use dom_struct::dom_struct;
|
||||||
use embedder_traits::{
|
use embedder_traits::{
|
||||||
MediaMetadata as EmbedderMediaMetadata, MediaSessionActionType, MediaSessionEvent,
|
MediaMetadata as EmbedderMediaMetadata, MediaSessionActionType, MediaSessionEvent,
|
||||||
};
|
};
|
||||||
|
use rustc_hash::FxBuildHasher;
|
||||||
|
|
||||||
use super::bindings::trace::HashMapTracedValues;
|
use super::bindings::trace::HashMapTracedValues;
|
||||||
use crate::conversions::Convert;
|
use crate::conversions::Convert;
|
||||||
|
@ -44,8 +45,9 @@ pub(crate) struct MediaSession {
|
||||||
playback_state: DomRefCell<MediaSessionPlaybackState>,
|
playback_state: DomRefCell<MediaSessionPlaybackState>,
|
||||||
/// <https://w3c.github.io/mediasession/#supported-media-session-actions>
|
/// <https://w3c.github.io/mediasession/#supported-media-session-actions>
|
||||||
#[ignore_malloc_size_of = "Rc"]
|
#[ignore_malloc_size_of = "Rc"]
|
||||||
action_handlers:
|
action_handlers: DomRefCell<
|
||||||
DomRefCell<HashMapTracedValues<MediaSessionActionType, Rc<MediaSessionActionHandler>>>,
|
HashMapTracedValues<MediaSessionActionType, Rc<MediaSessionActionHandler>, FxBuildHasher>,
|
||||||
|
>,
|
||||||
/// The media instance controlled by this media session.
|
/// The media instance controlled by this media session.
|
||||||
/// For now only HTMLMediaElements are controlled by media sessions.
|
/// For now only HTMLMediaElements are controlled by media sessions.
|
||||||
media_instance: MutNullableDom<HTMLMediaElement>,
|
media_instance: MutNullableDom<HTMLMediaElement>,
|
||||||
|
@ -58,7 +60,7 @@ impl MediaSession {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
metadata: DomRefCell::new(None),
|
metadata: DomRefCell::new(None),
|
||||||
playback_state: DomRefCell::new(MediaSessionPlaybackState::None),
|
playback_state: DomRefCell::new(MediaSessionPlaybackState::None),
|
||||||
action_handlers: DomRefCell::new(HashMapTracedValues::new()),
|
action_handlers: DomRefCell::new(HashMapTracedValues::new_fx()),
|
||||||
media_instance: Default::default(),
|
media_instance: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
@ -13,6 +12,7 @@ use dom_struct::dom_struct;
|
||||||
use js::jsapi::{Heap, JS_NewObject, JSObject};
|
use js::jsapi::{Heap, JS_NewObject, JSObject};
|
||||||
use js::jsval::UndefinedValue;
|
use js::jsval::UndefinedValue;
|
||||||
use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue};
|
use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use script_bindings::conversions::SafeToJSValConvertible;
|
use script_bindings::conversions::SafeToJSValConvertible;
|
||||||
|
|
||||||
use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||||
|
@ -280,7 +280,7 @@ impl Transferable for MessagePort {
|
||||||
|
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<MessagePortId, Self::Data>> {
|
) -> &'a mut Option<FxHashMap<MessagePortId, Self::Data>> {
|
||||||
match data {
|
match data {
|
||||||
StructuredData::Reader(r) => &mut r.port_impls,
|
StructuredData::Reader(r) => &mut r.port_impls,
|
||||||
StructuredData::Writer(w) => &mut w.ports,
|
StructuredData::Writer(w) => &mut w.ports,
|
||||||
|
|
|
@ -2,12 +2,11 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use base::id::{QuotaExceededErrorId, QuotaExceededErrorIndex};
|
use base::id::{QuotaExceededErrorId, QuotaExceededErrorIndex};
|
||||||
use constellation_traits::SerializableQuotaExceededError;
|
use constellation_traits::SerializableQuotaExceededError;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::gc::HandleObject;
|
use js::gc::HandleObject;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use script_bindings::codegen::GenericBindings::QuotaExceededErrorBinding::{
|
use script_bindings::codegen::GenericBindings::QuotaExceededErrorBinding::{
|
||||||
QuotaExceededErrorMethods, QuotaExceededErrorOptions,
|
QuotaExceededErrorMethods, QuotaExceededErrorOptions,
|
||||||
};
|
};
|
||||||
|
@ -165,7 +164,7 @@ impl Serializable for QuotaExceededError {
|
||||||
/// <https://webidl.spec.whatwg.org/#quotaexceedederror>
|
/// <https://webidl.spec.whatwg.org/#quotaexceedederror>
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<QuotaExceededErrorId, Self::Data>> {
|
) -> &'a mut Option<FxHashMap<QuotaExceededErrorId, Self::Data>> {
|
||||||
match data {
|
match data {
|
||||||
StructuredData::Reader(reader) => &mut reader.quota_exceeded_errors,
|
StructuredData::Reader(reader) => &mut reader.quota_exceeded_errors,
|
||||||
StructuredData::Writer(writer) => &mut writer.quota_exceeded_errors,
|
StructuredData::Writer(writer) => &mut writer.quota_exceeded_errors,
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::ptr::{self};
|
use std::ptr::{self};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -11,6 +10,7 @@ use std::rc::Rc;
|
||||||
use base::id::{MessagePortId, MessagePortIndex};
|
use base::id::{MessagePortId, MessagePortIndex};
|
||||||
use constellation_traits::MessagePortImpl;
|
use constellation_traits::MessagePortImpl;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use ipc_channel::ipc::IpcSharedMemory;
|
use ipc_channel::ipc::IpcSharedMemory;
|
||||||
use js::jsapi::{Heap, JSObject};
|
use js::jsapi::{Heap, JSObject};
|
||||||
use js::jsval::{JSVal, ObjectValue, UndefinedValue};
|
use js::jsval::{JSVal, ObjectValue, UndefinedValue};
|
||||||
|
@ -2434,7 +2434,7 @@ impl Transferable for ReadableStream {
|
||||||
/// Note: we are relying on the port transfer, so the data returned here are related to the port.
|
/// Note: we are relying on the port transfer, so the data returned here are related to the port.
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<MessagePortId, Self::Data>> {
|
) -> &'a mut Option<FxHashMap<MessagePortId, Self::Data>> {
|
||||||
match data {
|
match data {
|
||||||
StructuredData::Reader(r) => &mut r.port_impls,
|
StructuredData::Reader(r) => &mut r.port_impls,
|
||||||
StructuredData::Writer(w) => &mut w.ports,
|
StructuredData::Writer(w) => &mut w.ports,
|
||||||
|
|
|
@ -21,6 +21,7 @@ use html5ever::tree_builder::{
|
||||||
};
|
};
|
||||||
use html5ever::{Attribute as HtmlAttribute, ExpandedName, QualName, local_name, ns};
|
use html5ever::{Attribute as HtmlAttribute, ExpandedName, QualName, local_name, ns};
|
||||||
use markup5ever::TokenizerResult;
|
use markup5ever::TokenizerResult;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use style::context::QuirksMode as ServoQuirksMode;
|
use style::context::QuirksMode as ServoQuirksMode;
|
||||||
|
|
||||||
|
@ -697,7 +698,7 @@ struct ParseNodeData {
|
||||||
|
|
||||||
pub(crate) struct Sink {
|
pub(crate) struct Sink {
|
||||||
current_line: Cell<u64>,
|
current_line: Cell<u64>,
|
||||||
parse_node_data: RefCell<HashMap<ParseNodeId, ParseNodeData>>,
|
parse_node_data: RefCell<FxHashMap<ParseNodeId, ParseNodeData>>,
|
||||||
next_parse_node_id: Cell<ParseNodeId>,
|
next_parse_node_id: Cell<ParseNodeId>,
|
||||||
document_node: ParseNode,
|
document_node: ParseNode,
|
||||||
sender: Sender<ToTokenizerMsg>,
|
sender: Sender<ToTokenizerMsg>,
|
||||||
|
@ -708,7 +709,7 @@ impl Sink {
|
||||||
fn new(sender: Sender<ToTokenizerMsg>, allow_declarative_shadow_roots: bool) -> Sink {
|
fn new(sender: Sender<ToTokenizerMsg>, allow_declarative_shadow_roots: bool) -> Sink {
|
||||||
let sink = Sink {
|
let sink = Sink {
|
||||||
current_line: Cell::new(1),
|
current_line: Cell::new(1),
|
||||||
parse_node_data: RefCell::new(HashMap::new()),
|
parse_node_data: RefCell::new(FxHashMap::default()),
|
||||||
next_parse_node_id: Cell::new(1),
|
next_parse_node_id: Cell::new(1),
|
||||||
document_node: ParseNode {
|
document_node: ParseNode {
|
||||||
id: 0,
|
id: 0,
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::ptr::{self};
|
use std::ptr::{self};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
@ -13,6 +12,7 @@ use dom_struct::dom_struct;
|
||||||
use js::jsapi::{Heap, IsPromiseObject, JSObject};
|
use js::jsapi::{Heap, IsPromiseObject, JSObject};
|
||||||
use js::jsval::{JSVal, ObjectValue, UndefinedValue};
|
use js::jsval::{JSVal, ObjectValue, UndefinedValue};
|
||||||
use js::rust::{HandleObject as SafeHandleObject, HandleValue as SafeHandleValue, IntoHandle};
|
use js::rust::{HandleObject as SafeHandleObject, HandleValue as SafeHandleValue, IntoHandle};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use script_bindings::callback::ExceptionHandling;
|
use script_bindings::callback::ExceptionHandling;
|
||||||
use script_bindings::realms::InRealm;
|
use script_bindings::realms::InRealm;
|
||||||
|
|
||||||
|
@ -1193,7 +1193,7 @@ impl Transferable for TransformStream {
|
||||||
|
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<MessagePortId, Self::Data>> {
|
) -> &'a mut Option<FxHashMap<MessagePortId, Self::Data>> {
|
||||||
match data {
|
match data {
|
||||||
StructuredData::Reader(r) => &mut r.transform_streams_port_impls,
|
StructuredData::Reader(r) => &mut r.transform_streams_port_impls,
|
||||||
StructuredData::Writer(w) => &mut w.transform_streams_port,
|
StructuredData::Writer(w) => &mut w.transform_streams_port,
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::rust::HandleObject;
|
use js::rust::HandleObject;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use servo_media::ServoMedia;
|
use servo_media::ServoMedia;
|
||||||
use servo_media::streams::MediaStreamType;
|
use servo_media::streams::MediaStreamType;
|
||||||
use servo_media::streams::registry::MediaStreamId;
|
use servo_media::streams::registry::MediaStreamId;
|
||||||
|
@ -73,7 +73,7 @@ pub(crate) struct RTCPeerConnection {
|
||||||
ice_connection_state: Cell<RTCIceConnectionState>,
|
ice_connection_state: Cell<RTCIceConnectionState>,
|
||||||
signaling_state: Cell<RTCSignalingState>,
|
signaling_state: Cell<RTCSignalingState>,
|
||||||
#[ignore_malloc_size_of = "defined in servo-media"]
|
#[ignore_malloc_size_of = "defined in servo-media"]
|
||||||
data_channels: DomRefCell<HashMap<DataChannelId, Dom<RTCDataChannel>>>,
|
data_channels: DomRefCell<FxHashMap<DataChannelId, Dom<RTCDataChannel>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RTCSignaller {
|
struct RTCSignaller {
|
||||||
|
@ -171,7 +171,7 @@ impl RTCPeerConnection {
|
||||||
gathering_state: Cell::new(RTCIceGatheringState::New),
|
gathering_state: Cell::new(RTCIceGatheringState::New),
|
||||||
ice_connection_state: Cell::new(RTCIceConnectionState::New),
|
ice_connection_state: Cell::new(RTCIceConnectionState::New),
|
||||||
signaling_state: Cell::new(RTCSignalingState::Stable),
|
signaling_state: Cell::new(RTCSignalingState::Stable),
|
||||||
data_channels: DomRefCell::new(HashMap::new()),
|
data_channels: DomRefCell::new(FxHashMap::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ use num_traits::ToPrimitive;
|
||||||
use profile_traits::generic_channel as ProfiledGenericChannel;
|
use profile_traits::generic_channel as ProfiledGenericChannel;
|
||||||
use profile_traits::mem::ProfilerChan as MemProfilerChan;
|
use profile_traits::mem::ProfilerChan as MemProfilerChan;
|
||||||
use profile_traits::time::ProfilerChan as TimeProfilerChan;
|
use profile_traits::time::ProfilerChan as TimeProfilerChan;
|
||||||
|
use rustc_hash::{FxBuildHasher, FxHashMap};
|
||||||
use script_bindings::codegen::GenericBindings::WindowBinding::ScrollToOptions;
|
use script_bindings::codegen::GenericBindings::WindowBinding::ScrollToOptions;
|
||||||
use script_bindings::conversions::SafeToJSValConvertible;
|
use script_bindings::conversions::SafeToJSValConvertible;
|
||||||
use script_bindings::interfaces::WindowHelpers;
|
use script_bindings::interfaces::WindowHelpers;
|
||||||
|
@ -366,20 +367,22 @@ pub(crate) struct Window {
|
||||||
/// `ImageCache` it adds an entry to this list. When those loads are triggered from
|
/// `ImageCache` it adds an entry to this list. When those loads are triggered from
|
||||||
/// layout, they also add an etry to [`Self::pending_layout_images`].
|
/// layout, they also add an etry to [`Self::pending_layout_images`].
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
pending_image_callbacks: DomRefCell<HashMap<PendingImageId, Vec<PendingImageCallback>>>,
|
pending_image_callbacks: DomRefCell<FxHashMap<PendingImageId, Vec<PendingImageCallback>>>,
|
||||||
|
|
||||||
/// All of the elements that have an outstanding image request that was
|
/// All of the elements that have an outstanding image request that was
|
||||||
/// initiated by layout during a reflow. They are stored in the [`ScriptThread`]
|
/// initiated by layout during a reflow. They are stored in the [`ScriptThread`]
|
||||||
/// to ensure that the element can be marked dirty when the image data becomes
|
/// to ensure that the element can be marked dirty when the image data becomes
|
||||||
/// available at some point in the future.
|
/// available at some point in the future.
|
||||||
pending_layout_images:
|
pending_layout_images: DomRefCell<
|
||||||
DomRefCell<HashMapTracedValues<PendingImageId, Vec<PendingLayoutImageAncillaryData>>>,
|
HashMapTracedValues<PendingImageId, Vec<PendingLayoutImageAncillaryData>, FxBuildHasher>,
|
||||||
|
>,
|
||||||
|
|
||||||
/// Vector images for which layout has intiated rasterization at a specific size
|
/// Vector images for which layout has intiated rasterization at a specific size
|
||||||
/// and whose results are not yet available. They are stored in the [`ScriptThread`]
|
/// and whose results are not yet available. They are stored in the [`ScriptThread`]
|
||||||
/// so that the element can be marked dirty once the rasterization is completed.
|
/// so that the element can be marked dirty once the rasterization is completed.
|
||||||
pending_images_for_rasterization:
|
pending_images_for_rasterization: DomRefCell<
|
||||||
DomRefCell<HashMapTracedValues<PendingImageRasterizationKey, Vec<Dom<Node>>>>,
|
HashMapTracedValues<PendingImageRasterizationKey, Vec<Dom<Node>>, FxBuildHasher>,
|
||||||
|
>,
|
||||||
|
|
||||||
/// Directory to store unminified css for this window if unminify-css
|
/// Directory to store unminified css for this window if unminify-css
|
||||||
/// opt is enabled.
|
/// opt is enabled.
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
use std::cell::OnceCell;
|
use std::cell::OnceCell;
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use std::collections::{HashMap, hash_map};
|
use std::collections::hash_map;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::atomic::{AtomicIsize, Ordering};
|
use std::sync::atomic::{AtomicIsize, Ordering};
|
||||||
|
@ -25,6 +25,7 @@ use js::jsapi::{GCReason, JS_GC, JS_GetGCParameter, JSGCParamKey, JSTracer};
|
||||||
use malloc_size_of::malloc_size_of_is_0;
|
use malloc_size_of::malloc_size_of_is_0;
|
||||||
use net_traits::IpcSend;
|
use net_traits::IpcSend;
|
||||||
use net_traits::request::{Destination, RequestBuilder, RequestMode};
|
use net_traits::request::{Destination, RequestBuilder, RequestMode};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use servo_url::{ImmutableOrigin, ServoUrl};
|
use servo_url::{ImmutableOrigin, ServoUrl};
|
||||||
use style::thread_state::{self, ThreadState};
|
use style::thread_state::{self, ThreadState};
|
||||||
use swapper::{Swapper, swapper};
|
use swapper::{Swapper, swapper};
|
||||||
|
@ -458,7 +459,7 @@ struct WorkletThread {
|
||||||
global_init: WorkletGlobalScopeInit,
|
global_init: WorkletGlobalScopeInit,
|
||||||
|
|
||||||
/// The global scopes created by this thread
|
/// The global scopes created by this thread
|
||||||
global_scopes: HashMap<WorkletId, Dom<WorkletGlobalScope>>,
|
global_scopes: FxHashMap<WorkletId, Dom<WorkletGlobalScope>>,
|
||||||
|
|
||||||
/// A one-place buffer for control messages
|
/// A one-place buffer for control messages
|
||||||
control_buffer: Option<WorkletControl>,
|
control_buffer: Option<WorkletControl>,
|
||||||
|
@ -502,7 +503,7 @@ impl WorkletThread {
|
||||||
hot_backup_sender: init.hot_backup_sender,
|
hot_backup_sender: init.hot_backup_sender,
|
||||||
cold_backup_sender: init.cold_backup_sender,
|
cold_backup_sender: init.cold_backup_sender,
|
||||||
global_init: init.global_init,
|
global_init: init.global_init,
|
||||||
global_scopes: HashMap::new(),
|
global_scopes: FxHashMap::default(),
|
||||||
control_buffer: None,
|
control_buffer: None,
|
||||||
runtime: Runtime::new(None),
|
runtime: Runtime::new(None),
|
||||||
should_gc: false,
|
should_gc: false,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::collections::{HashMap, VecDeque};
|
use std::collections::VecDeque;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ptr::{self};
|
use std::ptr::{self};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -17,6 +17,7 @@ use js::rust::{
|
||||||
HandleObject as SafeHandleObject, HandleValue as SafeHandleValue,
|
HandleObject as SafeHandleObject, HandleValue as SafeHandleValue,
|
||||||
MutableHandleValue as SafeMutableHandleValue,
|
MutableHandleValue as SafeMutableHandleValue,
|
||||||
};
|
};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use script_bindings::codegen::GenericBindings::MessagePortBinding::MessagePortMethods;
|
use script_bindings::codegen::GenericBindings::MessagePortBinding::MessagePortMethods;
|
||||||
use script_bindings::conversions::SafeToJSValConvertible;
|
use script_bindings::conversions::SafeToJSValConvertible;
|
||||||
|
|
||||||
|
@ -1293,7 +1294,7 @@ impl Transferable for WritableStream {
|
||||||
/// Note: we are relying on the port transfer, so the data returned here are related to the port.
|
/// Note: we are relying on the port transfer, so the data returned here are related to the port.
|
||||||
fn serialized_storage<'a>(
|
fn serialized_storage<'a>(
|
||||||
data: StructuredData<'a, '_>,
|
data: StructuredData<'a, '_>,
|
||||||
) -> &'a mut Option<HashMap<MessagePortId, Self::Data>> {
|
) -> &'a mut Option<FxHashMap<MessagePortId, Self::Data>> {
|
||||||
match data {
|
match data {
|
||||||
StructuredData::Reader(r) => &mut r.port_impls,
|
StructuredData::Reader(r) => &mut r.port_impls,
|
||||||
StructuredData::Writer(w) => &mut w.ports,
|
StructuredData::Writer(w) => &mut w.ports,
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
#[cfg(feature = "webgpu")]
|
#[cfg(feature = "webgpu")]
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::HashSet;
|
|
||||||
use std::option::Option;
|
use std::option::Option;
|
||||||
use std::result::Result;
|
use std::result::Result;
|
||||||
|
|
||||||
|
@ -22,6 +21,7 @@ use net_traits::FetchResponseMsg;
|
||||||
use net_traits::image_cache::ImageCacheResponseMessage;
|
use net_traits::image_cache::ImageCacheResponseMessage;
|
||||||
use profile_traits::mem::{self as profile_mem, OpaqueSender, ReportsChan};
|
use profile_traits::mem::{self as profile_mem, OpaqueSender, ReportsChan};
|
||||||
use profile_traits::time::{self as profile_time};
|
use profile_traits::time::{self as profile_time};
|
||||||
|
use rustc_hash::FxHashSet;
|
||||||
use script_traits::{Painter, ScriptThreadMessage};
|
use script_traits::{Painter, ScriptThreadMessage};
|
||||||
use stylo_atoms::Atom;
|
use stylo_atoms::Atom;
|
||||||
use timers::TimerScheduler;
|
use timers::TimerScheduler;
|
||||||
|
@ -403,7 +403,7 @@ impl ScriptThreadReceivers {
|
||||||
&self,
|
&self,
|
||||||
task_queue: &TaskQueue<MainThreadScriptMsg>,
|
task_queue: &TaskQueue<MainThreadScriptMsg>,
|
||||||
timer_scheduler: &TimerScheduler,
|
timer_scheduler: &TimerScheduler,
|
||||||
fully_active: &HashSet<PipelineId>,
|
fully_active: &FxHashSet<PipelineId>,
|
||||||
) -> MixedMessage {
|
) -> MixedMessage {
|
||||||
select! {
|
select! {
|
||||||
recv(task_queue.select()) -> msg => {
|
recv(task_queue.select()) -> msg => {
|
||||||
|
@ -444,7 +444,7 @@ impl ScriptThreadReceivers {
|
||||||
pub(crate) fn try_recv(
|
pub(crate) fn try_recv(
|
||||||
&self,
|
&self,
|
||||||
task_queue: &TaskQueue<MainThreadScriptMsg>,
|
task_queue: &TaskQueue<MainThreadScriptMsg>,
|
||||||
fully_active: &HashSet<PipelineId>,
|
fully_active: &FxHashSet<PipelineId>,
|
||||||
) -> Option<MixedMessage> {
|
) -> Option<MixedMessage> {
|
||||||
if let Ok(message) = self.constellation_receiver.try_recv() {
|
if let Ok(message) = self.constellation_receiver.try_recv() {
|
||||||
let message = message
|
let message = message
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
//! loop.
|
//! loop.
|
||||||
|
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::HashSet;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::option::Option;
|
use std::option::Option;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -83,6 +83,7 @@ use percent_encoding::percent_decode;
|
||||||
use profile_traits::mem::{ProcessReports, ReportsChan, perform_memory_report};
|
use profile_traits::mem::{ProcessReports, ReportsChan, perform_memory_report};
|
||||||
use profile_traits::time::ProfilerCategory;
|
use profile_traits::time::ProfilerCategory;
|
||||||
use profile_traits::time_profile;
|
use profile_traits::time_profile;
|
||||||
|
use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet};
|
||||||
use script_traits::{
|
use script_traits::{
|
||||||
ConstellationInputEvent, DiscardBrowsingContext, DocumentActivity, InitialScriptState,
|
ConstellationInputEvent, DiscardBrowsingContext, DocumentActivity, InitialScriptState,
|
||||||
NewLayoutInfo, Painter, ProgressiveWebMetricType, ScriptThreadMessage, UpdatePipelineIdReason,
|
NewLayoutInfo, Painter, ProgressiveWebMetricType, ScriptThreadMessage, UpdatePipelineIdReason,
|
||||||
|
@ -204,7 +205,8 @@ pub struct ScriptThread {
|
||||||
documents: DomRefCell<DocumentCollection>,
|
documents: DomRefCell<DocumentCollection>,
|
||||||
/// The window proxies known by this thread
|
/// The window proxies known by this thread
|
||||||
/// TODO: this map grows, but never shrinks. Issue #15258.
|
/// TODO: this map grows, but never shrinks. Issue #15258.
|
||||||
window_proxies: DomRefCell<HashMapTracedValues<BrowsingContextId, Dom<WindowProxy>>>,
|
window_proxies:
|
||||||
|
DomRefCell<HashMapTracedValues<BrowsingContextId, Dom<WindowProxy>, FxBuildHasher>>,
|
||||||
/// A list of data pertaining to loads that have not yet received a network response
|
/// A list of data pertaining to loads that have not yet received a network response
|
||||||
incomplete_loads: DomRefCell<Vec<InProgressLoad>>,
|
incomplete_loads: DomRefCell<Vec<InProgressLoad>>,
|
||||||
/// A vector containing parser contexts which have not yet been fully processed
|
/// A vector containing parser contexts which have not yet been fully processed
|
||||||
|
@ -249,7 +251,7 @@ pub struct ScriptThread {
|
||||||
|
|
||||||
/// List of pipelines that have been owned and closed by this script thread.
|
/// List of pipelines that have been owned and closed by this script thread.
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
closed_pipelines: DomRefCell<HashSet<PipelineId>>,
|
closed_pipelines: DomRefCell<FxHashSet<PipelineId>>,
|
||||||
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#microtask-queue>
|
/// <https://html.spec.whatwg.org/multipage/#microtask-queue>
|
||||||
microtask_queue: Rc<MicrotaskQueue>,
|
microtask_queue: Rc<MicrotaskQueue>,
|
||||||
|
@ -311,7 +313,7 @@ pub struct ScriptThread {
|
||||||
|
|
||||||
/// A map from pipelines to all owned nodes ever created in this script thread
|
/// A map from pipelines to all owned nodes ever created in this script thread
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
pipeline_to_node_ids: DomRefCell<HashMap<PipelineId, NodeIdSet>>,
|
pipeline_to_node_ids: DomRefCell<FxHashMap<PipelineId, NodeIdSet>>,
|
||||||
|
|
||||||
/// Code is running as a consequence of a user interaction
|
/// Code is running as a consequence of a user interaction
|
||||||
is_user_interacting: Cell<bool>,
|
is_user_interacting: Cell<bool>,
|
||||||
|
@ -726,7 +728,7 @@ impl ScriptThread {
|
||||||
with_script_thread(|script_thread| script_thread.is_user_interacting.get())
|
with_script_thread(|script_thread| script_thread.is_user_interacting.get())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_fully_active_document_ids(&self) -> HashSet<PipelineId> {
|
pub(crate) fn get_fully_active_document_ids(&self) -> FxHashSet<PipelineId> {
|
||||||
self.documents
|
self.documents
|
||||||
.borrow()
|
.borrow()
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -737,7 +739,7 @@ impl ScriptThread {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fold(HashSet::new(), |mut set, id| {
|
.fold(FxHashSet::default(), |mut set, id| {
|
||||||
let _ = set.insert(id);
|
let _ = set.insert(id);
|
||||||
set
|
set
|
||||||
})
|
})
|
||||||
|
@ -983,7 +985,7 @@ impl ScriptThread {
|
||||||
ScriptThread {
|
ScriptThread {
|
||||||
documents: DomRefCell::new(DocumentCollection::default()),
|
documents: DomRefCell::new(DocumentCollection::default()),
|
||||||
last_render_opportunity_time: Default::default(),
|
last_render_opportunity_time: Default::default(),
|
||||||
window_proxies: DomRefCell::new(HashMapTracedValues::new()),
|
window_proxies: DomRefCell::new(HashMapTracedValues::new_fx()),
|
||||||
incomplete_loads: DomRefCell::new(vec![]),
|
incomplete_loads: DomRefCell::new(vec![]),
|
||||||
incomplete_parser_contexts: IncompleteParserContexts(RefCell::new(vec![])),
|
incomplete_parser_contexts: IncompleteParserContexts(RefCell::new(vec![])),
|
||||||
senders,
|
senders,
|
||||||
|
@ -996,7 +998,7 @@ impl ScriptThread {
|
||||||
timer_scheduler: Default::default(),
|
timer_scheduler: Default::default(),
|
||||||
microtask_queue,
|
microtask_queue,
|
||||||
js_runtime,
|
js_runtime,
|
||||||
closed_pipelines: DomRefCell::new(HashSet::new()),
|
closed_pipelines: DomRefCell::new(FxHashSet::default()),
|
||||||
mutation_observer_microtask_queued: Default::default(),
|
mutation_observer_microtask_queued: Default::default(),
|
||||||
mutation_observers: Default::default(),
|
mutation_observers: Default::default(),
|
||||||
signal_slots: Default::default(),
|
signal_slots: Default::default(),
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
use core::sync::atomic::Ordering;
|
use core::sync::atomic::Ordering;
|
||||||
use std::cell::Ref;
|
use std::cell::Ref;
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use base::id::PipelineId;
|
use base::id::PipelineId;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use strum::VariantArray;
|
use strum::VariantArray;
|
||||||
|
|
||||||
use crate::messaging::ScriptEventLoopSender;
|
use crate::messaging::ScriptEventLoopSender;
|
||||||
|
@ -20,7 +20,7 @@ enum TaskCancellers {
|
||||||
/// of them need to have the same canceller flag for all task sources.
|
/// of them need to have the same canceller flag for all task sources.
|
||||||
Shared(TaskCanceller),
|
Shared(TaskCanceller),
|
||||||
/// For `Window` each `TaskSource` has its own canceller.
|
/// For `Window` each `TaskSource` has its own canceller.
|
||||||
OnePerTaskSource(RefCell<HashMap<TaskSourceName, TaskCanceller>>),
|
OnePerTaskSource(RefCell<FxHashMap<TaskSourceName, TaskCanceller>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TaskCancellers {
|
impl TaskCancellers {
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
//! Machinery for [task-queue](https://html.spec.whatwg.org/multipage/#task-queue).
|
//! Machinery for [task-queue](https://html.spec.whatwg.org/multipage/#task-queue).
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::collections::{HashMap, HashSet, VecDeque};
|
use std::collections::VecDeque;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
|
||||||
use base::id::PipelineId;
|
use base::id::PipelineId;
|
||||||
use crossbeam_channel::{self, Receiver, Sender};
|
use crossbeam_channel::{self, Receiver, Sender};
|
||||||
|
use rustc_hash::{FxHashMap, FxHashSet};
|
||||||
use strum::VariantArray;
|
use strum::VariantArray;
|
||||||
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
|
@ -47,9 +48,9 @@ pub(crate) struct TaskQueue<T> {
|
||||||
/// A "business" counter, reset for each iteration of the event-loop
|
/// A "business" counter, reset for each iteration of the event-loop
|
||||||
taken_task_counter: Cell<u64>,
|
taken_task_counter: Cell<u64>,
|
||||||
/// Tasks that will be throttled for as long as we are "busy".
|
/// Tasks that will be throttled for as long as we are "busy".
|
||||||
throttled: DomRefCell<HashMap<TaskSourceName, VecDeque<QueuedTask>>>,
|
throttled: DomRefCell<FxHashMap<TaskSourceName, VecDeque<QueuedTask>>>,
|
||||||
/// Tasks for not fully-active documents.
|
/// Tasks for not fully-active documents.
|
||||||
inactive: DomRefCell<HashMap<PipelineId, VecDeque<QueuedTask>>>,
|
inactive: DomRefCell<FxHashMap<PipelineId, VecDeque<QueuedTask>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: QueuedTaskConversion> TaskQueue<T> {
|
impl<T: QueuedTaskConversion> TaskQueue<T> {
|
||||||
|
@ -68,7 +69,7 @@ impl<T: QueuedTaskConversion> TaskQueue<T> {
|
||||||
/// <https://html.spec.whatwg.org/multipage/#event-loop-processing-model:fully-active>
|
/// <https://html.spec.whatwg.org/multipage/#event-loop-processing-model:fully-active>
|
||||||
fn release_tasks_for_fully_active_documents(
|
fn release_tasks_for_fully_active_documents(
|
||||||
&self,
|
&self,
|
||||||
fully_active: &HashSet<PipelineId>,
|
fully_active: &FxHashSet<PipelineId>,
|
||||||
) -> Vec<T> {
|
) -> Vec<T> {
|
||||||
self.inactive
|
self.inactive
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
@ -103,7 +104,7 @@ impl<T: QueuedTaskConversion> TaskQueue<T> {
|
||||||
|
|
||||||
/// Process incoming tasks, immediately sending priority ones downstream,
|
/// Process incoming tasks, immediately sending priority ones downstream,
|
||||||
/// and categorizing potential throttles.
|
/// and categorizing potential throttles.
|
||||||
fn process_incoming_tasks(&self, first_msg: T, fully_active: &HashSet<PipelineId>) {
|
fn process_incoming_tasks(&self, first_msg: T, fully_active: &FxHashSet<PipelineId>) {
|
||||||
// 1. Make any previously stored task from now fully-active document available.
|
// 1. Make any previously stored task from now fully-active document available.
|
||||||
let mut incoming = self.release_tasks_for_fully_active_documents(fully_active);
|
let mut incoming = self.release_tasks_for_fully_active_documents(fully_active);
|
||||||
|
|
||||||
|
@ -196,14 +197,17 @@ impl<T: QueuedTaskConversion> TaskQueue<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Take all tasks again and then run `recv()`.
|
/// Take all tasks again and then run `recv()`.
|
||||||
pub(crate) fn take_tasks_and_recv(&self, fully_active: &HashSet<PipelineId>) -> Result<T, ()> {
|
pub(crate) fn take_tasks_and_recv(
|
||||||
|
&self,
|
||||||
|
fully_active: &FxHashSet<PipelineId>,
|
||||||
|
) -> Result<T, ()> {
|
||||||
self.take_tasks(T::wake_up_msg(), fully_active);
|
self.take_tasks(T::wake_up_msg(), fully_active);
|
||||||
self.recv()
|
self.recv()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Drain the queue for the current iteration of the event-loop.
|
/// Drain the queue for the current iteration of the event-loop.
|
||||||
/// Holding-back throttles above a given high-water mark.
|
/// Holding-back throttles above a given high-water mark.
|
||||||
pub(crate) fn take_tasks(&self, first_msg: T, fully_active: &HashSet<PipelineId>) {
|
pub(crate) fn take_tasks(&self, first_msg: T, fully_active: &FxHashSet<PipelineId>) {
|
||||||
// High-watermark: once reached, throttled tasks will be held-back.
|
// High-watermark: once reached, throttled tasks will be held-back.
|
||||||
const PER_ITERATION_MAX: u64 = 5;
|
const PER_ITERATION_MAX: u64 = 5;
|
||||||
// Always first check for new tasks, but don't reset 'taken_task_counter'.
|
// Always first check for new tasks, but don't reset 'taken_task_counter'.
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::cmp::{Ord, Ordering};
|
use std::cmp::{Ord, Ordering};
|
||||||
use std::collections::{HashMap, VecDeque};
|
use std::collections::VecDeque;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
@ -14,6 +14,7 @@ use deny_public_fields::DenyPublicFields;
|
||||||
use js::jsapi::Heap;
|
use js::jsapi::Heap;
|
||||||
use js::jsval::{JSVal, UndefinedValue};
|
use js::jsval::{JSVal, UndefinedValue};
|
||||||
use js::rust::HandleValue;
|
use js::rust::HandleValue;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use servo_config::pref;
|
use servo_config::pref;
|
||||||
use timers::{BoxedTimerCallback, TimerEventRequest};
|
use timers::{BoxedTimerCallback, TimerEventRequest};
|
||||||
|
@ -361,7 +362,7 @@ pub(crate) struct JsTimerHandle(i32);
|
||||||
pub(crate) struct JsTimers {
|
pub(crate) struct JsTimers {
|
||||||
next_timer_handle: Cell<JsTimerHandle>,
|
next_timer_handle: Cell<JsTimerHandle>,
|
||||||
/// <https://html.spec.whatwg.org/multipage/#list-of-active-timers>
|
/// <https://html.spec.whatwg.org/multipage/#list-of-active-timers>
|
||||||
active_timers: DomRefCell<HashMap<JsTimerHandle, JsTimerEntry>>,
|
active_timers: DomRefCell<FxHashMap<JsTimerHandle, JsTimerEntry>>,
|
||||||
/// The nesting level of the currently executing timer task or 0.
|
/// The nesting level of the currently executing timer task or 0.
|
||||||
nesting_level: Cell<u32>,
|
nesting_level: Cell<u32>,
|
||||||
/// Used to introduce a minimum delay in event intervals
|
/// Used to introduce a minimum delay in event intervals
|
||||||
|
@ -415,7 +416,7 @@ impl Default for JsTimers {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
JsTimers {
|
JsTimers {
|
||||||
next_timer_handle: Cell::new(JsTimerHandle(1)),
|
next_timer_handle: Cell::new(JsTimerHandle(1)),
|
||||||
active_timers: DomRefCell::new(HashMap::new()),
|
active_timers: DomRefCell::new(FxHashMap::default()),
|
||||||
nesting_level: Cell::new(0),
|
nesting_level: Cell::new(0),
|
||||||
min_duration: Cell::new(None),
|
min_duration: Cell::new(None),
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ embedder_traits = { workspace = true }
|
||||||
euclid = { workspace = true }
|
euclid = { workspace = true }
|
||||||
fonts_traits = { workspace = true }
|
fonts_traits = { workspace = true }
|
||||||
fnv = { workspace = true }
|
fnv = { workspace = true }
|
||||||
|
rustc-hash = { workspace = true }
|
||||||
http = { workspace = true }
|
http = { workspace = true }
|
||||||
hyper_serde = { workspace = true }
|
hyper_serde = { workspace = true }
|
||||||
ipc-channel = { workspace = true }
|
ipc-channel = { workspace = true }
|
||||||
|
|
|
@ -8,14 +8,13 @@
|
||||||
mod serializable;
|
mod serializable;
|
||||||
mod transferable;
|
mod transferable;
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use base::id::{
|
use base::id::{
|
||||||
BlobId, DomExceptionId, DomMatrixId, DomPointId, DomQuadId, DomRectId, ImageBitmapId,
|
BlobId, DomExceptionId, DomMatrixId, DomPointId, DomQuadId, DomRectId, ImageBitmapId,
|
||||||
MessagePortId, OffscreenCanvasId, QuotaExceededErrorId,
|
MessagePortId, OffscreenCanvasId, QuotaExceededErrorId,
|
||||||
};
|
};
|
||||||
use log::warn;
|
use log::warn;
|
||||||
use malloc_size_of_derive::MallocSizeOf;
|
use malloc_size_of_derive::MallocSizeOf;
|
||||||
|
use rustc_hash::{FxBuildHasher, FxHashMap};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
pub use serializable::*;
|
pub use serializable::*;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
@ -28,35 +27,35 @@ pub struct StructuredSerializedData {
|
||||||
/// Data serialized by SpiderMonkey.
|
/// Data serialized by SpiderMonkey.
|
||||||
pub serialized: Vec<u8>,
|
pub serialized: Vec<u8>,
|
||||||
/// Serialized in a structured callback,
|
/// Serialized in a structured callback,
|
||||||
pub blobs: Option<HashMap<BlobId, BlobImpl>>,
|
pub blobs: Option<FxHashMap<BlobId, BlobImpl>>,
|
||||||
/// Serialized point objects.
|
/// Serialized point objects.
|
||||||
pub points: Option<HashMap<DomPointId, DomPoint>>,
|
pub points: Option<FxHashMap<DomPointId, DomPoint>>,
|
||||||
/// Serialized rect objects.
|
/// Serialized rect objects.
|
||||||
pub rects: Option<HashMap<DomRectId, DomRect>>,
|
pub rects: Option<FxHashMap<DomRectId, DomRect>>,
|
||||||
/// Serialized quad objects.
|
/// Serialized quad objects.
|
||||||
pub quads: Option<HashMap<DomQuadId, DomQuad>>,
|
pub quads: Option<FxHashMap<DomQuadId, DomQuad>>,
|
||||||
/// Serialized matrix objects.
|
/// Serialized matrix objects.
|
||||||
pub matrices: Option<HashMap<DomMatrixId, DomMatrix>>,
|
pub matrices: Option<FxHashMap<DomMatrixId, DomMatrix>>,
|
||||||
/// Serialized exception objects.
|
/// Serialized exception objects.
|
||||||
pub exceptions: Option<HashMap<DomExceptionId, DomException>>,
|
pub exceptions: Option<FxHashMap<DomExceptionId, DomException>>,
|
||||||
/// Serialized quota exceeded errors.
|
/// Serialized quota exceeded errors.
|
||||||
pub quota_exceeded_errors:
|
pub quota_exceeded_errors:
|
||||||
Option<HashMap<QuotaExceededErrorId, SerializableQuotaExceededError>>,
|
Option<FxHashMap<QuotaExceededErrorId, SerializableQuotaExceededError>>,
|
||||||
/// Transferred objects.
|
/// Transferred objects.
|
||||||
pub ports: Option<HashMap<MessagePortId, MessagePortImpl>>,
|
pub ports: Option<FxHashMap<MessagePortId, MessagePortImpl>>,
|
||||||
/// Transform streams transferred objects.
|
/// Transform streams transferred objects.
|
||||||
pub transform_streams: Option<HashMap<MessagePortId, TransformStreamData>>,
|
pub transform_streams: Option<FxHashMap<MessagePortId, TransformStreamData>>,
|
||||||
/// Serialized image bitmap objects.
|
/// Serialized image bitmap objects.
|
||||||
pub image_bitmaps: Option<HashMap<ImageBitmapId, SerializableImageBitmap>>,
|
pub image_bitmaps: Option<FxHashMap<ImageBitmapId, SerializableImageBitmap>>,
|
||||||
/// Transferred image bitmap objects.
|
/// Transferred image bitmap objects.
|
||||||
pub transferred_image_bitmaps: Option<HashMap<ImageBitmapId, SerializableImageBitmap>>,
|
pub transferred_image_bitmaps: Option<FxHashMap<ImageBitmapId, SerializableImageBitmap>>,
|
||||||
/// Transferred offscreen canvas objects.
|
/// Transferred offscreen canvas objects.
|
||||||
pub offscreen_canvases: Option<HashMap<OffscreenCanvasId, TransferableOffscreenCanvas>>,
|
pub offscreen_canvases: Option<FxHashMap<OffscreenCanvasId, TransferableOffscreenCanvas>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StructuredSerializedData {
|
impl StructuredSerializedData {
|
||||||
fn is_empty(&self, val: Transferrable) -> bool {
|
fn is_empty(&self, val: Transferrable) -> bool {
|
||||||
fn is_field_empty<K, V>(field: &Option<HashMap<K, V>>) -> bool {
|
fn is_field_empty<K, V>(field: &Option<FxHashMap<K, V>>) -> bool {
|
||||||
field.as_ref().is_none_or(|h| h.is_empty())
|
field.as_ref().is_none_or(|h| h.is_empty())
|
||||||
}
|
}
|
||||||
match val {
|
match val {
|
||||||
|
@ -74,7 +73,7 @@ impl StructuredSerializedData {
|
||||||
fn clone_all_of_type<T: BroadcastClone>(&self, cloned: &mut StructuredSerializedData) {
|
fn clone_all_of_type<T: BroadcastClone>(&self, cloned: &mut StructuredSerializedData) {
|
||||||
let existing = T::source(self);
|
let existing = T::source(self);
|
||||||
let Some(existing) = existing else { return };
|
let Some(existing) = existing else { return };
|
||||||
let mut clones = HashMap::with_capacity(existing.len());
|
let mut clones = FxHashMap::with_capacity_and_hasher(existing.len(), FxBuildHasher);
|
||||||
|
|
||||||
for (original_id, obj) in existing.iter() {
|
for (original_id, obj) in existing.iter() {
|
||||||
if let Some(clone) = obj.clone_for_broadcast() {
|
if let Some(clone) = obj.clone_for_broadcast() {
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
//! be passed through the Constellation.
|
//! be passed through the Constellation.
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use base::id::{
|
use base::id::{
|
||||||
|
@ -19,6 +18,7 @@ use euclid::default::Transform3D;
|
||||||
use malloc_size_of_derive::MallocSizeOf;
|
use malloc_size_of_derive::MallocSizeOf;
|
||||||
use net_traits::filemanager_thread::RelativePos;
|
use net_traits::filemanager_thread::RelativePos;
|
||||||
use pixels::Snapshot;
|
use pixels::Snapshot;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use servo_url::ImmutableOrigin;
|
use servo_url::ImmutableOrigin;
|
||||||
use strum::EnumIter;
|
use strum::EnumIter;
|
||||||
|
@ -36,9 +36,9 @@ where
|
||||||
/// Only return None if cloning is impossible.
|
/// Only return None if cloning is impossible.
|
||||||
fn clone_for_broadcast(&self) -> Option<Self>;
|
fn clone_for_broadcast(&self) -> Option<Self>;
|
||||||
/// The field from which to clone values.
|
/// The field from which to clone values.
|
||||||
fn source(data: &StructuredSerializedData) -> &Option<HashMap<Self::Id, Self>>;
|
fn source(data: &StructuredSerializedData) -> &Option<FxHashMap<Self::Id, Self>>;
|
||||||
/// The field into which to place cloned values.
|
/// The field into which to place cloned values.
|
||||||
fn destination(data: &mut StructuredSerializedData) -> &mut Option<HashMap<Self::Id, Self>>;
|
fn destination(data: &mut StructuredSerializedData) -> &mut Option<FxHashMap<Self::Id, Self>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// All the DOM interfaces that can be serialized.
|
/// All the DOM interfaces that can be serialized.
|
||||||
|
@ -168,15 +168,11 @@ impl FileBlob {
|
||||||
impl BroadcastClone for BlobImpl {
|
impl BroadcastClone for BlobImpl {
|
||||||
type Id = BlobId;
|
type Id = BlobId;
|
||||||
|
|
||||||
fn source(
|
fn source(data: &StructuredSerializedData) -> &Option<FxHashMap<Self::Id, Self>> {
|
||||||
data: &StructuredSerializedData,
|
|
||||||
) -> &Option<std::collections::HashMap<Self::Id, Self>> {
|
|
||||||
&data.blobs
|
&data.blobs
|
||||||
}
|
}
|
||||||
|
|
||||||
fn destination(
|
fn destination(data: &mut StructuredSerializedData) -> &mut Option<FxHashMap<Self::Id, Self>> {
|
||||||
data: &mut StructuredSerializedData,
|
|
||||||
) -> &mut Option<std::collections::HashMap<Self::Id, Self>> {
|
|
||||||
&mut data.blobs
|
&mut data.blobs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,15 +300,11 @@ pub struct DomPoint {
|
||||||
impl BroadcastClone for DomPoint {
|
impl BroadcastClone for DomPoint {
|
||||||
type Id = DomPointId;
|
type Id = DomPointId;
|
||||||
|
|
||||||
fn source(
|
fn source(data: &StructuredSerializedData) -> &Option<FxHashMap<Self::Id, Self>> {
|
||||||
data: &StructuredSerializedData,
|
|
||||||
) -> &Option<std::collections::HashMap<Self::Id, Self>> {
|
|
||||||
&data.points
|
&data.points
|
||||||
}
|
}
|
||||||
|
|
||||||
fn destination(
|
fn destination(data: &mut StructuredSerializedData) -> &mut Option<FxHashMap<Self::Id, Self>> {
|
||||||
data: &mut StructuredSerializedData,
|
|
||||||
) -> &mut Option<std::collections::HashMap<Self::Id, Self>> {
|
|
||||||
&mut data.points
|
&mut data.points
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,15 +329,11 @@ pub struct DomRect {
|
||||||
impl BroadcastClone for DomRect {
|
impl BroadcastClone for DomRect {
|
||||||
type Id = DomRectId;
|
type Id = DomRectId;
|
||||||
|
|
||||||
fn source(
|
fn source(data: &StructuredSerializedData) -> &Option<FxHashMap<Self::Id, Self>> {
|
||||||
data: &StructuredSerializedData,
|
|
||||||
) -> &Option<std::collections::HashMap<Self::Id, Self>> {
|
|
||||||
&data.rects
|
&data.rects
|
||||||
}
|
}
|
||||||
|
|
||||||
fn destination(
|
fn destination(data: &mut StructuredSerializedData) -> &mut Option<FxHashMap<Self::Id, Self>> {
|
||||||
data: &mut StructuredSerializedData,
|
|
||||||
) -> &mut Option<std::collections::HashMap<Self::Id, Self>> {
|
|
||||||
&mut data.rects
|
&mut data.rects
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,15 +358,11 @@ pub struct DomQuad {
|
||||||
impl BroadcastClone for DomQuad {
|
impl BroadcastClone for DomQuad {
|
||||||
type Id = DomQuadId;
|
type Id = DomQuadId;
|
||||||
|
|
||||||
fn source(
|
fn source(data: &StructuredSerializedData) -> &Option<FxHashMap<Self::Id, Self>> {
|
||||||
data: &StructuredSerializedData,
|
|
||||||
) -> &Option<std::collections::HashMap<Self::Id, Self>> {
|
|
||||||
&data.quads
|
&data.quads
|
||||||
}
|
}
|
||||||
|
|
||||||
fn destination(
|
fn destination(data: &mut StructuredSerializedData) -> &mut Option<FxHashMap<Self::Id, Self>> {
|
||||||
data: &mut StructuredSerializedData,
|
|
||||||
) -> &mut Option<std::collections::HashMap<Self::Id, Self>> {
|
|
||||||
&mut data.quads
|
&mut data.quads
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,15 +383,11 @@ pub struct DomMatrix {
|
||||||
impl BroadcastClone for DomMatrix {
|
impl BroadcastClone for DomMatrix {
|
||||||
type Id = DomMatrixId;
|
type Id = DomMatrixId;
|
||||||
|
|
||||||
fn source(
|
fn source(data: &StructuredSerializedData) -> &Option<FxHashMap<Self::Id, Self>> {
|
||||||
data: &StructuredSerializedData,
|
|
||||||
) -> &Option<std::collections::HashMap<Self::Id, Self>> {
|
|
||||||
&data.matrices
|
&data.matrices
|
||||||
}
|
}
|
||||||
|
|
||||||
fn destination(
|
fn destination(data: &mut StructuredSerializedData) -> &mut Option<FxHashMap<Self::Id, Self>> {
|
||||||
data: &mut StructuredSerializedData,
|
|
||||||
) -> &mut Option<std::collections::HashMap<Self::Id, Self>> {
|
|
||||||
&mut data.matrices
|
&mut data.matrices
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,15 +406,11 @@ pub struct DomException {
|
||||||
impl BroadcastClone for DomException {
|
impl BroadcastClone for DomException {
|
||||||
type Id = DomExceptionId;
|
type Id = DomExceptionId;
|
||||||
|
|
||||||
fn source(
|
fn source(data: &StructuredSerializedData) -> &Option<FxHashMap<Self::Id, Self>> {
|
||||||
data: &StructuredSerializedData,
|
|
||||||
) -> &Option<std::collections::HashMap<Self::Id, Self>> {
|
|
||||||
&data.exceptions
|
&data.exceptions
|
||||||
}
|
}
|
||||||
|
|
||||||
fn destination(
|
fn destination(data: &mut StructuredSerializedData) -> &mut Option<FxHashMap<Self::Id, Self>> {
|
||||||
data: &mut StructuredSerializedData,
|
|
||||||
) -> &mut Option<std::collections::HashMap<Self::Id, Self>> {
|
|
||||||
&mut data.exceptions
|
&mut data.exceptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,11 +430,11 @@ pub struct SerializableQuotaExceededError {
|
||||||
impl BroadcastClone for SerializableQuotaExceededError {
|
impl BroadcastClone for SerializableQuotaExceededError {
|
||||||
type Id = QuotaExceededErrorId;
|
type Id = QuotaExceededErrorId;
|
||||||
|
|
||||||
fn source(data: &StructuredSerializedData) -> &Option<HashMap<Self::Id, Self>> {
|
fn source(data: &StructuredSerializedData) -> &Option<FxHashMap<Self::Id, Self>> {
|
||||||
&data.quota_exceeded_errors
|
&data.quota_exceeded_errors
|
||||||
}
|
}
|
||||||
|
|
||||||
fn destination(data: &mut StructuredSerializedData) -> &mut Option<HashMap<Self::Id, Self>> {
|
fn destination(data: &mut StructuredSerializedData) -> &mut Option<FxHashMap<Self::Id, Self>> {
|
||||||
&mut data.quota_exceeded_errors
|
&mut data.quota_exceeded_errors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,15 +452,11 @@ pub struct SerializableImageBitmap {
|
||||||
impl BroadcastClone for SerializableImageBitmap {
|
impl BroadcastClone for SerializableImageBitmap {
|
||||||
type Id = ImageBitmapId;
|
type Id = ImageBitmapId;
|
||||||
|
|
||||||
fn source(
|
fn source(data: &StructuredSerializedData) -> &Option<FxHashMap<Self::Id, Self>> {
|
||||||
data: &StructuredSerializedData,
|
|
||||||
) -> &Option<std::collections::HashMap<Self::Id, Self>> {
|
|
||||||
&data.image_bitmaps
|
&data.image_bitmaps
|
||||||
}
|
}
|
||||||
|
|
||||||
fn destination(
|
fn destination(data: &mut StructuredSerializedData) -> &mut Option<FxHashMap<Self::Id, Self>> {
|
||||||
data: &mut StructuredSerializedData,
|
|
||||||
) -> &mut Option<std::collections::HashMap<Self::Id, Self>> {
|
|
||||||
&mut data.image_bitmaps
|
&mut data.image_bitmaps
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue