Stop using RootedGuard's DerefMut impl (#36158)

* Stop using RootedGuard's DerefMut impl

Signed-off-by: Greg Morenz <greg-morenz@droid.cafe>

* Update mozjs version

Signed-off-by: Greg Morenz <greg-morenz@droid.cafe>

* `self.bytes` should not be mutably borrowed over GC pause

Signed-off-by: Greg Morenz <greg-morenz@droid.cafe>

---------

Signed-off-by: Greg Morenz <greg-morenz@droid.cafe>
This commit is contained in:
Greg Morenz 2025-03-28 08:39:42 -04:00 committed by GitHub
parent 96277c5688
commit c728f31a10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 19 deletions

22
Cargo.lock generated
View file

@ -520,7 +520,7 @@ dependencies = [
"bitflags 2.9.0",
"cexpr",
"clang-sys",
"itertools 0.13.0",
"itertools 0.10.5",
"proc-macro2",
"quote",
"regex",
@ -1065,7 +1065,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c"
dependencies = [
"lazy_static",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@ -2031,7 +2031,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
dependencies = [
"libc",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@ -2557,7 +2557,7 @@ dependencies = [
"gobject-sys",
"libc",
"system-deps",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@ -4018,7 +4018,7 @@ checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9"
dependencies = [
"hermit-abi 0.5.0",
"libc",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@ -4312,7 +4312,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
dependencies = [
"cfg-if",
"windows-targets 0.48.5",
"windows-targets 0.52.6",
]
[[package]]
@ -4703,7 +4703,7 @@ dependencies = [
[[package]]
name = "mozjs"
version = "0.14.1"
source = "git+https://github.com/servo/mozjs#39db84352d79ffa3e4fe756c8034af9def788f22"
source = "git+https://github.com/servo/mozjs#e4d4f9ac06162fe2647078dc4be8c270b7219807"
dependencies = [
"bindgen 0.71.1",
"cc",
@ -4715,7 +4715,7 @@ dependencies = [
[[package]]
name = "mozjs_sys"
version = "0.128.9-0"
source = "git+https://github.com/servo/mozjs#39db84352d79ffa3e4fe756c8034af9def788f22"
source = "git+https://github.com/servo/mozjs#e4d4f9ac06162fe2647078dc4be8c270b7219807"
dependencies = [
"bindgen 0.71.1",
"cc",
@ -6190,7 +6190,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@ -7530,7 +7530,7 @@ dependencies = [
"getrandom",
"once_cell",
"rustix",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@ -8839,7 +8839,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]

View file

@ -641,7 +641,7 @@ pub(crate) fn get_desired_proto(
// We might still have a cross-compartment wrapper for a known DOM
// constructor. CheckedUnwrapStatic is fine here, because we're looking for
// DOM constructors and those can't be cross-origin objects.
*new_target = CheckedUnwrapStatic(*new_target);
new_target.set(CheckedUnwrapStatic(*new_target));
if !new_target.is_null() && *new_target != *original_new_target {
get_proto_id_for_new_target(new_target.handle())
} else {

View file

@ -8,6 +8,7 @@ use std::mem;
use std::rc::Rc;
use dom_struct::dom_struct;
use js::gc::MutableHandle;
use js::jsapi::Heap;
use js::jsval::{JSVal, UndefinedValue};
use js::rust::{HandleObject as SafeHandleObject, HandleValue as SafeHandleValue};
@ -97,13 +98,13 @@ impl Callback for ReadLoopFulFillmentHandler {
};
// Append the bytes represented by chunk to bytes.
let mut bytes = self.bytes.borrow_mut();
bytes.extend_from_slice(&chunk);
self.bytes.borrow_mut().extend_from_slice(&chunk);
// Read-loop given reader, bytes, successSteps, and failureSteps.
rooted!(in(*cx) let mut this = Some(self.clone()));
read_loop(
&global,
&mut Some(self.clone()),
this.handle_mut(),
Box::new(ReadLoopRejectionHandler {
failure_steps: self.failure_steps.clone(),
}),
@ -133,7 +134,7 @@ impl Callback for ReadLoopRejectionHandler {
/// <https://streams.spec.whatwg.org/#read-loop>
fn read_loop(
global: &GlobalScope,
fulfillment_handler: &mut Option<ReadLoopFulFillmentHandler>,
mut fulfillment_handler: MutableHandle<Option<ReadLoopFulFillmentHandler>>,
rejection_handler: Box<ReadLoopRejectionHandler>,
realm: InRealm,
can_gc: CanGc,
@ -500,7 +501,7 @@ impl ReadableStreamDefaultReader {
let rejection_handler = Box::new(ReadLoopRejectionHandler { failure_steps });
read_loop(
global,
&mut fulfillment_handler,
fulfillment_handler.handle_mut(),
rejection_handler,
realm,
can_gc,

View file

@ -3107,12 +3107,12 @@ SetProxyReservedSlot(
create = """
rooted!(in(*cx) let mut proto = ptr::null_mut::<JSObject>());
if let Some(given) = given_proto {
*proto = *given;
proto.set(*given);
if get_context_realm(*cx) != get_object_realm(*given) {
assert!(JS_WrapObject(*cx, proto.handle_mut()));
}
} else {
*proto = *canonical_proto;
proto.set(*canonical_proto);
}
rooted!(in(*cx) let obj = JS_NewObjectWithGivenProto(
*cx,