mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +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,10 +2,9 @@
|
|||
* 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/. */
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
use crossbeam_channel::{Receiver, select};
|
||||
use devtools_traits::DevtoolScriptControlMsg;
|
||||
use rustc_hash::FxHashSet;
|
||||
|
||||
use crate::dom::bindings::conversions::DerivedFrom;
|
||||
use crate::dom::bindings::reflector::DomObject;
|
||||
|
@ -55,7 +54,7 @@ pub(crate) fn run_worker_event_loop<T, WorkerMsg, Event>(
|
|||
let event = select! {
|
||||
recv(worker_scope.control_receiver()) -> msg => T::from_control_msg(msg.unwrap()),
|
||||
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())
|
||||
},
|
||||
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() {
|
||||
// Batch all events that are ready.
|
||||
// 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() {
|
||||
Ok(message) => sequential.push(T::from_devtools_msg(message)),
|
||||
Err(_) => break,
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
//! Trait representing the concept of [serializable objects]
|
||||
//! (<https://html.spec.whatwg.org/multipage/#serializable-objects>).
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use base::id::{Index, NamespaceIndex, PipelineNamespaceId};
|
||||
use rustc_hash::FxHashMap;
|
||||
use script_bindings::structuredclone::MarkedAsSerializableInIdl;
|
||||
|
||||
use crate::dom::bindings::reflector::DomObject;
|
||||
|
@ -68,7 +67,7 @@ where
|
|||
/// should be used to read/store serialized instances of this type.
|
||||
fn serialized_storage<'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>() {}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
//! 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::os::raw;
|
||||
use std::ptr;
|
||||
|
@ -34,6 +33,7 @@ use js::rust::wrappers::{JS_ReadStructuredClone, JS_WriteStructuredClone};
|
|||
use js::rust::{
|
||||
CustomAutoRooterGuard, HandleValue, JSAutoStructuredCloneBufferWrapper, MutableHandleValue,
|
||||
};
|
||||
use rustc_hash::FxHashMap;
|
||||
use script_bindings::conversions::{IDLInterface, SafeToJSValConvertible};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
|
@ -191,7 +191,7 @@ unsafe fn write_object<T: Serializable>(
|
|||
) -> bool {
|
||||
if let Ok((new_id, serialized)) = object.serialize() {
|
||||
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);
|
||||
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)?;
|
||||
|
||||
// 2. Store the transferred object at a given key.
|
||||
let objects =
|
||||
T::serialized_storage(StructuredData::Writer(sc_writer)).get_or_insert_with(HashMap::new);
|
||||
let objects = T::serialized_storage(StructuredData::Writer(sc_writer))
|
||||
.get_or_insert(FxHashMap::default());
|
||||
objects.insert(id, object);
|
||||
|
||||
let index = id.index.0.get();
|
||||
|
@ -587,32 +587,33 @@ pub(crate) struct StructuredDataReader<'a> {
|
|||
/// A map of port implementations,
|
||||
/// used as part of the "transfer-receiving" steps of ports,
|
||||
/// 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,
|
||||
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,
|
||||
/// used as part of the "deserialize" steps of blobs,
|
||||
/// 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.
|
||||
pub(crate) points: Option<HashMap<DomPointId, DomPoint>>,
|
||||
pub(crate) points: Option<FxHashMap<DomPointId, DomPoint>>,
|
||||
/// A map of serialized rects.
|
||||
pub(crate) rects: Option<HashMap<DomRectId, DomRect>>,
|
||||
pub(crate) rects: Option<FxHashMap<DomRectId, DomRect>>,
|
||||
/// A map of serialized quads.
|
||||
pub(crate) quads: Option<HashMap<DomQuadId, DomQuad>>,
|
||||
pub(crate) quads: Option<FxHashMap<DomQuadId, DomQuad>>,
|
||||
/// A map of serialized matrices.
|
||||
pub(crate) matrices: Option<HashMap<DomMatrixId, DomMatrix>>,
|
||||
pub(crate) matrices: Option<FxHashMap<DomMatrixId, DomMatrix>>,
|
||||
/// 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.
|
||||
pub(crate) quota_exceeded_errors:
|
||||
Option<HashMap<QuotaExceededErrorId, SerializableQuotaExceededError>>,
|
||||
Option<FxHashMap<QuotaExceededErrorId, SerializableQuotaExceededError>>,
|
||||
// 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.
|
||||
pub(crate) transferred_image_bitmaps: Option<HashMap<ImageBitmapId, SerializableImageBitmap>>,
|
||||
pub(crate) transferred_image_bitmaps: Option<FxHashMap<ImageBitmapId, SerializableImageBitmap>>,
|
||||
/// 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.
|
||||
|
@ -622,30 +623,31 @@ pub(crate) struct StructuredDataWriter {
|
|||
/// Error record.
|
||||
pub(crate) error: Option<Error>,
|
||||
/// Transferred ports.
|
||||
pub(crate) ports: Option<HashMap<MessagePortId, MessagePortImpl>>,
|
||||
pub(crate) ports: Option<FxHashMap<MessagePortId, MessagePortImpl>>,
|
||||
/// Transferred transform streams.
|
||||
pub(crate) transform_streams_port: Option<HashMap<MessagePortId, TransformStreamData>>,
|
||||
pub(crate) transform_streams_port: Option<FxHashMap<MessagePortId, TransformStreamData>>,
|
||||
/// Serialized points.
|
||||
pub(crate) points: Option<HashMap<DomPointId, DomPoint>>,
|
||||
pub(crate) points: Option<FxHashMap<DomPointId, DomPoint>>,
|
||||
/// Serialized rects.
|
||||
pub(crate) rects: Option<HashMap<DomRectId, DomRect>>,
|
||||
pub(crate) rects: Option<FxHashMap<DomRectId, DomRect>>,
|
||||
/// Serialized quads.
|
||||
pub(crate) quads: Option<HashMap<DomQuadId, DomQuad>>,
|
||||
pub(crate) quads: Option<FxHashMap<DomQuadId, DomQuad>>,
|
||||
/// Serialized matrices.
|
||||
pub(crate) matrices: Option<HashMap<DomMatrixId, DomMatrix>>,
|
||||
pub(crate) matrices: Option<FxHashMap<DomMatrixId, DomMatrix>>,
|
||||
/// Serialized exceptions.
|
||||
pub(crate) exceptions: Option<HashMap<DomExceptionId, DomException>>,
|
||||
pub(crate) exceptions: Option<FxHashMap<DomExceptionId, DomException>>,
|
||||
/// Serialized quota exceeded errors.
|
||||
pub(crate) quota_exceeded_errors:
|
||||
Option<HashMap<QuotaExceededErrorId, SerializableQuotaExceededError>>,
|
||||
Option<FxHashMap<QuotaExceededErrorId, SerializableQuotaExceededError>>,
|
||||
/// Serialized blobs.
|
||||
pub(crate) blobs: Option<HashMap<BlobId, BlobImpl>>,
|
||||
pub(crate) blobs: Option<FxHashMap<BlobId, BlobImpl>>,
|
||||
/// Serialized image bitmaps.
|
||||
pub(crate) image_bitmaps: Option<HashMap<ImageBitmapId, SerializableImageBitmap>>,
|
||||
pub(crate) image_bitmaps: Option<FxHashMap<ImageBitmapId, SerializableImageBitmap>>,
|
||||
/// Transferred image bitmaps.
|
||||
pub(crate) transferred_image_bitmaps: Option<HashMap<ImageBitmapId, SerializableImageBitmap>>,
|
||||
pub(crate) transferred_image_bitmaps: Option<FxHashMap<ImageBitmapId, SerializableImageBitmap>>,
|
||||
/// 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.
|
||||
|
|
|
@ -40,6 +40,7 @@ use js::glue::{CallScriptTracer, CallStringTracer, CallValueTracer};
|
|||
use js::jsapi::{GCTraceKindToAscii, Heap, JSScript, JSString, JSTracer, TraceKind};
|
||||
use js::jsval::JSVal;
|
||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||
use rustc_hash::FxBuildHasher;
|
||||
pub(crate) use script_bindings::trace::*;
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
|
@ -92,6 +93,9 @@ impl<T: MallocSizeOf> MallocSizeOf for NoTrace<T> {
|
|||
/// HashMap wrapper, that has non-jsmanaged keys
|
||||
///
|
||||
/// 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))]
|
||||
#[derive(Clone, Debug)]
|
||||
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> {
|
||||
#[inline]
|
||||
pub(crate) fn iter(&self) -> std::collections::hash_map::Iter<'_, K, V> {
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
//! Trait representing the concept of [transferable objects]
|
||||
//! (<https://html.spec.whatwg.org/multipage/#transferable-objects>).
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::hash::Hash;
|
||||
|
||||
use base::id::NamespaceIndex;
|
||||
use rustc_hash::FxHashMap;
|
||||
use script_bindings::structuredclone::MarkedAsTransferableInIdl;
|
||||
|
||||
use crate::dom::bindings::error::Fallible;
|
||||
|
@ -40,7 +40,7 @@ where
|
|||
|
||||
fn serialized_storage<'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>() {}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
* 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/. */
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
@ -14,6 +13,7 @@ use js::jsapi::JSObject;
|
|||
use js::rust::HandleObject;
|
||||
use js::typedarray::{ArrayBufferU8, Uint8};
|
||||
use net_traits::filemanager_thread::RelativePos;
|
||||
use rustc_hash::FxHashMap;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::dom::bindings::buffer_source::create_buffer_source;
|
||||
|
@ -120,7 +120,7 @@ impl Serializable for Blob {
|
|||
|
||||
fn serialized_storage<'a>(
|
||||
reader: StructuredData<'a, '_>,
|
||||
) -> &'a mut Option<HashMap<BlobId, Self::Data>> {
|
||||
) -> &'a mut Option<FxHashMap<BlobId, Self::Data>> {
|
||||
match reader {
|
||||
StructuredData::Reader(r) => &mut r.blob_impls,
|
||||
StructuredData::Writer(w) => &mut w.blobs,
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cell::{Cell, Ref};
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
|
||||
use base::id::{ImageBitmapId, ImageBitmapIndex};
|
||||
|
@ -11,6 +10,7 @@ use constellation_traits::SerializableImageBitmap;
|
|||
use dom_struct::dom_struct;
|
||||
use euclid::default::{Point2D, Rect, Size2D};
|
||||
use pixels::{CorsStatus, PixelFormat, Snapshot, SnapshotAlphaMode, SnapshotPixelFormat};
|
||||
use rustc_hash::FxHashMap;
|
||||
use script_bindings::error::{Error, Fallible};
|
||||
use script_bindings::realms::{AlreadyInRealm, InRealm};
|
||||
|
||||
|
@ -663,7 +663,7 @@ impl Serializable for ImageBitmap {
|
|||
|
||||
fn serialized_storage<'a>(
|
||||
data: StructuredData<'a, '_>,
|
||||
) -> &'a mut Option<HashMap<ImageBitmapId, Self::Data>> {
|
||||
) -> &'a mut Option<FxHashMap<ImageBitmapId, Self::Data>> {
|
||||
match data {
|
||||
StructuredData::Reader(r) => &mut r.image_bitmaps,
|
||||
StructuredData::Writer(w) => &mut w.image_bitmaps,
|
||||
|
@ -716,7 +716,7 @@ impl Transferable for ImageBitmap {
|
|||
|
||||
fn serialized_storage<'a>(
|
||||
data: StructuredData<'a, '_>,
|
||||
) -> &'a mut Option<HashMap<ImageBitmapId, Self::Data>> {
|
||||
) -> &'a mut Option<FxHashMap<ImageBitmapId, Self::Data>> {
|
||||
match data {
|
||||
StructuredData::Reader(r) => &mut r.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/. */
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
|
||||
use base::id::{OffscreenCanvasId, OffscreenCanvasIndex};
|
||||
|
@ -12,6 +11,7 @@ use dom_struct::dom_struct;
|
|||
use euclid::default::Size2D;
|
||||
use js::rust::{HandleObject, HandleValue};
|
||||
use pixels::{EncodedImageType, Snapshot};
|
||||
use rustc_hash::FxHashMap;
|
||||
use script_bindings::weakref::WeakRef;
|
||||
|
||||
use crate::canvas_context::{CanvasContext, OffscreenRenderingContext};
|
||||
|
@ -261,7 +261,7 @@ impl Transferable for OffscreenCanvas {
|
|||
|
||||
fn serialized_storage<'a>(
|
||||
data: StructuredData<'a, '_>,
|
||||
) -> &'a mut Option<HashMap<OffscreenCanvasId, Self::Data>> {
|
||||
) -> &'a mut Option<FxHashMap<OffscreenCanvasId, Self::Data>> {
|
||||
match data {
|
||||
StructuredData::Reader(r) => &mut r.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::time::TimerMetadataFrameType;
|
||||
use regex::bytes::Regex;
|
||||
use rustc_hash::FxBuildHasher;
|
||||
use script_bindings::codegen::GenericBindings::ElementBinding::ElementMethods;
|
||||
use script_bindings::interfaces::DocumentHelpers;
|
||||
use script_bindings::script_runtime::JSContext;
|
||||
|
@ -474,15 +475,17 @@ pub(crate) struct Document {
|
|||
/// hosting the media controls UI.
|
||||
media_controls: DomRefCell<HashMap<String, Dom<ShadowRoot>>>,
|
||||
/// 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.
|
||||
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.
|
||||
has_pending_animated_image_update: Cell<bool>,
|
||||
/// List of all WebGPU contexts that need flushing.
|
||||
#[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>
|
||||
selection: MutNullableDom<Selection>,
|
||||
/// A timeline for animations which is used for synchronizing animations.
|
||||
|
@ -3418,11 +3421,11 @@ impl Document {
|
|||
shadow_roots: DomRefCell::new(HashSet::new()),
|
||||
shadow_roots_styles_changed: Cell::new(false),
|
||||
media_controls: DomRefCell::new(HashMap::new()),
|
||||
dirty_2d_contexts: DomRefCell::new(HashMapTracedValues::new()),
|
||||
dirty_webgl_contexts: DomRefCell::new(HashMapTracedValues::new()),
|
||||
dirty_2d_contexts: DomRefCell::new(HashMapTracedValues::new_fx()),
|
||||
dirty_webgl_contexts: DomRefCell::new(HashMapTracedValues::new_fx()),
|
||||
has_pending_animated_image_update: Cell::new(false),
|
||||
#[cfg(feature = "webgpu")]
|
||||
dirty_webgpu_contexts: DomRefCell::new(HashMapTracedValues::new()),
|
||||
dirty_webgpu_contexts: DomRefCell::new(HashMapTracedValues::new_fx()),
|
||||
selection: MutNullableDom::new(None),
|
||||
animation_timeline: if pref!(layout_animations_test_enabled) {
|
||||
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
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use base::id::{DomExceptionId, DomExceptionIndex};
|
||||
use constellation_traits::DomException;
|
||||
use dom_struct::dom_struct;
|
||||
use js::rust::HandleObject;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::DOMExceptionBinding::{
|
||||
DOMExceptionConstants, DOMExceptionMethods,
|
||||
|
@ -280,7 +279,7 @@ impl Serializable for DOMException {
|
|||
|
||||
fn serialized_storage<'a>(
|
||||
data: StructuredData<'a, '_>,
|
||||
) -> &'a mut Option<HashMap<DomExceptionId, Self::Data>> {
|
||||
) -> &'a mut Option<FxHashMap<DomExceptionId, Self::Data>> {
|
||||
match data {
|
||||
StructuredData::Reader(reader) => &mut reader.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
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use base::id::{DomMatrixId, DomMatrixIndex};
|
||||
use constellation_traits::DomMatrix;
|
||||
use dom_struct::dom_struct;
|
||||
use euclid::default::Transform3D;
|
||||
use js::rust::{CustomAutoRooterGuard, HandleObject};
|
||||
use js::typedarray::{Float32Array, Float64Array};
|
||||
use rustc_hash::FxHashMap;
|
||||
use script_bindings::str::DOMString;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::DOMMatrixBinding::{DOMMatrixInit, DOMMatrixMethods};
|
||||
|
@ -574,7 +573,7 @@ impl Serializable for DOMMatrix {
|
|||
|
||||
fn serialized_storage<'a>(
|
||||
data: StructuredData<'a, '_>,
|
||||
) -> &'a mut Option<HashMap<DomMatrixId, Self::Data>> {
|
||||
) -> &'a mut Option<FxHashMap<DomMatrixId, Self::Data>> {
|
||||
match data {
|
||||
StructuredData::Reader(reader) => &mut reader.matrices,
|
||||
StructuredData::Writer(writer) => &mut writer.matrices,
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::collections::HashMap;
|
||||
use std::{f64, ptr};
|
||||
|
||||
use base::id::{DomMatrixId, DomMatrixIndex};
|
||||
|
@ -17,6 +16,7 @@ use js::jsapi::JSObject;
|
|||
use js::jsval;
|
||||
use js::rust::{CustomAutoRooterGuard, HandleObject, ToString};
|
||||
use js::typedarray::{Float32Array, Float64Array};
|
||||
use rustc_hash::FxHashMap;
|
||||
use style::parser::ParserContext;
|
||||
use url::Url;
|
||||
|
||||
|
@ -1033,7 +1033,7 @@ impl Serializable for DOMMatrixReadOnly {
|
|||
|
||||
fn serialized_storage<'a>(
|
||||
data: StructuredData<'a, '_>,
|
||||
) -> &'a mut Option<HashMap<DomMatrixId, Self::Data>> {
|
||||
) -> &'a mut Option<FxHashMap<DomMatrixId, Self::Data>> {
|
||||
match data {
|
||||
StructuredData::Reader(reader) => &mut reader.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
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use base::id::{DomPointId, DomPointIndex};
|
||||
use constellation_traits::DomPoint;
|
||||
use dom_struct::dom_struct;
|
||||
use js::rust::HandleObject;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMethods};
|
||||
use crate::dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::DOMPointReadOnlyMethods;
|
||||
|
@ -165,7 +164,7 @@ impl Serializable for DOMPoint {
|
|||
|
||||
fn serialized_storage<'a>(
|
||||
data: StructuredData<'a, '_>,
|
||||
) -> &'a mut Option<HashMap<DomPointId, Self::Data>> {
|
||||
) -> &'a mut Option<FxHashMap<DomPointId, Self::Data>> {
|
||||
match data {
|
||||
StructuredData::Reader(reader) => &mut reader.points,
|
||||
StructuredData::Writer(writer) => &mut writer.points,
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use base::id::{DomPointId, DomPointIndex};
|
||||
use constellation_traits::DomPoint;
|
||||
use dom_struct::dom_struct;
|
||||
use js::rust::HandleObject;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::DOMMatrixBinding::DOMMatrixInit;
|
||||
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
|
||||
|
@ -213,7 +213,7 @@ impl Serializable for DOMPointReadOnly {
|
|||
|
||||
fn serialized_storage<'a>(
|
||||
data: StructuredData<'a, '_>,
|
||||
) -> &'a mut Option<HashMap<DomPointId, Self::Data>> {
|
||||
) -> &'a mut Option<FxHashMap<DomPointId, Self::Data>> {
|
||||
match data {
|
||||
StructuredData::Reader(r) => &mut r.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
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use base::id::{DomQuadId, DomQuadIndex};
|
||||
use constellation_traits::{DomPoint, DomQuad};
|
||||
use dom_struct::dom_struct;
|
||||
use js::rust::HandleObject;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMethods};
|
||||
use crate::dom::bindings::codegen::Bindings::DOMQuadBinding::{DOMQuadInit, DOMQuadMethods};
|
||||
|
@ -255,7 +254,7 @@ impl Serializable for DOMQuad {
|
|||
|
||||
fn serialized_storage<'a>(
|
||||
data: StructuredData<'a, '_>,
|
||||
) -> &'a mut Option<HashMap<DomQuadId, Self::Data>> {
|
||||
) -> &'a mut Option<FxHashMap<DomQuadId, Self::Data>> {
|
||||
match data {
|
||||
StructuredData::Reader(reader) => &mut reader.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
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use base::id::{DomRectId, DomRectIndex};
|
||||
use constellation_traits::DomRect;
|
||||
use dom_struct::dom_struct;
|
||||
use js::rust::HandleObject;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::{
|
||||
|
@ -162,7 +161,7 @@ impl Serializable for DOMRect {
|
|||
|
||||
fn serialized_storage<'a>(
|
||||
data: StructuredData<'a, '_>,
|
||||
) -> &'a mut Option<HashMap<DomRectId, Self::Data>> {
|
||||
) -> &'a mut Option<FxHashMap<DomRectId, Self::Data>> {
|
||||
match data {
|
||||
StructuredData::Reader(reader) => &mut reader.rects,
|
||||
StructuredData::Writer(writer) => &mut writer.rects,
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use base::id::{DomRectId, DomRectIndex};
|
||||
use constellation_traits::DomRect;
|
||||
use dom_struct::dom_struct;
|
||||
use js::rust::HandleObject;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::{
|
||||
DOMRectInit, DOMRectReadOnlyMethods,
|
||||
|
@ -239,7 +239,7 @@ impl Serializable for DOMRectReadOnly {
|
|||
|
||||
fn serialized_storage<'a>(
|
||||
data: StructuredData<'a, '_>,
|
||||
) -> &'a mut Option<HashMap<Type, Self::Data>> {
|
||||
) -> &'a mut Option<FxHashMap<Type, Self::Data>> {
|
||||
match data {
|
||||
StructuredData::Reader(reader) => &mut reader.rects,
|
||||
StructuredData::Writer(writer) => &mut writer.rects,
|
||||
|
|
|
@ -57,6 +57,7 @@ use net_traits::{
|
|||
ResourceThreads, fetch_async,
|
||||
};
|
||||
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 servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
||||
use timers::{TimerEventRequest, TimerId};
|
||||
|
@ -204,18 +205,22 @@ pub(crate) struct GlobalScope {
|
|||
broadcast_channel_state: DomRefCell<BroadcastChannelState>,
|
||||
|
||||
/// 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>
|
||||
registration_map: DomRefCell<
|
||||
HashMapTracedValues<ServiceWorkerRegistrationId, Dom<ServiceWorkerRegistration>>,
|
||||
HashMapTracedValues<
|
||||
ServiceWorkerRegistrationId,
|
||||
Dom<ServiceWorkerRegistration>,
|
||||
FxBuildHasher,
|
||||
>,
|
||||
>,
|
||||
|
||||
/// <https://cookiestore.spec.whatwg.org/#globals>
|
||||
cookie_store: MutNullableDom<CookieStore>,
|
||||
|
||||
/// <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.
|
||||
#[no_trace]
|
||||
|
@ -234,7 +239,7 @@ pub(crate) struct GlobalScope {
|
|||
module_map: DomRefCell<HashMapTracedValues<ServoUrl, Rc<ModuleTree>>>,
|
||||
|
||||
#[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.
|
||||
#[no_trace]
|
||||
|
@ -336,7 +341,7 @@ pub(crate) struct GlobalScope {
|
|||
|
||||
/// WebGPU devices
|
||||
#[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
|
||||
#[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.
|
||||
Managed(
|
||||
#[no_trace] MessagePortRouterId,
|
||||
HashMapTracedValues<MessagePortId, ManagedMessagePort>,
|
||||
HashMapTracedValues<MessagePortId, ManagedMessagePort, FxBuildHasher>,
|
||||
),
|
||||
/// This global is not managing any ports at this time.
|
||||
UnManaged,
|
||||
|
@ -765,9 +770,9 @@ impl GlobalScope {
|
|||
blob_state: Default::default(),
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
crypto: Default::default(),
|
||||
registration_map: DomRefCell::new(HashMapTracedValues::new()),
|
||||
registration_map: DomRefCell::new(HashMapTracedValues::new_fx()),
|
||||
cookie_store: Default::default(),
|
||||
worker_map: DomRefCell::new(HashMapTracedValues::new()),
|
||||
worker_map: DomRefCell::new(HashMapTracedValues::new_fx()),
|
||||
pipeline_id,
|
||||
devtools_wants_updates: Default::default(),
|
||||
console_timers: DomRefCell::new(Default::default()),
|
||||
|
@ -793,7 +798,7 @@ impl GlobalScope {
|
|||
#[cfg(feature = "webgpu")]
|
||||
gpu_id_hub,
|
||||
#[cfg(feature = "webgpu")]
|
||||
gpu_devices: DomRefCell::new(HashMapTracedValues::new()),
|
||||
gpu_devices: DomRefCell::new(HashMapTracedValues::new_fx()),
|
||||
frozen_supported_performance_entry_types: CachedFrozenArray::new(),
|
||||
https_state: Cell::new(HttpsState::None),
|
||||
console_group_stack: DomRefCell::new(Vec::new()),
|
||||
|
@ -1703,7 +1708,7 @@ impl GlobalScope {
|
|||
}),
|
||||
);
|
||||
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(
|
||||
ScriptToConstellationMessage::NewMessagePortRouter(router_id, port_control_sender),
|
||||
);
|
||||
|
@ -2373,7 +2378,7 @@ impl GlobalScope {
|
|||
.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
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
|
||||
use canvas_traits::webgl::{GLContextAttributes, WebGLVersion};
|
||||
|
@ -19,6 +18,7 @@ use js::error::throw_type_error;
|
|||
use js::rust::{HandleObject, HandleValue};
|
||||
use layout_api::HTMLCanvasData;
|
||||
use pixels::{EncodedImageType, Snapshot};
|
||||
use rustc_hash::FxHashMap;
|
||||
use script_bindings::weakref::WeakRef;
|
||||
use servo_media::streams::MediaStreamType;
|
||||
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.
|
||||
callback_id: Cell<u32>,
|
||||
#[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 {
|
||||
|
@ -90,7 +90,7 @@ impl HTMLCanvasElement {
|
|||
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
|
||||
context_mode: DomRefCell::new(None),
|
||||
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::{
|
||||
MediaMetadata as EmbedderMediaMetadata, MediaSessionActionType, MediaSessionEvent,
|
||||
};
|
||||
use rustc_hash::FxBuildHasher;
|
||||
|
||||
use super::bindings::trace::HashMapTracedValues;
|
||||
use crate::conversions::Convert;
|
||||
|
@ -44,8 +45,9 @@ pub(crate) struct MediaSession {
|
|||
playback_state: DomRefCell<MediaSessionPlaybackState>,
|
||||
/// <https://w3c.github.io/mediasession/#supported-media-session-actions>
|
||||
#[ignore_malloc_size_of = "Rc"]
|
||||
action_handlers:
|
||||
DomRefCell<HashMapTracedValues<MediaSessionActionType, Rc<MediaSessionActionHandler>>>,
|
||||
action_handlers: DomRefCell<
|
||||
HashMapTracedValues<MediaSessionActionType, Rc<MediaSessionActionHandler>, FxBuildHasher>,
|
||||
>,
|
||||
/// The media instance controlled by this media session.
|
||||
/// For now only HTMLMediaElements are controlled by media sessions.
|
||||
media_instance: MutNullableDom<HTMLMediaElement>,
|
||||
|
@ -58,7 +60,7 @@ impl MediaSession {
|
|||
reflector_: Reflector::new(),
|
||||
metadata: DomRefCell::new(None),
|
||||
playback_state: DomRefCell::new(MediaSessionPlaybackState::None),
|
||||
action_handlers: DomRefCell::new(HashMapTracedValues::new()),
|
||||
action_handlers: DomRefCell::new(HashMapTracedValues::new_fx()),
|
||||
media_instance: Default::default(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::HashMap;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
@ -13,6 +12,7 @@ use dom_struct::dom_struct;
|
|||
use js::jsapi::{Heap, JS_NewObject, JSObject};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue};
|
||||
use rustc_hash::FxHashMap;
|
||||
use script_bindings::conversions::SafeToJSValConvertible;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||
|
@ -280,7 +280,7 @@ impl Transferable for MessagePort {
|
|||
|
||||
fn serialized_storage<'a>(
|
||||
data: StructuredData<'a, '_>,
|
||||
) -> &'a mut Option<HashMap<MessagePortId, Self::Data>> {
|
||||
) -> &'a mut Option<FxHashMap<MessagePortId, Self::Data>> {
|
||||
match data {
|
||||
StructuredData::Reader(r) => &mut r.port_impls,
|
||||
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
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use base::id::{QuotaExceededErrorId, QuotaExceededErrorIndex};
|
||||
use constellation_traits::SerializableQuotaExceededError;
|
||||
use dom_struct::dom_struct;
|
||||
use js::gc::HandleObject;
|
||||
use rustc_hash::FxHashMap;
|
||||
use script_bindings::codegen::GenericBindings::QuotaExceededErrorBinding::{
|
||||
QuotaExceededErrorMethods, QuotaExceededErrorOptions,
|
||||
};
|
||||
|
@ -165,7 +164,7 @@ impl Serializable for QuotaExceededError {
|
|||
/// <https://webidl.spec.whatwg.org/#quotaexceedederror>
|
||||
fn serialized_storage<'a>(
|
||||
data: StructuredData<'a, '_>,
|
||||
) -> &'a mut Option<HashMap<QuotaExceededErrorId, Self::Data>> {
|
||||
) -> &'a mut Option<FxHashMap<QuotaExceededErrorId, Self::Data>> {
|
||||
match data {
|
||||
StructuredData::Reader(reader) => &mut reader.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/. */
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::VecDeque;
|
||||
use std::ptr::{self};
|
||||
use std::rc::Rc;
|
||||
|
@ -11,6 +10,7 @@ use std::rc::Rc;
|
|||
use base::id::{MessagePortId, MessagePortIndex};
|
||||
use constellation_traits::MessagePortImpl;
|
||||
use dom_struct::dom_struct;
|
||||
use rustc_hash::FxHashMap;
|
||||
use ipc_channel::ipc::IpcSharedMemory;
|
||||
use js::jsapi::{Heap, JSObject};
|
||||
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.
|
||||
fn serialized_storage<'a>(
|
||||
data: StructuredData<'a, '_>,
|
||||
) -> &'a mut Option<HashMap<MessagePortId, Self::Data>> {
|
||||
) -> &'a mut Option<FxHashMap<MessagePortId, Self::Data>> {
|
||||
match data {
|
||||
StructuredData::Reader(r) => &mut r.port_impls,
|
||||
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 markup5ever::TokenizerResult;
|
||||
use rustc_hash::FxHashMap;
|
||||
use servo_url::ServoUrl;
|
||||
use style::context::QuirksMode as ServoQuirksMode;
|
||||
|
||||
|
@ -697,7 +698,7 @@ struct ParseNodeData {
|
|||
|
||||
pub(crate) struct Sink {
|
||||
current_line: Cell<u64>,
|
||||
parse_node_data: RefCell<HashMap<ParseNodeId, ParseNodeData>>,
|
||||
parse_node_data: RefCell<FxHashMap<ParseNodeId, ParseNodeData>>,
|
||||
next_parse_node_id: Cell<ParseNodeId>,
|
||||
document_node: ParseNode,
|
||||
sender: Sender<ToTokenizerMsg>,
|
||||
|
@ -708,7 +709,7 @@ impl Sink {
|
|||
fn new(sender: Sender<ToTokenizerMsg>, allow_declarative_shadow_roots: bool) -> Sink {
|
||||
let sink = Sink {
|
||||
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),
|
||||
document_node: ParseNode {
|
||||
id: 0,
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::collections::HashMap;
|
||||
use std::ptr::{self};
|
||||
use std::rc::Rc;
|
||||
|
||||
|
@ -13,6 +12,7 @@ use dom_struct::dom_struct;
|
|||
use js::jsapi::{Heap, IsPromiseObject, JSObject};
|
||||
use js::jsval::{JSVal, ObjectValue, UndefinedValue};
|
||||
use js::rust::{HandleObject as SafeHandleObject, HandleValue as SafeHandleValue, IntoHandle};
|
||||
use rustc_hash::FxHashMap;
|
||||
use script_bindings::callback::ExceptionHandling;
|
||||
use script_bindings::realms::InRealm;
|
||||
|
||||
|
@ -1193,7 +1193,7 @@ impl Transferable for TransformStream {
|
|||
|
||||
fn serialized_storage<'a>(
|
||||
data: StructuredData<'a, '_>,
|
||||
) -> &'a mut Option<HashMap<MessagePortId, Self::Data>> {
|
||||
) -> &'a mut Option<FxHashMap<MessagePortId, Self::Data>> {
|
||||
match data {
|
||||
StructuredData::Reader(r) => &mut r.transform_streams_port_impls,
|
||||
StructuredData::Writer(w) => &mut w.transform_streams_port,
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use js::rust::HandleObject;
|
||||
use rustc_hash::FxHashMap;
|
||||
use servo_media::ServoMedia;
|
||||
use servo_media::streams::MediaStreamType;
|
||||
use servo_media::streams::registry::MediaStreamId;
|
||||
|
@ -73,7 +73,7 @@ pub(crate) struct RTCPeerConnection {
|
|||
ice_connection_state: Cell<RTCIceConnectionState>,
|
||||
signaling_state: Cell<RTCSignalingState>,
|
||||
#[ignore_malloc_size_of = "defined in servo-media"]
|
||||
data_channels: DomRefCell<HashMap<DataChannelId, Dom<RTCDataChannel>>>,
|
||||
data_channels: DomRefCell<FxHashMap<DataChannelId, Dom<RTCDataChannel>>>,
|
||||
}
|
||||
|
||||
struct RTCSignaller {
|
||||
|
@ -171,7 +171,7 @@ impl RTCPeerConnection {
|
|||
gathering_state: Cell::new(RTCIceGatheringState::New),
|
||||
ice_connection_state: Cell::new(RTCIceConnectionState::New),
|
||||
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::mem::ProfilerChan as MemProfilerChan;
|
||||
use profile_traits::time::ProfilerChan as TimeProfilerChan;
|
||||
use rustc_hash::{FxBuildHasher, FxHashMap};
|
||||
use script_bindings::codegen::GenericBindings::WindowBinding::ScrollToOptions;
|
||||
use script_bindings::conversions::SafeToJSValConvertible;
|
||||
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
|
||||
/// layout, they also add an etry to [`Self::pending_layout_images`].
|
||||
#[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
|
||||
/// 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
|
||||
/// available at some point in the future.
|
||||
pending_layout_images:
|
||||
DomRefCell<HashMapTracedValues<PendingImageId, Vec<PendingLayoutImageAncillaryData>>>,
|
||||
pending_layout_images: DomRefCell<
|
||||
HashMapTracedValues<PendingImageId, Vec<PendingLayoutImageAncillaryData>, FxBuildHasher>,
|
||||
>,
|
||||
|
||||
/// 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`]
|
||||
/// so that the element can be marked dirty once the rasterization is completed.
|
||||
pending_images_for_rasterization:
|
||||
DomRefCell<HashMapTracedValues<PendingImageRasterizationKey, Vec<Dom<Node>>>>,
|
||||
pending_images_for_rasterization: DomRefCell<
|
||||
HashMapTracedValues<PendingImageRasterizationKey, Vec<Dom<Node>>, FxBuildHasher>,
|
||||
>,
|
||||
|
||||
/// Directory to store unminified css for this window if unminify-css
|
||||
/// opt is enabled.
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
use std::cell::OnceCell;
|
||||
use std::cmp::max;
|
||||
use std::collections::{HashMap, hash_map};
|
||||
use std::collections::hash_map;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
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 net_traits::IpcSend;
|
||||
use net_traits::request::{Destination, RequestBuilder, RequestMode};
|
||||
use rustc_hash::FxHashMap;
|
||||
use servo_url::{ImmutableOrigin, ServoUrl};
|
||||
use style::thread_state::{self, ThreadState};
|
||||
use swapper::{Swapper, swapper};
|
||||
|
@ -458,7 +459,7 @@ struct WorkletThread {
|
|||
global_init: WorkletGlobalScopeInit,
|
||||
|
||||
/// 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
|
||||
control_buffer: Option<WorkletControl>,
|
||||
|
@ -502,7 +503,7 @@ impl WorkletThread {
|
|||
hot_backup_sender: init.hot_backup_sender,
|
||||
cold_backup_sender: init.cold_backup_sender,
|
||||
global_init: init.global_init,
|
||||
global_scopes: HashMap::new(),
|
||||
global_scopes: FxHashMap::default(),
|
||||
control_buffer: None,
|
||||
runtime: Runtime::new(None),
|
||||
should_gc: false,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::collections::VecDeque;
|
||||
use std::mem;
|
||||
use std::ptr::{self};
|
||||
use std::rc::Rc;
|
||||
|
@ -17,6 +17,7 @@ use js::rust::{
|
|||
HandleObject as SafeHandleObject, HandleValue as SafeHandleValue,
|
||||
MutableHandleValue as SafeMutableHandleValue,
|
||||
};
|
||||
use rustc_hash::FxHashMap;
|
||||
use script_bindings::codegen::GenericBindings::MessagePortBinding::MessagePortMethods;
|
||||
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.
|
||||
fn serialized_storage<'a>(
|
||||
data: StructuredData<'a, '_>,
|
||||
) -> &'a mut Option<HashMap<MessagePortId, Self::Data>> {
|
||||
) -> &'a mut Option<FxHashMap<MessagePortId, Self::Data>> {
|
||||
match data {
|
||||
StructuredData::Reader(r) => &mut r.port_impls,
|
||||
StructuredData::Writer(w) => &mut w.ports,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue