Fix invalid rooting for PropertyDescriptor (#34018)

* Clean up unnecessary uses of RootedGuard.

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

* Update mozjs.

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

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2024-10-28 15:03:24 -04:00 committed by GitHub
parent 884732dfb2
commit 1070f7ac12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 16 deletions

8
Cargo.lock generated
View file

@ -4093,7 +4093,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"windows-targets 0.48.5", "windows-targets 0.52.6",
] ]
[[package]] [[package]]
@ -4518,7 +4518,7 @@ dependencies = [
[[package]] [[package]]
name = "mozjs" name = "mozjs"
version = "0.14.1" version = "0.14.1"
source = "git+https://github.com/servo/mozjs#a02aaf1e11fd275f2f129d0c7ca80a9d07460036" source = "git+https://github.com/servo/mozjs#118aae2bcdb39617473b2cfe9fc680274ebbb9fc"
dependencies = [ dependencies = [
"bindgen", "bindgen",
"cc", "cc",
@ -4530,8 +4530,8 @@ dependencies = [
[[package]] [[package]]
name = "mozjs_sys" name = "mozjs_sys"
version = "0.128.3-0" version = "0.128.3-1"
source = "git+https://github.com/servo/mozjs#a02aaf1e11fd275f2f129d0c7ca80a9d07460036" source = "git+https://github.com/servo/mozjs#118aae2bcdb39617473b2cfe9fc680274ebbb9fc"
dependencies = [ dependencies = [
"bindgen", "bindgen",
"cc", "cc",

View file

@ -3205,7 +3205,7 @@ class CGCollectJSONAttributesMethod(CGAbstractMethod):
args = [Argument('*mut JSContext', 'cx'), args = [Argument('*mut JSContext', 'cx'),
Argument('RawHandleObject', 'obj'), Argument('RawHandleObject', 'obj'),
Argument('*mut libc::c_void', 'this'), Argument('*mut libc::c_void', 'this'),
Argument('&RootedGuard<*mut JSObject>', 'result')] Argument('HandleObject', 'result')]
CGAbstractMethod.__init__(self, descriptor, 'CollectJSONAttributes', CGAbstractMethod.__init__(self, descriptor, 'CollectJSONAttributes',
'bool', args, pub=True, unsafe=True) 'bool', args, pub=True, unsafe=True)
self.toJSONMethod = toJSONMethod self.toJSONMethod = toJSONMethod
@ -3232,7 +3232,7 @@ let global = incumbent_global.reflector().get_jsobject();\n"""
if !get_${name}(cx, obj, this, JSJitGetterCallArgs { _base: temp.handle_mut().into() }) { if !get_${name}(cx, obj, this, JSJitGetterCallArgs { _base: temp.handle_mut().into() }) {
return false; return false;
} }
if !JS_DefineProperty(cx, result.handle(), if !JS_DefineProperty(cx, result,
${nameAsArray}, ${nameAsArray},
temp.handle(), JSPROP_ENUMERATE as u32) { temp.handle(), JSPROP_ENUMERATE as u32) {
return false; return false;
@ -4118,7 +4118,7 @@ class CGDefaultToJSONMethod(CGSpecializedMethod):
parents = len(jsonDescriptors) - 1 parents = len(jsonDescriptors) - 1
form = """ form = """
if !${parentclass}CollectJSONAttributes(cx, _obj, this, &result) { if !${parentclass}CollectJSONAttributes(cx, _obj, this, result.handle()) {
return false; return false;
} }
""" """
@ -6250,13 +6250,13 @@ let global = GlobalScope::from_object(JS_CALLEE(*cx, vp).to_object());
if len(self.exposureSet) == 1: if len(self.exposureSet) == 1:
args = [ args = [
f"global.downcast::<dom::types::{list(self.exposureSet)[0]}>().unwrap()", f"global.downcast::<dom::types::{list(self.exposureSet)[0]}>().unwrap()",
"Some(desired_proto.handle())", "Some(desired_proto)",
"CanGc::note()" "CanGc::note()"
] ]
else: else:
args = [ args = [
"global", "global",
"Some(desired_proto.handle())", "Some(desired_proto)",
"CanGc::note()" "CanGc::note()"
] ]
@ -6265,11 +6265,11 @@ let global = GlobalScope::from_object(JS_CALLEE(*cx, vp).to_object());
call_default_constructor( call_default_constructor(
cx, cx,
&args, &args,
global, &global,
PrototypeList::ID::{MakeNativeName(self.descriptor.name)}, PrototypeList::ID::{MakeNativeName(self.descriptor.name)},
\"{ctorName}\", \"{ctorName}\",
CreateInterfaceObjects, CreateInterfaceObjects,
|cx, args, global, desired_proto| {{ |cx: SafeJSContext, args: &CallArgs, global: &GlobalScope, desired_proto: HandleObject| {{
{constructor.define()} {constructor.define()}
}} }}
) )

View file

@ -7,7 +7,6 @@ use std::ptr;
use html5ever::interface::QualName; use html5ever::interface::QualName;
use html5ever::{local_name, namespace_url, ns, LocalName}; use html5ever::{local_name, namespace_url, ns, LocalName};
use js::conversions::ToJSValConvertible; use js::conversions::ToJSValConvertible;
use js::gc::RootedGuard;
use js::glue::{UnwrapObjectDynamic, UnwrapObjectStatic}; use js::glue::{UnwrapObjectDynamic, UnwrapObjectStatic};
use js::jsapi::{CallArgs, CurrentGlobalOrNull, JSAutoRealm, JSObject}; use js::jsapi::{CallArgs, CurrentGlobalOrNull, JSAutoRealm, JSObject};
use js::rust::wrappers::{JS_SetPrototype, JS_WrapObject}; use js::rust::wrappers::{JS_SetPrototype, JS_WrapObject};
@ -406,11 +405,11 @@ pub unsafe fn call_html_constructor<T: DerivedFrom<Element> + DomObject>(
pub unsafe fn call_default_constructor( pub unsafe fn call_default_constructor(
cx: JSContext, cx: JSContext,
args: &CallArgs, args: &CallArgs,
global: DomRoot<GlobalScope>, global: &GlobalScope,
proto_id: PrototypeList::ID, proto_id: PrototypeList::ID,
ctor_name: &str, ctor_name: &str,
creator: unsafe fn(JSContext, HandleObject, *mut ProtoOrIfaceArray), creator: unsafe fn(JSContext, HandleObject, *mut ProtoOrIfaceArray),
constructor: impl FnOnce(JSContext, &CallArgs, &GlobalScope, RootedGuard<*mut JSObject>) -> bool, constructor: impl FnOnce(JSContext, &CallArgs, &GlobalScope, HandleObject) -> bool,
) -> bool { ) -> bool {
if !args.is_constructing() { if !args.is_constructing() {
throw_constructor_without_new(*cx, ctor_name); throw_constructor_without_new(*cx, ctor_name);
@ -423,5 +422,5 @@ pub unsafe fn call_default_constructor(
return false; return false;
} }
constructor(cx, args, &global, desired_proto) constructor(cx, args, global, desired_proto.handle())
} }

View file

@ -83,7 +83,7 @@ pub mod module {
}; };
pub use js::rust::{ pub use js::rust::{
get_context_realm, get_object_class, get_object_realm, CustomAutoRooterGuard, GCMethods, get_context_realm, get_object_class, get_object_realm, CustomAutoRooterGuard, GCMethods,
Handle, MutableHandle, RootedGuard, Handle, MutableHandle,
}; };
pub use js::typedarray::{ pub use js::typedarray::{
ArrayBuffer, ArrayBufferView, Float32Array, Float64Array, Uint8Array, Uint8ClampedArray, ArrayBuffer, ArrayBufferView, Float32Array, Float64Array, Uint8Array, Uint8ClampedArray,