Start marking functions that can transitively trigger a GC (#33144)

* Mark JS reflector wrappers as CanGc.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Propagate CanGc from reflect_dom_object_with_proto.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Mark DOM constructors as GC operations.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2024-08-22 07:42:36 -04:00 committed by GitHub
parent 9a1051c917
commit 60ef6bc461
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
140 changed files with 1336 additions and 304 deletions

View file

@ -2889,7 +2889,8 @@ class CGWrapMethod(CGAbstractMethod):
args = [Argument('SafeJSContext', 'cx'),
Argument('&GlobalScope', 'scope'),
Argument('Option<HandleObject>', 'given_proto'),
Argument(f"Box<{descriptor.concreteType}>", 'object')]
Argument(f"Box<{descriptor.concreteType}>", 'object'),
Argument('CanGc', '_can_gc')]
retval = f'DomRoot<{descriptor.concreteType}>'
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
pub=True, unsafe=True)
@ -3082,6 +3083,7 @@ impl DomObjectWrap for {name} {{
&GlobalScope,
Option<HandleObject>,
Box<Self>,
CanGc,
) -> Root<Dom<Self>> = Wrap;
}}
"""
@ -3105,6 +3107,7 @@ impl DomObjectIteratorWrap for {name} {{
&GlobalScope,
Option<HandleObject>,
Box<IterableIterator<Self>>,
CanGc,
) -> Root<Dom<IterableIterator<Self>>> = Wrap;
}}
"""
@ -6234,7 +6237,7 @@ if proto_result.is_err() {{
"""
name = self.constructor.identifier.name
nativeName = MakeNativeName(self.descriptor.binaryNameFor(name))
args = ["&global", "Some(desired_proto.handle())"]
args = ["&global", "Some(desired_proto.handle())", "CanGc::note()"]
constructorCall = CGMethodCall(args, nativeName, True,
self.descriptor, self.constructor)
return CGList([CGGeneric(preamble), constructorCall])