Truly independent web browser
LibWeb: Keep structured serialization memory in Rust
Shannon Booth23150e5e7f67
diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/cpp.rs b/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/cpp.rsindex ac1d6c3a79e..2b2e4e2a878 100644--- a/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/cpp.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/cpp.rs@@ -17,6 +17,7 @@ use ak::Utf16String;use libjs_rust::api::{ArrayBuffer, ArrayBufferShared, Gc, Object, RawNativeFunctionResult, Realm, Value};use crate::bindings::{CallContext, Exception, WebIdlResult};+use crate::html::structured_serialize::memory::{DeserializationMemory, SerializationMemory};unsafe extern "C" {fn web_structured_serialize_writer_create_for_transfer() -> *mut c_void;@@ -139,18 +140,7 @@ unsafe extern "C" {message: ak::Span<'_, u8>,) -> RawNativeFunctionResult;- fn web_structured_serialize_memory_get(memory: *mut c_void, value: u64, index: &mut u32) -> bool;- fn web_structured_serialize_memory_set(memory: *mut c_void, value: u64, index: u32);- fn web_structured_serialize_memory_size(memory: *mut c_void) -> u32;- fn web_structured_serialize_memory_create() -> *mut c_void;- fn web_structured_serialize_memory_destroy(memory: *mut c_void);fn web_structured_serialize_serializable_payload_version() -> u64;- fn web_structured_deserialize_memory_size(memory: *mut c_void) -> usize;- fn web_structured_deserialize_memory_append(memory: *mut c_void, value: u64);- fn web_structured_deserialize_memory_get(memory: *mut c_void, index: usize) -> u64;- fn web_structured_deserialize_memory_set(memory: *mut c_void, index: usize, value: u64);- fn web_structured_deserialize_memory_create() -> *mut c_void;- fn web_structured_deserialize_memory_destroy(memory: *mut c_void);fn web_structured_serialize_current_settings_object_agent_cluster(agent_cluster: &mut u64) -> bool;fn web_structured_serialize_current_settings_object_cross_origin_isolated_capability() -> bool;@@ -678,65 +668,6 @@ pub(crate) fn data_clone_error_from_serialization_error(realm: Gc<Realm>, messag}}-/// The memory of a structured serialization: an HTML::SerializationMemory that C++ lends, which maps the values that-/// the serialization serialized to their positions.-#[derive(Clone, Copy)]-pub(crate) struct SerializationMemory(NonNull<c_void>);--impl SerializationMemory {- /// # Safety- ///- /// `memory` must be a memory that C++ lends while this is used.- pub(crate) unsafe fn from_raw(memory: *mut c_void) -> Self {- Self(NonNull::new(memory).expect("C++ lends a memory"))- }-- pub(crate) fn as_raw(self) -> *mut c_void {- self.0.as_ptr()- }-- pub(crate) fn get(self, value: Value) -> Option<u32> {- let mut index = 0;- // SAFETY: The memory is lent.- unsafe { web_structured_serialize_memory_get(self.as_raw(), value.to_raw(), &mut index) }.then_some(index)- }-- pub(crate) fn contains(self, value: Value) -> bool {- self.get(value).is_some()- }-- pub(crate) fn set(self, value: Value, index: u32) {- // SAFETY: The memory is lent, and it roots the value.- unsafe { web_structured_serialize_memory_set(self.as_raw(), value.to_raw(), index) };- }-- pub(crate) fn size(self) -> u32 {- // SAFETY: The memory is lent.- unsafe { web_structured_serialize_memory_size(self.as_raw()) }- }-}--/// A memory of a structured serialization that this owns.-pub(crate) struct OwnedSerializationMemory(SerializationMemory);--impl OwnedSerializationMemory {- pub(crate) fn new() -> Self {- // SAFETY: LibWeb returns a new memory, which this owns.- Self(unsafe { SerializationMemory::from_raw(web_structured_serialize_memory_create()) })- }-- pub(crate) fn memory(&self) -> SerializationMemory {- self.0- }-}--impl Drop for OwnedSerializationMemory {- fn drop(&mut self) {- // SAFETY: This owns the memory.- unsafe { web_structured_serialize_memory_destroy(self.0.as_raw()) };- }-}-/// HTML::serializable_payload_version: the per-interface payload version that a storage record holds after the/// interface name of every serializable object.pub(crate) fn serializable_payload_version() -> u64 {@@ -744,65 +675,6 @@ pub(crate) fn serializable_payload_version() -> u64 {unsafe { web_structured_serialize_serializable_payload_version() }}-/// The memory of a structured deserialization: an HTML::DeserializationMemory, which holds the values that the-/// deserialization created at their positions.-#[derive(Clone, Copy)]-pub(crate) struct DeserializationMemory(NonNull<c_void>);--impl DeserializationMemory {- /// # Safety- ///- /// `memory` must be a memory that C++ lends while this is used.- pub(crate) unsafe fn from_raw(memory: *mut c_void) -> Self {- Self(NonNull::new(memory).expect("C++ lends a memory"))- }-- pub(crate) fn as_raw(self) -> *mut c_void {- self.0.as_ptr()- }-- pub(crate) fn size(self) -> usize {- // SAFETY: The memory is lent.- unsafe { web_structured_deserialize_memory_size(self.as_raw()) }- }-- pub(crate) fn append(self, value: Value) {- // SAFETY: The memory is lent, and it roots the value.- unsafe { web_structured_deserialize_memory_append(self.as_raw(), value.to_raw()) };- }-- pub(crate) fn get(self, index: usize) -> Value {- // SAFETY: The memory is lent, and it holds live values.- unsafe { Value::from_raw(web_structured_deserialize_memory_get(self.as_raw(), index)) }- }-- pub(crate) fn set(self, index: usize, value: Value) {- // SAFETY: The memory is lent, and it roots the value.- unsafe { web_structured_deserialize_memory_set(self.as_raw(), index, value.to_raw()) };- }-}--/// A memory of a structured deserialization that this owns.-pub(crate) struct OwnedDeserializationMemory(DeserializationMemory);--impl OwnedDeserializationMemory {- pub(crate) fn new() -> Self {- // SAFETY: LibWeb returns a new memory, which this owns.- Self(unsafe { DeserializationMemory::from_raw(web_structured_deserialize_memory_create()) })- }-- pub(crate) fn memory(&self) -> DeserializationMemory {- self.0- }-}--impl Drop for OwnedDeserializationMemory {- fn drop(&mut self) {- // SAFETY: This owns the memory.- unsafe { web_structured_deserialize_memory_destroy(self.0.as_raw()) };- }-}-/// The agent cluster of the current settings object, if it has one.pub(crate) fn current_settings_object_agent_cluster() -> Option<u64> {let mut agent_cluster = 0;@@ -846,7 +718,7 @@ pub(crate) fn serialization_steps(object: Gc<Object>,serialized: StructuredSerializeWriter,for_storage: bool,- memory: SerializationMemory,+ memory: &SerializationMemory,) -> WebIdlResult<()> {// SAFETY: The realm and the object are live, and the writer and the memory are lent.completion(unsafe {@@ -855,7 +727,7 @@ pub(crate) fn serialization_steps(object_into_abi(object),serialized.as_raw(),for_storage,- memory.as_raw(),+ memory.as_abi(),)})?;Ok(())@@ -895,7 +767,7 @@ pub(crate) fn serializable_steps(interface_name: u16) -> SerializableSteps {pub(crate) fn deserialize_rust_platform_object(interface_name: u16,serialized: StructuredSerializeReader,- memory: DeserializationMemory,+ memory: &DeserializationMemory,) -> WebIdlResult<Value> {// SAFETY: The realm is live, and the reader and the memory are lent.completion(unsafe {@@ -903,7 +775,7 @@ pub(crate) fn deserialize_rust_platform_object(interface_name,serialized.realm_raw(),serialized.as_raw(),- memory.as_raw(),+ memory.as_abi(),)})}@@ -1063,13 +935,13 @@ impl SerializedTransferRecord {}/// StructuredDeserialize of the record's [[Serialized]], with its shared memory.- pub(crate) fn deserialize(self, realm: Gc<Realm>, memory: DeserializationMemory) -> WebIdlResult<Value> {+ pub(crate) fn deserialize(self, realm: Gc<Realm>, memory: &DeserializationMemory) -> WebIdlResult<Value> {// SAFETY: The record and the memory are lent, and the realm is live.completion(unsafe {web_structured_serialize_transfer_record_deserialize(self.0.as_ptr(),realm.as_ptr().cast(),- memory.as_raw(),+ memory.as_abi(),)})}diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/exports.rs b/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/exports.rsindex 330b3cec548..ff16d9fece3 100644--- a/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/exports.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/exports.rs@@ -15,9 +15,10 @@ use libjs_rust::api::{Gc, MarkedVec, Object, RawNativeFunctionResult, ThrowCompluse crate::bindings::interface::realm_arguments;use crate::bindings::{CallContext, WebIdlResult};use crate::html::structured_serialize::cpp::{- DeserializationMemory, SerializationMemory, SerializedTransferRecord, StructuredSerializeReader,- StructuredSerializeWriter, TransferDataDecoder, TransferredValues,+ SerializedTransferRecord, StructuredSerializeReader, StructuredSerializeWriter, TransferDataDecoder,+ TransferredValues,};+use crate::html::structured_serialize::memory::{DeserializationMemory, SerializationMemory};use crate::html::structured_serialize::{AllowSharedArrayBuffers, structured_deserialize_internal, structured_deserialize_with_transfer,structured_deserialize_with_transfer_internal, structured_serialize_internal, structured_serialize_with_transfer,@@ -33,7 +34,8 @@ fn completion(cx: &CallContext, result: WebIdlResult<Value>) -> RawNativeFunctio////// # Safety///-/// The pointers must be the VM, and a writer and a memory that C++ lends. The value must be live.+/// The pointers must be the VM, a writer that C++ lends, and the memory of the serialization that a serialization step+/// serializes a value of, or null for a new one. The value must be live.#[unsafe(no_mangle)]pub unsafe extern "C" fn web_rust_structured_serialize_internal(vm: *mut c_void,@@ -45,13 +47,15 @@ pub unsafe extern "C" fn web_rust_structured_serialize_internal() -> RawNativeFunctionResult {// SAFETY: The caller passes the VM.let vm = unsafe { &*vm.cast::<Vm>() };- // SAFETY: The caller lends the writer and the memory, and passes a live value.- let (serialized, memory, value) = unsafe {- (- StructuredSerializeWriter::from_raw(serialized),- SerializationMemory::from_raw(memory),- Value::from_raw(value),- )+ // SAFETY: The caller lends the writer, and passes a live value.+ let (serialized, value) = unsafe { (StructuredSerializeWriter::from_raw(serialized), Value::from_raw(value)) };+ let new_memory;+ let memory = if memory.is_null() {+ new_memory = SerializationMemory::new(vm);+ &new_memory+ } else {+ // SAFETY: The caller passes the memory of the serialization that it runs in.+ unsafe { SerializationMemory::from_abi(memory) }};// NB: Code outside of any script serializes values too, with no current realm. An object's exception is created in// its realm then; a Symbol throws too, but only script serializes one.@@ -81,7 +85,8 @@ pub unsafe extern "C" fn web_rust_structured_serialize_internal(////// # Safety///-/// The pointers must be the VM, a live realm, and a reader and a memory that C++ lends.+/// The pointers must be the VM, a live realm, a reader that C++ lends, and the memory of the deserialization that a+/// deserialization step deserializes a value of, or null for a new one.#[unsafe(no_mangle)]pub unsafe extern "C" fn web_rust_structured_deserialize_internal(vm: *mut c_void,@@ -93,12 +98,15 @@ pub unsafe extern "C" fn web_rust_structured_deserialize_internal(// SAFETY: The caller passes the VM and a live realm.let (vm, target_realm) = unsafe { realm_arguments(vm, target_realm) };let cx = CallContext::new(vm, target_realm);- // SAFETY: The caller lends the reader and the memory.- let (serialized, memory) = unsafe {- (- StructuredSerializeReader::from_raw(serialized, target_realm),- DeserializationMemory::from_raw(memory),- )+ // SAFETY: The caller lends the reader.+ let serialized = unsafe { StructuredSerializeReader::from_raw(serialized, target_realm) };+ let new_memory;+ let memory = if memory.is_null() {+ new_memory = DeserializationMemory::new(vm);+ &new_memory+ } else {+ // SAFETY: The caller passes the memory of the deserialization that it runs in.+ unsafe { DeserializationMemory::from_abi(memory) }};let result = structured_deserialize_internal(&cx, serialized, memory, check_fully_consumed);completion(&cx, result)diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/memory.rs b/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/memory.rsnew file mode 100644index 00000000000..8ebdabd3197--- /dev/null+++ b/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/memory.rs@@ -0,0 +1,102 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++//! The memories of structured serializations and deserializations, which C++ only passes on, as opaque pointers, to+//! the serializations of the values that the serialization steps of a platform object hold.++use core::cell::RefCell;+use core::ffi::c_void;+use std::collections::HashMap;++use libjs_rust::api::{MarkedVec, Value, Vm};++pub(crate) struct SerializationMemory<'vm> {+ values: MarkedVec<'vm, Value>,+ positions: RefCell<HashMap<u64, u32>>,+}++impl<'vm> SerializationMemory<'vm> {+ pub(crate) fn new(vm: &'vm Vm) -> Self {+ Self {+ values: MarkedVec::new(vm),+ positions: RefCell::new(HashMap::new()),+ }+ }++ /// The memory that C++ passes on.+ ///+ /// # Safety+ ///+ /// `memory` must be a memory that Rust lent to C++ for the call that passes it back.+ pub(crate) unsafe fn from_abi<'a>(memory: *mut c_void) -> &'a Self {+ // SAFETY: The caller passes a memory that outlives the call.+ unsafe { &*memory.cast::<Self>() }+ }++ pub(crate) fn as_abi(&self) -> *mut c_void {+ core::ptr::from_ref(self).cast_mut().cast()+ }++ pub(crate) fn get(&self, value: Value) -> Option<u32> {+ self.positions.borrow().get(&value.to_raw()).copied()+ }++ pub(crate) fn contains(&self, value: Value) -> bool {+ self.get(value).is_some()+ }++ pub(crate) fn set(&self, value: Value, index: u32) {+ if self.positions.borrow_mut().insert(value.to_raw(), index).is_none() {+ self.values.push(value);+ }+ }++ pub(crate) fn size(&self) -> u32 {+ u32::try_from(self.positions.borrow().len()).expect("a serialization has fewer than 2^32 values")+ }+}++pub(crate) struct DeserializationMemory<'vm> {+ values: MarkedVec<'vm, Value>,+}++impl<'vm> DeserializationMemory<'vm> {+ pub(crate) fn new(vm: &'vm Vm) -> Self {+ Self {+ values: MarkedVec::new(vm),+ }+ }++ /// The memory that C++ passes on.+ ///+ /// # Safety+ ///+ /// `memory` must be a memory that Rust lent to C++ for the call that passes it back.+ pub(crate) unsafe fn from_abi<'a>(memory: *mut c_void) -> &'a Self {+ // SAFETY: The caller passes a memory that outlives the call.+ unsafe { &*memory.cast::<Self>() }+ }++ pub(crate) fn as_abi(&self) -> *mut c_void {+ core::ptr::from_ref(self).cast_mut().cast()+ }++ pub(crate) fn size(&self) -> usize {+ self.values.len()+ }++ pub(crate) fn append(&self, value: Value) {+ self.values.push(value);+ }++ pub(crate) fn get(&self, index: usize) -> Value {+ self.values.get(index).expect("the memory has a value at the index")+ }++ pub(crate) fn set(&self, index: usize, value: Value) {+ self.values.set(index, value);+ }+}diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/mod.rs b/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/mod.rsindex 9ac91b52126..e011c7d0a38 100644--- a/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/mod.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/html/structured_serialize/mod.rs@@ -16,6 +16,7 @@pub(crate) mod cpp;pub(crate) mod exports;+pub(crate) mod memory;use ak::Utf16String;use libjs_rust::api::{@@ -30,15 +31,16 @@ use libjs_rust::api::{use crate::bindings::{CallContext, Exception, WebIdlResult};use crate::crypto::crypto_key;use crate::html::structured_serialize::cpp::{- DeserializationMemory, OwnedDeserializationMemory, OwnedSerializedTransferRecord, OwnedStructuredSerializeWriter,- SerializableSteps, SerializationMemory, SerializationType, SerializedTransferRecord, StructuredSerializeReader,- StructuredSerializeWriter, TransferDataDecoder, TransferDataHolder, create_transferred_platform_object,- current_settings_object_agent_cluster, current_settings_object_cross_origin_isolated_capability,- data_clone_error_from_serialization_error, deserialize_rust_platform_object, is_exposed, is_platform_object,- is_transferable, is_transferable_interface_exposed, realm_agent_cluster, serializable_interface_name,- serializable_payload_version, serializable_steps, serialization_steps, transfer_steps, transferable_is_detached,- transferable_primary_interface, transferable_set_detached,+ OwnedSerializedTransferRecord, OwnedStructuredSerializeWriter, SerializableSteps, SerializationType,+ SerializedTransferRecord, StructuredSerializeReader, StructuredSerializeWriter, TransferDataDecoder,+ TransferDataHolder, create_transferred_platform_object, current_settings_object_agent_cluster,+ current_settings_object_cross_origin_isolated_capability, data_clone_error_from_serialization_error,+ deserialize_rust_platform_object, is_exposed, is_platform_object, is_transferable,+ is_transferable_interface_exposed, realm_agent_cluster, serializable_interface_name, serializable_payload_version,+ serializable_steps, serialization_steps, transfer_steps, transferable_is_detached, transferable_primary_interface,+ transferable_set_detached,};+use crate::html::structured_serialize::memory::{DeserializationMemory, SerializationMemory};use crate::webidl::dom_exception::{self, DOMExceptionFields};use crate::webidl::quota_exceeded_error::{self, QuotaExceededErrorFields};@@ -419,7 +421,7 @@ fn serialize_viewed_array_buffer(data_holder: StructuredSerializeWriter,view: ViewType,for_storage: bool,- memory: SerializationMemory,+ memory: &SerializationMemory,allow_shared_array_buffers: AllowSharedArrayBuffers,) -> WebIdlResult<()> {// 15. Otherwise, if value has a [[ViewedArrayBuffer]] internal slot:@@ -505,17 +507,17 @@ fn serialize_viewed_array_buffer(// Serializing and deserializing are each two passes:// 1. Fill up the memory with all the values, but without translating references// 2. Translate all the references into the appropriate form-struct Serializer<'vm> {+struct Serializer<'a, 'vm, 'memory> {vm: &'vm Vm,// NB: The current realm, which a serialization outside of any script has none of.realm: Option<Gc<Realm>>,serialized: StructuredSerializeWriter,- memory: SerializationMemory, // JS value -> index+ memory: &'a SerializationMemory<'memory>, // JS value -> indexfor_storage: bool,allow_shared_array_buffers: AllowSharedArrayBuffers,}-impl Serializer<'_> {+impl Serializer<'_, '_, '_> {// https://html.spec.whatwg.org/multipage/structured-data.html#structuredserializeinternalfn serialize(&self, value: Value) -> WebIdlResult<()> {let vm = self.vm;@@ -908,13 +910,13 @@ impl Serializer<'_> {}}-struct Deserializer<'a, 'vm> {+struct Deserializer<'a, 'vm, 'memory> {cx: &'a CallContext<'vm>,serialized: StructuredSerializeReader,- memory: DeserializationMemory,+ memory: &'a DeserializationMemory<'memory>,}-impl Deserializer<'_, '_> {+impl Deserializer<'_, '_, '_> {// https://html.spec.whatwg.org/multipage/structured-data.html#structureddeserializefn deserialize(&self) -> WebIdlResult<Value> {self.deserialize_value(self.serialized.decode_u8()?)@@ -1496,7 +1498,7 @@ pub(crate) fn structured_serialize_with_transfer(let vm = cx.vm();// 1. Let memory be an empty map.- let memory = cpp::OwnedSerializationMemory::new();+ let memory = SerializationMemory::new(vm);// 2. For each transferable of transferList:for transferable in transfer_list {@@ -1516,12 +1518,12 @@ pub(crate) fn structured_serialize_with_transfer(let transferable_value = Value::from_object(*transferable);// 3. If memory[transferable] exists, then throw a "DataCloneError" DOMException.- if memory.memory().contains(transferable_value) {+ if memory.contains(transferable_value) {return Err(data_clone_error("Cannot transfer value twice"));}// 4. Set memory[transferable] to { [[Type]]: an uninitialized value, [[AgentCluster]]: null }.- memory.memory().set(transferable_value, memory.memory().size());+ memory.set(transferable_value, memory.size());}// 3. Let serialized be ? StructuredSerializeInternal(value, false, memory).@@ -1534,7 +1536,7 @@ pub(crate) fn structured_serialize_with_transfer(serialized.writer(),value,false,- memory.memory(),+ &memory,AllowSharedArrayBuffers::CrossOriginIsolatedOnly,)?;@@ -1648,7 +1650,7 @@ pub(crate) fn structured_deserialize_with_transfer<'vm>(let target_realm = cx.realm();// 1. Let memory be an empty map.- let memory = OwnedDeserializationMemory::new();+ let memory = DeserializationMemory::new(cx.vm());// FIXME: 2. If serializeWithTransferResult.[[AgentCluster]] is not null and targetRealm's corresponding agent cluster is not serializeWithTransferResult.[[AgentCluster]], then throw a "DataCloneError" DOMException.// FIXME: 3. For each interfaceName of serializeWithTransferResult.[[InterfaceNames]]:@@ -1667,14 +1669,14 @@ pub(crate) fn structured_deserialize_with_transfer<'vm>(let value = structured_deserialize_with_transfer_internal(cx, decoder.decoder())?;// 5. Set memory[transferDataHolder] to value.- memory.memory().append(value);+ memory.append(value);// 6. Append value to transferredValues.transferred_values.push(value.as_object());}// 6. Let deserialized be ? StructuredDeserialize(serializeWithTransferResult.[[Serialized]], targetRealm, memory).- let deserialized = serialize_with_transfer_result.deserialize(target_realm, memory.memory())?;+ let deserialized = serialize_with_transfer_result.deserialize(target_realm, &memory)?;// NB: The deserialized values hold their own references to the shared memory they use. The record can outlive its// delivery, as in a task that awaits garbage collection, so it must not keep that memory alive.@@ -1755,7 +1757,7 @@ pub(crate) fn structured_serialize_internal(serialized: StructuredSerializeWriter,value: Value,for_storage: bool,- memory: SerializationMemory,+ memory: &SerializationMemory,allow_shared_array_buffers: AllowSharedArrayBuffers,) -> WebIdlResult<()> {let serializer = Serializer {@@ -1772,7 +1774,7 @@ pub(crate) fn structured_serialize_internal(pub(crate) fn structured_deserialize_internal(cx: &CallContext,serialized: StructuredSerializeReader,- memory: DeserializationMemory,+ memory: &DeserializationMemory,check_fully_consumed: bool,) -> WebIdlResult<Value> {let deserializer = Deserializer { cx, serialized, memory };diff --git a/Libraries/LibWeb/Bindings/RustSerialization.h b/Libraries/LibWeb/Bindings/RustSerialization.hindex 4d439dfa1eb..d77f1a0748b 100644--- a/Libraries/LibWeb/Bindings/RustSerialization.h+++ b/Libraries/LibWeb/Bindings/RustSerialization.h@@ -32,7 +32,7 @@ struct RustSerializationWriter {GC::Ref<JS::Realm> realm;HTML::StructuredSerializeWriter& serialized;bool for_storage { false };- HTML::SerializationMemory& memory;+ HTML::SerializationMemory* memory { nullptr };};// The record of a structured deserialization, and its memory, in the realm that the deserialization creates its values@@ -40,7 +40,7 @@ struct RustSerializationWriter {struct RustSerializationReader {GC::Ref<JS::Realm> realm;HTML::StructuredSerializeReader& serialized;- HTML::DeserializationMemory& memory;+ HTML::DeserializationMemory* memory { nullptr };};// The data holder of a transferred object. What the steps throw is created in the realm of the transfer.diff --git a/Libraries/LibWeb/Fetch/FetchMethod.cpp b/Libraries/LibWeb/Fetch/FetchMethod.cppindex 3ec4bbc05ee..5c2deabca72 100644--- a/Libraries/LibWeb/Fetch/FetchMethod.cpp+++ b/Libraries/LibWeb/Fetch/FetchMethod.cpp@@ -59,7 +59,7 @@ static JS::Value deserialize_serialized_abort_reason(JS::Realm& realm, Infrastru// 3. If abortReason is non-null, then set deserializedError to StructuredDeserialize(abortReason, realm).// If that threw an exception or returned undefined, then set deserializedError to fallbackError.if (controller.serialized_abort_reason().has_value()) {- auto deserialized_error_or_exception = HTML::structured_deserialize(realm.vm(), controller.serialized_abort_reason().value(), realm, {});+ auto deserialized_error_or_exception = HTML::structured_deserialize(realm.vm(), controller.serialized_abort_reason().value(), realm);if (!deserialized_error_or_exception.is_exception() && !deserialized_error_or_exception.value().is_undefined())deserialized_error = deserialized_error_or_exception.value();}diff --git a/Libraries/LibWeb/HTML/BroadcastChannel.cpp b/Libraries/LibWeb/HTML/BroadcastChannel.cppindex 50a88310bd5..fa64bf01fc5 100644--- a/Libraries/LibWeb/HTML/BroadcastChannel.cpp+++ b/Libraries/LibWeb/HTML/BroadcastChannel.cpp@@ -253,7 +253,7 @@ void BroadcastChannel::deliver_message_locally(BroadcastChannelMessage const& me// 3. Let data be StructuredDeserialize(serialized, targetRealm).// If this throws an exception, catch it, fire an event named messageerror at destination, using MessageEvent, with its// origin initialized to sourceOrigin, and then abort these steps.- auto data_or_error = structured_deserialize(vm, message.serialized_message, target_realm, {}, &message.shared_buffers);+ auto data_or_error = structured_deserialize(vm, message.serialized_message, target_realm, &message.shared_buffers);if (data_or_error.is_exception()) {MessageEventInit event_init;auto event = MessageEvent::create(target_realm.global_object(), HTML::EventNames::messageerror, event_init, message.source_origin);diff --git a/Libraries/LibWeb/HTML/StructuredSerialize.cpp b/Libraries/LibWeb/HTML/StructuredSerialize.cppindex a50741eda4c..cf9a1643028 100644--- a/Libraries/LibWeb/HTML/StructuredSerialize.cpp+++ b/Libraries/LibWeb/HTML/StructuredSerialize.cpp@@ -1149,9 +1149,8 @@ WebIDL::ExceptionOr<IPCSerializationRecord> structured_serialize(JS::VM& vm, JS:WebIDL::ExceptionOr<IPCSerializationRecord> structured_serialize(JS::VM& vm, JS::Value value, AllowSharedArrayBuffers allow_shared_array_buffers){// 1. Return ? StructuredSerializeInternal(value, false).- SerializationMemory memory = {};auto serialized = StructuredSerializeWriter::create_ipc();- TRY(structured_serialize_internal(vm, serialized, value, false, memory, allow_shared_array_buffers));+ TRY(structured_serialize_internal(vm, serialized, value, false, nullptr, allow_shared_array_buffers));return serialized.take_ipc_record();}@@ -1162,10 +1161,9 @@ WebIDL::ExceptionOr<IPCSerializationRecord> structured_serialize(JS::VM& vm, JS:WebIDL::ExceptionOr<IPCSerializationRecord> structured_serialize(JS::VM& vm, JS::Value value, Vector<Core::AnonymousBuffer>& shared_buffers){// 1. Return ? StructuredSerializeInternal(value, false).- SerializationMemory memory = {};auto serialized = StructuredSerializeWriter::create_ipc();serialized.enable_shared_buffers();- TRY(structured_serialize_internal(vm, serialized, value, false, memory));+ TRY(structured_serialize_internal(vm, serialized, value, false));shared_buffers = serialized.take_shared_buffers();return serialized.take_ipc_record();}@@ -1174,9 +1172,8 @@ WebIDL::ExceptionOr<IPCSerializationRecord> structured_serialize(JS::VM& vm, JS:WebIDL::ExceptionOr<StorageSerializationRecord> structured_serialize_for_storage(JS::VM& vm, JS::Value value){// 1. Return ? StructuredSerializeInternal(value, true).- SerializationMemory memory = {};auto serialized = StructuredSerializeWriter::create_storage();- TRY(structured_serialize_internal(vm, serialized, value, true, memory));+ TRY(structured_serialize_internal(vm, serialized, value, true));return serialized.take_storage_record();}@@ -1189,40 +1186,34 @@ StorageSerializationRecord structured_serialize_undefined_or_null_for_storage(JS}// https://html.spec.whatwg.org/multipage/structured-data.html#structuredserializeinternal-WebIDL::ExceptionOr<void> structured_serialize_internal(JS::VM& vm, StructuredSerializeWriter& serialized, JS::Value value, bool for_storage, SerializationMemory& memory, AllowSharedArrayBuffers allow_shared_array_buffers)+WebIDL::ExceptionOr<void> structured_serialize_internal(JS::VM& vm, StructuredSerializeWriter& serialized, JS::Value value, bool for_storage, SerializationMemory* memory, AllowSharedArrayBuffers allow_shared_array_buffers){- TRY(JS::HostABI::completion_from_abi<JS::Value>(web_rust_structured_serialize_internal(JS::HostABI::vm_to_abi(vm), &serialized, JS::HostABI::value_to_abi(value), for_storage, &memory, to_underlying(allow_shared_array_buffers))));+ TRY(JS::HostABI::completion_from_abi<JS::Value>(web_rust_structured_serialize_internal(JS::HostABI::vm_to_abi(vm), &serialized, JS::HostABI::value_to_abi(value), for_storage, memory, to_underlying(allow_shared_array_buffers))));return {};}// https://html.spec.whatwg.org/multipage/structured-data.html#structureddeserialize-WebIDL::ExceptionOr<JS::Value> structured_deserialize(JS::VM& vm, IPCSerializationRecord const& serialized, JS::Realm& target_realm, Optional<DeserializationMemory> memory, Vector<Core::AnonymousBuffer> const* shared_buffers)+WebIDL::ExceptionOr<JS::Value> structured_deserialize(JS::VM& vm, IPCSerializationRecord const& serialized, JS::Realm& target_realm, Vector<Core::AnonymousBuffer> const* shared_buffers){TemporaryExecutionContext execution_context { target_realm };- if (!memory.has_value())- memory = DeserializationMemory {};-StructuredSerializeReader decoder { serialized };if (shared_buffers)decoder.set_shared_buffers(*shared_buffers);- return structured_deserialize_internal(vm, decoder, target_realm, *memory);+ return structured_deserialize_internal(vm, decoder, target_realm);}-WebIDL::ExceptionOr<JS::Value> structured_deserialize(JS::VM& vm, StorageSerializationRecord const& serialized, JS::Realm& target_realm, Optional<DeserializationMemory> memory)+WebIDL::ExceptionOr<JS::Value> structured_deserialize(JS::VM& vm, StorageSerializationRecord const& serialized, JS::Realm& target_realm){TemporaryExecutionContext execution_context { target_realm };- if (!memory.has_value())- memory = DeserializationMemory {};-StructuredSerializeReader decoder { serialized };- return structured_deserialize_internal(vm, decoder, target_realm, *memory, CheckFullyConsumed::Yes);+ return structured_deserialize_internal(vm, decoder, target_realm, nullptr, CheckFullyConsumed::Yes);}-WebIDL::ExceptionOr<JS::Value> structured_deserialize_internal(JS::VM& vm, StructuredSerializeReader& serialized, JS::Realm& target_realm, DeserializationMemory& memory, CheckFullyConsumed check_fully_consumed)+WebIDL::ExceptionOr<JS::Value> structured_deserialize_internal(JS::VM& vm, StructuredSerializeReader& serialized, JS::Realm& target_realm, DeserializationMemory* memory, CheckFullyConsumed check_fully_consumed){- return TRY(JS::HostABI::completion_from_abi<JS::Value>(web_rust_structured_deserialize_internal(JS::HostABI::vm_to_abi(vm), &target_realm, &serialized, &memory, check_fully_consumed == CheckFullyConsumed::Yes)));+ return TRY(JS::HostABI::completion_from_abi<JS::Value>(web_rust_structured_deserialize_internal(JS::HostABI::vm_to_abi(vm), &target_realm, &serialized, memory, check_fully_consumed == CheckFullyConsumed::Yes)));}TransferDataDecoder::TransferDataDecoder(IPCSerializationRecord const& record)diff --git a/Libraries/LibWeb/HTML/StructuredSerialize.h b/Libraries/LibWeb/HTML/StructuredSerialize.hindex ec5484a99ef..e1451b650ce 100644--- a/Libraries/LibWeb/HTML/StructuredSerialize.h+++ b/Libraries/LibWeb/HTML/StructuredSerialize.h@@ -14,7 +14,6 @@#include <AK/NonnullOwnPtr.h>#include <AK/Span.h>#include <AK/StringView.h>-#include <AK/TypeCasts.h>#include <AK/Vector.h>#include <LibCore/AnonymousBuffer.h>#include <LibCrypto/Forward.h>@@ -160,11 +159,11 @@ WEB_API WebIDL::ExceptionOr<IPCSerializationRecord> structured_serialize(JS::VM&WEB_API WebIDL::ExceptionOr<IPCSerializationRecord> structured_serialize(JS::VM&, JS::Value, Vector<Core::AnonymousBuffer>& shared_buffers);WEB_API WebIDL::ExceptionOr<StorageSerializationRecord> structured_serialize_for_storage(JS::VM&, JS::Value);WEB_API StorageSerializationRecord structured_serialize_undefined_or_null_for_storage(JS::Value);-WEB_API WebIDL::ExceptionOr<void> structured_serialize_internal(JS::VM&, StructuredSerializeWriter&, JS::Value, bool for_storage, SerializationMemory&, AllowSharedArrayBuffers = AllowSharedArrayBuffers::CrossOriginIsolatedOnly);+WEB_API WebIDL::ExceptionOr<void> structured_serialize_internal(JS::VM&, StructuredSerializeWriter&, JS::Value, bool for_storage, SerializationMemory* = nullptr, AllowSharedArrayBuffers = AllowSharedArrayBuffers::CrossOriginIsolatedOnly);-WEB_API WebIDL::ExceptionOr<JS::Value> structured_deserialize(JS::VM&, IPCSerializationRecord const&, JS::Realm&, Optional<DeserializationMemory> = {}, Vector<Core::AnonymousBuffer> const* shared_buffers = nullptr);-WebIDL::ExceptionOr<JS::Value> structured_deserialize(JS::VM&, StorageSerializationRecord const&, JS::Realm&, Optional<DeserializationMemory> = {});-WEB_API WebIDL::ExceptionOr<JS::Value> structured_deserialize_internal(JS::VM&, StructuredSerializeReader&, JS::Realm&, DeserializationMemory&, CheckFullyConsumed = CheckFullyConsumed::No);+WEB_API WebIDL::ExceptionOr<JS::Value> structured_deserialize(JS::VM&, IPCSerializationRecord const&, JS::Realm&, Vector<Core::AnonymousBuffer> const* shared_buffers = nullptr);+WebIDL::ExceptionOr<JS::Value> structured_deserialize(JS::VM&, StorageSerializationRecord const&, JS::Realm&);+WEB_API WebIDL::ExceptionOr<JS::Value> structured_deserialize_internal(JS::VM&, StructuredSerializeReader&, JS::Realm&, DeserializationMemory* = nullptr, CheckFullyConsumed = CheckFullyConsumed::No);WEB_API WebIDL::Exception data_clone_error_from_serialization_error(JS::Realm&, AK::Error const&);@@ -188,16 +187,6 @@ struct SerializableRegistryEntry {WEB_API ReadonlySpan<SerializableRegistryEntry> serializable_storage_registry();-template<typename T>-WebIDL::ExceptionOr<GC::Ref<T>> deserialize_nested_as(JS::VM& vm, StructuredSerializeReader& reader, JS::Realm& realm, DeserializationMemory& memory)-{- auto value = TRY(structured_deserialize_internal(vm, reader, realm, memory));- auto* object = value.is_object() ? as_if<T>(value.as_object()) : nullptr;- if (!object)- return data_clone_error_from_serialization_error(realm, AK::Error::from_string_literal("Nested serializable has an unexpected type"));- return GC::Ref<T> { *object };-}-template<typename T>WebIDL::ExceptionOr<void> encode_or_throw_data_clone_error(JS::Realm& realm, TransferDataEncoder& encoder, T const& value){@@ -241,7 +230,7 @@ struct SerializablePlatformObject {InterfaceName interface_name;GC::Ptr<JS::Realm> realm;- WebIDL::ExceptionOr<void> serialization_steps(HTML::StructuredSerializeWriter&, bool for_storage, HTML::SerializationMemory&) const;+ WebIDL::ExceptionOr<void> serialization_steps(HTML::StructuredSerializeWriter&, bool for_storage, HTML::SerializationMemory*) const;};// A platform object that is a transferable object, of an interface implemented in C++ or in Rust.@@ -266,6 +255,6 @@ WEB_API WebIDL::ExceptionOr<GC::Ref<JS::HostObject>> create_transferred_platform// The deserialization steps of an interface implemented in Rust create its object from what they read, rather than// fill in an object that was created before them.WEB_API bool serializable_interface_is_implemented_in_rust(InterfaceName);-WEB_API WebIDL::ExceptionOr<GC::Ref<JS::HostObject>> deserialize_rust_platform_object(InterfaceName, JS::Realm&, HTML::StructuredSerializeReader&, HTML::DeserializationMemory&);+WEB_API WebIDL::ExceptionOr<GC::Ref<JS::HostObject>> deserialize_rust_platform_object(InterfaceName, JS::Realm&, HTML::StructuredSerializeReader&, HTML::DeserializationMemory*);}diff --git a/Libraries/LibWeb/HTML/StructuredSerializeRustIntegration.cpp b/Libraries/LibWeb/HTML/StructuredSerializeRustIntegration.cppindex 14a8a7b3419..90142ce4f40 100644--- a/Libraries/LibWeb/HTML/StructuredSerializeRustIntegration.cpp+++ b/Libraries/LibWeb/HTML/StructuredSerializeRustIntegration.cpp@@ -26,6 +26,7 @@#include <LibWeb/Bindings/WritableStream.h>#include <LibWeb/HTML/ImageBitmap.h>#include <LibWeb/HTML/Scripting/Environments.h>+#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>#include <LibWeb/HTML/StructuredSerialize.h>#include <LibWeb/WebIDL/DOMException.h>@@ -91,18 +92,7 @@ JSCompletion web_structured_serialize_reader_array_buffer_from_shared_memory(StrJSObject* web_structured_serialize_reader_array_buffer_sharing_side_table_entry(StructuredSerializeReader*, void* realm, u32 side_table_index, size_t byte_length, bool preserve_growability);JSCompletion web_structured_serialize_data_clone_error_from_serialization_error(void* realm, ReadonlyBytes message);-bool web_structured_serialize_memory_get(SerializationMemory*, JSValue, u32* index);-void web_structured_serialize_memory_set(SerializationMemory*, JSValue, u32 index);-u32 web_structured_serialize_memory_size(SerializationMemory*);-SerializationMemory* web_structured_serialize_memory_create();-void web_structured_serialize_memory_destroy(SerializationMemory*);u64 web_structured_serialize_serializable_payload_version();-size_t web_structured_deserialize_memory_size(DeserializationMemory*);-void web_structured_deserialize_memory_append(DeserializationMemory*, JSValue);-JSValue web_structured_deserialize_memory_get(DeserializationMemory*, size_t index);-void web_structured_deserialize_memory_set(DeserializationMemory*, size_t index, JSValue);-DeserializationMemory* web_structured_deserialize_memory_create();-void web_structured_deserialize_memory_destroy(DeserializationMemory*);bool web_structured_serialize_current_settings_object_agent_cluster(u64* agent_cluster);bool web_structured_serialize_current_settings_object_cross_origin_isolated_capability();@@ -467,70 +457,11 @@ JSCompletion web_structured_serialize_data_clone_error_from_serialization_error(return Bindings::completion_to_abi(js_realm, WebIDL::ExceptionOr<JS::Value> { data_clone_error_from_serialization_error(js_realm, error) });}-bool web_structured_serialize_memory_get(SerializationMemory* memory, JSValue value, u32* index)-{- auto found = memory->get(JS::HostABI::value_from_abi(value));- if (!found.has_value())- return false;- *index = found.value();- return true;-}--void web_structured_serialize_memory_set(SerializationMemory* memory, JSValue value, u32 index)-{- memory->set(GC::make_root(JS::HostABI::value_from_abi(value)), index);-}--u32 web_structured_serialize_memory_size(SerializationMemory* memory)-{- return memory->size();-}--SerializationMemory* web_structured_serialize_memory_create()-{- return new SerializationMemory;-}--void web_structured_serialize_memory_destroy(SerializationMemory* memory)-{- delete memory;-}-u64 web_structured_serialize_serializable_payload_version(){return serializable_payload_version;}-size_t web_structured_deserialize_memory_size(DeserializationMemory* memory)-{- return memory->size();-}--void web_structured_deserialize_memory_append(DeserializationMemory* memory, JSValue value)-{- memory->append(JS::HostABI::value_from_abi(value));-}--JSValue web_structured_deserialize_memory_get(DeserializationMemory* memory, size_t index)-{- return JS::HostABI::value_to_abi((*memory)[index]);-}--void web_structured_deserialize_memory_set(DeserializationMemory* memory, size_t index, JSValue value)-{- (*memory)[index] = JS::HostABI::value_from_abi(value);-}--DeserializationMemory* web_structured_deserialize_memory_create()-{- return new DeserializationMemory;-}--void web_structured_deserialize_memory_destroy(DeserializationMemory* memory)-{- delete memory;-}-bool web_structured_serialize_current_settings_object_agent_cluster(u64* agent_cluster){auto id = current_settings_object().agent_cluster_id();@@ -572,7 +503,7 @@ JSCompletion web_structured_serialize_serialization_steps(void* realm, JSObject*{auto serializable = Bindings::serializable_from_object(*JS::HostABI::object_from_abi(object));VERIFY(serializable.has_value());- return void_completion_to_abi(realm_from_abi(realm), serializable->serialization_steps(*writer, for_storage, *memory));+ return void_completion_to_abi(realm_from_abi(realm), serializable->serialization_steps(*writer, for_storage, memory));}bool web_structured_serialize_is_exposed(u16 interface_name, void* realm)@@ -598,7 +529,7 @@ u8 web_structured_serialize_serializable_steps(u16 interface_name)JSCompletion web_structured_serialize_deserialize_rust_platform_object(u16 interface_name, void* realm, StructuredSerializeReader* reader, DeserializationMemory* memory){auto& js_realm = realm_from_abi(realm);- auto object = Bindings::deserialize_rust_platform_object(static_cast<Bindings::InterfaceName>(interface_name), js_realm, *reader, *memory);+ auto object = Bindings::deserialize_rust_platform_object(static_cast<Bindings::InterfaceName>(interface_name), js_realm, *reader, memory);if (object.is_exception())return Bindings::completion_to_abi(js_realm, WebIDL::ExceptionOr<JS::Value> { object.release_error() });return JS::HostABI::completion_to_abi(JS::ThrowCompletionOr<JS::Value> { object.release_value() });@@ -757,7 +688,10 @@ TransferDataDecoder* web_structured_serialize_transfer_record_take_data_holder(SJSCompletion web_structured_serialize_transfer_record_deserialize(SerializedTransferRecord* record, void* realm, DeserializationMemory* memory){auto& js_realm = realm_from_abi(realm);- auto deserialized = structured_deserialize(js_realm.vm(), record->serialized, js_realm, *memory, &record->shared_buffers);+ TemporaryExecutionContext execution_context { js_realm };+ StructuredSerializeReader reader { record->serialized };+ reader.set_shared_buffers(record->shared_buffers);+ auto deserialized = structured_deserialize_internal(js_realm.vm(), reader, js_realm, memory);if (deserialized.is_exception())return Bindings::completion_to_abi(js_realm, WebIDL::ExceptionOr<JS::Value> { deserialized.release_error() });return JS::HostABI::completion_to_abi(JS::ThrowCompletionOr<JS::Value> { deserialized.release_value() });diff --git a/Libraries/LibWeb/HTML/StructuredSerializeTypes.h b/Libraries/LibWeb/HTML/StructuredSerializeTypes.hindex 5f6b9568cdc..8b213d7931f 100644--- a/Libraries/LibWeb/HTML/StructuredSerializeTypes.h+++ b/Libraries/LibWeb/HTML/StructuredSerializeTypes.h@@ -8,9 +8,7 @@#include <AK/Array.h>#include <AK/ByteBuffer.h>-#include <AK/HashMap.h>#include <AK/Vector.h>-#include <LibGC/Root.h>#include <LibIPC/Forward.h>#include <LibJS/Forward.h>#include <LibWeb/Export.h>@@ -18,8 +16,10 @@namespace Web::HTML {-using DeserializationMemory = GC::RootVector<JS::Value>;-using SerializationMemory = HashMap<GC::Root<JS::Value>, u32>;+// The memories of a structured serialization and deserialization, which the Rust implementation keeps, and which C+++// only passes on to the serializations of the values that the serialization steps of a platform object hold.+struct SerializationMemory;+struct DeserializationMemory;enum class SerializationType : u8 {IPC,diff --git a/Meta/Generators/libweb_bindings/structured_serialize.py b/Meta/Generators/libweb_bindings/structured_serialize.pyindex df6efbaae88..1f624d1276e 100644--- a/Meta/Generators/libweb_bindings/structured_serialize.py+++ b/Meta/Generators/libweb_bindings/structured_serialize.py@@ -224,7 +224,7 @@ Optional<SerializablePlatformObject> serializable_from_object(JS::Object& object}}-WebIDL::ExceptionOr<void> SerializablePlatformObject::serialization_steps(HTML::StructuredSerializeWriter& serialized, bool for_storage, HTML::SerializationMemory& memory) const+WebIDL::ExceptionOr<void> SerializablePlatformObject::serialization_steps(HTML::StructuredSerializeWriter& serialized, bool for_storage, HTML::SerializationMemory* memory) const{[[maybe_unused]] RustSerializationWriter writer { .realm = *realm, .serialized = serialized, .for_storage = for_storage, .memory = memory };switch (interface_name) {@@ -258,7 +258,7 @@ bool serializable_interface_is_implemented_in_rust(InterfaceName interface_name)}}-WebIDL::ExceptionOr<GC::Ref<JS::HostObject>> deserialize_rust_platform_object(InterfaceName interface_name, JS::Realm& realm, HTML::StructuredSerializeReader& serialized, HTML::DeserializationMemory& memory)+WebIDL::ExceptionOr<GC::Ref<JS::HostObject>> deserialize_rust_platform_object(InterfaceName interface_name, JS::Realm& realm, HTML::StructuredSerializeReader& serialized, HTML::DeserializationMemory* memory){[[maybe_unused]] RustSerializationReader reader { .realm = realm, .serialized = serialized, .memory = memory };switch (interface_name) {diff --git a/Meta/Linters/check_libweb_realm_mentions.py b/Meta/Linters/check_libweb_realm_mentions.pyindex fa43b6c6a93..039f3a331e3 100755--- a/Meta/Linters/check_libweb_realm_mentions.py+++ b/Meta/Linters/check_libweb_realm_mentions.py@@ -52,7 +52,7 @@ ALLOWED_REALM_MENTIONS = {"FileAPI": (2, 9, "Blob glue still creates streams and buffers in selected realms"),"HTML": (65,- 194,+ 193,"HTML algorithms still contain structured serialization, including posted-message preparation, canvas, navigation transfer/reconstruction, worker/worklet, and event realm use, and cross-origin Window/Location property functions are created in the current realm; RemoteWindow mirrors Window's postMessage; ""the C++ glue of the Rust structured serialization reads records and creates platform objects in a given realm",),diff --git a/Tests/LibWeb/StructuredSerializeTestHelpers.h b/Tests/LibWeb/StructuredSerializeTestHelpers.hindex e34e91d0f45..5ae388990b8 100644--- a/Tests/LibWeb/StructuredSerializeTestHelpers.h+++ b/Tests/LibWeb/StructuredSerializeTestHelpers.h@@ -267,8 +267,7 @@ inline Web::WebIDL::ExceptionOr<JS::Value> storage_deserialize(Web::HTML::Storag{auto& realm = test_realm();Web::HTML::StructuredSerializeReader reader { record };- Web::HTML::DeserializationMemory memory;- return Web::HTML::structured_deserialize_internal(realm.vm(), reader, realm, memory, Web::HTML::CheckFullyConsumed::Yes);+ return Web::HTML::structured_deserialize_internal(realm.vm(), reader, realm, nullptr, Web::HTML::CheckFullyConsumed::Yes);}inline void append_little_endian_double(Vector<u8>& bytes, double value)@@ -457,8 +456,7 @@ inline Web::WebIDL::ExceptionOr<JS::Value> principal_storage_deserialize(Web::HTvm.push_execution_context(settings.realm_execution_context());Web::HTML::StructuredSerializeReader reader { record };- Web::HTML::DeserializationMemory memory;- auto result = Web::HTML::structured_deserialize_internal(vm, reader, realm, memory, Web::HTML::CheckFullyConsumed::Yes);+ auto result = Web::HTML::structured_deserialize_internal(vm, reader, realm, nullptr, Web::HTML::CheckFullyConsumed::Yes);while (vm.execution_context_stack().size() > depth)vm.pop_execution_context();diff --git a/Tests/LibWeb/TestStructuredSerializeSharedArrayBuffer.cpp b/Tests/LibWeb/TestStructuredSerializeSharedArrayBuffer.cppindex 821bfa498a6..0b0fe313a49 100644--- a/Tests/LibWeb/TestStructuredSerializeSharedArrayBuffer.cpp+++ b/Tests/LibWeb/TestStructuredSerializeSharedArrayBuffer.cpp@@ -243,8 +243,7 @@ TEST_CASE(storage_serialization_rejects_shared_array_buffers_even_when_same_agenauto source = make_shared_array_buffer(source_realm(), "not for storage"sv.bytes());auto writer = Web::HTML::StructuredSerializeWriter::create_storage();- Web::HTML::SerializationMemory memory;- auto result = Web::HTML::structured_serialize_internal(vm, writer, JS::Value { source.ptr() }, true, memory, Web::HTML::AllowSharedArrayBuffers::SameAgentAlways);+ auto result = Web::HTML::structured_serialize_internal(vm, writer, JS::Value { source.ptr() }, true, nullptr, Web::HTML::AllowSharedArrayBuffers::SameAgentAlways);EXPECT(result.is_error());}