No tracing of nop traceable fields (#29926)

* Add `no_trace` option to JSTraceable derive

* NoTrace wrapper

* Port some types to no_trace schematics

* Fixing my unsafe mistakes (not tracing traceables)

* Add docs & safety guards for no_trace

Safety guards (trait shenanigans) guarantees safety usage of `no_trace`

* Port canvas_traits to no_trace

* Port servo_media to no_trace

* Port net_traits to no_trace

* Port style to no_trace

* Port webgpu to no_trace

* Port script_traits to no_trace

* Port canvas_traits, devtools_traits, embedder_traits, profile_traits to no_trace

* unrooted_must_root lint in seperate file

* Add trace_in_no_trace_lint as script_plugin

* Composable types in must_not_have_traceable

* Introduced HashMapTracedValues wrapper

* `HashMap<NoTrace<K>,V>`->`HashMapTracedValues<K,V>`

* Port rest of servo's types to no_trace

* Port html5ever, euclid, mime and http to no_trace

* Port remaining externals to no_trace

* Port webxr and Arc<Mutex<_>>

* Fix spelling in notrace doc
This commit is contained in:
Samson 2023-08-04 12:17:43 +02:00 committed by GitHub
parent 66e0d543cf
commit 9514f670d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
167 changed files with 1903 additions and 1020 deletions

View file

@ -43,12 +43,14 @@ use js::jsval::{JSVal, NullValue, ObjectValue, UndefinedValue};
use js::rust::wrappers::{Construct1, JS_GetProperty, SameValue};
use js::rust::{HandleObject, HandleValue, MutableHandleValue};
use std::cell::Cell;
use std::collections::{HashMap, VecDeque};
use std::collections::VecDeque;
use std::mem;
use std::ops::Deref;
use std::ptr;
use std::rc::Rc;
use super::bindings::trace::HashMapTracedValues;
/// <https://dom.spec.whatwg.org/#concept-element-custom-element-state>
#[derive(Clone, Copy, Eq, JSTraceable, MallocSizeOf, PartialEq)]
pub enum CustomElementState {
@ -72,12 +74,12 @@ pub struct CustomElementRegistry {
window: Dom<Window>,
#[ignore_malloc_size_of = "Rc"]
when_defined: DomRefCell<HashMap<LocalName, Rc<Promise>>>,
when_defined: DomRefCell<HashMapTracedValues<LocalName, Rc<Promise>>>,
element_definition_is_running: Cell<bool>,
#[ignore_malloc_size_of = "Rc"]
definitions: DomRefCell<HashMap<LocalName, Rc<CustomElementDefinition>>>,
definitions: DomRefCell<HashMapTracedValues<LocalName, Rc<CustomElementDefinition>>>,
}
impl CustomElementRegistry {
@ -85,9 +87,9 @@ impl CustomElementRegistry {
CustomElementRegistry {
reflector_: Reflector::new(),
window: Dom::from_ref(window),
when_defined: DomRefCell::new(HashMap::new()),
when_defined: DomRefCell::new(HashMapTracedValues::new()),
element_definition_is_running: Cell::new(false),
definitions: DomRefCell::new(HashMap::new()),
definitions: DomRefCell::new(HashMapTracedValues::new()),
}
}
@ -101,7 +103,7 @@ impl CustomElementRegistry {
/// Cleans up any active promises
/// <https://github.com/servo/servo/issues/15318>
pub fn teardown(&self) {
self.when_defined.borrow_mut().clear()
self.when_defined.borrow_mut().0.clear()
}
/// <https://html.spec.whatwg.org/multipage/#look-up-a-custom-element-definition>
@ -112,6 +114,7 @@ impl CustomElementRegistry {
) -> Option<Rc<CustomElementDefinition>> {
self.definitions
.borrow()
.0
.values()
.find(|definition| {
// Step 4-5
@ -127,6 +130,7 @@ impl CustomElementRegistry {
) -> Option<Rc<CustomElementDefinition>> {
self.definitions
.borrow()
.0
.values()
.find(|definition| definition.constructor.callback() == constructor.get())
.cloned()
@ -497,8 +501,10 @@ pub enum ConstructionStackEntry {
/// <https://html.spec.whatwg.org/multipage/#custom-element-definition>
#[derive(Clone, JSTraceable, MallocSizeOf)]
pub struct CustomElementDefinition {
#[no_trace]
pub name: LocalName,
#[no_trace]
pub local_name: LocalName,
#[ignore_malloc_size_of = "Rc"]