Skip to content

Truly independent web browser

LibJS+LibWeb: Build cells under a deferral of collections

Shannon Booth580e45deb517
diff --git a/Libraries/LibJS/Rust/src/api.rs b/Libraries/LibJS/Rust/src/api.rs
index 07628ad68ee..f3707bac0a9 100644
--- a/Libraries/LibJS/Rust/src/api.rs
+++ b/Libraries/LibJS/Rust/src/api.rs
@@ -11,6 +11,7 @@
pub use crate::embedding::host::host_object::{HostObject, host_class_of, host_data_of, is_host_instance_of};
pub use crate::gc::class::ExternalMemorySize;
+pub use crate::gc::defer_gc::DeferGc;
pub use crate::gc::embedder_cell::{EmbedderCell, EmbedderClass, EmbedderValue};
pub use crate::gc::foreign::ForeignCellSlot;
pub use crate::gc::gc_ref_cell::{GcRefCell, GcRefMut};
diff --git a/Libraries/LibJS/Rust/src/bytecode/executable.rs b/Libraries/LibJS/Rust/src/bytecode/executable.rs
index faabda4ad66..5eaaf4beeec 100644
--- a/Libraries/LibJS/Rust/src/bytecode/executable.rs
+++ b/Libraries/LibJS/Rust/src/bytecode/executable.rs
@@ -25,8 +25,8 @@ use crate::bytecode::generator::{LocalVariable, PendingClassBlueprint};
use crate::bytecode_cache::{DecodedBytecodeBytes, DecodedExecutableRecord};
use crate::gc::class::{Finalize, GcCell, define_cell};
use crate::gc::defer_gc::DeferGc;
-use crate::gc::sweep::Sweep;
use crate::gc::root::MarkedVec;
+use crate::gc::sweep::Sweep;
use crate::gc::visitor::{Trace, Visitor};
use crate::interpreter::vm::Vm;
use crate::jit::InterpreterTier;
@@ -134,7 +134,9 @@ impl PropertyLookupCacheEntryData {
|| self.from_shape.is_some_and(|shape| sweep.is_dead(shape))
|| self.shape.is_some_and(|shape| sweep.is_dead(shape))
|| self.prototype.is_some_and(|prototype| sweep.is_dead(prototype))
- || self.prototype_chain_validity.is_some_and(|validity| sweep.is_dead(validity))
+ || self
+ .prototype_chain_validity
+ .is_some_and(|validity| sweep.is_dead(validity))
}
}
@@ -1004,7 +1006,9 @@ impl KeyedPropertyLookupCache {
// NB: Entries of the keyed property store cache for puts it does not make have a shape but no type.
if lookup.shape.is_some_and(|shape| sweep.is_dead(shape))
|| lookup.prototype.is_some_and(|prototype| sweep.is_dead(prototype))
- || lookup.prototype_chain_validity.is_some_and(|validity| sweep.is_dead(validity))
+ || lookup
+ .prototype_chain_validity
+ .is_some_and(|validity| sweep.is_dead(validity))
|| lookup.new_shape.is_some_and(|shape| sweep.is_dead(shape))
{
*entry = KeyedPropertyLookupCacheEntry::default();
@@ -1032,7 +1036,7 @@ define_cell!(TemplateObjectCache, Other);
impl TemplateObjectCache {
pub fn create(vm: &Vm) -> Gc<TemplateObjectCache> {
- vm.heap().allocate(TemplateObjectCache {
+ vm.heap().allocate(|_| TemplateObjectCache {
header: CellHeader::for_class(Self::CLASS),
cached_template_object: Cell::new(None),
})
@@ -1100,7 +1104,7 @@ impl ObjectPropertyIteratorCacheData {
} else {
(false, 0)
};
- let cache_data = vm.heap().allocate(Self {
+ let cache_data = vm.heap().allocate(|_| Self {
header: CellHeader::for_class(Self::CLASS),
shape_is_dictionary: Cell::new(shape_is_dictionary),
fast_path: Cell::new(fast_path),
@@ -1137,7 +1141,7 @@ impl ObjectPropertyIteratorCacheData {
pub fn create(vm: &Vm, properties: &MarkedVec<'_, PropertyKey>) -> Gc<ObjectPropertyIteratorCacheData> {
// The slow path keeps only the key list. Values are converted lazily during enumeration,
// because deleted keys have to be filtered with has_property() at each step anyway.
- vm.heap().allocate(Self {
+ vm.heap().allocate(|_| Self {
header: CellHeader::for_class(Self::CLASS),
shape_is_dictionary: Cell::new(false),
fast_path: Cell::new(ObjectPropertyIteratorFastPath::None),
@@ -1582,7 +1586,7 @@ impl Executable {
source_code: Option<&Rc<SourceCode>>,
replaced_executable: Option<Gc<Executable>>,
) -> Gc<Executable> {
- let executable = vm.heap().allocate_deferring_gc(|defer_gc| {
+ let executable = vm.heap().allocate(|defer_gc| {
Self::build(
vm,
parts,
diff --git a/Libraries/LibJS/Rust/src/console.rs b/Libraries/LibJS/Rust/src/console.rs
index c1b829a443f..3de1437c48c 100644
--- a/Libraries/LibJS/Rust/src/console.rs
+++ b/Libraries/LibJS/Rust/src/console.rs
@@ -94,7 +94,7 @@ fn message_with_label(vm: &Vm, before: &str, label: &Utf16String, after: &str) -
impl Console {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<Console> {
- vm.heap().allocate(Console {
+ vm.heap().allocate(|_| Console {
header: CellHeader::for_class(Self::CLASS),
realm,
client: Cell::new(None),
diff --git a/Libraries/LibJS/Rust/src/contrib/test262/262_object.rs b/Libraries/LibJS/Rust/src/contrib/test262/262_object.rs
index 19649701ae7..b7c1734678b 100644
--- a/Libraries/LibJS/Rust/src/contrib/test262/262_object.rs
+++ b/Libraries/LibJS/Rust/src/contrib/test262/262_object.rs
@@ -49,14 +49,11 @@ fn key(name: &str) -> PropertyKey {
impl Dollar262Object {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<Dollar262Object> {
- realm.create_object(
- vm,
- Dollar262Object {
- base: Object::new_without_prototype(vm, Self::CLASS, realm, MayInterfereWithIndexedPropertyAccess::No),
- agent: Cell::new(None),
- is_htmldda: Cell::new(None),
- },
- )
+ realm.create_object(vm, |_| Dollar262Object {
+ base: Object::new_without_prototype(vm, Self::CLASS, realm, MayInterfereWithIndexedPropertyAccess::No),
+ agent: Cell::new(None),
+ is_htmldda: Cell::new(None),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/contrib/test262/agent_object.rs b/Libraries/LibJS/Rust/src/contrib/test262/agent_object.rs
index 394954d2dca..b7e29006089 100644
--- a/Libraries/LibJS/Rust/src/contrib/test262/agent_object.rs
+++ b/Libraries/LibJS/Rust/src/contrib/test262/agent_object.rs
@@ -46,12 +46,9 @@ define_object_class!(AgentObject, extends: [Object], methods: {
impl AgentObject {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<AgentObject> {
- realm.create_object(
- vm,
- AgentObject {
- base: Object::new_without_prototype(vm, Self::CLASS, realm, MayInterfereWithIndexedPropertyAccess::No),
- },
- )
+ realm.create_object(vm, |_| AgentObject {
+ base: Object::new_without_prototype(vm, Self::CLASS, realm, MayInterfereWithIndexedPropertyAccess::No),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/contrib/test262/global_object.rs b/Libraries/LibJS/Rust/src/contrib/test262/global_object.rs
index ebc8080f208..17f5a3b4df5 100644
--- a/Libraries/LibJS/Rust/src/contrib/test262/global_object.rs
+++ b/Libraries/LibJS/Rust/src/contrib/test262/global_object.rs
@@ -42,13 +42,10 @@ impl Test262GlobalObject {
/// Allocates the global object of `realm`, whose initialize() InitializeHostDefinedRealm runs once the realm has
/// its global environment.
pub fn allocate(vm: &Vm, realm: Gc<Realm>) -> Gc<Test262GlobalObject> {
- allocate_object(
- vm,
- Test262GlobalObject {
- base: GlobalObject::new(vm, Self::CLASS, realm),
- dollar_262: Cell::new(None),
- },
- )
+ allocate_object(vm, |_| Test262GlobalObject {
+ base: GlobalObject::new(vm, Self::CLASS, realm),
+ dollar_262: Cell::new(None),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/contrib/test262/is_htmldda.rs b/Libraries/LibJS/Rust/src/contrib/test262/is_htmldda.rs
index 515aae5a909..69134fa0c92 100644
--- a/Libraries/LibJS/Rust/src/contrib/test262/is_htmldda.rs
+++ b/Libraries/LibJS/Rust/src/contrib/test262/is_htmldda.rs
@@ -63,7 +63,7 @@ impl IsHTMLDDA {
realm.function_prototype(),
);
base.set_is_htmldda(vm);
- realm.create_object(vm, IsHTMLDDA { base })
+ realm.create_object(vm, |_| IsHTMLDDA { base })
}
#[allow(clippy::unnecessary_wraps, reason = "NativeFunction::call returns a completion")]
diff --git a/Libraries/LibJS/Rust/src/embedding/error.rs b/Libraries/LibJS/Rust/src/embedding/error.rs
index 9b0a60bd91a..f62c8022fd6 100644
--- a/Libraries/LibJS/Rust/src/embedding/error.rs
+++ b/Libraries/LibJS/Rust/src/embedding/error.rs
@@ -122,7 +122,7 @@ pub unsafe extern "C" fn js_error_create_with_prototype(
let vm = unsafe { vm_from_abi(vm) };
// SAFETY: The caller passes a realm and an object of the VM.
let (realm, prototype) = unsafe { (cell_from_abi(realm), cell_from_abi(prototype)) };
- let error = realm.create_object(vm, Error::new(vm, Error::CLASS, prototype));
+ let error = realm.create_object(vm, |_| Error::new(vm, Error::CLASS, prototype));
cell_into_abi(error.upcast())
}
diff --git a/Libraries/LibJS/Rust/src/embedding/host/console_client.rs b/Libraries/LibJS/Rust/src/embedding/host/console_client.rs
index a5ef0c4c2dd..cae4284cba1 100644
--- a/Libraries/LibJS/Rust/src/embedding/host/console_client.rs
+++ b/Libraries/LibJS/Rust/src/embedding/host/console_client.rs
@@ -284,7 +284,7 @@ pub unsafe extern "C" fn js_console_client_create(
let console = unsafe { Gc::from_non_null(console) };
// SAFETY: The caller guarantees that the table outlives every client created with it.
let host_methods = unsafe { methods.as_ref() }.expect("a console client has methods");
- let client = vm.heap().allocate(HostConsoleClient {
+ let client = vm.heap().allocate(|_| HostConsoleClient {
base: ConsoleClient::new(HostConsoleClient::CLASS, &HOST_CONSOLE_CLIENT_METHODS, console),
host_methods,
context: ForeignCellSlot::empty(),
diff --git a/Libraries/LibJS/Rust/src/embedding/host/host_array.rs b/Libraries/LibJS/Rust/src/embedding/host/host_array.rs
index ab2d2becab8..5987261efcd 100644
--- a/Libraries/LibJS/Rust/src/embedding/host/host_array.rs
+++ b/Libraries/LibJS/Rust/src/embedding/host/host_array.rs
@@ -161,7 +161,7 @@ impl HostArray {
};
// SAFETY: The caller passes an absent or live cell, which the slot then keeps alive.
unsafe { array.host_data.set(host_data) };
- let array = allocate_object_in(vm, allocator, array);
+ let array = allocate_object_in(vm, allocator, |_| array);
array.initialize(vm, realm);
array
}
diff --git a/Libraries/LibJS/Rust/src/embedding/host/host_function.rs b/Libraries/LibJS/Rust/src/embedding/host/host_function.rs
index 7a79c0e22da..686e8eba174 100644
--- a/Libraries/LibJS/Rust/src/embedding/host/host_function.rs
+++ b/Libraries/LibJS/Rust/src/embedding/host/host_function.rs
@@ -193,7 +193,7 @@ impl HostFunction {
};
// SAFETY: The caller passes an absent or live cell, which the slot then keeps alive.
unsafe { function.host_data.set(host_data) };
- let function = allocate_object_in(vm, allocator, function);
+ let function = allocate_object_in(vm, allocator, |_| function);
function.initialize(vm, realm);
function
}
diff --git a/Libraries/LibJS/Rust/src/embedding/host/host_module.rs b/Libraries/LibJS/Rust/src/embedding/host/host_module.rs
index c632c5b25c8..7b917e82c94 100644
--- a/Libraries/LibJS/Rust/src/embedding/host/host_module.rs
+++ b/Libraries/LibJS/Rust/src/embedding/host/host_module.rs
@@ -165,14 +165,11 @@ impl HostModule {
) -> Gc<HostModule> {
let (class, allocator) = runtime_class_and_allocator_of_host_class(vm, host_class, JS_HOST_CLASS_MODULE);
module_hooks_of(host_class);
- vm.heap().allocate_in(
- allocator,
- HostModule {
- base: CyclicModule::new(class, realm, filename, false, requested_modules, host_defined),
- host_class,
- host_data,
- },
- )
+ vm.heap().allocate_in(allocator, |_| HostModule {
+ base: CyclicModule::new(class, realm, filename, false, requested_modules, host_defined),
+ host_class,
+ host_data,
+ })
}
pub fn host_class(&self) -> &'static JSHostClass {
diff --git a/Libraries/LibJS/Rust/src/embedding/host/host_object.rs b/Libraries/LibJS/Rust/src/embedding/host/host_object.rs
index b035d7198a5..ec58f9a952c 100644
--- a/Libraries/LibJS/Rust/src/embedding/host/host_object.rs
+++ b/Libraries/LibJS/Rust/src/embedding/host/host_object.rs
@@ -452,7 +452,7 @@ impl HostObject {
host_object.wrappable.set(wrappable);
host_object.host_data.set(host_data);
}
- let host_object = allocate_object_in(vm, allocator, host_object);
+ let host_object = allocate_object_in(vm, allocator, |_| host_object);
host_object.initialize(vm, realm);
host_object
}
diff --git a/Libraries/LibJS/Rust/src/gc/embedder_cell.rs b/Libraries/LibJS/Rust/src/gc/embedder_cell.rs
index 4dca984def9..bf777880dbf 100644
--- a/Libraries/LibJS/Rust/src/gc/embedder_cell.rs
+++ b/Libraries/LibJS/Rust/src/gc/embedder_cell.rs
@@ -19,6 +19,7 @@ use core::ptr::NonNull;
use super::class::{Class, ExternalMemorySize, GcCell, MIN_CELL_SIZE, class_of};
use super::class_id::ClassId;
+use super::defer_gc::DeferGc;
use super::visitor::{Trace, Visitor};
use crate::interpreter::vm::Vm;
use crate::layout::cell::{CellHeader, CellKind, Gc};
@@ -141,19 +142,15 @@ unsafe impl<T: EmbedderValue> GcCell for EmbedderCell<T> {
}
impl<T: EmbedderValue> EmbedderClass<T> {
- /// Moves `value` into a new cell of the class, from the allocator of the class, which the first allocation for
- /// the class creates.
- pub fn allocate(&'static self, vm: &Vm, value: T) -> Gc<EmbedderCell<T>> {
+ /// Moves the value that `build` returns into a new cell of the class, as Heap::allocate() does.
+ pub fn allocate(&'static self, vm: &Vm, build: impl FnOnce(&DeferGc<'_>) -> T) -> Gc<EmbedderCell<T>> {
let allocator = vm.heap().embedder_class_allocator(&self.class);
- vm.heap().allocate_in(
- allocator,
- EmbedderCell {
- header: CellHeader::for_class(&self.class),
- value: ValueWithRoomForFreeListLink {
- value: ManuallyDrop::new(value),
- },
+ vm.heap().allocate_in(allocator, |defer_gc| EmbedderCell {
+ header: CellHeader::for_class(&self.class),
+ value: ValueWithRoomForFreeListLink {
+ value: ManuallyDrop::new(build(defer_gc)),
},
- )
+ })
}
/// The cell behind the pointer, if it is a cell of this class.
diff --git a/Libraries/LibJS/Rust/src/gc/heap.rs b/Libraries/LibJS/Rust/src/gc/heap.rs
index d5b4a74e54d..678aa14bcc3 100644
--- a/Libraries/LibJS/Rust/src/gc/heap.rs
+++ b/Libraries/LibJS/Rust/src/gc/heap.rs
@@ -224,50 +224,48 @@ impl Heap {
}
}
- /// Moves `cell` into the heap. Nothing can collect garbage between taking the storage and writing the cell, so
- /// the collector never sees a partially written cell.
- pub fn allocate<T: GcCell>(&self, cell: T) -> Gc<T> {
- let allocator = self.allocator_for(T::CLASS);
- // SAFETY: The allocator is the one of the cell's static class, whose cells have the size and alignment of a T.
- unsafe { self.allocate_with(allocator, size_of::<T>(), AllocationKind::Cell, cell, |_| {}) }
- }
-
/// Moves the cell that `build` returns into the heap, with collections deferred from before `build` runs until
/// the cell is in the heap.
- pub fn allocate_deferring_gc<T: GcCell>(&self, build: impl FnOnce(&DeferGc<'_>) -> T) -> Gc<T> {
- let defer_gc = DeferGc::of_heap(self);
- let cell = self.allocate(build(&defer_gc));
- drop(defer_gc);
- cell
+ pub fn allocate<T: GcCell>(&self, build: impl FnOnce(&DeferGc<'_>) -> T) -> Gc<T> {
+ let allocator = self.allocator_for(T::CLASS);
+ // SAFETY: The allocator is the one of the cell's static class, whose cells have the size and alignment of a T.
+ unsafe { self.allocate_with(allocator, size_of::<T>(), AllocationKind::Cell, build, |_| {}) }
}
- /// Moves `cell`, whose class is the one `allocator` was created for or a class derived from it, into the storage
- /// of that allocator. A derived class shares its ancestor's allocator when its cells may share heap blocks with the
- /// ancestor's, as a host class that shares its parent's allocator does.
- pub fn allocate_in<T: GcCell>(&self, allocator: RuntimeClassAllocator, cell: T) -> Gc<T> {
+ /// allocate() into the storage of `allocator`, which was created for the class of the cell or a class it derives
+ /// from.
+ pub fn allocate_in<T: GcCell>(
+ &self,
+ allocator: RuntimeClassAllocator,
+ build: impl FnOnce(&DeferGc<'_>) -> T,
+ ) -> Gc<T> {
assert!(
allocator.class.type_info.cell_size as usize == size_of::<T>() && allocator.class.is_subclass_of(T::CLASS),
"{} cells are not {}s",
allocator.class.name,
T::CLASS.name
);
- // SAFETY: Every cell starts with its header.
- debug_assert!(
- unsafe { (*core::ptr::from_ref(&cell).cast::<CellHeader>()).class }.is_subclass_of(allocator.class)
- );
+ let build = |defer_gc: &DeferGc<'_>| {
+ let cell = build(defer_gc);
+ // SAFETY: Every cell starts with its header.
+ debug_assert!(
+ unsafe { (*core::ptr::from_ref(&cell).cast::<CellHeader>()).class }.is_subclass_of(allocator.class)
+ );
+ cell
+ };
// SAFETY: The allocator's cells have the size of a T, checked above, and T's alignment, as its class extends T's.
- unsafe { self.allocate_with(allocator.allocator, size_of::<T>(), AllocationKind::Cell, cell, |_| {}) }
+ unsafe { self.allocate_with(allocator.allocator, size_of::<T>(), AllocationKind::Cell, build, |_| {}) }
}
- /// Moves `cell` into a cell of `size_class`, whose class is the class of the cell or one that it extends, and fills
- /// the rest of the larger cell with copies of `tail`. Finding and tracing the part beyond the T is up to the T.
+ /// allocate() into a cell of `size_class`, whose class is the class of the cell or one that it extends, filling the
+ /// rest of the larger cell with copies of `tail`. Finding and tracing the part beyond the T is up to the T.
pub fn allocate_with_size_class<T: GcCell, E: Copy>(
&self,
size_class: SizeClassAllocator,
- cell: T,
+ build: impl FnOnce(&DeferGc<'_>) -> T,
tail: E,
) -> Gc<T> {
- self.allocate_in_size_class(size_class, AllocationKind::Cell, cell, tail)
+ self.allocate_in_size_class(size_class, AllocationKind::Cell, build, tail)
}
/// allocate_with_size_class() for a cell that another cell keeps its storage in, instead of malloc memory: it never
@@ -277,10 +275,10 @@ impl Heap {
pub fn allocate_storage_with_size_class<T: GcCell, E: Copy>(
&self,
size_class: SizeClassAllocator,
- cell: T,
+ build: impl FnOnce(&DeferGc<'_>) -> T,
tail: E,
) -> Gc<T> {
- self.allocate_in_size_class(size_class, AllocationKind::Storage, cell, tail)
+ self.allocate_in_size_class(size_class, AllocationKind::Storage, build, tail)
}
#[inline(always)]
@@ -288,7 +286,7 @@ impl Heap {
&self,
size_class: SizeClassAllocator,
kind: AllocationKind,
- cell: T,
+ build: impl FnOnce(&DeferGc<'_>) -> T,
tail: E,
) -> Gc<T> {
const {
@@ -304,10 +302,14 @@ impl Heap {
size_class.class.name,
T::CLASS.name
);
- // SAFETY: Every cell starts with its header.
- debug_assert!(
- unsafe { (*core::ptr::from_ref(&cell).cast::<CellHeader>()).class }.is_subclass_of(size_class.class)
- );
+ let build = |defer_gc: &DeferGc<'_>| {
+ let cell = build(defer_gc);
+ // SAFETY: Every cell starts with its header.
+ debug_assert!(
+ unsafe { (*core::ptr::from_ref(&cell).cast::<CellHeader>()).class }.is_subclass_of(size_class.class)
+ );
+ cell
+ };
let tail_size = size_class.cell_size as usize - size_of::<T>();
assert!(
tail_size.is_multiple_of(size_of::<E>()),
@@ -328,7 +330,7 @@ impl Heap {
size_class.allocator,
size_class.cell_size as usize,
kind,
- cell,
+ build,
initialize_tail,
)
}
@@ -344,28 +346,66 @@ impl Heap {
allocator: HeapAllocator,
cell_size: usize,
kind: AllocationKind,
+ build: impl FnOnce(&DeferGc<'_>) -> T,
+ initialize_tail: impl FnOnce(*mut u8),
+ ) -> Gc<T> {
+ let defer_gc = DeferGc::of_heap(self);
+ let cell = build(&defer_gc);
+ // SAFETY: The allocator belongs to this heap and hands out cells of cell_size bytes.
+ let cell = match unsafe { self.take_from_local_free_list(allocator, cell_size, kind) } {
+ // SAFETY: The storage is a cell of the allocator, so it has the size and the alignment the caller guarantees.
+ Some(storage) => unsafe { Self::write_cell(storage.cast(), cell, initialize_tail, false) },
+ // SAFETY: The caller's guarantees about the allocator and the tail pass on.
+ None => unsafe { self.allocate_from_heap(&defer_gc, allocator, kind, cell, initialize_tail) },
+ };
+ // NB: A collection that became due runs now, with the cell in the heap and its Gc on the stack.
+ drop(defer_gc);
+ cell
+ }
+
+ /// Takes the storage from LibGC, which defers the collection that is due until the deferral ends.
+ ///
+ /// # Safety
+ ///
+ /// As for allocate_with().
+ unsafe fn allocate_from_heap<T: GcCell>(
+ &self,
+ _: &DeferGc<'_>,
+ allocator: HeapAllocator,
+ kind: AllocationKind,
cell: T,
initialize_tail: impl FnOnce(*mut u8),
) -> Gc<T> {
let mut must_mark = false;
- // SAFETY: The allocator belongs to this heap and hands out cells of cell_size bytes.
- let storage = match unsafe { self.take_from_local_free_list(allocator, cell_size, kind) } {
- Some(storage) => storage,
- // SAFETY: The heap and the allocator are live.
- None => unsafe {
- let raw = allocator.raw.as_ptr();
- let storage = match kind {
- AllocationKind::Cell => capi::gc_heap_allocate_cell(self.raw.as_ptr(), raw, &raw mut must_mark),
- AllocationKind::Storage => {
- capi::gc_heap_allocate_storage_cell(self.raw.as_ptr(), raw, &raw mut must_mark)
- }
- };
- NonNull::new(storage).expect("LibGC allocates the cell")
- },
- }
- .cast::<T>();
+ let raw = allocator.raw.as_ptr();
+ // SAFETY: The heap and the allocator are live.
+ let storage = unsafe {
+ match kind {
+ AllocationKind::Cell => capi::gc_heap_allocate_cell(self.raw.as_ptr(), raw, &raw mut must_mark),
+ AllocationKind::Storage => {
+ capi::gc_heap_allocate_storage_cell(self.raw.as_ptr(), raw, &raw mut must_mark)
+ }
+ }
+ };
+ let storage = NonNull::new(storage).expect("LibGC allocates the cell").cast::<T>();
// SAFETY: LibGC returned uninitialized storage of at least the size and the alignment of a T, as the caller
- // guarantees, which nothing can collect garbage before it is written.
+ // guarantees.
+ unsafe { Self::write_cell(storage, cell, initialize_tail, must_mark) }
+ }
+
+ /// Writes `cell` to `storage` and has `initialize_tail` write the rest of the cell, with `must_mark` as its mark.
+ ///
+ /// # Safety
+ ///
+ /// `storage` must be uninitialized storage of at least the size and the alignment of a T, which nothing can collect
+ /// garbage before it is written, and `initialize_tail` must write every byte beyond the T.
+ unsafe fn write_cell<T: GcCell>(
+ storage: NonNull<T>,
+ cell: T,
+ initialize_tail: impl FnOnce(*mut u8),
+ must_mark: bool,
+ ) -> Gc<T> {
+ // SAFETY: The caller passes storage for a T with room for the tail.
unsafe {
storage.write(cell);
initialize_tail(storage.as_ptr().cast::<u8>().add(size_of::<T>()));
diff --git a/Libraries/LibJS/Rust/src/gc/heap_function.rs b/Libraries/LibJS/Rust/src/gc/heap_function.rs
index 9cac7c85a5a..b1971c498f3 100644
--- a/Libraries/LibJS/Rust/src/gc/heap_function.rs
+++ b/Libraries/LibJS/Rust/src/gc/heap_function.rs
@@ -92,7 +92,7 @@ where
}
// The captures stay in `storage` on the stack, where the collector finds them, until the function that keeps
// them alive exists.
- vm.heap().allocate(HeapFunction {
+ vm.heap().allocate(|_| HeapFunction {
header: CellHeader::for_class(HeapFunction::CLASS),
call: call_with_captures::<C, F>,
trace: trace_captures::<C, F>,
diff --git a/Libraries/LibJS/Rust/src/interpreter/vm.rs b/Libraries/LibJS/Rust/src/interpreter/vm.rs
index f21ea1fad11..a94a8e0759a 100644
--- a/Libraries/LibJS/Rust/src/interpreter/vm.rs
+++ b/Libraries/LibJS/Rust/src/interpreter/vm.rs
@@ -768,7 +768,7 @@ impl Vm {
let allocate_interned_string = |string: &str| {
let string = self
.heap()
- .allocate(PrimitiveString::new(Utf16String::from_utf8(string)));
+ .allocate(|_| PrimitiveString::new(Utf16String::from_utf8(string)));
string.set_interned();
string
};
@@ -797,12 +797,12 @@ impl Vm {
let _ = self.well_known_symbols.set(WellKnownSymbols::create(self));
let _ = self.global_symbol_registry.set(GlobalSymbolRegistry::create(self));
- let _ = self.job_queues.set(self.heap().allocate(JobQueues {
+ let _ = self.job_queues.set(self.heap().allocate(|_| JobQueues {
header: CellHeader::for_class(JobQueues::CLASS),
promise_jobs: GcRefCell::new(VecDeque::new()),
finalization_registry_cleanup_jobs: GcRefCell::new(Vec::new()),
}));
- let _ = self.loaded_modules.set(self.heap().allocate(LoadedModules {
+ let _ = self.loaded_modules.set(self.heap().allocate(|_| LoadedModules {
header: CellHeader::for_class(LoadedModules::CLASS),
stored_modules: GcRefCell::new(Vec::new()),
}));
diff --git a/Libraries/LibJS/Rust/src/jit/allocation.rs b/Libraries/LibJS/Rust/src/jit/allocation.rs
index 5b14adc9673..a30f3859fbc 100644
--- a/Libraries/LibJS/Rust/src/jit/allocation.rs
+++ b/Libraries/LibJS/Rust/src/jit/allocation.rs
@@ -314,7 +314,7 @@ pub fn make_call_environment_template(vm: &Vm, function: Gc<EcmascriptFunctionOb
}
shared_data
.call_environment_template
- .set(Some(vm.heap().allocate(template)));
+ .set(Some(vm.heap().allocate(|_| template)));
}
/// The template of the function environments that calls of `function` get (see `EnvironmentTemplateSnapshot`), if the
diff --git a/Libraries/LibJS/Rust/src/runtime/abstract_operations.rs b/Libraries/LibJS/Rust/src/runtime/abstract_operations.rs
index 38aa985eee8..f16bce5f84c 100644
--- a/Libraries/LibJS/Rust/src/runtime/abstract_operations.rs
+++ b/Libraries/LibJS/Rust/src/runtime/abstract_operations.rs
@@ -18,6 +18,7 @@ use num_traits::{Signed, Zero};
use crate::bytecode::executable::{Executable, StaticPropertyLookupCacheSite};
use crate::compile::{CompiledEval, EvalContext, parse_eval};
use crate::gc::class::{Extends, GcCell};
+use crate::gc::defer_gc::DeferGc;
use crate::gc::gc_ref_cell::GcRefCell;
use crate::gc::root::MarkedVec;
use crate::hash_table::Utf16FlyStringHashTable;
@@ -735,23 +736,23 @@ pub fn ordinary_create_from_constructor(
constructor: Gc<FunctionObject>,
intrinsic_default_prototype: IntrinsicDefaultPrototype,
) -> ThrowCompletionOr<Gc<Object>> {
- ordinary_create_from_constructor_of(vm, realm, constructor, intrinsic_default_prototype, |prototype| {
+ ordinary_create_from_constructor_of(vm, realm, constructor, intrinsic_default_prototype, |_, prototype| {
Object::new_with_prototype(vm, Object::CLASS, prototype, MayInterfereWithIndexedPropertyAccess::No)
})
}
// 10.1.13 OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ), https://tc39.es/ecma262/#sec-ordinarycreatefromconstructor
/// The form of OrdinaryCreateFromConstructor that creates an object with the internal slots of a T, which `create`
-/// makes from the prototype.
+/// builds from the prototype, as Heap::allocate() does.
pub fn ordinary_create_from_constructor_of<T: GcCell + Extends<Object>>(
vm: &Vm,
realm: Gc<Realm>,
constructor: Gc<FunctionObject>,
intrinsic_default_prototype: IntrinsicDefaultPrototype,
- create: impl FnOnce(Gc<Object>) -> T,
+ create: impl FnOnce(&DeferGc<'_>, Gc<Object>) -> T,
) -> ThrowCompletionOr<Gc<T>> {
let prototype = get_prototype_from_constructor(vm, constructor, intrinsic_default_prototype)?;
- Ok(realm.create_object(vm, create(prototype)))
+ Ok(realm.create_object(vm, |defer_gc| create(defer_gc, prototype)))
}
// 10.1.14 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ), https://tc39.es/ecma262/#sec-getprototypefromconstructor
diff --git a/Libraries/LibJS/Rust/src/runtime/accessor.rs b/Libraries/LibJS/Rust/src/runtime/accessor.rs
index 894162919ef..02e9699d4f1 100644
--- a/Libraries/LibJS/Rust/src/runtime/accessor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/accessor.rs
@@ -33,7 +33,7 @@ impl Accessor {
cached_value_key: Option<Gc<Symbol>>,
) -> Gc<Accessor> {
assert!(cached_value_key.is_none_or(|cached_value_key| cached_value_key.is_private()));
- vm.heap().allocate(Accessor {
+ vm.heap().allocate(|_| Accessor {
header: CellHeader::for_class(Self::CLASS),
getter: Cell::new(getter),
setter: Cell::new(setter),
diff --git a/Libraries/LibJS/Rust/src/runtime/aggregate_error.rs b/Libraries/LibJS/Rust/src/runtime/aggregate_error.rs
index 56ca73061ba..a379a485435 100644
--- a/Libraries/LibJS/Rust/src/runtime/aggregate_error.rs
+++ b/Libraries/LibJS/Rust/src/runtime/aggregate_error.rs
@@ -45,9 +45,8 @@ impl AggregateError {
}
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<AggregateError> {
- realm.create_object(
- vm,
- AggregateError::new(vm, realm.intrinsics().aggregate_error_prototype(vm)),
- )
+ realm.create_object(vm, |_| {
+ AggregateError::new(vm, realm.intrinsics().aggregate_error_prototype(vm))
+ })
}
}
diff --git a/Libraries/LibJS/Rust/src/runtime/aggregate_error_constructor.rs b/Libraries/LibJS/Rust/src/runtime/aggregate_error_constructor.rs
index 8c8230d13f3..76fa7f35c43 100644
--- a/Libraries/LibJS/Rust/src/runtime/aggregate_error_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/aggregate_error_constructor.rs
@@ -39,16 +39,13 @@ define_native_function_class!(
impl AggregateErrorConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<AggregateErrorConstructor> {
- realm.create_object(
- vm,
- AggregateErrorConstructor {
- base: NativeFunction::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().error_constructor(vm).upcast(),
- ),
- },
- )
+ realm.create_object(vm, |_| AggregateErrorConstructor {
+ base: NativeFunction::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().error_constructor(vm).upcast(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -88,7 +85,7 @@ impl AggregateErrorConstructor {
// 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%AggregateError.prototype%", « [[ErrorData]] »).
let prototype = get_prototype_from_constructor(vm, new_target, Intrinsics::aggregate_error_prototype)?;
- let aggregate_error = realm.create_object(vm, AggregateError::new_in_constructor(vm, prototype));
+ let aggregate_error = realm.create_object(vm, |_| AggregateError::new_in_constructor(vm, prototype));
// 3. If message is not undefined, then
if !message.is_undefined() {
diff --git a/Libraries/LibJS/Rust/src/runtime/aggregate_error_prototype.rs b/Libraries/LibJS/Rust/src/runtime/aggregate_error_prototype.rs
index c58fad01b0d..2097453880a 100644
--- a/Libraries/LibJS/Rust/src/runtime/aggregate_error_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/aggregate_error_prototype.rs
@@ -30,17 +30,14 @@ define_object_class!(AggregateErrorPrototype, extends: [Object], methods: {
impl AggregateErrorPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<AggregateErrorPrototype> {
- realm.create_object(
- vm,
- AggregateErrorPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().error_prototype(vm),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| AggregateErrorPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().error_prototype(vm),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, _realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/arguments_object.rs b/Libraries/LibJS/Rust/src/runtime/arguments_object.rs
index d294e9695d2..f0df2fd22b9 100644
--- a/Libraries/LibJS/Rust/src/runtime/arguments_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/arguments_object.rs
@@ -90,19 +90,16 @@ impl ArgumentsObject {
},
);
base.inline_named_capacity.set(INLINE_NAMED_STORAGE_CAPACITY as u8 + 1);
- allocate_object(
- vm,
- ArgumentsObject {
- base,
- extra_inline_named_storage: Cell::new(Value::UNDEFINED),
- environment: Cell::new(environment),
- parameter_map: RefCell::new(ParameterMap {
- names: Rc::from([]),
- mapped_count: 0,
- unmapped: Vec::new(),
- }),
- },
- )
+ allocate_object(vm, |_| ArgumentsObject {
+ base,
+ extra_inline_named_storage: Cell::new(Value::UNDEFINED),
+ environment: Cell::new(environment),
+ parameter_map: RefCell::new(ParameterMap {
+ names: Rc::from([]),
+ mapped_count: 0,
+ unmapped: Vec::new(),
+ }),
+ })
}
/// Maps the indices below `mapped_count` to the parameters `names` gives them, where they have one.
diff --git a/Libraries/LibJS/Rust/src/runtime/array.rs b/Libraries/LibJS/Rust/src/runtime/array.rs
index d3d8144e0bf..0ae5bb5fcaf 100644
--- a/Libraries/LibJS/Rust/src/runtime/array.rs
+++ b/Libraries/LibJS/Rust/src/runtime/array.rs
@@ -125,7 +125,7 @@ impl Array {
// 3. Let A be MakeBasicObject(« [[Prototype]], [[Extensible]] »).
// 4. Set A.[[Prototype]] to proto.
// 5. Set A.[[DefineOwnProperty]] as specified in 10.4.2.1.
- let array = allocate_object(vm, Self::new(vm, realm, prototype));
+ let array = allocate_object(vm, |_| Self::new(vm, realm, prototype));
// 6. Perform ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }).
// OPTIMIZATION: The length of an array is the size of its indexed storage, and a new array's length is already
diff --git a/Libraries/LibJS/Rust/src/runtime/array_buffer.rs b/Libraries/LibJS/Rust/src/runtime/array_buffer.rs
index 53f603a3cff..aeaa60ee596 100644
--- a/Libraries/LibJS/Rust/src/runtime/array_buffer.rs
+++ b/Libraries/LibJS/Rust/src/runtime/array_buffer.rs
@@ -922,7 +922,7 @@ impl ArrayBuffer {
};
let prototype = prototype_for_shared_state(vm, realm, is_shared);
- Ok(realm.create_object(vm, ArrayBuffer::new_with_buffer(vm, buffer, is_shared, prototype)))
+ Ok(realm.create_object(vm, |_| ArrayBuffer::new_with_buffer(vm, buffer, is_shared, prototype)))
}
/// ArrayBuffer::create(Realm&, ByteBuffer, DataBlock::Shared)
@@ -930,8 +930,9 @@ impl ArrayBuffer {
let owned_buffer =
OwnedBackingStore::create_uninitialized(bytes.len()).expect("allocating the data block succeeds");
let prototype = prototype_for_shared_state(vm, realm, is_shared);
- let array_buffer =
- realm.create_object(vm, ArrayBuffer::new_with_buffer(vm, owned_buffer, is_shared, prototype));
+ let array_buffer = realm.create_object(vm, |_| {
+ ArrayBuffer::new_with_buffer(vm, owned_buffer, is_shared, prototype)
+ });
array_buffer.overwrite(0, bytes);
vm.heap()
.did_allocate_external_memory(array_buffer.external_memory_size());
@@ -958,7 +959,7 @@ impl ArrayBuffer {
);
};
let prototype = prototype_for_shared_state(vm, realm, is_shared);
- let array_buffer = realm.create_object(vm, ArrayBuffer::new_with_buffer(vm, buffer, is_shared, prototype));
+ let array_buffer = realm.create_object(vm, |_| ArrayBuffer::new_with_buffer(vm, buffer, is_shared, prototype));
array_buffer.with_data_block(|data_block| {
let written = if byte_length == 0 {
write(&mut [])
@@ -982,7 +983,7 @@ impl ArrayBuffer {
pub fn create_from_data_block(vm: &Vm, realm: Gc<Realm>, block: DataBlock) -> Gc<ArrayBuffer> {
let is_shared = block.is_shared;
let prototype = prototype_for_shared_state(vm, realm, is_shared);
- let array_buffer = realm.create_object(vm, ArrayBuffer::new(vm, is_shared, prototype));
+ let array_buffer = realm.create_object(vm, |_| ArrayBuffer::new(vm, is_shared, prototype));
array_buffer.set_data_block(vm, block);
array_buffer
}
@@ -1653,7 +1654,7 @@ pub fn allocate_array_buffer(
realm,
constructor,
Intrinsics::array_buffer_prototype,
- |prototype| ArrayBuffer::new(vm, Shared::No, prototype),
+ |_, prototype| ArrayBuffer::new(vm, Shared::No, prototype),
)?;
// 5. Let block be ? CreateByteDataBlock(byteLength).
@@ -1858,7 +1859,7 @@ pub fn allocate_shared_array_buffer(
realm,
constructor,
Intrinsics::shared_array_buffer_prototype,
- |prototype| ArrayBuffer::new(vm, Shared::Yes, prototype),
+ |_, prototype| ArrayBuffer::new(vm, Shared::Yes, prototype),
)?;
// 6. If allocatingGrowableBuffer is true, let allocLength be maxByteLength; otherwise let allocLength be byteLength.
diff --git a/Libraries/LibJS/Rust/src/runtime/array_buffer_constructor.rs b/Libraries/LibJS/Rust/src/runtime/array_buffer_constructor.rs
index aaa9eb545b8..16268facbfb 100644
--- a/Libraries/LibJS/Rust/src/runtime/array_buffer_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/array_buffer_constructor.rs
@@ -37,17 +37,14 @@ define_native_function_class!(
impl ArrayBufferConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<ArrayBufferConstructor> {
- realm.create_object(
- vm,
- ArrayBufferConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.ArrayBuffer.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| ArrayBufferConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.ArrayBuffer.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/array_buffer_prototype.rs b/Libraries/LibJS/Rust/src/runtime/array_buffer_prototype.rs
index 28cfbffc068..2fcfca019ab 100644
--- a/Libraries/LibJS/Rust/src/runtime/array_buffer_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/array_buffer_prototype.rs
@@ -44,17 +44,14 @@ fn this_array_buffer(vm: &Vm) -> ThrowCompletionOr<Gc<ArrayBuffer>> {
impl ArrayBufferPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<ArrayBufferPrototype> {
- realm.create_object(
- vm,
- ArrayBufferPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| ArrayBufferPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/array_constructor.rs b/Libraries/LibJS/Rust/src/runtime/array_constructor.rs
index 74dfa5e03de..13ad7b45bbe 100644
--- a/Libraries/LibJS/Rust/src/runtime/array_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/array_constructor.rs
@@ -104,17 +104,14 @@ define_native_function_class!(
impl ArrayConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<ArrayConstructor> {
- realm.create_object(
- vm,
- ArrayConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Array.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| ArrayConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Array.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/array_iterator.rs b/Libraries/LibJS/Rust/src/runtime/array_iterator.rs
index c2179c42269..88bc5bc63df 100644
--- a/Libraries/LibJS/Rust/src/runtime/array_iterator.rs
+++ b/Libraries/LibJS/Rust/src/runtime/array_iterator.rs
@@ -71,20 +71,17 @@ impl ArrayIterator {
// 3. Set iterator.[[ArrayLikeNextIndex]] to 0.
// 4. Set iterator.[[ArrayLikeIterationKind]] to kind.
// 5. Return iterator.
- realm.create_object(
- vm,
- ArrayIterator {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().array_iterator_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- array: Cell::new(array),
- iteration_kind,
- index: Cell::new(0),
- },
- )
+ realm.create_object(vm, |_| ArrayIterator {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().array_iterator_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ array: Cell::new(array),
+ iteration_kind,
+ index: Cell::new(0),
+ })
}
fn as_builtin_iterator_if_next_is_not_redefined(_: &Object, next_method: Value) -> Option<BuiltinIteratorNext> {
diff --git a/Libraries/LibJS/Rust/src/runtime/array_iterator_prototype.rs b/Libraries/LibJS/Rust/src/runtime/array_iterator_prototype.rs
index 96407c8f79e..695f4b0bee5 100644
--- a/Libraries/LibJS/Rust/src/runtime/array_iterator_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/array_iterator_prototype.rs
@@ -38,17 +38,14 @@ define_object_class!(ArrayIteratorPrototype, extends: [Object], methods: {
impl ArrayIteratorPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<ArrayIteratorPrototype> {
- realm.create_object(
- vm,
- ArrayIteratorPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().iterator_prototype(vm),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| ArrayIteratorPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().iterator_prototype(vm),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/array_prototype.rs b/Libraries/LibJS/Rust/src/runtime/array_prototype.rs
index 3f47aaa0707..07146330671 100644
--- a/Libraries/LibJS/Rust/src/runtime/array_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/array_prototype.rs
@@ -126,12 +126,9 @@ pub(crate) static SLICE_FUNCTION: RawNativeFunctionPointer = raw_native!(ArrayPr
impl ArrayPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<ArrayPrototype> {
- realm.create_object(
- vm,
- ArrayPrototype {
- base: Array::new_with_class(vm, Self::CLASS, realm, realm.object_prototype()),
- },
- )
+ realm.create_object(vm, |_| ArrayPrototype {
+ base: Array::new_with_class(vm, Self::CLASS, realm, realm.object_prototype()),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/async_disposable_stack_constructor.rs b/Libraries/LibJS/Rust/src/runtime/async_disposable_stack_constructor.rs
index ef7dbd64b82..ef9267c9000 100644
--- a/Libraries/LibJS/Rust/src/runtime/async_disposable_stack_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/async_disposable_stack_constructor.rs
@@ -37,17 +37,14 @@ define_native_function_class!(
impl AsyncDisposableStackConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<AsyncDisposableStackConstructor> {
- realm.create_object(
- vm,
- AsyncDisposableStackConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.AsyncDisposableStack.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| AsyncDisposableStackConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.AsyncDisposableStack.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -90,7 +87,7 @@ impl AsyncDisposableStackConstructor {
realm,
new_target,
Intrinsics::async_disposable_stack_prototype,
- |prototype| AsyncDisposableStack::new(vm, prototype),
+ |_, prototype| AsyncDisposableStack::new(vm, prototype),
)?;
Ok(async_disposable_stack.upcast())
}
diff --git a/Libraries/LibJS/Rust/src/runtime/async_disposable_stack_prototype.rs b/Libraries/LibJS/Rust/src/runtime/async_disposable_stack_prototype.rs
index ad8406333dd..503cee4b9cc 100644
--- a/Libraries/LibJS/Rust/src/runtime/async_disposable_stack_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/async_disposable_stack_prototype.rs
@@ -52,17 +52,14 @@ fn current_realm(vm: &Vm) -> Gc<Realm> {
impl AsyncDisposableStackPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<AsyncDisposableStackPrototype> {
- realm.create_object(
- vm,
- AsyncDisposableStackPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| AsyncDisposableStackPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -294,7 +291,7 @@ impl AsyncDisposableStackPrototype {
realm,
realm.intrinsics().async_disposable_stack_constructor(vm).upcast(),
Intrinsics::async_disposable_stack_prototype,
- |prototype| AsyncDisposableStack::new(vm, prototype),
+ |_, prototype| AsyncDisposableStack::new(vm, prototype),
)?;
// 6. Set newAsyncDisposableStack.[[DisposeCapability]] to asyncDisposableStack.[[DisposeCapability]].
diff --git a/Libraries/LibJS/Rust/src/runtime/async_from_sync_iterator.rs b/Libraries/LibJS/Rust/src/runtime/async_from_sync_iterator.rs
index c9bcdc88fe5..a9d27c85826 100644
--- a/Libraries/LibJS/Rust/src/runtime/async_from_sync_iterator.rs
+++ b/Libraries/LibJS/Rust/src/runtime/async_from_sync_iterator.rs
@@ -37,18 +37,15 @@ impl Deref for AsyncFromSyncIterator {
impl AsyncFromSyncIterator {
pub fn create(vm: &Vm, realm: Gc<Realm>, sync_iterator_record: Gc<IteratorRecord>) -> Gc<AsyncFromSyncIterator> {
- realm.create_object(
- vm,
- AsyncFromSyncIterator {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().async_from_sync_iterator_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- sync_iterator_record: Cell::new(sync_iterator_record),
- },
- )
+ realm.create_object(vm, |_| AsyncFromSyncIterator {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().async_from_sync_iterator_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ sync_iterator_record: Cell::new(sync_iterator_record),
+ })
}
pub fn sync_iterator_record(&self) -> Gc<IteratorRecord> {
diff --git a/Libraries/LibJS/Rust/src/runtime/async_from_sync_iterator_prototype.rs b/Libraries/LibJS/Rust/src/runtime/async_from_sync_iterator_prototype.rs
index 1e46dfa6b30..f93b5583a1b 100644
--- a/Libraries/LibJS/Rust/src/runtime/async_from_sync_iterator_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/async_from_sync_iterator_prototype.rs
@@ -158,17 +158,14 @@ fn async_from_sync_iterator_continuation(
impl AsyncFromSyncIteratorPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<AsyncFromSyncIteratorPrototype> {
- realm.create_object(
- vm,
- AsyncFromSyncIteratorPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().async_iterator_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| AsyncFromSyncIteratorPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().async_iterator_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/async_function_constructor.rs b/Libraries/LibJS/Rust/src/runtime/async_function_constructor.rs
index e2e644f7f8f..3dc43cb2298 100644
--- a/Libraries/LibJS/Rust/src/runtime/async_function_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/async_function_constructor.rs
@@ -35,17 +35,14 @@ define_native_function_class!(
impl AsyncFunctionConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<AsyncFunctionConstructor> {
- realm.create_object(
- vm,
- AsyncFunctionConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.AsyncFunction.as_string().clone(),
- realm.intrinsics().function_constructor(vm).upcast(),
- ),
- },
- )
+ realm.create_object(vm, |_| AsyncFunctionConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.AsyncFunction.as_string().clone(),
+ realm.intrinsics().function_constructor(vm).upcast(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/async_function_driver_wrapper.rs b/Libraries/LibJS/Rust/src/runtime/async_function_driver_wrapper.rs
index 51e054f994f..860e5a7dc5b 100644
--- a/Libraries/LibJS/Rust/src/runtime/async_function_driver_wrapper.rs
+++ b/Libraries/LibJS/Rust/src/runtime/async_function_driver_wrapper.rs
@@ -101,18 +101,15 @@ impl AsyncFunctionDriverWrapper {
let generator_object = GeneratorObject::create(vm, realm, generating_function, context.copy());
generator_object.set_generator_state(GeneratorState::SuspendedYield);
// Note: The top_level_promise is also kept alive by this Wrapper
- let wrapper = realm.create_object(
- vm,
- AsyncFunctionDriverWrapper {
- base: Promise::new(vm, Self::CLASS, realm.intrinsics().promise_prototype(vm)),
- generator_object: Cell::new(generator_object),
- top_level_promise: Cell::new(top_level_promise),
- current_promise: Cell::new(None),
- suspended_execution_context: GcRefCell::new(None),
- on_settled: Cell::new(None),
- is_initial_execution: Cell::new(true),
- },
- );
+ let wrapper = realm.create_object(vm, |_| AsyncFunctionDriverWrapper {
+ base: Promise::new(vm, Self::CLASS, realm.intrinsics().promise_prototype(vm)),
+ generator_object: Cell::new(generator_object),
+ top_level_promise: Cell::new(top_level_promise),
+ current_promise: Cell::new(None),
+ suspended_execution_context: GcRefCell::new(None),
+ on_settled: Cell::new(None),
+ is_initial_execution: Cell::new(true),
+ });
Self::run(wrapper, vm, Ok(IterationResult::new(value, false)));
top_level_promise
diff --git a/Libraries/LibJS/Rust/src/runtime/async_function_prototype.rs b/Libraries/LibJS/Rust/src/runtime/async_function_prototype.rs
index b8f183040c5..efe9b8f0165 100644
--- a/Libraries/LibJS/Rust/src/runtime/async_function_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/async_function_prototype.rs
@@ -32,17 +32,14 @@ define_object_class!(AsyncFunctionPrototype, extends: [Object], methods: {
impl AsyncFunctionPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<AsyncFunctionPrototype> {
- realm.create_object(
- vm,
- AsyncFunctionPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.function_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| AsyncFunctionPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.function_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, _realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/async_generator.rs b/Libraries/LibJS/Rust/src/runtime/async_generator.rs
index 487f5f2c57c..558ce4518f9 100644
--- a/Libraries/LibJS/Rust/src/runtime/async_generator.rs
+++ b/Libraries/LibJS/Rust/src/runtime/async_generator.rs
@@ -93,27 +93,24 @@ impl AsyncGenerator {
let generating_executable = generating_function.bytecode_executable(vm);
let yield_continuation = execution_context.yield_continuation.get();
- realm.create_object(
- vm,
- AsyncGenerator {
- base: Object::new_with_realm_and_prototype(
- vm,
- Self::CLASS,
- realm,
- Some(generating_function_prototype_object),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- async_generator_state: Cell::new(AsyncGeneratorState::SuspendedStart),
- async_generator_context: GcRefCell::new(Some(execution_context)),
- async_generator_queue: GcRefCell::new(VecDeque::new()),
- generator_brand: None,
- generating_executable: Cell::new(generating_executable),
- yield_continuation: Cell::new(yield_continuation),
- current_promise: Cell::new(None),
- pending_completion_value: Cell::new(Value::UNDEFINED),
- pending_completion_type: Cell::new(CompletionType::Normal),
- },
- )
+ realm.create_object(vm, |_| AsyncGenerator {
+ base: Object::new_with_realm_and_prototype(
+ vm,
+ Self::CLASS,
+ realm,
+ Some(generating_function_prototype_object),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ async_generator_state: Cell::new(AsyncGeneratorState::SuspendedStart),
+ async_generator_context: GcRefCell::new(Some(execution_context)),
+ async_generator_queue: GcRefCell::new(VecDeque::new()),
+ generator_brand: None,
+ generating_executable: Cell::new(generating_executable),
+ yield_continuation: Cell::new(yield_continuation),
+ current_promise: Cell::new(None),
+ pending_completion_value: Cell::new(Value::UNDEFINED),
+ pending_completion_type: Cell::new(CompletionType::Normal),
+ })
}
fn as_gc(&self) -> Gc<AsyncGenerator> {
diff --git a/Libraries/LibJS/Rust/src/runtime/async_generator_function_constructor.rs b/Libraries/LibJS/Rust/src/runtime/async_generator_function_constructor.rs
index 63cb5184fab..5b4a8bb5270 100644
--- a/Libraries/LibJS/Rust/src/runtime/async_generator_function_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/async_generator_function_constructor.rs
@@ -37,17 +37,14 @@ impl AsyncGeneratorFunctionConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<AsyncGeneratorFunctionConstructor> {
// NB: The spec has %Function% as the [[Prototype]] of %AsyncGeneratorFunction%, but this uses
// %Function.prototype%.
- realm.create_object(
- vm,
- AsyncGeneratorFunctionConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.AsyncGeneratorFunction.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| AsyncGeneratorFunctionConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.AsyncGeneratorFunction.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/async_generator_function_prototype.rs b/Libraries/LibJS/Rust/src/runtime/async_generator_function_prototype.rs
index b3874c2d0b2..971dcf74563 100644
--- a/Libraries/LibJS/Rust/src/runtime/async_generator_function_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/async_generator_function_prototype.rs
@@ -32,17 +32,14 @@ define_object_class!(AsyncGeneratorFunctionPrototype, extends: [Object], methods
impl AsyncGeneratorFunctionPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<AsyncGeneratorFunctionPrototype> {
- realm.create_object(
- vm,
- AsyncGeneratorFunctionPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.function_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| AsyncGeneratorFunctionPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.function_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/async_generator_prototype.rs b/Libraries/LibJS/Rust/src/runtime/async_generator_prototype.rs
index 2fcf29f04d6..983490fa549 100644
--- a/Libraries/LibJS/Rust/src/runtime/async_generator_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/async_generator_prototype.rs
@@ -74,17 +74,14 @@ fn async_generator_validate(
impl AsyncGeneratorPrototype {
// 27.6.1 Properties of the AsyncGenerator Prototype Object, https://tc39.es/ecma262/#sec-properties-of-asyncgenerator-prototype
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<AsyncGeneratorPrototype> {
- realm.create_object(
- vm,
- AsyncGeneratorPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().async_iterator_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| AsyncGeneratorPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().async_iterator_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/async_iterator_prototype.rs b/Libraries/LibJS/Rust/src/runtime/async_iterator_prototype.rs
index 2298213aeb8..8bc560d4a38 100644
--- a/Libraries/LibJS/Rust/src/runtime/async_iterator_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/async_iterator_prototype.rs
@@ -35,17 +35,14 @@ define_object_class!(AsyncIteratorPrototype, extends: [Object], methods: {
impl AsyncIteratorPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<AsyncIteratorPrototype> {
- realm.create_object(
- vm,
- AsyncIteratorPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| AsyncIteratorPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/atomics_object.rs b/Libraries/LibJS/Rust/src/runtime/atomics_object.rs
index cd0e12f77e7..c09d9452070 100644
--- a/Libraries/LibJS/Rust/src/runtime/atomics_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/atomics_object.rs
@@ -307,17 +307,14 @@ fn perform_atomic_operation(vm: &Vm, operation: ReadWriteModifyOperation) -> Thr
impl AtomicsObject {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<AtomicsObject> {
- realm.create_object(
- vm,
- AtomicsObject {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| AtomicsObject {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/big_int.rs b/Libraries/LibJS/Rust/src/runtime/big_int.rs
index c0545110c7f..c19abad0043 100644
--- a/Libraries/LibJS/Rust/src/runtime/big_int.rs
+++ b/Libraries/LibJS/Rust/src/runtime/big_int.rs
@@ -37,7 +37,7 @@ impl BigInt {
}
pub fn create(vm: &Vm, big_integer: SignedBigInteger) -> Gc<BigInt> {
- vm.heap().allocate(Self::new(big_integer))
+ vm.heap().allocate(|_| Self::new(big_integer))
}
pub fn big_integer(&self) -> &SignedBigInteger {
diff --git a/Libraries/LibJS/Rust/src/runtime/big_int_constructor.rs b/Libraries/LibJS/Rust/src/runtime/big_int_constructor.rs
index b91644dbfbb..312385208f2 100644
--- a/Libraries/LibJS/Rust/src/runtime/big_int_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/big_int_constructor.rs
@@ -37,17 +37,14 @@ define_native_function_class!(
impl BigIntConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<BigIntConstructor> {
- realm.create_object(
- vm,
- BigIntConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.BigInt.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| BigIntConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.BigInt.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/big_int_object.rs b/Libraries/LibJS/Rust/src/runtime/big_int_object.rs
index 7e71861fbab..deb40f41f7c 100644
--- a/Libraries/LibJS/Rust/src/runtime/big_int_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/big_int_object.rs
@@ -36,18 +36,15 @@ impl Deref for BigIntObject {
impl BigIntObject {
pub fn create(vm: &Vm, realm: Gc<Realm>, bigint: Gc<BigInt>) -> Gc<BigIntObject> {
- realm.create_object(
- vm,
- BigIntObject {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().bigint_prototype(vm),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- bigint,
- },
- )
+ realm.create_object(vm, |_| BigIntObject {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().bigint_prototype(vm),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ bigint,
+ })
}
pub fn bigint(&self) -> Gc<BigInt> {
diff --git a/Libraries/LibJS/Rust/src/runtime/big_int_prototype.rs b/Libraries/LibJS/Rust/src/runtime/big_int_prototype.rs
index f4081a5d5a9..44c660f6825 100644
--- a/Libraries/LibJS/Rust/src/runtime/big_int_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/big_int_prototype.rs
@@ -61,17 +61,14 @@ fn this_bigint_value(vm: &Vm, value: Value) -> ThrowCompletionOr<Gc<BigInt>> {
impl BigIntPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<BigIntPrototype> {
- realm.create_object(
- vm,
- BigIntPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| BigIntPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/boolean_constructor.rs b/Libraries/LibJS/Rust/src/runtime/boolean_constructor.rs
index 2162dc5f2bf..9743f574856 100644
--- a/Libraries/LibJS/Rust/src/runtime/boolean_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/boolean_constructor.rs
@@ -35,17 +35,14 @@ define_native_function_class!(
impl BooleanConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<BooleanConstructor> {
- realm.create_object(
- vm,
- BooleanConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Boolean.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| BooleanConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Boolean.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -90,7 +87,7 @@ impl BooleanConstructor {
// 5. Return O.
let prototype = get_prototype_from_constructor(vm, new_target, Intrinsics::boolean_prototype)?;
Ok(realm
- .create_object(vm, BooleanObject::new(vm, BooleanObject::CLASS, b, prototype))
+ .create_object(vm, |_| BooleanObject::new(vm, BooleanObject::CLASS, b, prototype))
.upcast())
}
}
diff --git a/Libraries/LibJS/Rust/src/runtime/boolean_object.rs b/Libraries/LibJS/Rust/src/runtime/boolean_object.rs
index aa67a805277..a9a85b35164 100644
--- a/Libraries/LibJS/Rust/src/runtime/boolean_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/boolean_object.rs
@@ -44,10 +44,9 @@ impl BooleanObject {
}
pub fn create(vm: &Vm, realm: Gc<Realm>, value: bool) -> Gc<BooleanObject> {
- realm.create_object(
- vm,
- BooleanObject::new(vm, Self::CLASS, value, realm.intrinsics().boolean_prototype(vm)),
- )
+ realm.create_object(vm, |_| {
+ BooleanObject::new(vm, Self::CLASS, value, realm.intrinsics().boolean_prototype(vm))
+ })
}
pub fn boolean(&self) -> bool {
diff --git a/Libraries/LibJS/Rust/src/runtime/boolean_prototype.rs b/Libraries/LibJS/Rust/src/runtime/boolean_prototype.rs
index d25bddfcd3a..5d1472f4dd7 100644
--- a/Libraries/LibJS/Rust/src/runtime/boolean_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/boolean_prototype.rs
@@ -56,12 +56,9 @@ fn this_boolean_value(vm: &Vm, value: Value) -> ThrowCompletionOr<bool> {
impl BooleanPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<BooleanPrototype> {
- realm.create_object(
- vm,
- BooleanPrototype {
- base: BooleanObject::new(vm, Self::CLASS, false, realm.object_prototype()),
- },
- )
+ realm.create_object(vm, |_| BooleanPrototype {
+ base: BooleanObject::new(vm, Self::CLASS, false, realm.object_prototype()),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/bound_function.rs b/Libraries/LibJS/Rust/src/runtime/bound_function.rs
index 93d65f25ff2..7748ef6fcf0 100644
--- a/Libraries/LibJS/Rust/src/runtime/bound_function.rs
+++ b/Libraries/LibJS/Rust/src/runtime/bound_function.rs
@@ -120,15 +120,12 @@ impl BoundFunction {
// 7. Set obj.[[BoundTargetFunction]] to targetFunction.
// 8. Set obj.[[BoundThis]] to boundThis.
// 9. Set obj.[[BoundArguments]] to boundArgs.
- let object = allocate_object(
- vm,
- BoundFunction {
- base,
- bound_target_function: Cell::new(target_function),
- bound_this: Cell::new(bound_this),
- bound_arguments: OnceCell::new(),
- },
- );
+ let object = allocate_object(vm, |_| BoundFunction {
+ base,
+ bound_target_function: Cell::new(target_function),
+ bound_this: Cell::new(bound_this),
+ bound_arguments: OnceCell::new(),
+ });
// The caller keeps the bound arguments alive until the function that does holds them, and nothing allocates
// from the heap in between.
if object
diff --git a/Libraries/LibJS/Rust/src/runtime/completion.rs b/Libraries/LibJS/Rust/src/runtime/completion.rs
index 94967332fb7..5e2687b1492 100644
--- a/Libraries/LibJS/Rust/src/runtime/completion.rs
+++ b/Libraries/LibJS/Rust/src/runtime/completion.rs
@@ -137,7 +137,7 @@ pub fn r#await(vm: &Vm, value: Value) -> ThrowCompletionOr<Value> {
// 2. Let promise be ? PromiseResolve(%Promise%, value).
let promise_object = promise_resolve(vm, realm.intrinsics().promise_constructor(vm).upcast(), value)?;
- let awaited_completion = vm.heap().allocate(AwaitedCompletion {
+ let awaited_completion = vm.heap().allocate(|_| AwaitedCompletion {
header: CellHeader::for_class(AwaitedCompletion::CLASS),
success: Cell::new(None),
result: Cell::new(Value::UNDEFINED),
diff --git a/Libraries/LibJS/Rust/src/runtime/console_object.rs b/Libraries/LibJS/Rust/src/runtime/console_object.rs
index 927a26b300e..183e213730f 100644
--- a/Libraries/LibJS/Rust/src/runtime/console_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/console_object.rs
@@ -49,18 +49,15 @@ fn console_of_current_realm(vm: &Vm) -> Gc<Console> {
impl ConsoleObject {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<ConsoleObject> {
let prototype = create_console_prototype(vm, realm);
- realm.create_object(
- vm,
- ConsoleObject {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- prototype.upcast(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- console: Cell::new(None),
- },
- )
+ realm.create_object(vm, |_| ConsoleObject {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ prototype.upcast(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ console: Cell::new(None),
+ })
}
pub fn console(&self) -> Gc<Console> {
diff --git a/Libraries/LibJS/Rust/src/runtime/console_object_prototype.rs b/Libraries/LibJS/Rust/src/runtime/console_object_prototype.rs
index bffdb01d7b3..140c5c418bf 100644
--- a/Libraries/LibJS/Rust/src/runtime/console_object_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/console_object_prototype.rs
@@ -25,16 +25,13 @@ define_object_class!(ConsoleObjectPrototype, extends: [Object], methods: {
impl ConsoleObjectPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<ConsoleObjectPrototype> {
- realm.create_object(
- vm,
- ConsoleObjectPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| ConsoleObjectPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
}
diff --git a/Libraries/LibJS/Rust/src/runtime/data_view.rs b/Libraries/LibJS/Rust/src/runtime/data_view.rs
index 0fe9e753af9..eed290121a8 100644
--- a/Libraries/LibJS/Rust/src/runtime/data_view.rs
+++ b/Libraries/LibJS/Rust/src/runtime/data_view.rs
@@ -62,10 +62,9 @@ impl DataView {
byte_offset: usize,
) -> Gc<DataView> {
let prototype = realm.intrinsics().data_view_prototype(vm);
- realm.create_object(
- vm,
- DataView::new(vm, viewed_buffer, byte_length, byte_offset, prototype),
- )
+ realm.create_object(vm, |_| {
+ DataView::new(vm, viewed_buffer, byte_length, byte_offset, prototype)
+ })
}
pub fn viewed_array_buffer(&self) -> Gc<ArrayBuffer> {
diff --git a/Libraries/LibJS/Rust/src/runtime/data_view_constructor.rs b/Libraries/LibJS/Rust/src/runtime/data_view_constructor.rs
index 64d6daf2947..04259cb5288 100644
--- a/Libraries/LibJS/Rust/src/runtime/data_view_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/data_view_constructor.rs
@@ -39,17 +39,14 @@ define_native_function_class!(
impl DataViewConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<DataViewConstructor> {
- realm.create_object(
- vm,
- DataViewConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.DataView.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| DataViewConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.DataView.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -155,10 +152,13 @@ impl DataViewConstructor {
}
// 10. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%DataView.prototype%", « [[DataView]], [[ViewedArrayBuffer]], [[ByteLength]], [[ByteOffset]] »).
- let data_view =
- ordinary_create_from_constructor_of(vm, realm, new_target, Intrinsics::data_view_prototype, |prototype| {
- DataView::new(vm, buffer, view_byte_length, offset, prototype)
- })?;
+ let data_view = ordinary_create_from_constructor_of(
+ vm,
+ realm,
+ new_target,
+ Intrinsics::data_view_prototype,
+ |_, prototype| DataView::new(vm, buffer, view_byte_length, offset, prototype),
+ )?;
// 11. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
if buffer.is_detached() {
diff --git a/Libraries/LibJS/Rust/src/runtime/data_view_prototype.rs b/Libraries/LibJS/Rust/src/runtime/data_view_prototype.rs
index e98ca1f8096..dc46bd26817 100644
--- a/Libraries/LibJS/Rust/src/runtime/data_view_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/data_view_prototype.rs
@@ -184,17 +184,14 @@ fn set_view_value(
impl DataViewPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<DataViewPrototype> {
- realm.create_object(
- vm,
- DataViewPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| DataViewPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/date.rs b/Libraries/LibJS/Rust/src/runtime/date.rs
index f0e953ba6a1..85f0c866dc0 100644
--- a/Libraries/LibJS/Rust/src/runtime/date.rs
+++ b/Libraries/LibJS/Rust/src/runtime/date.rs
@@ -66,7 +66,7 @@ impl Date {
}
pub fn create(vm: &Vm, realm: Gc<Realm>, date_value: f64) -> Gc<Date> {
- realm.create_object(vm, Date::new(vm, date_value, realm.intrinsics().date_prototype(vm)))
+ realm.create_object(vm, |_| Date::new(vm, date_value, realm.intrinsics().date_prototype(vm)))
}
pub fn date_value(&self) -> f64 {
diff --git a/Libraries/LibJS/Rust/src/runtime/date_constructor.rs b/Libraries/LibJS/Rust/src/runtime/date_constructor.rs
index 383832e24c7..a02109b4e6e 100644
--- a/Libraries/LibJS/Rust/src/runtime/date_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/date_constructor.rs
@@ -62,17 +62,14 @@ fn argument_or(vm: &Vm, index: usize, fallback: f64) -> ThrowCompletionOr<f64> {
impl DateConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<DateConstructor> {
- realm.create_object(
- vm,
- DateConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Date.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| DateConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Date.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -201,7 +198,7 @@ impl DateConstructor {
// 7. Set O.[[DateValue]] to dv.
// 8. Return O.
Ok(
- ordinary_create_from_constructor_of(vm, realm, new_target, Intrinsics::date_prototype, |prototype| {
+ ordinary_create_from_constructor_of(vm, realm, new_target, Intrinsics::date_prototype, |_, prototype| {
Date::new(vm, date_value, prototype)
})?
.upcast(),
diff --git a/Libraries/LibJS/Rust/src/runtime/date_prototype.rs b/Libraries/LibJS/Rust/src/runtime/date_prototype.rs
index d9eb1e54244..43b58ab362d 100644
--- a/Libraries/LibJS/Rust/src/runtime/date_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/date_prototype.rs
@@ -105,17 +105,14 @@ fn argument_or_empty(vm: &Vm, index: usize) -> ThrowCompletionOr<Option<f64>> {
impl DatePrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<DatePrototype> {
- realm.create_object(
- vm,
- DatePrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| DatePrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/declarative_environment.rs b/Libraries/LibJS/Rust/src/runtime/declarative_environment.rs
index 060d572d01d..d08087b11c2 100644
--- a/Libraries/LibJS/Rust/src/runtime/declarative_environment.rs
+++ b/Libraries/LibJS/Rust/src/runtime/declarative_environment.rs
@@ -233,11 +233,11 @@ pub fn allocate_environment<T: GcCell>(
) -> Gc<T> {
let heap = vm.heap();
let Some(size_class) = inline_binding_size_class(binding_capacity) else {
- return heap.allocate(environment);
+ return heap.allocate(|_| environment);
};
let environment = heap.allocate_with_size_class(
heap.size_classes(T::CLASS, cell_sizes)[size_class],
- environment,
+ |_| environment,
Value::EMPTY,
);
let declarative_environment = declarative(&environment);
@@ -308,7 +308,7 @@ impl DeclarativeEnvironment {
}
pub fn create(vm: &Vm, outer_environment: Option<Gc<Environment>>) -> Gc<DeclarativeEnvironment> {
- vm.heap().allocate(Self::new(Self::CLASS, outer_environment))
+ vm.heap().allocate(|_| Self::new(Self::CLASS, outer_environment))
}
/// A new environment with room for `binding_capacity` bindings in its cell, if a size class has that much.
diff --git a/Libraries/LibJS/Rust/src/runtime/descriptor_array.rs b/Libraries/LibJS/Rust/src/runtime/descriptor_array.rs
index 477cabcf8fd..a1aeb2beb7b 100644
--- a/Libraries/LibJS/Rust/src/runtime/descriptor_array.rs
+++ b/Libraries/LibJS/Rust/src/runtime/descriptor_array.rs
@@ -133,7 +133,7 @@ impl DescriptorArray {
}
pub fn create(vm: &Vm) -> Gc<DescriptorArray> {
- vm.heap().allocate(Self::from_parts(Vec::new(), Vec::new()))
+ vm.heap().allocate(|_| Self::from_parts(Vec::new(), Vec::new()))
}
/// The first `descriptor_count` properties of `other`, in its insertion order.
@@ -157,7 +157,7 @@ impl DescriptorArray {
);
// The keys are clones of the keys `other` holds, which keeps their symbols alive while this allocates.
vm.heap()
- .allocate(Self::from_parts(entries, entry_indices_by_enum_index))
+ .allocate(|_| Self::from_parts(entries, entry_indices_by_enum_index))
}
pub fn size(&self) -> u32 {
diff --git a/Libraries/LibJS/Rust/src/runtime/disposable_resource_stack.rs b/Libraries/LibJS/Rust/src/runtime/disposable_resource_stack.rs
index ce2d47b556f..9af13add7d3 100644
--- a/Libraries/LibJS/Rust/src/runtime/disposable_resource_stack.rs
+++ b/Libraries/LibJS/Rust/src/runtime/disposable_resource_stack.rs
@@ -58,7 +58,7 @@ pub enum AsyncDisposeResourcesStep {
impl DisposableResourceStack {
pub fn create(vm: &Vm) -> Gc<DisposableResourceStack> {
- vm.heap().allocate(DisposableResourceStack {
+ vm.heap().allocate(|_| DisposableResourceStack {
header: CellHeader::for_class(Self::CLASS),
dispose_capability: GcRefCell::new(new_dispose_capability()),
async_disposal_started: Cell::new(false),
diff --git a/Libraries/LibJS/Rust/src/runtime/disposable_stack_constructor.rs b/Libraries/LibJS/Rust/src/runtime/disposable_stack_constructor.rs
index eff25c6a861..f094d61e512 100644
--- a/Libraries/LibJS/Rust/src/runtime/disposable_stack_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/disposable_stack_constructor.rs
@@ -37,17 +37,14 @@ define_native_function_class!(
impl DisposableStackConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<DisposableStackConstructor> {
- realm.create_object(
- vm,
- DisposableStackConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.DisposableStack.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| DisposableStackConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.DisposableStack.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -90,7 +87,7 @@ impl DisposableStackConstructor {
realm,
new_target,
Intrinsics::disposable_stack_prototype,
- |prototype| DisposableStack::new(vm, prototype),
+ |_, prototype| DisposableStack::new(vm, prototype),
)?;
Ok(disposable_stack.upcast())
}
diff --git a/Libraries/LibJS/Rust/src/runtime/disposable_stack_prototype.rs b/Libraries/LibJS/Rust/src/runtime/disposable_stack_prototype.rs
index 5adca7312a2..f41e5aaa662 100644
--- a/Libraries/LibJS/Rust/src/runtime/disposable_stack_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/disposable_stack_prototype.rs
@@ -51,17 +51,14 @@ fn current_realm(vm: &Vm) -> Gc<Realm> {
impl DisposableStackPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<DisposableStackPrototype> {
- realm.create_object(
- vm,
- DisposableStackPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| DisposableStackPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -253,7 +250,7 @@ impl DisposableStackPrototype {
realm,
realm.intrinsics().disposable_stack_constructor(vm).upcast(),
Intrinsics::disposable_stack_prototype,
- |prototype| DisposableStack::new(vm, prototype),
+ |_, prototype| DisposableStack::new(vm, prototype),
)?;
// 6. Set newDisposableStack.[[DisposeCapability]] to disposableStack.[[DisposeCapability]].
diff --git a/Libraries/LibJS/Rust/src/runtime/ecmascript_function_object.rs b/Libraries/LibJS/Rust/src/runtime/ecmascript_function_object.rs
index d1304d9db08..fcaeba43d11 100644
--- a/Libraries/LibJS/Rust/src/runtime/ecmascript_function_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/ecmascript_function_object.rs
@@ -157,10 +157,9 @@ impl EcmascriptFunctionObject {
prototype: Gc<Object>,
) -> Gc<EcmascriptFunctionObject> {
shared_data.note_closure_created();
- let function = allocate_object(
- vm,
- Self::new(vm, shared_data, parent_environment, private_environment, prototype),
- );
+ let function = allocate_object(vm, |_| {
+ Self::new(vm, shared_data, parent_environment, private_environment, prototype)
+ });
function.initialize(vm, realm);
function
}
diff --git a/Libraries/LibJS/Rust/src/runtime/environment_shape.rs b/Libraries/LibJS/Rust/src/runtime/environment_shape.rs
index 3b435042686..278928f6493 100644
--- a/Libraries/LibJS/Rust/src/runtime/environment_shape.rs
+++ b/Libraries/LibJS/Rust/src/runtime/environment_shape.rs
@@ -82,7 +82,7 @@ impl EnvironmentShape {
}
vm.heap()
- .allocate(Self::new(binding_names, binding_flags, binding_indices))
+ .allocate(|_| Self::new(binding_names, binding_flags, binding_indices))
}
pub fn size(&self) -> usize {
diff --git a/Libraries/LibJS/Rust/src/runtime/error.rs b/Libraries/LibJS/Rust/src/runtime/error.rs
index af05599e037..0f637d02e85 100644
--- a/Libraries/LibJS/Rust/src/runtime/error.rs
+++ b/Libraries/LibJS/Rust/src/runtime/error.rs
@@ -169,7 +169,9 @@ impl Error {
}
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<Error> {
- realm.create_object(vm, Error::new(vm, Error::CLASS, realm.intrinsics().error_prototype(vm)))
+ realm.create_object(vm, |_| {
+ Error::new(vm, Error::CLASS, realm.intrinsics().error_prototype(vm))
+ })
}
pub fn create_with_message(vm: &Vm, realm: Gc<Realm>, message: Utf16String) -> Gc<Error> {
@@ -244,7 +246,7 @@ macro_rules! define_native_errors {
}
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<$class> {
- realm.create_object(vm, $class::new(vm, realm.intrinsics().$prototype(vm)))
+ realm.create_object(vm, |_| $class::new(vm, realm.intrinsics().$prototype(vm)))
}
pub fn create_with_message(vm: &Vm, realm: Gc<Realm>, message: Utf16String) -> Gc<$class> {
diff --git a/Libraries/LibJS/Rust/src/runtime/error_constructor.rs b/Libraries/LibJS/Rust/src/runtime/error_constructor.rs
index 858244ce1d4..6dcc1913177 100644
--- a/Libraries/LibJS/Rust/src/runtime/error_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/error_constructor.rs
@@ -38,17 +38,14 @@ define_native_function_class!(
impl ErrorConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<ErrorConstructor> {
- realm.create_object(
- vm,
- ErrorConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Error.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| ErrorConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Error.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -98,7 +95,7 @@ impl ErrorConstructor {
// 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%Error.prototype%", « [[ErrorData]] »).
let prototype = get_prototype_from_constructor(vm, new_target, Intrinsics::error_prototype)?;
- let error = realm.create_object(vm, Error::new_in_constructor(vm, Error::CLASS, prototype));
+ let error = realm.create_object(vm, |_| Error::new_in_constructor(vm, Error::CLASS, prototype));
// 3. If message is not undefined, then
if !message.is_undefined() {
@@ -160,7 +157,7 @@ macro_rules! define_native_error_constructors {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<$constructor> {
realm.create_object(
vm,
- $constructor {
+ |_| $constructor {
base: NativeFunction::new_with_name(
vm,
Self::CLASS,
@@ -211,7 +208,7 @@ macro_rules! define_native_error_constructors {
// 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%NativeError.prototype%", « [[ErrorData]] »).
let prototype = get_prototype_from_constructor(vm, new_target, Intrinsics::$prototype)?;
- let error = realm.create_object(vm, $class::new_in_constructor(vm, prototype));
+ let error = realm.create_object(vm, |_| $class::new_in_constructor(vm, prototype));
// 3. If message is not undefined, then
if !message.is_undefined() {
diff --git a/Libraries/LibJS/Rust/src/runtime/error_data.rs b/Libraries/LibJS/Rust/src/runtime/error_data.rs
index 837d6be308d..98b486a4333 100644
--- a/Libraries/LibJS/Rust/src/runtime/error_data.rs
+++ b/Libraries/LibJS/Rust/src/runtime/error_data.rs
@@ -237,7 +237,7 @@ impl ExternalMemorySize for ErrorDataCell {
impl ErrorDataCell {
/// ErrorDataCell::capture(vm): error data with the call stack of the running execution context.
pub fn capture(vm: &Vm) -> Gc<ErrorDataCell> {
- let cell = vm.heap().allocate(Self {
+ let cell = vm.heap().allocate(|_| Self {
header: CellHeader::for_class(Self::CLASS),
error_data: ErrorData::new(vm),
});
diff --git a/Libraries/LibJS/Rust/src/runtime/error_prototype.rs b/Libraries/LibJS/Rust/src/runtime/error_prototype.rs
index 03f81fb8f73..97ab44733f9 100644
--- a/Libraries/LibJS/Rust/src/runtime/error_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/error_prototype.rs
@@ -37,17 +37,14 @@ define_object_class!(ErrorPrototype, extends: [Object], methods: {
impl ErrorPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<ErrorPrototype> {
- realm.create_object(
- vm,
- ErrorPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| ErrorPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -246,7 +243,7 @@ macro_rules! define_native_error_prototypes {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<$prototype> {
realm.create_object(
vm,
- $prototype {
+ |_| $prototype {
base: Object::new_with_prototype(
vm,
Self::CLASS,
diff --git a/Libraries/LibJS/Rust/src/runtime/finalization_registry_constructor.rs b/Libraries/LibJS/Rust/src/runtime/finalization_registry_constructor.rs
index 085fd6d47ab..8c5bd575f86 100644
--- a/Libraries/LibJS/Rust/src/runtime/finalization_registry_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/finalization_registry_constructor.rs
@@ -37,17 +37,14 @@ define_native_function_class!(
impl FinalizationRegistryConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<FinalizationRegistryConstructor> {
- realm.create_object(
- vm,
- FinalizationRegistryConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.FinalizationRegistry.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| FinalizationRegistryConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.FinalizationRegistry.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -102,7 +99,7 @@ impl FinalizationRegistryConstructor {
realm,
new_target,
Intrinsics::finalization_registry_prototype,
- |prototype| FinalizationRegistry::new(vm, function_realm, cleanup_job_callback, prototype),
+ |_, prototype| FinalizationRegistry::new(vm, function_realm, cleanup_job_callback, prototype),
)?;
Ok(finalization_registry.upcast())
}
diff --git a/Libraries/LibJS/Rust/src/runtime/finalization_registry_prototype.rs b/Libraries/LibJS/Rust/src/runtime/finalization_registry_prototype.rs
index dee7900d0ca..efa6da1a2da 100644
--- a/Libraries/LibJS/Rust/src/runtime/finalization_registry_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/finalization_registry_prototype.rs
@@ -43,17 +43,14 @@ fn typed_this_finalization_registry(vm: &Vm) -> ThrowCompletionOr<Gc<Finalizatio
impl FinalizationRegistryPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<FinalizationRegistryPrototype> {
- realm.create_object(
- vm,
- FinalizationRegistryPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| FinalizationRegistryPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/function_constructor.rs b/Libraries/LibJS/Rust/src/runtime/function_constructor.rs
index 9ff353b18bd..f955b2112b0 100644
--- a/Libraries/LibJS/Rust/src/runtime/function_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/function_constructor.rs
@@ -42,17 +42,14 @@ define_native_function_class!(
impl FunctionConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<FunctionConstructor> {
- realm.create_object(
- vm,
- FunctionConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Function.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| FunctionConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Function.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/function_prototype.rs b/Libraries/LibJS/Rust/src/runtime/function_prototype.rs
index 85343ec2887..f97d8317d2e 100644
--- a/Libraries/LibJS/Rust/src/runtime/function_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/function_prototype.rs
@@ -111,7 +111,7 @@ impl FunctionPrototype {
}
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<FunctionPrototype> {
- realm.create_object(vm, Self::new(vm, realm))
+ realm.create_object(vm, |_| Self::new(vm, realm))
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/generator_function_constructor.rs b/Libraries/LibJS/Rust/src/runtime/generator_function_constructor.rs
index f6b417ad243..67470ec4750 100644
--- a/Libraries/LibJS/Rust/src/runtime/generator_function_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/generator_function_constructor.rs
@@ -35,16 +35,13 @@ define_native_function_class!(
impl GeneratorFunctionConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<GeneratorFunctionConstructor> {
- realm.create_object(
- vm,
- GeneratorFunctionConstructor {
- base: NativeFunction::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().function_constructor(vm).upcast(),
- ),
- },
- )
+ realm.create_object(vm, |_| GeneratorFunctionConstructor {
+ base: NativeFunction::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().function_constructor(vm).upcast(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/generator_function_prototype.rs b/Libraries/LibJS/Rust/src/runtime/generator_function_prototype.rs
index fea61fca09e..1564927fdf2 100644
--- a/Libraries/LibJS/Rust/src/runtime/generator_function_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/generator_function_prototype.rs
@@ -32,17 +32,14 @@ define_object_class!(GeneratorFunctionPrototype, extends: [Object], methods: {
impl GeneratorFunctionPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<GeneratorFunctionPrototype> {
- realm.create_object(
- vm,
- GeneratorFunctionPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.function_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| GeneratorFunctionPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.function_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/generator_object.rs b/Libraries/LibJS/Rust/src/runtime/generator_object.rs
index 4ef779d6934..a6163e959f3 100644
--- a/Libraries/LibJS/Rust/src/runtime/generator_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/generator_object.rs
@@ -162,8 +162,7 @@ impl GeneratorObject {
let generating_executable = generating_function.bytecode_executable(vm);
let yield_continuation = execution_context.yield_continuation.get();
- let object = realm.create_object(
- vm,
+ let object = realm.create_object(vm, |_| {
GeneratorObject::new(
vm,
Self::CLASS,
@@ -172,8 +171,8 @@ impl GeneratorObject {
execution_context,
None,
GeneratorObject::execute,
- ),
- );
+ )
+ });
object.generating_executable.set(Some(generating_executable));
object.yield_continuation.set(yield_continuation);
object
diff --git a/Libraries/LibJS/Rust/src/runtime/generator_prototype.rs b/Libraries/LibJS/Rust/src/runtime/generator_prototype.rs
index b4a775398f6..5e81c06f21e 100644
--- a/Libraries/LibJS/Rust/src/runtime/generator_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/generator_prototype.rs
@@ -39,17 +39,14 @@ const DISPLAY_NAME: &str = "Generator";
impl GeneratorPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<GeneratorPrototype> {
- realm.create_object(
- vm,
- GeneratorPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().iterator_prototype(vm),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| GeneratorPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().iterator_prototype(vm),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/global_environment.rs b/Libraries/LibJS/Rust/src/runtime/global_environment.rs
index 80a536ce275..a3ccd94d08f 100644
--- a/Libraries/LibJS/Rust/src/runtime/global_environment.rs
+++ b/Libraries/LibJS/Rust/src/runtime/global_environment.rs
@@ -83,7 +83,7 @@ impl GlobalEnvironment {
let object_record = ObjectEnvironment::create(vm, global_object, IsWithEnvironment::No, None);
let declarative_record = DeclarativeEnvironment::create(vm, None);
declarative_record.track_binding_assignments();
- vm.heap().allocate(GlobalEnvironment {
+ vm.heap().allocate(|_| GlobalEnvironment {
base: Environment::new(Self::CLASS, None, false),
object_record: Cell::new(Some(object_record)),
global_this_value: Cell::new(Some(this_value)),
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/collator_compare_function.rs b/Libraries/LibJS/Rust/src/runtime/intl/collator_compare_function.rs
index cbfd0173305..c610937568b 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/collator_compare_function.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/collator_compare_function.rs
@@ -61,13 +61,10 @@ impl Deref for CollatorCompareFunction {
impl CollatorCompareFunction {
pub fn create(vm: &Vm, realm: Gc<Realm>, collator: Gc<Collator>) -> Gc<CollatorCompareFunction> {
- realm.create_object(
- vm,
- CollatorCompareFunction {
- base: NativeFunction::new_with_prototype(vm, Self::CLASS, realm.function_prototype()),
- collator: Cell::new(collator),
- },
- )
+ realm.create_object(vm, |_| CollatorCompareFunction {
+ base: NativeFunction::new_with_prototype(vm, Self::CLASS, realm.function_prototype()),
+ collator: Cell::new(collator),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/collator_constructor.rs b/Libraries/LibJS/Rust/src/runtime/intl/collator_constructor.rs
index 4e0a33a6dc8..cc2fb6b1faf 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/collator_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/collator_constructor.rs
@@ -43,17 +43,14 @@ define_native_function_class!(
impl CollatorConstructor {
// 10.1 The Intl.Collator Constructor, https://tc39.es/ecma402/#sec-the-intl-collator-constructor
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<CollatorConstructor> {
- realm.create_object(
- vm,
- CollatorConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Collator.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| CollatorConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Collator.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -104,7 +101,7 @@ impl CollatorConstructor {
realm,
new_target,
Intrinsics::intl_collator_prototype,
- |prototype| Collator::new(vm, prototype),
+ |_, prototype| Collator::new(vm, prototype),
)?;
// 4. NOTE: The source of locale data for ResolveOptions depends upon the "usage" property of options, but the following
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/collator_prototype.rs b/Libraries/LibJS/Rust/src/runtime/intl/collator_prototype.rs
index b8d6b91df9b..1dc99b73227 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/collator_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/collator_prototype.rs
@@ -40,17 +40,14 @@ fn typed_this_collator(vm: &Vm) -> ThrowCompletionOr<Gc<Collator>> {
impl CollatorPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<CollatorPrototype> {
- realm.create_object(
- vm,
- CollatorPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| CollatorPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/date_time_format_constructor.rs b/Libraries/LibJS/Rust/src/runtime/intl/date_time_format_constructor.rs
index 69a3ca898ba..d1cbaf4a736 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/date_time_format_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/date_time_format_constructor.rs
@@ -59,17 +59,14 @@ define_native_function_class!(
impl DateTimeFormatConstructor {
// 11.1 The Intl.DateTimeFormat Constructor, https://tc39.es/ecma402/#sec-intl-datetimeformat-constructor
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<DateTimeFormatConstructor> {
- realm.create_object(
- vm,
- DateTimeFormatConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.DateTimeFormat.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| DateTimeFormatConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.DateTimeFormat.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -242,7 +239,7 @@ pub fn create_date_time_format(
realm,
new_target,
Intrinsics::intl_date_time_format_prototype,
- |prototype| DateTimeFormat::new(vm, prototype),
+ |_, prototype| DateTimeFormat::new(vm, prototype),
)?;
// 2. Let hour12 be undefined.
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/date_time_format_function.rs b/Libraries/LibJS/Rust/src/runtime/intl/date_time_format_function.rs
index 425a12175b8..f18cd82a9db 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/date_time_format_function.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/date_time_format_function.rs
@@ -65,13 +65,10 @@ impl DateTimeFormatFunction {
// 11.5.4 DateTime Format Functions, https://tc39.es/ecma402/#sec-datetime-format-functions
// 15.6.3 DateTime Format Functions, https://tc39.es/proposal-temporal/#sec-datetime-format-functions
pub fn create(vm: &Vm, realm: Gc<Realm>, date_time_format: Gc<DateTimeFormat>) -> Gc<DateTimeFormatFunction> {
- realm.create_object(
- vm,
- DateTimeFormatFunction {
- base: NativeFunction::new_with_prototype(vm, Self::CLASS, realm.function_prototype()),
- date_time_format: Cell::new(date_time_format),
- },
- )
+ realm.create_object(vm, |_| DateTimeFormatFunction {
+ base: NativeFunction::new_with_prototype(vm, Self::CLASS, realm.function_prototype()),
+ date_time_format: Cell::new(date_time_format),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/date_time_format_prototype.rs b/Libraries/LibJS/Rust/src/runtime/intl/date_time_format_prototype.rs
index d14640f8669..1745fcd20d1 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/date_time_format_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/date_time_format_prototype.rs
@@ -85,17 +85,14 @@ fn unwrapped_this_date_time_format(vm: &Vm) -> ThrowCompletionOr<Gc<DateTimeForm
impl DateTimeFormatPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<DateTimeFormatPrototype> {
- realm.create_object(
- vm,
- DateTimeFormatPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| DateTimeFormatPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/display_names_constructor.rs b/Libraries/LibJS/Rust/src/runtime/intl/display_names_constructor.rs
index ba97829ffb9..93ea6d8047c 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/display_names_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/display_names_constructor.rs
@@ -41,17 +41,14 @@ define_native_function_class!(
impl DisplayNamesConstructor {
// 12.1 The Intl.DisplayNames Constructor, https://tc39.es/ecma402/#sec-intl-displaynames-constructor
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<DisplayNamesConstructor> {
- realm.create_object(
- vm,
- DisplayNamesConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.DisplayNames.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| DisplayNamesConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.DisplayNames.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -105,7 +102,7 @@ impl DisplayNamesConstructor {
realm,
new_target,
Intrinsics::intl_display_names_prototype,
- |prototype| DisplayNames::new(vm, prototype),
+ |_, prototype| DisplayNames::new(vm, prototype),
)?;
// 3. Let optionsResolution be ? ResolveOptions(%Intl.DisplayNames%, %Intl.DisplayNames%.[[LocaleData]], locales, options, « REQUIRE-OPTIONS »).
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/display_names_prototype.rs b/Libraries/LibJS/Rust/src/runtime/intl/display_names_prototype.rs
index 7d1567938b6..f5bca5ddeab 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/display_names_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/display_names_prototype.rs
@@ -41,17 +41,14 @@ fn typed_this_display_names(vm: &Vm) -> ThrowCompletionOr<Gc<DisplayNames>> {
impl DisplayNamesPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<DisplayNamesPrototype> {
- realm.create_object(
- vm,
- DisplayNamesPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| DisplayNamesPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/duration_format_constructor.rs b/Libraries/LibJS/Rust/src/runtime/intl/duration_format_constructor.rs
index 5f740c5d1bb..a194ac707e9 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/duration_format_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/duration_format_constructor.rs
@@ -46,17 +46,14 @@ define_native_function_class!(
impl DurationFormatConstructor {
// 13.1 The Intl.DurationFormat Constructor, https://tc39.es/ecma402/#sec-intl-durationformat-constructor
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<DurationFormatConstructor> {
- realm.create_object(
- vm,
- DurationFormatConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.DurationFormat.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| DurationFormatConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.DurationFormat.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -109,7 +106,7 @@ impl DurationFormatConstructor {
realm,
new_target,
Intrinsics::intl_duration_format_prototype,
- |prototype| DurationFormat::new(vm, prototype),
+ |_, prototype| DurationFormat::new(vm, prototype),
)?;
// 3. Let optionsResolution be ? ResolveOptions(%Intl.DurationFormat%, %Intl.DurationFormat%.[[LocaleData]], locales, options).
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/duration_format_prototype.rs b/Libraries/LibJS/Rust/src/runtime/intl/duration_format_prototype.rs
index c51dc960a98..98e8384524b 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/duration_format_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/duration_format_prototype.rs
@@ -44,17 +44,14 @@ fn typed_this_duration_format(vm: &Vm) -> ThrowCompletionOr<Gc<DurationFormat>>
impl DurationFormatPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<DurationFormatPrototype> {
- realm.create_object(
- vm,
- DurationFormatPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| DurationFormatPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/intl.rs b/Libraries/LibJS/Rust/src/runtime/intl/intl.rs
index 03abb95c97b..f7666624221 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/intl.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/intl.rs
@@ -46,24 +46,21 @@ define_object_class!(Intl, extends: [Object], methods: {
impl Intl {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<Intl> {
- realm.create_object(
- vm,
- Intl {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- // The Intl object has a [[FallbackSymbol]] internal slot, which is a new %Symbol% in the current realm
- // with the [[Description]] "IntlLegacyConstructedSymbol".
- fallback_symbol: Symbol::create(
- vm,
- Some(Utf16String::from_utf8("IntlLegacyConstructedSymbol")),
- SymbolKind::Unique,
- ),
- },
- )
+ realm.create_object(vm, |_| Intl {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ // The Intl object has a [[FallbackSymbol]] internal slot, which is a new %Symbol% in the current realm
+ // with the [[Description]] "IntlLegacyConstructedSymbol".
+ fallback_symbol: Symbol::create(
+ vm,
+ Some(Utf16String::from_utf8("IntlLegacyConstructedSymbol")),
+ SymbolKind::Unique,
+ ),
+ })
}
/// %Intl%.[[FallbackSymbol]] of the given realm.
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/list_format_constructor.rs b/Libraries/LibJS/Rust/src/runtime/intl/list_format_constructor.rs
index 8405f5f5720..52695c5a3f5 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/list_format_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/list_format_constructor.rs
@@ -43,17 +43,14 @@ define_native_function_class!(
impl ListFormatConstructor {
// 14.1 The Intl.ListFormat Constructor, https://tc39.es/ecma402/#sec-intl-listformat-constructor
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<ListFormatConstructor> {
- realm.create_object(
- vm,
- ListFormatConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.ListFormat.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| ListFormatConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.ListFormat.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -107,7 +104,7 @@ impl ListFormatConstructor {
realm,
new_target,
Intrinsics::intl_list_format_prototype,
- |prototype| ListFormat::new(vm, prototype),
+ |_, prototype| ListFormat::new(vm, prototype),
)?;
// 3. Let optionsResolution be ? ResolveOptions(%Intl.ListFormat%, %Intl.ListFormat%.[[LocaleData]], locales, options).
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/list_format_prototype.rs b/Libraries/LibJS/Rust/src/runtime/intl/list_format_prototype.rs
index 36aa408ca3b..854c2597a1d 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/list_format_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/list_format_prototype.rs
@@ -39,17 +39,14 @@ fn typed_this_list_format(vm: &Vm) -> ThrowCompletionOr<Gc<ListFormat>> {
impl ListFormatPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<ListFormatPrototype> {
- realm.create_object(
- vm,
- ListFormatPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| ListFormatPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/locale.rs b/Libraries/LibJS/Rust/src/runtime/intl/locale.rs
index afb491efbce..a4007698887 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/locale.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/locale.rs
@@ -75,7 +75,7 @@ impl Locale {
}
pub fn create(vm: &Vm, realm: Gc<Realm>, source_locale: Gc<Locale>, locale_tag: Utf16String) -> Gc<Locale> {
- let locale = realm.create_object(vm, Locale::new(vm, realm.intrinsics().intl_locale_prototype(vm)));
+ let locale = realm.create_object(vm, |_| Locale::new(vm, realm.intrinsics().intl_locale_prototype(vm)));
locale.set_locale(locale_tag);
locale.calendar.replace(source_locale.calendar());
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/locale_constructor.rs b/Libraries/LibJS/Rust/src/runtime/intl/locale_constructor.rs
index 25a9bd80955..bba9696fab1 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/locale_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/locale_constructor.rs
@@ -366,17 +366,14 @@ define_native_function_class!(
impl LocaleConstructor {
// 15.1 The Intl.Locale Constructor, https://tc39.es/ecma402/#sec-intl-locale-constructor
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<LocaleConstructor> {
- realm.create_object(
- vm,
- LocaleConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Locale.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| LocaleConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Locale.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -427,7 +424,7 @@ impl LocaleConstructor {
realm,
new_target,
Intrinsics::intl_locale_prototype,
- |prototype| Locale::new(vm, prototype),
+ |_, prototype| Locale::new(vm, prototype),
)?;
// 7. If tag is not a String and tag is not an Object, throw a TypeError exception.
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/locale_prototype.rs b/Libraries/LibJS/Rust/src/runtime/intl/locale_prototype.rs
index f5156f4a700..bb8d7c37170 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/locale_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/locale_prototype.rs
@@ -55,17 +55,14 @@ fn optional_string_value(vm: &Vm, string: Option<Utf16String>) -> Value {
impl LocalePrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<LocalePrototype> {
- realm.create_object(
- vm,
- LocalePrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| LocalePrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/number_format_constructor.rs b/Libraries/LibJS/Rust/src/runtime/intl/number_format_constructor.rs
index 5d669dd7141..381386bef4b 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/number_format_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/number_format_constructor.rs
@@ -62,17 +62,14 @@ define_native_function_class!(
impl NumberFormatConstructor {
// 16.1 The Intl.NumberFormat Constructor, https://tc39.es/ecma402/#sec-intl-numberformat-constructor
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<NumberFormatConstructor> {
- realm.create_object(
- vm,
- NumberFormatConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.NumberFormat.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| NumberFormatConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.NumberFormat.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -136,7 +133,7 @@ impl NumberFormatConstructor {
realm,
new_target,
Intrinsics::intl_number_format_prototype,
- |prototype| NumberFormat::new(vm, prototype),
+ |_, prototype| NumberFormat::new(vm, prototype),
)?;
// 3. Let optionsResolution be ? ResolveOptions(%Intl.NumberFormat%, %Intl.NumberFormat%.[[LocaleData]], locales, options, « COERCE-OPTIONS »).
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/number_format_function.rs b/Libraries/LibJS/Rust/src/runtime/intl/number_format_function.rs
index bd7e62c22f2..caa1df1645c 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/number_format_function.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/number_format_function.rs
@@ -61,13 +61,10 @@ impl Deref for NumberFormatFunction {
impl NumberFormatFunction {
// 16.5.2 Number Format Functions, https://tc39.es/ecma402/#sec-number-format-functions
pub fn create(vm: &Vm, realm: Gc<Realm>, number_format: Gc<NumberFormat>) -> Gc<NumberFormatFunction> {
- realm.create_object(
- vm,
- NumberFormatFunction {
- base: NativeFunction::new_with_prototype(vm, Self::CLASS, realm.function_prototype()),
- number_format: Cell::new(number_format),
- },
- )
+ realm.create_object(vm, |_| NumberFormatFunction {
+ base: NativeFunction::new_with_prototype(vm, Self::CLASS, realm.function_prototype()),
+ number_format: Cell::new(number_format),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/number_format_prototype.rs b/Libraries/LibJS/Rust/src/runtime/intl/number_format_prototype.rs
index 33973df7b8c..e2e3a88e0ed 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/number_format_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/number_format_prototype.rs
@@ -83,17 +83,14 @@ fn unwrapped_this_number_format(vm: &Vm) -> ThrowCompletionOr<Gc<NumberFormat>>
impl NumberFormatPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<NumberFormatPrototype> {
- realm.create_object(
- vm,
- NumberFormatPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| NumberFormatPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/plural_rules_constructor.rs b/Libraries/LibJS/Rust/src/runtime/intl/plural_rules_constructor.rs
index 2582684dc19..7618dfffdb7 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/plural_rules_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/plural_rules_constructor.rs
@@ -44,17 +44,14 @@ define_native_function_class!(
impl PluralRulesConstructor {
// 17.1 The Intl.PluralRules Constructor, https://tc39.es/ecma402/#sec-intl-pluralrules-constructor
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<PluralRulesConstructor> {
- realm.create_object(
- vm,
- PluralRulesConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.PluralRules.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| PluralRulesConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.PluralRules.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -107,7 +104,7 @@ impl PluralRulesConstructor {
realm,
new_target,
Intrinsics::intl_plural_rules_prototype,
- |prototype| PluralRules::new(vm, prototype),
+ |_, prototype| PluralRules::new(vm, prototype),
)?;
// 3. Let optionsResolution be ? ResolveOptions(%Intl.PluralRules%, %Intl.PluralRules%.[[LocaleData]], locales, options, « COERCE-OPTIONS »).
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/plural_rules_prototype.rs b/Libraries/LibJS/Rust/src/runtime/intl/plural_rules_prototype.rs
index 6b9b2b73a75..dae6514775e 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/plural_rules_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/plural_rules_prototype.rs
@@ -45,17 +45,14 @@ fn typed_this_plural_rules(vm: &Vm) -> ThrowCompletionOr<Gc<PluralRules>> {
impl PluralRulesPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<PluralRulesPrototype> {
- realm.create_object(
- vm,
- PluralRulesPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| PluralRulesPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/relative_time_format_constructor.rs b/Libraries/LibJS/Rust/src/runtime/intl/relative_time_format_constructor.rs
index 94f4541a674..28c5f1a87e9 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/relative_time_format_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/relative_time_format_constructor.rs
@@ -43,17 +43,14 @@ define_native_function_class!(
impl RelativeTimeFormatConstructor {
// 18.1 The Intl.RelativeTimeFormat Constructor, https://tc39.es/ecma402/#sec-intl-relativetimeformat-constructor
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<RelativeTimeFormatConstructor> {
- realm.create_object(
- vm,
- RelativeTimeFormatConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.RelativeTimeFormat.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| RelativeTimeFormatConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.RelativeTimeFormat.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -106,7 +103,7 @@ impl RelativeTimeFormatConstructor {
realm,
new_target,
Intrinsics::intl_relative_time_format_prototype,
- |prototype| RelativeTimeFormat::new(vm, prototype),
+ |_, prototype| RelativeTimeFormat::new(vm, prototype),
)?;
// 3. Let optionsResolution be ? ResolveOptions(%Intl.RelativeTimeFormat%, %Intl.RelativeTimeFormat%.[[LocaleData]], locales, options, « COERCE-OPTIONS »).
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/relative_time_format_prototype.rs b/Libraries/LibJS/Rust/src/runtime/intl/relative_time_format_prototype.rs
index fe90ff81f60..0abb5c2e53c 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/relative_time_format_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/relative_time_format_prototype.rs
@@ -42,17 +42,14 @@ fn typed_this_relative_time_format(vm: &Vm) -> ThrowCompletionOr<Gc<RelativeTime
impl RelativeTimeFormatPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<RelativeTimeFormatPrototype> {
- realm.create_object(
- vm,
- RelativeTimeFormatPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| RelativeTimeFormatPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/segment_iterator.rs b/Libraries/LibJS/Rust/src/runtime/intl/segment_iterator.rs
index a8a955d3903..799b20c49a2 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/segment_iterator.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/segment_iterator.rs
@@ -66,20 +66,17 @@ impl SegmentIterator {
// 5. Set iterator.[[IteratedStringNextSegmentCodeUnitIndex]] to 0.
// 6. Return iterator.
segmenter.set_segmented_text(Utf16View::of_string(&string));
- realm.create_object(
- vm,
- SegmentIterator {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().intl_segment_iterator_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- iterating_segmenter: RefCell::new(Some(segmenter)),
- iterated_string: string,
- segments: Cell::new(segments),
- },
- )
+ realm.create_object(vm, |_| SegmentIterator {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().intl_segment_iterator_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ iterating_segmenter: RefCell::new(Some(segmenter)),
+ iterated_string: string,
+ segments: Cell::new(segments),
+ })
}
pub fn iterating_segmenter(&self) -> &RefCell<Option<unicode::Segmenter>> {
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/segment_iterator_prototype.rs b/Libraries/LibJS/Rust/src/runtime/intl/segment_iterator_prototype.rs
index dd100844f4b..164f52dff8c 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/segment_iterator_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/segment_iterator_prototype.rs
@@ -38,17 +38,14 @@ define_object_class!(SegmentIteratorPrototype, extends: [Object], methods: {
impl SegmentIteratorPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<SegmentIteratorPrototype> {
- realm.create_object(
- vm,
- SegmentIteratorPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().iterator_prototype(vm),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| SegmentIteratorPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().iterator_prototype(vm),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/segmenter_constructor.rs b/Libraries/LibJS/Rust/src/runtime/intl/segmenter_constructor.rs
index 1697e516616..1dfe19899f2 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/segmenter_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/segmenter_constructor.rs
@@ -43,17 +43,14 @@ define_native_function_class!(
impl SegmenterConstructor {
// 19.1 The Intl.Segmenter Constructor, https://tc39.es/ecma402/#sec-intl-segmenter-constructor
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<SegmenterConstructor> {
- realm.create_object(
- vm,
- SegmenterConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Segmenter.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| SegmenterConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Segmenter.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -106,7 +103,7 @@ impl SegmenterConstructor {
realm,
new_target,
Intrinsics::intl_segmenter_prototype,
- |prototype| Segmenter::new(vm, prototype),
+ |_, prototype| Segmenter::new(vm, prototype),
)?;
// 4. Let optionsResolution be ? ResolveOptions(%Intl.Segmenter%, %Intl.Segmenter%.[[LocaleData]], locales, options).
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/segmenter_prototype.rs b/Libraries/LibJS/Rust/src/runtime/intl/segmenter_prototype.rs
index 766ed49fc49..40fa1c747b8 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/segmenter_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/segmenter_prototype.rs
@@ -40,17 +40,14 @@ fn typed_this_segmenter(vm: &Vm) -> ThrowCompletionOr<Gc<Segmenter>> {
impl SegmenterPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<SegmenterPrototype> {
- realm.create_object(
- vm,
- SegmenterPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| SegmenterPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/segments.rs b/Libraries/LibJS/Rust/src/runtime/intl/segments.rs
index 8c92e0fac89..df5ad3ecf0e 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/segments.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/segments.rs
@@ -64,20 +64,17 @@ impl Segments {
// 5. Return segments.
let segments_string = string.utf16_string();
segmenter.set_segmented_text(Utf16View::of_string(&segments_string));
- realm.create_object(
- vm,
- Segments {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().intl_segments_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- segments_segmenter: RefCell::new(Some(segmenter)),
- segments_string_value: Cell::new(string),
- segments_string,
- },
- )
+ realm.create_object(vm, |_| Segments {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().intl_segments_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ segments_segmenter: RefCell::new(Some(segmenter)),
+ segments_string_value: Cell::new(string),
+ segments_string,
+ })
}
pub fn segments_segmenter(&self) -> &RefCell<Option<unicode::Segmenter>> {
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/segments_prototype.rs b/Libraries/LibJS/Rust/src/runtime/intl/segments_prototype.rs
index bce157fba8c..a4cb3337783 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/segments_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/segments_prototype.rs
@@ -41,17 +41,14 @@ fn typed_this_segments(vm: &Vm) -> ThrowCompletionOr<Gc<Segments>> {
impl SegmentsPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<SegmentsPrototype> {
- realm.create_object(
- vm,
- SegmentsPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| SegmentsPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/intrinsics.rs b/Libraries/LibJS/Rust/src/runtime/intrinsics.rs
index 540f2ef0a49..6be7ace31b9 100644
--- a/Libraries/LibJS/Rust/src/runtime/intrinsics.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intrinsics.rs
@@ -1086,7 +1086,7 @@ impl Intrinsics {
// 9.3.2 CreateIntrinsics ( realmRec ), https://tc39.es/ecma262/#sec-createintrinsics
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<Intrinsics> {
// 1. Set realmRec.[[Intrinsics]] to a new Record.
- let intrinsics = vm.heap().allocate(Intrinsics::new(realm));
+ let intrinsics = vm.heap().allocate(|_| Intrinsics::new(realm));
realm.set_intrinsics(intrinsics);
// 2. Set fields of realmRec.[[Intrinsics]] with the values listed in Table 6.
@@ -1130,10 +1130,10 @@ impl Intrinsics {
// These are done first since other prototypes depend on their presence.
self.empty_object_shape.set(Some(Shape::create(vm, realm)));
- let object_prototype = allocate_object(vm, ObjectPrototype::new(vm, realm));
+ let object_prototype = allocate_object(vm, |_| ObjectPrototype::new(vm, realm));
self.object_prototype.set(Some(object_prototype.upcast()));
object_prototype.convert_to_prototype_if_needed(vm);
- let function_prototype = allocate_object(vm, FunctionPrototype::new(vm, realm));
+ let function_prototype = allocate_object(vm, |_| FunctionPrototype::new(vm, realm));
self.function_prototype.set(Some(function_prototype.upcast()));
function_prototype.convert_to_prototype_if_needed(vm);
let object_prototype: Gc<Object> = object_prototype.upcast();
diff --git a/Libraries/LibJS/Rust/src/runtime/iterator.rs b/Libraries/LibJS/Rust/src/runtime/iterator.rs
index b703598771d..b6b708a48c7 100644
--- a/Libraries/LibJS/Rust/src/runtime/iterator.rs
+++ b/Libraries/LibJS/Rust/src/runtime/iterator.rs
@@ -100,7 +100,7 @@ impl Deref for IteratorRecord {
impl IteratorRecord {
pub fn create(vm: &Vm, iterator: Option<Gc<Object>>, next_method: Value, done: bool) -> Gc<IteratorRecord> {
- vm.heap().allocate(IteratorRecord {
+ vm.heap().allocate(|_| IteratorRecord {
header: CellHeader::for_class(Self::CLASS),
record: IteratorRecordImpl::new(iterator, next_method, done),
})
@@ -135,13 +135,10 @@ impl Deref for Iterator {
impl Iterator {
pub fn create(vm: &Vm, prototype: Gc<Object>, iterated: Gc<IteratorRecord>) -> Gc<Iterator> {
- allocate_object(
- vm,
- Iterator {
- base: Object::new_with_prototype(vm, Self::CLASS, prototype, MayInterfereWithIndexedPropertyAccess::No),
- iterated: Cell::new(iterated),
- },
- )
+ allocate_object(vm, |_| Iterator {
+ base: Object::new_with_prototype(vm, Self::CLASS, prototype, MayInterfereWithIndexedPropertyAccess::No),
+ iterated: Cell::new(iterated),
+ })
}
pub fn iterated(&self) -> Gc<IteratorRecord> {
diff --git a/Libraries/LibJS/Rust/src/runtime/iterator_constructor.rs b/Libraries/LibJS/Rust/src/runtime/iterator_constructor.rs
index 1f511770f56..0d19bb8b954 100644
--- a/Libraries/LibJS/Rust/src/runtime/iterator_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/iterator_constructor.rs
@@ -57,17 +57,14 @@ fn current_realm(vm: &Vm) -> Gc<Realm> {
impl IteratorConstructor {
// 27.1.3.1 The Iterator Constructor, https://tc39.es/ecma262/#sec-iterator-constructor
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<IteratorConstructor> {
- realm.create_object(
- vm,
- IteratorConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Iterator.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| IteratorConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Iterator.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -483,7 +480,7 @@ impl Finalize for ConcatIterator {
impl ConcatIterator {
fn create(vm: &Vm) -> Gc<ConcatIterator> {
- vm.heap().allocate(ConcatIterator {
+ vm.heap().allocate(|_| ConcatIterator {
header: CellHeader::for_class(Self::CLASS),
iterables: GcRefCell::new(Vec::new()),
index: Cell::new(0),
@@ -611,7 +608,7 @@ impl Finalize for ZipIterator {
impl ZipIterator {
fn create(vm: &Vm, realm: Gc<Realm>, mode: ZipMode) -> Gc<ZipIterator> {
- vm.heap().allocate(ZipIterator {
+ vm.heap().allocate(|_| ZipIterator {
header: CellHeader::for_class(Self::CLASS),
realm,
mode,
diff --git a/Libraries/LibJS/Rust/src/runtime/iterator_helper.rs b/Libraries/LibJS/Rust/src/runtime/iterator_helper.rs
index aa9318ed144..891b1ca52e1 100644
--- a/Libraries/LibJS/Rust/src/runtime/iterator_helper.rs
+++ b/Libraries/LibJS/Rust/src/runtime/iterator_helper.rs
@@ -139,23 +139,20 @@ impl IteratorHelper {
.running_execution_context_if_any()
.expect("an iterator helper is created by a running built-in")
.copy();
- let iterator = realm.create_object(
- vm,
- IteratorHelper {
- base: GeneratorObject::new(
- vm,
- Self::CLASS,
- realm,
- Some(prototype),
- execution_context,
- Some(ITERATOR_HELPER_BRAND),
- IteratorHelper::execute,
- ),
- underlying_iterators: GcRefCell::new(Vec::new()),
- closure: Cell::new(closure),
- counter: Cell::new(0.0),
- },
- );
+ let iterator = realm.create_object(vm, |_| IteratorHelper {
+ base: GeneratorObject::new(
+ vm,
+ Self::CLASS,
+ realm,
+ Some(prototype),
+ execution_context,
+ Some(ITERATOR_HELPER_BRAND),
+ IteratorHelper::execute,
+ ),
+ underlying_iterators: GcRefCell::new(Vec::new()),
+ closure: Cell::new(closure),
+ counter: Cell::new(0.0),
+ });
*iterator.underlying_iterators.borrow_mut(vm) = underlying_iterators.to_vec();
iterator
}
diff --git a/Libraries/LibJS/Rust/src/runtime/iterator_helper_prototype.rs b/Libraries/LibJS/Rust/src/runtime/iterator_helper_prototype.rs
index 9087a0e88ed..9c18a9f7e3b 100644
--- a/Libraries/LibJS/Rust/src/runtime/iterator_helper_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/iterator_helper_prototype.rs
@@ -41,17 +41,14 @@ const DISPLAY_NAME: &str = "IteratorHelper";
impl IteratorHelperPrototype {
// 27.1.2.1 The %IteratorHelperPrototype% Object, https://tc39.es/ecma262/#sec-%iteratorhelperprototype%-object
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<IteratorHelperPrototype> {
- realm.create_object(
- vm,
- IteratorHelperPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().iterator_prototype(vm),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| IteratorHelperPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().iterator_prototype(vm),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/iterator_prototype.rs b/Libraries/LibJS/Rust/src/runtime/iterator_prototype.rs
index e6225c19cbf..33a5f0a70d2 100644
--- a/Libraries/LibJS/Rust/src/runtime/iterator_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/iterator_prototype.rs
@@ -75,17 +75,14 @@ fn return_undefined() -> HelperIterationResult {
impl IteratorPrototype {
// 27.1.2 The %IteratorPrototype% Object, https://tc39.es/ecma262/#sec-%iteratorprototype%-object
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<IteratorPrototype> {
- realm.create_object(
- vm,
- IteratorPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| IteratorPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -1150,7 +1147,7 @@ define_cell!(FlatMapIterator, Other);
impl FlatMapIterator {
fn create(vm: &Vm) -> Gc<FlatMapIterator> {
- vm.heap().allocate(FlatMapIterator {
+ vm.heap().allocate(|_| FlatMapIterator {
header: CellHeader::for_class(Self::CLASS),
inner_iterator: Cell::new(None),
})
diff --git a/Libraries/LibJS/Rust/src/runtime/job_callback.rs b/Libraries/LibJS/Rust/src/runtime/job_callback.rs
index 5fec6e29dff..4ab1dbb8507 100644
--- a/Libraries/LibJS/Rust/src/runtime/job_callback.rs
+++ b/Libraries/LibJS/Rust/src/runtime/job_callback.rs
@@ -32,7 +32,7 @@ define_cell!(JobCallback, Other);
impl JobCallback {
pub fn create(vm: &Vm, callback: Gc<FunctionObject>, custom_data: ForeignCellSlot) -> Gc<JobCallback> {
- vm.heap().allocate(JobCallback {
+ vm.heap().allocate(|_| JobCallback {
header: CellHeader::for_class(Self::CLASS),
callback: Cell::new(callback),
custom_data,
diff --git a/Libraries/LibJS/Rust/src/runtime/json_object.rs b/Libraries/LibJS/Rust/src/runtime/json_object.rs
index a64c445474d..49b209c5b84 100644
--- a/Libraries/LibJS/Rust/src/runtime/json_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/json_object.rs
@@ -999,17 +999,14 @@ fn parse_simdjson_document(
impl JSONObject {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<JSONObject> {
- realm.create_object(
- vm,
- JSONObject {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| JSONObject {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/map.rs b/Libraries/LibJS/Rust/src/runtime/map.rs
index a13a8d86c51..28507e7ff28 100644
--- a/Libraries/LibJS/Rust/src/runtime/map.rs
+++ b/Libraries/LibJS/Rust/src/runtime/map.rs
@@ -145,7 +145,7 @@ impl Map {
}
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<Map> {
- realm.create_object(vm, Map::new(vm, realm.intrinsics().map_prototype(vm)))
+ realm.create_object(vm, |_| Map::new(vm, realm.intrinsics().map_prototype(vm)))
}
// 24.1.3.1 Map.prototype.clear ( ), https://tc39.es/ecma262/#sec-map.prototype.clear
diff --git a/Libraries/LibJS/Rust/src/runtime/map_constructor.rs b/Libraries/LibJS/Rust/src/runtime/map_constructor.rs
index 184010b822f..c9a50f9006d 100644
--- a/Libraries/LibJS/Rust/src/runtime/map_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/map_constructor.rs
@@ -122,17 +122,14 @@ impl<'vm> KeyedGroups<'vm> for ValueKeyedGroups<'vm> {
impl MapConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<MapConstructor> {
- realm.create_object(
- vm,
- MapConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Map.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| MapConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Map.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -183,9 +180,10 @@ impl MapConstructor {
fn construct(_: &NativeFunction, vm: &Vm, new_target: Gc<FunctionObject>) -> ThrowCompletionOr<Gc<Object>> {
let realm = vm.current_realm().expect("a constructor runs in a realm");
- let map = ordinary_create_from_constructor_of(vm, realm, new_target, Intrinsics::map_prototype, |prototype| {
- Map::new(vm, prototype)
- })?;
+ let map =
+ ordinary_create_from_constructor_of(vm, realm, new_target, Intrinsics::map_prototype, |_, prototype| {
+ Map::new(vm, prototype)
+ })?;
if vm.argument(0).is_nullish() {
return Ok(map.upcast());
diff --git a/Libraries/LibJS/Rust/src/runtime/map_iterator.rs b/Libraries/LibJS/Rust/src/runtime/map_iterator.rs
index 1e0fee9116a..d61fb070e86 100644
--- a/Libraries/LibJS/Rust/src/runtime/map_iterator.rs
+++ b/Libraries/LibJS/Rust/src/runtime/map_iterator.rs
@@ -72,21 +72,18 @@ define_object_class!(MapIterator, extends: [Object], methods: {
impl MapIterator {
pub fn create(vm: &Vm, realm: Gc<Realm>, map: Gc<Map>, iteration_kind: PropertyKind) -> Gc<MapIterator> {
- realm.create_object(
- vm,
- MapIterator {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().map_iterator_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- map,
- done: Cell::new(false),
- iteration_kind,
- iterator: map.begin(),
- },
- )
+ realm.create_object(vm, |_| MapIterator {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().map_iterator_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ map,
+ done: Cell::new(false),
+ iteration_kind,
+ iterator: map.begin(),
+ })
}
fn as_builtin_iterator_if_next_is_not_redefined(_: &Object, next_method: Value) -> Option<BuiltinIteratorNext> {
diff --git a/Libraries/LibJS/Rust/src/runtime/map_iterator_prototype.rs b/Libraries/LibJS/Rust/src/runtime/map_iterator_prototype.rs
index a56a2e52ea9..6f4f3b20d4f 100644
--- a/Libraries/LibJS/Rust/src/runtime/map_iterator_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/map_iterator_prototype.rs
@@ -38,17 +38,14 @@ define_object_class!(MapIteratorPrototype, extends: [Object], methods: {
impl MapIteratorPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<MapIteratorPrototype> {
- realm.create_object(
- vm,
- MapIteratorPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().iterator_prototype(vm),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| MapIteratorPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().iterator_prototype(vm),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/map_prototype.rs b/Libraries/LibJS/Rust/src/runtime/map_prototype.rs
index 82301f24fc0..fbf0c004b49 100644
--- a/Libraries/LibJS/Rust/src/runtime/map_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/map_prototype.rs
@@ -59,18 +59,15 @@ fn typed_this_map(vm: &Vm) -> ThrowCompletionOr<Gc<Map>> {
impl MapPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<MapPrototype> {
- realm.create_object(
- vm,
- MapPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- entries_function: Cell::new(None),
- },
- )
+ realm.create_object(vm, |_| MapPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ entries_function: Cell::new(None),
+ })
}
/// The original Map.prototype.entries, which is also the original Map.prototype[%Symbol.iterator%].
diff --git a/Libraries/LibJS/Rust/src/runtime/math_object.rs b/Libraries/LibJS/Rust/src/runtime/math_object.rs
index 17df8c65a96..a7d053218ac 100644
--- a/Libraries/LibJS/Rust/src/runtime/math_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/math_object.rs
@@ -119,17 +119,14 @@ pub(crate) static IMUL_FUNCTION: RawNativeFunctionPointer = raw_native!(MathObje
impl MathObject {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<MathObject> {
- realm.create_object(
- vm,
- MathObject {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| MathObject {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/module.rs b/Libraries/LibJS/Rust/src/runtime/module.rs
index 4487c1d1e18..00e09c528f5 100644
--- a/Libraries/LibJS/Rust/src/runtime/module.rs
+++ b/Libraries/LibJS/Rust/src/runtime/module.rs
@@ -133,7 +133,7 @@ impl GraphLoadingState {
pending_module_count: usize,
host_defined: ForeignCellSlot,
) -> Gc<GraphLoadingState> {
- vm.heap().allocate(GraphLoadingState {
+ vm.heap().allocate(|_| GraphLoadingState {
header: CellHeader::for_class(Self::CLASS),
promise_capability,
is_loading: Cell::new(is_loading),
diff --git a/Libraries/LibJS/Rust/src/runtime/module_environment.rs b/Libraries/LibJS/Rust/src/runtime/module_environment.rs
index a2ea0fb5546..073e69d7380 100644
--- a/Libraries/LibJS/Rust/src/runtime/module_environment.rs
+++ b/Libraries/LibJS/Rust/src/runtime/module_environment.rs
@@ -95,7 +95,7 @@ fn environment_of_module(module: Gc<Module>) -> Option<Gc<Environment>> {
impl ModuleEnvironment {
// 9.1.2.6 NewModuleEnvironment ( E ), https://tc39.es/ecma262/#sec-newmoduleenvironment
pub fn create(vm: &Vm, outer_environment: Option<Gc<Environment>>) -> Gc<ModuleEnvironment> {
- vm.heap().allocate(ModuleEnvironment {
+ vm.heap().allocate(|_| ModuleEnvironment {
base: DeclarativeEnvironment::new(Self::CLASS, outer_environment),
indirect_bindings: GcRefCell::default(),
})
diff --git a/Libraries/LibJS/Rust/src/runtime/module_namespace_object.rs b/Libraries/LibJS/Rust/src/runtime/module_namespace_object.rs
index c6f88e071fa..e45a6c99c32 100644
--- a/Libraries/LibJS/Rust/src/runtime/module_namespace_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/module_namespace_object.rs
@@ -96,19 +96,16 @@ impl ModuleNamespaceObject {
}
});
- realm.create_object(
- vm,
- ModuleNamespaceObject {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::Yes,
- ),
- module,
- exports,
- },
- )
+ realm.create_object(vm, |_| ModuleNamespaceObject {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::Yes,
+ ),
+ module,
+ exports,
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/native_function.rs b/Libraries/LibJS/Rust/src/runtime/native_function.rs
index 52e077ccf2a..6e96a6f95fb 100644
--- a/Libraries/LibJS/Rust/src/runtime/native_function.rs
+++ b/Libraries/LibJS/Rust/src/runtime/native_function.rs
@@ -513,13 +513,10 @@ impl CapturingNativeFunction {
"a native function captures its state through its captures, not its behaviour"
);
};
- let function = allocate_object(
- vm,
- CapturingNativeFunction {
- base,
- native_function: OnceCell::new(),
- },
- );
+ let function = allocate_object(vm, |_| CapturingNativeFunction {
+ base,
+ native_function: OnceCell::new(),
+ });
// The captures stay on the stack, where the collector finds them, until the function that keeps them alive
// exists. Nothing allocates from the heap between allocating the function and storing them in it.
let behaviour: Box<dyn NativeFunctionBehaviour> = Box::new(CapturingBehaviour { captures, behaviour });
@@ -754,10 +751,9 @@ impl RawNativeFunction {
let realm = realm.unwrap_or_else(|| vm.current_realm().expect("there is a current realm"));
let prototype = realm.function_prototype();
- let function = allocate_object(
- vm,
- Self::new_with_realm(vm, Self::CLASS, behaviour, Some(prototype), realm, builtin),
- );
+ let function = allocate_object(vm, |_| {
+ Self::new_with_realm(vm, Self::CLASS, behaviour, Some(prototype), realm, builtin)
+ });
function.unsafe_set_shape(realm.native_function_shape());
function.initialize_direct(realm.native_function_length_offset(), Value::from_i32(length));
let function_name = function.make_function_name(vm, &ClassElementName::PropertyKey(name.clone()), prefix);
@@ -771,10 +767,9 @@ impl RawNativeFunction {
name: &Utf16FlyString,
function: RawNativeFunctionPointer,
) -> Gc<RawNativeFunction> {
- allocate_object(
- vm,
- Self::new_with_name(vm, Self::CLASS, name.clone(), function, realm.function_prototype()),
- )
+ allocate_object(vm, |_| {
+ Self::new_with_name(vm, Self::CLASS, name.clone(), function, realm.function_prototype())
+ })
}
fn call(function: &NativeFunction, vm: &Vm) -> ThrowCompletionOr<Value> {
@@ -832,10 +827,9 @@ impl DirectGetterFunction {
configuration: DirectGetterConfiguration,
prefix: Option<&str>,
) -> Gc<DirectGetterFunction> {
- let function = allocate_object(
- vm,
- Self::new(vm, behaviour, realm.function_prototype(), realm, configuration),
- );
+ let function = allocate_object(vm, |_| {
+ Self::new(vm, behaviour, realm.function_prototype(), realm, configuration)
+ });
function.unsafe_set_shape(realm.native_function_shape());
function.initialize_direct(realm.native_function_length_offset(), Value::from_i32(length));
let function_name = function.make_function_name(vm, &ClassElementName::PropertyKey(name.clone()), prefix);
diff --git a/Libraries/LibJS/Rust/src/runtime/native_javascript_backed_function.rs b/Libraries/LibJS/Rust/src/runtime/native_javascript_backed_function.rs
index 2c7bf14565b..b848deb35a7 100644
--- a/Libraries/LibJS/Rust/src/runtime/native_javascript_backed_function.rs
+++ b/Libraries/LibJS/Rust/src/runtime/native_javascript_backed_function.rs
@@ -98,13 +98,10 @@ impl NativeJavaScriptBackedFunction {
// 7. Set func.[[Extensible]] to true.
// 8. Set func.[[Realm]] to realm.
// 9. Set func.[[InitialName]] to null.
- let function = realm.create_object(
- vm,
- NativeJavaScriptBackedFunction {
- base: NativeFunction::new_with_name(vm, Self::CLASS, shared_data.name(), prototype),
- shared_function_instance_data: Cell::new(shared_data),
- },
- );
+ let function = realm.create_object(vm, |_| NativeJavaScriptBackedFunction {
+ base: NativeFunction::new_with_name(vm, Self::CLASS, shared_data.name(), prototype),
+ shared_function_instance_data: Cell::new(shared_data),
+ });
function.unsafe_set_shape(realm.native_function_shape());
diff --git a/Libraries/LibJS/Rust/src/runtime/number_constructor.rs b/Libraries/LibJS/Rust/src/runtime/number_constructor.rs
index 6a5fc7c8c67..2f1c68abb05 100644
--- a/Libraries/LibJS/Rust/src/runtime/number_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/number_constructor.rs
@@ -64,17 +64,14 @@ fn get_value_from_constructor_argument(vm: &Vm) -> ThrowCompletionOr<Value> {
impl NumberConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<NumberConstructor> {
- realm.create_object(
- vm,
- NumberConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Number.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| NumberConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Number.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -177,10 +174,9 @@ impl NumberConstructor {
// 6. Return O.
let prototype = get_prototype_from_constructor(vm, new_target, Intrinsics::number_prototype)?;
Ok(realm
- .create_object(
- vm,
- NumberObject::new(vm, NumberObject::CLASS, number.as_f64(), prototype),
- )
+ .create_object(vm, |_| {
+ NumberObject::new(vm, NumberObject::CLASS, number.as_f64(), prototype)
+ })
.upcast())
}
diff --git a/Libraries/LibJS/Rust/src/runtime/number_object.rs b/Libraries/LibJS/Rust/src/runtime/number_object.rs
index 4a2a0c918d4..08a690b1c05 100644
--- a/Libraries/LibJS/Rust/src/runtime/number_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/number_object.rs
@@ -44,10 +44,9 @@ impl NumberObject {
}
pub fn create(vm: &Vm, realm: Gc<Realm>, value: f64) -> Gc<NumberObject> {
- realm.create_object(
- vm,
- NumberObject::new(vm, Self::CLASS, value, realm.intrinsics().number_prototype(vm)),
- )
+ realm.create_object(vm, |_| {
+ NumberObject::new(vm, Self::CLASS, value, realm.intrinsics().number_prototype(vm))
+ })
}
pub fn number(&self) -> f64 {
diff --git a/Libraries/LibJS/Rust/src/runtime/number_prototype.rs b/Libraries/LibJS/Rust/src/runtime/number_prototype.rs
index 5391c5c4cb2..0f17b6be466 100644
--- a/Libraries/LibJS/Rust/src/runtime/number_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/number_prototype.rs
@@ -65,12 +65,9 @@ fn number_to_string_value(vm: &Vm, number_value: Value) -> Value {
impl NumberPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<NumberPrototype> {
- realm.create_object(
- vm,
- NumberPrototype {
- base: NumberObject::new(vm, Self::CLASS, 0.0, realm.object_prototype()),
- },
- )
+ realm.create_object(vm, |_| NumberPrototype {
+ base: NumberObject::new(vm, Self::CLASS, 0.0, realm.object_prototype()),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/object.rs b/Libraries/LibJS/Rust/src/runtime/object.rs
index 54b5220b4d8..adb1ff9a93b 100644
--- a/Libraries/LibJS/Rust/src/runtime/object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/object.rs
@@ -17,6 +17,7 @@ use crate::bytecode::executable::PropertyLookupCache;
use crate::bytecode::property_access::{Strict, put_by_property_key};
use crate::embedding::abi_types::JSRealm;
use crate::gc::class::{Class, Extends, ExternalMemorySize, GcCell, define_cell};
+use crate::gc::defer_gc::DeferGc;
use crate::gc::gc_ref_cell::GcRefCell;
use crate::gc::heap::{Heap, RuntimeClassAllocator, SizeClassAllocator};
use crate::gc::root::MarkedVec;
@@ -552,15 +553,19 @@ fn are_dense_enough(filled: usize, length: usize) -> bool {
}
pub(crate) const MAX_TRANSITIONS_BEFORE_CONVERTING_TO_DICTIONARY: u32 = 64;
-/// Moves an object into the heap and finishes what its constructor could not do before it had an address: its named
-/// properties start out in its inline storage. Every object, of any class, is allocated through this.
-pub fn allocate_object<T: GcCell + Extends<Object>>(vm: &Vm, object: T) -> Gc<T> {
- set_up_named_storage(vm.heap().allocate(object))
+/// Moves the object that `build` returns into the heap, as Heap::allocate() does, and finishes what its constructor
+/// could not do before it had an address: its named properties start out in its inline storage.
+pub fn allocate_object<T: GcCell + Extends<Object>>(vm: &Vm, build: impl FnOnce(&DeferGc<'_>) -> T) -> Gc<T> {
+ set_up_named_storage(vm.heap().allocate(build))
}
/// allocate_object() for an object whose class was derived at run time, from that class's allocator.
-pub fn allocate_object_in<T: GcCell + Extends<Object>>(vm: &Vm, allocator: RuntimeClassAllocator, object: T) -> Gc<T> {
- set_up_named_storage(vm.heap().allocate_in(allocator, object))
+pub fn allocate_object_in<T: GcCell + Extends<Object>>(
+ vm: &Vm,
+ allocator: RuntimeClassAllocator,
+ build: impl FnOnce(&DeferGc<'_>) -> T,
+) -> Gc<T> {
+ set_up_named_storage(vm.heap().allocate_in(allocator, build))
}
#[inline(always)]
@@ -673,29 +678,26 @@ impl Object {
// 10.1.12 OrdinaryObjectCreate ( proto [ , additionalInternalSlotsList ] ), https://tc39.es/ecma262/#sec-ordinaryobjectcreate
pub fn create(vm: &Vm, realm: Gc<Realm>, prototype: Option<Gc<Object>>) -> Gc<Object> {
let Some(prototype) = prototype else {
- return allocate_object(
- vm,
+ return allocate_object(vm, |_| {
Self::new_with_shape(
Self::CLASS,
realm.empty_object_shape(),
MayInterfereWithIndexedPropertyAccess::No,
- ),
- );
+ )
+ });
};
if prototype == realm.object_prototype() {
- return allocate_object(
- vm,
+ return allocate_object(vm, |_| {
Self::new_with_shape(
Self::CLASS,
realm.new_object_shape(),
MayInterfereWithIndexedPropertyAccess::No,
- ),
- );
+ )
+ });
}
- allocate_object(
- vm,
- Self::new_with_prototype(vm, Self::CLASS, prototype, MayInterfereWithIndexedPropertyAccess::No),
- )
+ allocate_object(vm, |_| {
+ Self::new_with_prototype(vm, Self::CLASS, prototype, MayInterfereWithIndexedPropertyAccess::No)
+ })
}
pub fn create_prototype(vm: &Vm, realm: Gc<Realm>, prototype: Option<Gc<Object>>) -> Gc<Object> {
@@ -703,20 +705,18 @@ impl Object {
if let Some(prototype) = prototype {
shape.set_prototype_without_transition(vm, prototype);
}
- allocate_object(
- vm,
- Self::new_with_shape(Self::CLASS, shape, MayInterfereWithIndexedPropertyAccess::No),
- )
+ allocate_object(vm, |_| {
+ Self::new_with_shape(Self::CLASS, shape, MayInterfereWithIndexedPropertyAccess::No)
+ })
}
pub fn create_with_premade_shape(vm: &Vm, shape: Gc<Shape>) -> Gc<Object> {
let property_count = shape.property_count();
// OPTIMIZATION: Objects with up to two properties, the most common ones, are in the first size class.
if property_count <= INLINE_NAMED_STORAGE_CAPACITY as u32 {
- return allocate_object(
- vm,
- Self::new_with_shape(Self::CLASS, shape, MayInterfereWithIndexedPropertyAccess::No),
- );
+ return allocate_object(vm, |_| {
+ Self::new_with_shape(Self::CLASS, shape, MayInterfereWithIndexedPropertyAccess::No)
+ });
}
Self::create_in_size_class(vm, shape, property_count)
}
@@ -749,7 +749,7 @@ impl Object {
let object = Self::new_with_shape(Self::CLASS, shape, MayInterfereWithIndexedPropertyAccess::No);
let size_class = plain_object_size_class(property_count);
if size_class == 0 {
- return allocate_object(vm, object);
+ return allocate_object(vm, |_| object);
}
object
.inline_named_capacity
@@ -757,7 +757,7 @@ impl Object {
let size_class_allocator = plain_object_size_classes(vm.heap())[size_class - 1];
set_up_named_storage(
vm.heap()
- .allocate_with_size_class(size_class_allocator, object, Value::UNDEFINED),
+ .allocate_with_size_class(size_class_allocator, |_| object, Value::UNDEFINED),
)
}
diff --git a/Libraries/LibJS/Rust/src/runtime/object_constructor.rs b/Libraries/LibJS/Rust/src/runtime/object_constructor.rs
index caf1486497a..3c567d4e0a7 100644
--- a/Libraries/LibJS/Rust/src/runtime/object_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/object_constructor.rs
@@ -48,17 +48,14 @@ define_native_function_class!(
impl ObjectConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<ObjectConstructor> {
- realm.create_object(
- vm,
- ObjectConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Object.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| ObjectConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Object.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/object_environment.rs b/Libraries/LibJS/Rust/src/runtime/object_environment.rs
index 43a608dbf6b..2a2ca6d4073 100644
--- a/Libraries/LibJS/Rust/src/runtime/object_environment.rs
+++ b/Libraries/LibJS/Rust/src/runtime/object_environment.rs
@@ -85,7 +85,7 @@ impl ObjectEnvironment {
is_with_environment: IsWithEnvironment,
outer_environment: Option<Gc<Environment>>,
) -> Gc<ObjectEnvironment> {
- vm.heap().allocate(ObjectEnvironment {
+ vm.heap().allocate(|_| ObjectEnvironment {
base: Environment::new(Self::CLASS, outer_environment, false),
binding_object,
with_environment: is_with_environment == IsWithEnvironment::Yes,
diff --git a/Libraries/LibJS/Rust/src/runtime/object_prototype.rs b/Libraries/LibJS/Rust/src/runtime/object_prototype.rs
index 76390967a29..cc74a05734e 100644
--- a/Libraries/LibJS/Rust/src/runtime/object_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/object_prototype.rs
@@ -133,7 +133,7 @@ impl ObjectPrototype {
}
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<ObjectPrototype> {
- realm.create_object(vm, Self::new(vm, realm))
+ realm.create_object(vm, |_| Self::new(vm, realm))
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/primitive_string.rs b/Libraries/LibJS/Rust/src/runtime/primitive_string.rs
index 530973c596d..51d536315c7 100644
--- a/Libraries/LibJS/Rust/src/runtime/primitive_string.rs
+++ b/Libraries/LibJS/Rust/src/runtime/primitive_string.rs
@@ -162,7 +162,7 @@ impl PrimitiveString {
return Self::create_from_fly_string(vm, &to_utf16_fly_string(&string));
}
- vm.heap().allocate(Self::new(string))
+ vm.heap().allocate(|_| Self::new(string))
}
/// Creates a string of ASCII characters.
@@ -185,7 +185,7 @@ impl PrimitiveString {
if length < size_of::<usize>() {
return Self::create(vm, Utf16String::from_ascii(&characters[..length]));
}
- vm.heap().allocate(InlineString::new(characters, length)).upcast()
+ vm.heap().allocate(|_| InlineString::new(characters, length)).upcast()
}
pub fn create_from_utf16_view(vm: &Vm, string: Utf16View<'_>) -> Gc<PrimitiveString> {
@@ -226,7 +226,7 @@ impl PrimitiveString {
return interned_string;
}
- let new_string = vm.heap().allocate(Self::new(Utf16String::from(string)));
+ let new_string = vm.heap().allocate(|_| Self::new(Utf16String::from(string)));
cache_slot.set(Some(new_string));
new_string
}
@@ -263,7 +263,7 @@ impl PrimitiveString {
{
cached_string
}
- _ => vm.heap().allocate(Self::new(Utf16String::from(string))),
+ _ => vm.heap().allocate(|_| Self::new(Utf16String::from(string))),
};
interned_string.set_interned();
vm.interned_strings()
@@ -352,7 +352,7 @@ impl PrimitiveString {
/// The rope string of the non-empty strings `lhs` and `rhs`, whose lengths add up to less than `u32::MAX`.
pub(crate) fn create_rope(vm: &Vm, lhs: Gc<PrimitiveString>, rhs: Gc<PrimitiveString>) -> Gc<PrimitiveString> {
- vm.heap().allocate(RopeString::new(lhs, rhs)).upcast()
+ vm.heap().allocate(|_| RopeString::new(lhs, rhs)).upcast()
}
pub fn create_from_substring(
@@ -405,7 +405,7 @@ impl PrimitiveString {
}
vm.heap()
- .allocate(Substring::new(string, code_unit_offset, code_unit_length))
+ .allocate(|_| Substring::new(string, code_unit_offset, code_unit_length))
.upcast()
}
diff --git a/Libraries/LibJS/Rust/src/runtime/private_environment.rs b/Libraries/LibJS/Rust/src/runtime/private_environment.rs
index 9d937d88dbb..bf9c2459743 100644
--- a/Libraries/LibJS/Rust/src/runtime/private_environment.rs
+++ b/Libraries/LibJS/Rust/src/runtime/private_environment.rs
@@ -74,7 +74,7 @@ impl PrivateEnvironment {
let unique_id = vm.next_private_environment_id().get();
assert!(unique_id != u64::MAX);
vm.next_private_environment_id().set(unique_id + 1);
- vm.heap().allocate(PrivateEnvironment {
+ vm.heap().allocate(|_| PrivateEnvironment {
header: CellHeader::for_class(Self::CLASS),
outer: Cell::new(parent),
storage: PrivateEnvironmentStorage {
diff --git a/Libraries/LibJS/Rust/src/runtime/promise.rs b/Libraries/LibJS/Rust/src/runtime/promise.rs
index 22c67eef80e..afa7670d546 100644
--- a/Libraries/LibJS/Rust/src/runtime/promise.rs
+++ b/Libraries/LibJS/Rust/src/runtime/promise.rs
@@ -124,10 +124,9 @@ impl Deref for Promise {
impl Promise {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<Promise> {
- realm.create_object(
- vm,
- Promise::new(vm, Self::CLASS, realm.intrinsics().promise_prototype(vm)),
- )
+ realm.create_object(vm, |_| {
+ Promise::new(vm, Self::CLASS, realm.intrinsics().promise_prototype(vm))
+ })
}
/// A promise with `prototype`, for `class`, which is Promise or a class that extends it.
diff --git a/Libraries/LibJS/Rust/src/runtime/promise_capability.rs b/Libraries/LibJS/Rust/src/runtime/promise_capability.rs
index d1e99110b95..3de72f827fc 100644
--- a/Libraries/LibJS/Rust/src/runtime/promise_capability.rs
+++ b/Libraries/LibJS/Rust/src/runtime/promise_capability.rs
@@ -40,7 +40,7 @@ impl PromiseCapability {
resolve: Gc<FunctionObject>,
reject: Gc<FunctionObject>,
) -> Gc<PromiseCapability> {
- vm.heap().allocate(PromiseCapability {
+ vm.heap().allocate(|_| PromiseCapability {
header: CellHeader::for_class(Self::CLASS),
promise: Cell::new(promise),
resolve: Cell::new(resolve),
@@ -144,7 +144,7 @@ pub fn new_promise_capability(vm: &Vm, constructor: Value) -> ThrowCompletionOr<
realm,
constructor.as_function(),
|intrinsics, vm| intrinsics.promise_prototype(vm),
- |prototype| Promise::new(vm, Promise::CLASS, prototype),
+ |_, prototype| Promise::new(vm, Promise::CLASS, prototype),
)?;
let resolving_functions = promise.create_resolving_functions(vm);
return Ok(PromiseCapability::create(
@@ -156,7 +156,7 @@ pub fn new_promise_capability(vm: &Vm, constructor: Value) -> ThrowCompletionOr<
}
// 3. Let resolvingFunctions be the Record { [[Resolve]]: undefined, [[Reject]]: undefined }.
- let resolving_functions = vm.heap().allocate(ResolvingFunctions {
+ let resolving_functions = vm.heap().allocate(|_| ResolvingFunctions {
header: CellHeader::for_class(ResolvingFunctions::CLASS),
resolve: Cell::new(Value::UNDEFINED),
reject: Cell::new(Value::UNDEFINED),
diff --git a/Libraries/LibJS/Rust/src/runtime/promise_constructor.rs b/Libraries/LibJS/Rust/src/runtime/promise_constructor.rs
index a9d5f9d5a24..2ed206b39dc 100644
--- a/Libraries/LibJS/Rust/src/runtime/promise_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/promise_constructor.rs
@@ -603,17 +603,14 @@ define_native_function_class!(
impl PromiseConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<PromiseConstructor> {
- realm.create_object(
- vm,
- PromiseConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Promise.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| PromiseConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Promise.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -745,7 +742,7 @@ impl PromiseConstructor {
realm,
new_target,
|intrinsics, vm| intrinsics.promise_prototype(vm),
- |prototype| Promise::new(vm, Promise::CLASS, prototype),
+ |_, prototype| Promise::new(vm, Promise::CLASS, prototype),
)?;
// 8. Let resolvingFunctions be CreateResolvingFunctions(promise).
diff --git a/Libraries/LibJS/Rust/src/runtime/promise_prototype.rs b/Libraries/LibJS/Rust/src/runtime/promise_prototype.rs
index a851dfc747b..308acf1fcb5 100644
--- a/Libraries/LibJS/Rust/src/runtime/promise_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/promise_prototype.rs
@@ -46,17 +46,14 @@ fn then_native_function() -> RawNativeFunctionPointer {
impl PromisePrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<PromisePrototype> {
- realm.create_object(
- vm,
- PromisePrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().object_prototype(vm),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| PromisePrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().object_prototype(vm),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
pub fn is_original_then_function(vm: &Vm, value: Value) -> bool {
diff --git a/Libraries/LibJS/Rust/src/runtime/promise_reaction.rs b/Libraries/LibJS/Rust/src/runtime/promise_reaction.rs
index 03efa932c82..fd106c1b4ed 100644
--- a/Libraries/LibJS/Rust/src/runtime/promise_reaction.rs
+++ b/Libraries/LibJS/Rust/src/runtime/promise_reaction.rs
@@ -40,7 +40,7 @@ impl PromiseReaction {
capability: Option<Gc<PromiseCapability>>,
handler: Option<Gc<JobCallback>>,
) -> Gc<PromiseReaction> {
- vm.heap().allocate(PromiseReaction {
+ vm.heap().allocate(|_| PromiseReaction {
header: CellHeader::for_class(Self::CLASS),
reaction_type,
capability: Cell::new(capability),
diff --git a/Libraries/LibJS/Rust/src/runtime/promise_resolving_element_functions.rs b/Libraries/LibJS/Rust/src/runtime/promise_resolving_element_functions.rs
index b211b647fc9..468d614d949 100644
--- a/Libraries/LibJS/Rust/src/runtime/promise_resolving_element_functions.rs
+++ b/Libraries/LibJS/Rust/src/runtime/promise_resolving_element_functions.rs
@@ -42,7 +42,7 @@ define_cell!(RemainingElements, Other);
impl RemainingElements {
pub fn create(vm: &Vm, initial_value: u64) -> Gc<RemainingElements> {
- vm.heap().allocate(RemainingElements {
+ vm.heap().allocate(|_| RemainingElements {
header: CellHeader::for_class(Self::CLASS),
value: Cell::new(initial_value),
})
@@ -81,7 +81,7 @@ impl Finalize for PromiseValueList {
impl PromiseValueList {
pub fn create(vm: &Vm) -> Gc<PromiseValueList> {
- vm.heap().allocate(PromiseValueList {
+ vm.heap().allocate(|_| PromiseValueList {
header: CellHeader::for_class(Self::CLASS),
values: GcRefCell::new(Vec::new()),
})
@@ -249,7 +249,7 @@ macro_rules! define_promise_resolving_element_function {
) -> Gc<$type> {
realm.create_object(
vm,
- $type {
+ |_| $type {
base: PromiseResolvingElementFunction::new(
vm,
Self::CLASS,
diff --git a/Libraries/LibJS/Rust/src/runtime/promise_resolving_function.rs b/Libraries/LibJS/Rust/src/runtime/promise_resolving_function.rs
index 0f3e59a5c36..4f9fa3319a9 100644
--- a/Libraries/LibJS/Rust/src/runtime/promise_resolving_function.rs
+++ b/Libraries/LibJS/Rust/src/runtime/promise_resolving_function.rs
@@ -68,16 +68,15 @@ impl Deref for PromiseResolvingFunction {
impl PromiseResolvingFunction {
pub fn create_resolve(vm: &Vm, realm: Gc<Realm>, promise: Gc<Promise>) -> Gc<PromiseResolvingFunction> {
- realm.create_object(
- vm,
+ realm.create_object(vm, |_| {
Self::new(
vm,
promise,
PromiseResolvingFunctionKind::Resolve,
None,
realm.function_prototype(),
- ),
- )
+ )
+ })
}
pub fn create_reject(
@@ -86,16 +85,15 @@ impl PromiseResolvingFunction {
promise: Gc<Promise>,
resolve_function: Gc<PromiseResolvingFunction>,
) -> Gc<PromiseResolvingFunction> {
- realm.create_object(
- vm,
+ realm.create_object(vm, |_| {
Self::new(
vm,
promise,
PromiseResolvingFunctionKind::Reject,
Some(resolve_function),
realm.function_prototype(),
- ),
- )
+ )
+ })
}
fn new(
diff --git a/Libraries/LibJS/Rust/src/runtime/proxy_constructor.rs b/Libraries/LibJS/Rust/src/runtime/proxy_constructor.rs
index a95dcbb0591..dc37290b7e7 100644
--- a/Libraries/LibJS/Rust/src/runtime/proxy_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/proxy_constructor.rs
@@ -71,17 +71,14 @@ define_native_function_class!(
impl ProxyConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<ProxyConstructor> {
- realm.create_object(
- vm,
- ProxyConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Proxy.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| ProxyConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Proxy.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/proxy_object.rs b/Libraries/LibJS/Rust/src/runtime/proxy_object.rs
index 744e50d12a7..63fdb20990b 100644
--- a/Libraries/LibJS/Rust/src/runtime/proxy_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/proxy_object.rs
@@ -185,7 +185,7 @@ impl<'list, 'vm> UncheckedResultKeys<'list, 'vm> {
impl ProxyObject {
pub fn create(vm: &Vm, realm: Gc<Realm>, target: Gc<Object>, handler: Gc<Object>) -> Gc<ProxyObject> {
- realm.create_object(vm, Self::new(vm, target, handler, realm.object_prototype()))
+ realm.create_object(vm, |_| Self::new(vm, target, handler, realm.object_prototype()))
}
fn new(vm: &Vm, target: Gc<Object>, handler: Gc<Object>, prototype: Gc<Object>) -> ProxyObject {
diff --git a/Libraries/LibJS/Rust/src/runtime/raw_json_object.rs b/Libraries/LibJS/Rust/src/runtime/raw_json_object.rs
index 2714a79776d..5ee66f60b57 100644
--- a/Libraries/LibJS/Rust/src/runtime/raw_json_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/raw_json_object.rs
@@ -27,24 +27,18 @@ define_object_class!(RawJSONObject, extends: [Object], methods: {
impl RawJSONObject {
pub fn create(vm: &Vm, realm: Gc<Realm>, prototype: Option<Gc<Object>>) -> Gc<RawJSONObject> {
let Some(prototype) = prototype else {
- return realm.create_object(
- vm,
- RawJSONObject {
- base: Object::new_with_shape(
- Self::CLASS,
- realm.empty_object_shape(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- );
+ return realm.create_object(vm, |_| RawJSONObject {
+ base: Object::new_with_shape(
+ Self::CLASS,
+ realm.empty_object_shape(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ });
};
- realm.create_object(
- vm,
- RawJSONObject {
- base: Object::new_with_prototype(vm, Self::CLASS, prototype, MayInterfereWithIndexedPropertyAccess::No),
- },
- )
+ realm.create_object(vm, |_| RawJSONObject {
+ base: Object::new_with_prototype(vm, Self::CLASS, prototype, MayInterfereWithIndexedPropertyAccess::No),
+ })
}
}
diff --git a/Libraries/LibJS/Rust/src/runtime/realm.rs b/Libraries/LibJS/Rust/src/runtime/realm.rs
index 8d76917dd55..a8a706a3088 100644
--- a/Libraries/LibJS/Rust/src/runtime/realm.rs
+++ b/Libraries/LibJS/Rust/src/runtime/realm.rs
@@ -9,6 +9,7 @@ use core::ffi::c_void;
use core::ptr::NonNull;
use crate::gc::class::{Extends, GcCell, define_cell};
+use crate::gc::defer_gc::DeferGc;
use crate::gc::embedder_cell::{EmbedderCell, EmbedderValue};
use crate::gc::foreign::ForeignCellSlot;
use crate::gc::visitor::{Trace, Visitor};
@@ -136,7 +137,7 @@ impl Realm {
/// A realm without intrinsics, a global object or a global environment, which
/// InitializeHostDefinedRealm goes on to create.
pub fn create(vm: &Vm) -> Gc<Realm> {
- vm.heap().allocate(Realm {
+ vm.heap().allocate(|_| Realm {
header: CellHeader::for_class(Self::CLASS),
global_object: Cell::new(None),
global_declarative_environment: Cell::new(None),
@@ -209,7 +210,7 @@ impl Realm {
// a. Let global be OrdinaryObjectCreate(realm.[[Intrinsics]].[[%Object.prototype%]]).
// NOTE: We allocate a proper GlobalObject directly as this plain object is
// turned into one via SetDefaultGlobalBindings in the spec.
- allocate_object(vm, GlobalObject::new(vm, GlobalObject::CLASS, realm)).upcast()
+ allocate_object(vm, |_| GlobalObject::new(vm, GlobalObject::CLASS, realm)).upcast()
};
// 14. If the host requires that the this binding in realm's global scope return an object other than the global object, then
@@ -241,8 +242,8 @@ impl Realm {
/// Realm::create<T>(): allocates an object and runs its initialize(), which defines the properties of built-in
/// objects.
- pub fn create_object<T: GcCell + Extends<Object>>(&self, vm: &Vm, object: T) -> Gc<T> {
- let object = allocate_object(vm, object);
+ pub fn create_object<T: GcCell + Extends<Object>>(&self, vm: &Vm, build: impl FnOnce(&DeferGc<'_>) -> T) -> Gc<T> {
+ let object = allocate_object(vm, build);
object.upcast::<Object>().initialize(vm, self.as_gc());
object
}
diff --git a/Libraries/LibJS/Rust/src/runtime/reflect_object.rs b/Libraries/LibJS/Rust/src/runtime/reflect_object.rs
index 2cd7f452229..553471e5aac 100644
--- a/Libraries/LibJS/Rust/src/runtime/reflect_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/reflect_object.rs
@@ -39,17 +39,14 @@ define_object_class!(ReflectObject, extends: [Object], methods: {
impl ReflectObject {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<ReflectObject> {
- realm.create_object(
- vm,
- ReflectObject {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| ReflectObject {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/regexp_constructor.rs b/Libraries/LibJS/Rust/src/runtime/regexp_constructor.rs
index d1245545861..fd3e6a664df 100644
--- a/Libraries/LibJS/Rust/src/runtime/regexp_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/regexp_constructor.rs
@@ -93,18 +93,15 @@ define_native_function_class!(
impl RegExpConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<RegExpConstructor> {
- realm.create_object(
- vm,
- RegExpConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.RegExp.as_string().clone(),
- realm.function_prototype(),
- ),
- legacy_static_properties: RegExpLegacyStaticProperties::default(),
- },
- )
+ realm.create_object(vm, |_| RegExpConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.RegExp.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ legacy_static_properties: RegExpLegacyStaticProperties::default(),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/regexp_object.rs b/Libraries/LibJS/Rust/src/runtime/regexp_object.rs
index 2c3e62c023c..a1085bc50de 100644
--- a/Libraries/LibJS/Rust/src/runtime/regexp_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/regexp_object.rs
@@ -173,15 +173,14 @@ pub(crate) const NEW_REGEXP_OBJECT_LAST_INDEX_OFFSET: u32 = 0;
impl RegExpObject {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<RegExpObject> {
- realm.create_object(
- vm,
+ realm.create_object(vm, |_| {
Self::new(
vm,
Utf16String::default(),
Utf16String::default(),
realm.intrinsics().regexp_prototype(vm),
- ),
- )
+ )
+ })
}
pub fn create_with_pattern_and_flags(
@@ -194,18 +193,15 @@ impl RegExpObject {
// from a premade shape that already has the "lastIndex" property initialize() would define.
let shape = realm.intrinsics().new_regexp_object_shape(vm);
let flag_bits = to_flag_bits(Utf16View::of_string(&flags));
- let regexp_object = allocate_object(
- vm,
- RegExpObject {
- base: Object::new_with_shape(Self::CLASS, shape, MayInterfereWithIndexedPropertyAccess::No),
- pattern: RefCell::new(pattern),
- flags: RefCell::new(flags),
- flag_bits: Cell::new(flag_bits),
- legacy_features_enabled: Cell::new(false),
- cached_regex: RefCell::new(None),
- realm: Cell::new(None),
- },
- );
+ let regexp_object = allocate_object(vm, |_| RegExpObject {
+ base: Object::new_with_shape(Self::CLASS, shape, MayInterfereWithIndexedPropertyAccess::No),
+ pattern: RefCell::new(pattern),
+ flags: RefCell::new(flags),
+ flag_bits: Cell::new(flag_bits),
+ legacy_features_enabled: Cell::new(false),
+ cached_regex: RefCell::new(None),
+ realm: Cell::new(None),
+ });
regexp_object.initialize_direct(NEW_REGEXP_OBJECT_LAST_INDEX_OFFSET, Value::from_i32(0));
regexp_object
}
@@ -465,7 +461,7 @@ pub fn regexp_alloc(vm: &Vm, new_target: Gc<FunctionObject>) -> ThrowCompletionO
current_realm,
new_target,
Intrinsics::regexp_prototype,
- |prototype| RegExpObject::new(vm, Utf16String::default(), Utf16String::default(), prototype),
+ |_, prototype| RegExpObject::new(vm, Utf16String::default(), Utf16String::default(), prototype),
)?;
// 2. Let thisRealm be the current Realm Record.
diff --git a/Libraries/LibJS/Rust/src/runtime/regexp_prototype.rs b/Libraries/LibJS/Rust/src/runtime/regexp_prototype.rs
index a0fa4b8d388..5ba838dfcab 100644
--- a/Libraries/LibJS/Rust/src/runtime/regexp_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/regexp_prototype.rs
@@ -808,17 +808,14 @@ fn has_intrinsic_getter(
impl RegExpPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<RegExpPrototype> {
- realm.create_object(
- vm,
- RegExpPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| RegExpPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/regexp_string_iterator.rs b/Libraries/LibJS/Rust/src/runtime/regexp_string_iterator.rs
index 13b65e9d8eb..c7881632a95 100644
--- a/Libraries/LibJS/Rust/src/runtime/regexp_string_iterator.rs
+++ b/Libraries/LibJS/Rust/src/runtime/regexp_string_iterator.rs
@@ -51,22 +51,19 @@ impl RegExpStringIterator {
// 5. Set iterator.[[Unicode]] to fullUnicode.
// 6. Set iterator.[[Done]] to false.
// 7. Return iterator.
- realm.create_object(
- vm,
- RegExpStringIterator {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().regexp_string_iterator_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- regexp_object,
- string,
- global,
- unicode,
- done: Cell::new(false),
- },
- )
+ realm.create_object(vm, |_| RegExpStringIterator {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().regexp_string_iterator_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ regexp_object,
+ string,
+ global,
+ unicode,
+ done: Cell::new(false),
+ })
}
pub fn regexp_object(&self) -> Gc<Object> {
diff --git a/Libraries/LibJS/Rust/src/runtime/regexp_string_iterator_prototype.rs b/Libraries/LibJS/Rust/src/runtime/regexp_string_iterator_prototype.rs
index ab85609caca..8db53524802 100644
--- a/Libraries/LibJS/Rust/src/runtime/regexp_string_iterator_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/regexp_string_iterator_prototype.rs
@@ -41,17 +41,14 @@ define_object_class!(RegExpStringIteratorPrototype, extends: [Object], methods:
impl RegExpStringIteratorPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<RegExpStringIteratorPrototype> {
- realm.create_object(
- vm,
- RegExpStringIteratorPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().iterator_prototype(vm),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| RegExpStringIteratorPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().iterator_prototype(vm),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/set.rs b/Libraries/LibJS/Rust/src/runtime/set.rs
index 92839883cd3..49cabc6ded2 100644
--- a/Libraries/LibJS/Rust/src/runtime/set.rs
+++ b/Libraries/LibJS/Rust/src/runtime/set.rs
@@ -43,7 +43,7 @@ impl Set {
}
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<Set> {
- realm.create_object(vm, Set::new(vm, realm.intrinsics().set_prototype(vm)))
+ realm.create_object(vm, |_| Set::new(vm, realm.intrinsics().set_prototype(vm)))
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/set_constructor.rs b/Libraries/LibJS/Rust/src/runtime/set_constructor.rs
index 1f5e10b8939..50e7445eed9 100644
--- a/Libraries/LibJS/Rust/src/runtime/set_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/set_constructor.rs
@@ -42,17 +42,14 @@ define_native_function_class!(
impl SetConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<SetConstructor> {
- realm.create_object(
- vm,
- SetConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Set.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| SetConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Set.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -95,9 +92,10 @@ impl SetConstructor {
let iterable = vm.argument(0);
// 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, "%Set.prototype%", « [[SetData]] »).
- let set = ordinary_create_from_constructor_of(vm, realm, new_target, Intrinsics::set_prototype, |prototype| {
- Set::new(vm, prototype)
- })?;
+ let set =
+ ordinary_create_from_constructor_of(vm, realm, new_target, Intrinsics::set_prototype, |_, prototype| {
+ Set::new(vm, prototype)
+ })?;
// 3. Set set.[[SetData]] to a new empty List.
diff --git a/Libraries/LibJS/Rust/src/runtime/set_iterator.rs b/Libraries/LibJS/Rust/src/runtime/set_iterator.rs
index 55e40737bd1..12f2d28e310 100644
--- a/Libraries/LibJS/Rust/src/runtime/set_iterator.rs
+++ b/Libraries/LibJS/Rust/src/runtime/set_iterator.rs
@@ -70,21 +70,18 @@ define_object_class!(SetIterator, extends: [Object], methods: {
impl SetIterator {
pub fn create(vm: &Vm, realm: Gc<Realm>, set: Gc<Set>, iteration_kind: PropertyKind) -> Gc<SetIterator> {
- realm.create_object(
- vm,
- SetIterator {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().set_iterator_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- set,
- done: Cell::new(false),
- iteration_kind,
- iterator: set.begin(),
- },
- )
+ realm.create_object(vm, |_| SetIterator {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().set_iterator_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ set,
+ done: Cell::new(false),
+ iteration_kind,
+ iterator: set.begin(),
+ })
}
fn as_builtin_iterator_if_next_is_not_redefined(_: &Object, next_method: Value) -> Option<BuiltinIteratorNext> {
diff --git a/Libraries/LibJS/Rust/src/runtime/set_iterator_prototype.rs b/Libraries/LibJS/Rust/src/runtime/set_iterator_prototype.rs
index 09fdeb3e5bf..f758523e4f8 100644
--- a/Libraries/LibJS/Rust/src/runtime/set_iterator_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/set_iterator_prototype.rs
@@ -38,17 +38,14 @@ define_object_class!(SetIteratorPrototype, extends: [Object], methods: {
impl SetIteratorPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<SetIteratorPrototype> {
- realm.create_object(
- vm,
- SetIteratorPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().iterator_prototype(vm),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| SetIteratorPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().iterator_prototype(vm),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/set_prototype.rs b/Libraries/LibJS/Rust/src/runtime/set_prototype.rs
index 77c7f36b1b1..d673afc97fe 100644
--- a/Libraries/LibJS/Rust/src/runtime/set_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/set_prototype.rs
@@ -60,18 +60,15 @@ fn current_realm(vm: &Vm) -> Gc<Realm> {
impl SetPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<SetPrototype> {
- realm.create_object(
- vm,
- SetPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- values_function: Cell::new(None),
- },
- )
+ realm.create_object(vm, |_| SetPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ values_function: Cell::new(None),
+ })
}
/// The original Set.prototype.values, which is also the original Set.prototype.keys and
diff --git a/Libraries/LibJS/Rust/src/runtime/shape.rs b/Libraries/LibJS/Rust/src/runtime/shape.rs
index 6e318233f83..2e0580a8dec 100644
--- a/Libraries/LibJS/Rust/src/runtime/shape.rs
+++ b/Libraries/LibJS/Rust/src/runtime/shape.rs
@@ -353,7 +353,7 @@ impl Shape {
/// A new unique shape with no properties and no prototype.
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<Shape> {
- vm.heap().allocate(Self::new(realm))
+ vm.heap().allocate(|_| Self::new(realm))
}
fn as_gc(&self) -> Gc<Shape> {
@@ -578,7 +578,7 @@ impl Shape {
}
let new_shape = vm
.heap()
- .allocate(Self::new_from_previous_shape(self, PropertyCountChange::Increment));
+ .allocate(|_| Self::new_from_previous_shape(self, PropertyCountChange::Increment));
let property_count = self.property_count();
let metadata = PropertyMetadata {
@@ -619,7 +619,7 @@ impl Shape {
}
let new_shape = vm
.heap()
- .allocate(Self::new_from_previous_shape(self, PropertyCountChange::Preserve));
+ .allocate(|_| Self::new_from_previous_shape(self, PropertyCountChange::Preserve));
let descriptors = self.copy_descriptors(vm);
new_shape.set_descriptors(Some(descriptors));
descriptors.set_attributes(vm, property_key, attributes, self.property_count());
@@ -675,7 +675,7 @@ impl Shape {
}
let new_shape = vm
.heap()
- .allocate(Self::new_from_previous_shape_with_prototype(self, realm, new_prototype));
+ .allocate(|_| Self::new_from_previous_shape_with_prototype(self, realm, new_prototype));
if self.is_dictionary() && self.property_count() > MAX_DESCRIPTOR_COUNT {
new_shape.become_dictionary_shape();
self.copy_properties_to_dictionary_shape(vm, &new_shape);
@@ -695,7 +695,7 @@ impl Shape {
}
let new_shape = vm
.heap()
- .allocate(Self::new_from_previous_shape(self, PropertyCountChange::Decrement));
+ .allocate(|_| Self::new_from_previous_shape(self, PropertyCountChange::Decrement));
let descriptors = self.copy_descriptors(vm);
new_shape.set_descriptors(Some(descriptors));
descriptors.remove(vm, property_key, self.property_count());
diff --git a/Libraries/LibJS/Rust/src/runtime/shared_array_buffer_constructor.rs b/Libraries/LibJS/Rust/src/runtime/shared_array_buffer_constructor.rs
index 66a2bab6570..66dae113f85 100644
--- a/Libraries/LibJS/Rust/src/runtime/shared_array_buffer_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/shared_array_buffer_constructor.rs
@@ -36,17 +36,14 @@ define_native_function_class!(
impl SharedArrayBufferConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<SharedArrayBufferConstructor> {
- realm.create_object(
- vm,
- SharedArrayBufferConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.SharedArrayBuffer.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| SharedArrayBufferConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.SharedArrayBuffer.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/shared_array_buffer_prototype.rs b/Libraries/LibJS/Rust/src/runtime/shared_array_buffer_prototype.rs
index f70a2aa4c00..dffa7b83252 100644
--- a/Libraries/LibJS/Rust/src/runtime/shared_array_buffer_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/shared_array_buffer_prototype.rs
@@ -41,17 +41,14 @@ fn this_array_buffer(vm: &Vm) -> ThrowCompletionOr<Gc<ArrayBuffer>> {
impl SharedArrayBufferPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<SharedArrayBufferPrototype> {
- realm.create_object(
- vm,
- SharedArrayBufferPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| SharedArrayBufferPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/shared_function_instance_data.rs b/Libraries/LibJS/Rust/src/runtime/shared_function_instance_data.rs
index 7f6cd45ba16..5ecc59b8602 100644
--- a/Libraries/LibJS/Rust/src/runtime/shared_function_instance_data.rs
+++ b/Libraries/LibJS/Rust/src/runtime/shared_function_instance_data.rs
@@ -282,17 +282,19 @@ impl SharedFunctionInstanceData {
Vec::new()
};
- let shared = vm.heap().allocate(Self::new(
- description.function_kind,
- name,
- description.function_length,
- description.formal_parameter_count,
- description.strict,
- description.is_arrow,
- description.has_simple_parameter_list,
- mapped_parameter_names,
- Some(description.payload),
- ));
+ let shared = vm.heap().allocate(|_| {
+ Self::new(
+ description.function_kind,
+ name,
+ description.function_length,
+ description.formal_parameter_count,
+ description.strict,
+ description.is_arrow,
+ description.has_simple_parameter_list,
+ mapped_parameter_names,
+ Some(description.payload),
+ )
+ });
shared.update_can_inline_call();
// Set parsing insights that must be available before lazy compilation.
@@ -334,17 +336,19 @@ impl SharedFunctionInstanceData {
let source_text_length = source_text_range.end.saturating_sub(source_text_range.start);
let is_arrow_function = function.is_arrow();
- let shared = vm.heap().allocate(Self::new(
- function.function_kind(),
- name,
- function.length(),
- function.parameter_count(),
- function.has_strict_code() || outer_strict,
- is_arrow_function,
- has_simple_parameter_list,
- simple_parameter_names.unwrap_or_default(),
- None,
- ));
+ let shared = vm.heap().allocate(|_| {
+ Self::new(
+ function.function_kind(),
+ name,
+ function.length(),
+ function.parameter_count(),
+ function.has_strict_code() || outer_strict,
+ is_arrow_function,
+ has_simple_parameter_list,
+ simple_parameter_names.unwrap_or_default(),
+ None,
+ )
+ });
shared.update_can_inline_call();
// Set parsing insights that must be available before lazy compilation.
@@ -444,17 +448,19 @@ impl SharedFunctionInstanceData {
has_simple_parameter_list: bool,
parameter_names_for_mapped_arguments: Vec<Utf16FlyString>,
) -> Gc<SharedFunctionInstanceData> {
- let shared = vm.heap().allocate(Self::new(
- kind,
- name,
- function_length,
- formal_parameter_count,
- strict,
- is_arrow_function,
- has_simple_parameter_list,
- parameter_names_for_mapped_arguments,
- None,
- ));
+ let shared = vm.heap().allocate(|_| {
+ Self::new(
+ kind,
+ name,
+ function_length,
+ formal_parameter_count,
+ strict,
+ is_arrow_function,
+ has_simple_parameter_list,
+ parameter_names_for_mapped_arguments,
+ None,
+ )
+ });
shared.update_can_inline_call();
shared
}
diff --git a/Libraries/LibJS/Rust/src/runtime/source_text_module.rs b/Libraries/LibJS/Rust/src/runtime/source_text_module.rs
index c4a417314ab..b6bbf7784f3 100644
--- a/Libraries/LibJS/Rust/src/runtime/source_text_module.rs
+++ b/Libraries/LibJS/Rust/src/runtime/source_text_module.rs
@@ -444,7 +444,7 @@ impl SourceTextModule {
(Some(parts.executable), None)
};
- let module = vm.heap().allocate(SourceTextModule {
+ let module = vm.heap().allocate(|_| SourceTextModule {
base: CyclicModule::new(
Self::CLASS,
realm,
diff --git a/Libraries/LibJS/Rust/src/runtime/special_property_cache.rs b/Libraries/LibJS/Rust/src/runtime/special_property_cache.rs
index 84546849390..db8b1a9d937 100644
--- a/Libraries/LibJS/Rust/src/runtime/special_property_cache.rs
+++ b/Libraries/LibJS/Rust/src/runtime/special_property_cache.rs
@@ -119,7 +119,7 @@ unsafe impl Trace for SpecialPropertyCache {
impl SpecialPropertyCache {
fn create(vm: &Vm) -> Gc<SpecialPropertyCache> {
- vm.heap().allocate(SpecialPropertyCache {
+ vm.heap().allocate(|_| SpecialPropertyCache {
header: CellHeader::for_class(Self::CLASS),
class: Cell::new(None),
gave_up: Cell::new(false),
diff --git a/Libraries/LibJS/Rust/src/runtime/string_constructor.rs b/Libraries/LibJS/Rust/src/runtime/string_constructor.rs
index 4119305b816..a21a9af2d28 100644
--- a/Libraries/LibJS/Rust/src/runtime/string_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/string_constructor.rs
@@ -42,17 +42,14 @@ define_native_function_class!(
impl StringConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<StringConstructor> {
- realm.create_object(
- vm,
- StringConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.String.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| StringConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.String.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/string_iterator.rs b/Libraries/LibJS/Rust/src/runtime/string_iterator.rs
index 431a3d041c7..63e65513b00 100644
--- a/Libraries/LibJS/Rust/src/runtime/string_iterator.rs
+++ b/Libraries/LibJS/Rust/src/runtime/string_iterator.rs
@@ -40,20 +40,17 @@ define_object_class!(StringIterator, extends: [Object], methods: {
impl StringIterator {
pub fn create(vm: &Vm, realm: Gc<Realm>, string: Utf16String) -> Gc<StringIterator> {
- realm.create_object(
- vm,
- StringIterator {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().string_iterator_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- string,
- position: Cell::new(0),
- done: Cell::new(false),
- },
- )
+ realm.create_object(vm, |_| StringIterator {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().string_iterator_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ string,
+ position: Cell::new(0),
+ done: Cell::new(false),
+ })
}
fn as_builtin_iterator_if_next_is_not_redefined(_: &Object, next_method: Value) -> Option<BuiltinIteratorNext> {
diff --git a/Libraries/LibJS/Rust/src/runtime/string_iterator_prototype.rs b/Libraries/LibJS/Rust/src/runtime/string_iterator_prototype.rs
index 1ac93baeff1..e74326c95f9 100644
--- a/Libraries/LibJS/Rust/src/runtime/string_iterator_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/string_iterator_prototype.rs
@@ -38,17 +38,14 @@ define_object_class!(StringIteratorPrototype, extends: [Object], methods: {
impl StringIteratorPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<StringIteratorPrototype> {
- realm.create_object(
- vm,
- StringIteratorPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().iterator_prototype(vm),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| StringIteratorPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().iterator_prototype(vm),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/string_object.rs b/Libraries/LibJS/Rust/src/runtime/string_object.rs
index 19382b297bb..ea4f5fa4dce 100644
--- a/Libraries/LibJS/Rust/src/runtime/string_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/string_object.rs
@@ -84,7 +84,7 @@ impl StringObject {
// 7. Let length be the length of value.
// 8. Perform ! DefinePropertyOrThrow(S, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }).
// 9. Return S.
- realm.create_object(vm, StringObject::new(vm, Self::CLASS, primitive_string, prototype))
+ realm.create_object(vm, |_| StringObject::new(vm, Self::CLASS, primitive_string, prototype))
}
pub fn primitive_string(&self) -> Gc<PrimitiveString> {
diff --git a/Libraries/LibJS/Rust/src/runtime/string_prototype.rs b/Libraries/LibJS/Rust/src/runtime/string_prototype.rs
index d5012dd99ee..142c33690e4 100644
--- a/Libraries/LibJS/Rust/src/runtime/string_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/string_prototype.rs
@@ -279,12 +279,9 @@ impl StringPrototype {
}
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<StringPrototype> {
- realm.create_object(
- vm,
- StringPrototype {
- base: StringObject::new(vm, Self::CLASS, vm.empty_string(), realm.object_prototype()),
- },
- )
+ realm.create_object(vm, |_| StringPrototype {
+ base: StringObject::new(vm, Self::CLASS, vm.empty_string(), realm.object_prototype()),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/suppressed_error.rs b/Libraries/LibJS/Rust/src/runtime/suppressed_error.rs
index f54f6ab5ed2..08db8934bd7 100644
--- a/Libraries/LibJS/Rust/src/runtime/suppressed_error.rs
+++ b/Libraries/LibJS/Rust/src/runtime/suppressed_error.rs
@@ -45,9 +45,8 @@ impl SuppressedError {
}
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<SuppressedError> {
- realm.create_object(
- vm,
- SuppressedError::new(vm, realm.intrinsics().suppressed_error_prototype(vm)),
- )
+ realm.create_object(vm, |_| {
+ SuppressedError::new(vm, realm.intrinsics().suppressed_error_prototype(vm))
+ })
}
}
diff --git a/Libraries/LibJS/Rust/src/runtime/suppressed_error_constructor.rs b/Libraries/LibJS/Rust/src/runtime/suppressed_error_constructor.rs
index 451b2bee4d3..b85306181a1 100644
--- a/Libraries/LibJS/Rust/src/runtime/suppressed_error_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/suppressed_error_constructor.rs
@@ -37,16 +37,13 @@ define_native_function_class!(
impl SuppressedErrorConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<SuppressedErrorConstructor> {
- realm.create_object(
- vm,
- SuppressedErrorConstructor {
- base: NativeFunction::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().error_constructor(vm).upcast(),
- ),
- },
- )
+ realm.create_object(vm, |_| SuppressedErrorConstructor {
+ base: NativeFunction::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().error_constructor(vm).upcast(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -91,7 +88,7 @@ impl SuppressedErrorConstructor {
realm,
new_target,
Intrinsics::suppressed_error_prototype,
- |prototype| SuppressedError::new_in_constructor(vm, prototype),
+ |_, prototype| SuppressedError::new_in_constructor(vm, prototype),
)?;
// 3. If message is not undefined, then
diff --git a/Libraries/LibJS/Rust/src/runtime/suppressed_error_prototype.rs b/Libraries/LibJS/Rust/src/runtime/suppressed_error_prototype.rs
index 1ccab982269..c64dca9903a 100644
--- a/Libraries/LibJS/Rust/src/runtime/suppressed_error_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/suppressed_error_prototype.rs
@@ -30,17 +30,14 @@ define_object_class!(SuppressedErrorPrototype, extends: [Object], methods: {
impl SuppressedErrorPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<SuppressedErrorPrototype> {
- realm.create_object(
- vm,
- SuppressedErrorPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().error_prototype(vm),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| SuppressedErrorPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().error_prototype(vm),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, _realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/symbol.rs b/Libraries/LibJS/Rust/src/runtime/symbol.rs
index 02c7de5a4a2..b32aaf60b28 100644
--- a/Libraries/LibJS/Rust/src/runtime/symbol.rs
+++ b/Libraries/LibJS/Rust/src/runtime/symbol.rs
@@ -80,7 +80,7 @@ impl Symbol {
}
pub fn create(vm: &Vm, description: Option<Utf16String>, kind: Kind) -> Gc<Symbol> {
- vm.heap().allocate(Self::new(description, kind))
+ vm.heap().allocate(|_| Self::new(description, kind))
}
pub fn create_private(vm: &Vm) -> Gc<Symbol> {
@@ -151,7 +151,7 @@ define_cell!(GlobalSymbolRegistry, Other);
impl GlobalSymbolRegistry {
pub fn create(vm: &Vm) -> Gc<GlobalSymbolRegistry> {
- vm.heap().allocate(GlobalSymbolRegistry {
+ vm.heap().allocate(|_| GlobalSymbolRegistry {
header: CellHeader::for_class(Self::CLASS),
symbols: GcRefCell::new(SymbolsByKey(HashMap::new())),
})
diff --git a/Libraries/LibJS/Rust/src/runtime/symbol_constructor.rs b/Libraries/LibJS/Rust/src/runtime/symbol_constructor.rs
index 103072f9b5c..107d488f16a 100644
--- a/Libraries/LibJS/Rust/src/runtime/symbol_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/symbol_constructor.rs
@@ -36,17 +36,14 @@ define_native_function_class!(
impl SymbolConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<SymbolConstructor> {
- realm.create_object(
- vm,
- SymbolConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Symbol.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| SymbolConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Symbol.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/symbol_object.rs b/Libraries/LibJS/Rust/src/runtime/symbol_object.rs
index 881c8e7c100..eb0be6a7d5f 100644
--- a/Libraries/LibJS/Rust/src/runtime/symbol_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/symbol_object.rs
@@ -36,18 +36,15 @@ impl Deref for SymbolObject {
impl SymbolObject {
pub fn create(vm: &Vm, realm: Gc<Realm>, primitive_symbol: Gc<Symbol>) -> Gc<SymbolObject> {
- realm.create_object(
- vm,
- SymbolObject {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().symbol_prototype(vm),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- symbol: primitive_symbol,
- },
- )
+ realm.create_object(vm, |_| SymbolObject {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().symbol_prototype(vm),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ symbol: primitive_symbol,
+ })
}
pub fn primitive_symbol(&self) -> Gc<Symbol> {
diff --git a/Libraries/LibJS/Rust/src/runtime/symbol_prototype.rs b/Libraries/LibJS/Rust/src/runtime/symbol_prototype.rs
index 3d02d272a27..a5025728ce2 100644
--- a/Libraries/LibJS/Rust/src/runtime/symbol_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/symbol_prototype.rs
@@ -38,17 +38,14 @@ define_object_class!(SymbolPrototype, extends: [Object], methods: {
impl SymbolPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<SymbolPrototype> {
- realm.create_object(
- vm,
- SymbolPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| SymbolPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/synthetic_module.rs b/Libraries/LibJS/Rust/src/runtime/synthetic_module.rs
index 47475fe393f..accbcd6e44f 100644
--- a/Libraries/LibJS/Rust/src/runtime/synthetic_module.rs
+++ b/Libraries/LibJS/Rust/src/runtime/synthetic_module.rs
@@ -115,7 +115,7 @@ impl SyntheticModule {
"the evaluation steps capture their state through their captures"
);
};
- let module = vm.heap().allocate(SyntheticModule {
+ let module = vm.heap().allocate(|_| SyntheticModule {
base: Module::new(Self::CLASS, realm, filename, ForeignCellSlot::empty()),
export_names,
evaluation_steps: OnceCell::new(),
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/duration.rs b/Libraries/LibJS/Rust/src/runtime/temporal/duration.rs
index 751f7a3b5b1..4c683debe47 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/duration.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/duration.rs
@@ -1042,7 +1042,7 @@ pub fn create_temporal_duration(
realm,
new_target,
Intrinsics::temporal_duration_prototype,
- |prototype| Duration::new(vm, fields, prototype),
+ |_, prototype| Duration::new(vm, fields, prototype),
)?;
// 14. Return object.
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/duration_constructor.rs b/Libraries/LibJS/Rust/src/runtime/temporal/duration_constructor.rs
index a5a9b6accb2..54ef442e986 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/duration_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/duration_constructor.rs
@@ -48,17 +48,14 @@ define_native_function_class!(
impl DurationConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<DurationConstructor> {
- realm.create_object(
- vm,
- DurationConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Duration.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| DurationConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Duration.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/duration_prototype.rs b/Libraries/LibJS/Rust/src/runtime/temporal/duration_prototype.rs
index f1137f41d6a..f26b575294e 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/duration_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/duration_prototype.rs
@@ -99,17 +99,14 @@ fn get_options_or_string_option(vm: &Vm, value: Value, key: &PropertyKey) -> Thr
impl DurationPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<DurationPrototype> {
- realm.create_object(
- vm,
- DurationPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| DurationPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/instant.rs b/Libraries/LibJS/Rust/src/runtime/temporal/instant.rs
index b4887907b8a..8688f3de474 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/instant.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/instant.rs
@@ -144,7 +144,7 @@ pub fn create_temporal_instant(
realm,
new_target,
Intrinsics::temporal_instant_prototype,
- |prototype| Instant::new(vm, epoch_nanoseconds, prototype),
+ |_, prototype| Instant::new(vm, epoch_nanoseconds, prototype),
)?;
// 5. Return object.
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/instant_constructor.rs b/Libraries/LibJS/Rust/src/runtime/temporal/instant_constructor.rs
index 2508d063bbd..59d6c9b2bab 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/instant_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/instant_constructor.rs
@@ -42,17 +42,14 @@ define_native_function_class!(
impl InstantConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<InstantConstructor> {
- realm.create_object(
- vm,
- InstantConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.Instant.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| InstantConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.Instant.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/instant_prototype.rs b/Libraries/LibJS/Rust/src/runtime/temporal/instant_prototype.rs
index d63a5dd70ab..1c982fc271d 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/instant_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/instant_prototype.rs
@@ -68,17 +68,14 @@ fn string_value(vm: &Vm, string: &str) -> Value {
impl InstantPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<InstantPrototype> {
- realm.create_object(
- vm,
- InstantPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| InstantPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/now.rs b/Libraries/LibJS/Rust/src/runtime/temporal/now.rs
index 7959fb5877f..8cf1d362ff7 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/now.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/now.rs
@@ -47,17 +47,14 @@ define_object_class!(Now, extends: [Object], methods: {
impl Now {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<Now> {
- realm.create_object(
- vm,
- Now {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| Now {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/plain_date.rs b/Libraries/LibJS/Rust/src/runtime/temporal/plain_date.rs
index 897df4c4436..f955ebed91d 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/plain_date.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/plain_date.rs
@@ -128,7 +128,7 @@ pub fn create_temporal_date(
realm,
new_target,
Intrinsics::temporal_plain_date_prototype,
- |prototype| PlainDate::new(vm, iso_date, calendar, prototype),
+ |_, prototype| PlainDate::new(vm, iso_date, calendar, prototype),
)?;
// 6. Return object.
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_constructor.rs b/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_constructor.rs
index 0f1bea4572e..456d6f2c034 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_constructor.rs
@@ -43,17 +43,14 @@ define_native_function_class!(
impl PlainDateConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<PlainDateConstructor> {
- realm.create_object(
- vm,
- PlainDateConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.PlainDate.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| PlainDateConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.PlainDate.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_prototype.rs b/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_prototype.rs
index d19a40c3e76..a2f04e79d08 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_prototype.rs
@@ -82,17 +82,14 @@ fn calendar_date_of(plain_date: &PlainDate) -> CalendarDate {
impl PlainDatePrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<PlainDatePrototype> {
- realm.create_object(
- vm,
- PlainDatePrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| PlainDatePrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_time.rs b/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_time.rs
index 0f0c0bcd9fb..298d50b1f50 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_time.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_time.rs
@@ -387,7 +387,7 @@ pub fn create_temporal_date_time(
realm,
new_target,
Intrinsics::temporal_plain_date_time_prototype,
- |prototype| PlainDateTime::new(vm, iso_date_time, calendar, prototype),
+ |_, prototype| PlainDateTime::new(vm, iso_date_time, calendar, prototype),
)?;
// 6. Return object.
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_time_constructor.rs b/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_time_constructor.rs
index 2a741900408..2f6b03839c1 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_time_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_time_constructor.rs
@@ -45,17 +45,14 @@ define_native_function_class!(
impl PlainDateTimeConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<PlainDateTimeConstructor> {
- realm.create_object(
- vm,
- PlainDateTimeConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.PlainDateTime.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| PlainDateTimeConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.PlainDateTime.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_time_prototype.rs b/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_time_prototype.rs
index d643ded54ce..ebc8bbcdb00 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_time_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/plain_date_time_prototype.rs
@@ -84,17 +84,14 @@ fn calendar_date_of(plain_date_time: &PlainDateTime) -> CalendarDate {
impl PlainDateTimePrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<PlainDateTimePrototype> {
- realm.create_object(
- vm,
- PlainDateTimePrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| PlainDateTimePrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/plain_month_day.rs b/Libraries/LibJS/Rust/src/runtime/temporal/plain_month_day.rs
index 93df21ffeac..c8215390a00 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/plain_month_day.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/plain_month_day.rs
@@ -220,7 +220,7 @@ pub fn create_temporal_month_day(
realm,
new_target,
Intrinsics::temporal_plain_month_day_prototype,
- |prototype| PlainMonthDay::new(vm, iso_date, calendar, prototype),
+ |_, prototype| PlainMonthDay::new(vm, iso_date, calendar, prototype),
)?;
// 6. Return object.
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/plain_month_day_constructor.rs b/Libraries/LibJS/Rust/src/runtime/temporal/plain_month_day_constructor.rs
index 92e7c679022..a04c68dd4ab 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/plain_month_day_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/plain_month_day_constructor.rs
@@ -43,17 +43,14 @@ define_native_function_class!(
impl PlainMonthDayConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<PlainMonthDayConstructor> {
- realm.create_object(
- vm,
- PlainMonthDayConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.PlainMonthDay.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| PlainMonthDayConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.PlainMonthDay.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/plain_month_day_prototype.rs b/Libraries/LibJS/Rust/src/runtime/temporal/plain_month_day_prototype.rs
index b37019a1a81..20231f1fb9b 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/plain_month_day_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/plain_month_day_prototype.rs
@@ -63,17 +63,14 @@ fn string_value(vm: &Vm, string: &str) -> Value {
impl PlainMonthDayPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<PlainMonthDayPrototype> {
- realm.create_object(
- vm,
- PlainMonthDayPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| PlainMonthDayPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/plain_time.rs b/Libraries/LibJS/Rust/src/runtime/temporal/plain_time.rs
index 24ee6700805..924287faadc 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/plain_time.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/plain_time.rs
@@ -532,7 +532,7 @@ pub fn create_temporal_time(
realm,
new_target,
Intrinsics::temporal_plain_time_prototype,
- |prototype| PlainTime::new(vm, time, prototype),
+ |_, prototype| PlainTime::new(vm, time, prototype),
)?;
// 4. Return object.
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/plain_time_constructor.rs b/Libraries/LibJS/Rust/src/runtime/temporal/plain_time_constructor.rs
index 8157cab78ed..2efe901e203 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/plain_time_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/plain_time_constructor.rs
@@ -41,17 +41,14 @@ define_native_function_class!(
impl PlainTimeConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<PlainTimeConstructor> {
- realm.create_object(
- vm,
- PlainTimeConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.PlainTime.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| PlainTimeConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.PlainTime.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/plain_time_prototype.rs b/Libraries/LibJS/Rust/src/runtime/temporal/plain_time_prototype.rs
index 8c4cb5a174f..17bb16613a9 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/plain_time_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/plain_time_prototype.rs
@@ -63,17 +63,14 @@ fn string_value(vm: &Vm, string: &str) -> Value {
impl PlainTimePrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<PlainTimePrototype> {
- realm.create_object(
- vm,
- PlainTimePrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| PlainTimePrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/plain_year_month.rs b/Libraries/LibJS/Rust/src/runtime/temporal/plain_year_month.rs
index 0c093976266..dd139b4fe99 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/plain_year_month.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/plain_year_month.rs
@@ -242,7 +242,7 @@ pub fn create_temporal_year_month(
realm,
new_target,
Intrinsics::temporal_plain_year_month_prototype,
- |prototype| PlainYearMonth::new(vm, iso_date, calendar, prototype),
+ |_, prototype| PlainYearMonth::new(vm, iso_date, calendar, prototype),
)?;
// 6. Return object.
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/plain_year_month_constructor.rs b/Libraries/LibJS/Rust/src/runtime/temporal/plain_year_month_constructor.rs
index d5fa61ed9a9..3b34e40a4a3 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/plain_year_month_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/plain_year_month_constructor.rs
@@ -43,17 +43,14 @@ define_native_function_class!(
impl PlainYearMonthConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<PlainYearMonthConstructor> {
- realm.create_object(
- vm,
- PlainYearMonthConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.PlainYearMonth.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| PlainYearMonthConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.PlainYearMonth.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/plain_year_month_prototype.rs b/Libraries/LibJS/Rust/src/runtime/temporal/plain_year_month_prototype.rs
index 6e4321fadd6..b798bcc0f00 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/plain_year_month_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/plain_year_month_prototype.rs
@@ -76,17 +76,14 @@ fn string_value(vm: &Vm, string: &str) -> Value {
impl PlainYearMonthPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<PlainYearMonthPrototype> {
- realm.create_object(
- vm,
- PlainYearMonthPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| PlainYearMonthPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/temporal.rs b/Libraries/LibJS/Rust/src/runtime/temporal/temporal.rs
index 2d8b96c2d69..e6d4a82466a 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/temporal.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/temporal.rs
@@ -34,17 +34,14 @@ define_object_class!(Temporal, extends: [Object], methods: {
impl Temporal {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<Temporal> {
- realm.create_object(
- vm,
- Temporal {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| Temporal {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/zoned_date_time.rs b/Libraries/LibJS/Rust/src/runtime/temporal/zoned_date_time.rs
index d2ee0721704..e74c2b756f9 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/zoned_date_time.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/zoned_date_time.rs
@@ -514,7 +514,7 @@ pub fn create_temporal_zoned_date_time(
realm,
new_target,
Intrinsics::temporal_zoned_date_time_prototype,
- |prototype| ZonedDateTime::new(vm, epoch_nanoseconds, time_zone, calendar, prototype),
+ |_, prototype| ZonedDateTime::new(vm, epoch_nanoseconds, time_zone, calendar, prototype),
)?;
// 7. Return object.
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/zoned_date_time_constructor.rs b/Libraries/LibJS/Rust/src/runtime/temporal/zoned_date_time_constructor.rs
index c349d887cf4..de7331314c3 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/zoned_date_time_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/zoned_date_time_constructor.rs
@@ -46,17 +46,14 @@ define_native_function_class!(
impl ZonedDateTimeConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<ZonedDateTimeConstructor> {
- realm.create_object(
- vm,
- ZonedDateTimeConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.ZonedDateTime.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| ZonedDateTimeConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.ZonedDateTime.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/temporal/zoned_date_time_prototype.rs b/Libraries/LibJS/Rust/src/runtime/temporal/zoned_date_time_prototype.rs
index 355b9793aac..6c4c2a6f849 100644
--- a/Libraries/LibJS/Rust/src/runtime/temporal/zoned_date_time_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/temporal/zoned_date_time_prototype.rs
@@ -107,17 +107,14 @@ fn calendar_date_of(zoned_date_time: &ZonedDateTime, iso_date_time: &ISODateTime
impl ZonedDateTimePrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<ZonedDateTimePrototype> {
- realm.create_object(
- vm,
- ZonedDateTimePrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| ZonedDateTimePrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/typed_array.rs b/Libraries/LibJS/Rust/src/runtime/typed_array.rs
index c737c1b08cd..55b59a51554 100644
--- a/Libraries/LibJS/Rust/src/runtime/typed_array.rs
+++ b/Libraries/LibJS/Rust/src/runtime/typed_array.rs
@@ -1698,7 +1698,7 @@ macro_rules! define_typed_arrays {
ArrayBuffer::create(vm, realm, length as usize * element_size, crate::runtime::array_buffer::Shared::No)?;
let typed_array = realm.create_object(
vm,
- $class {
+ |_| $class {
base: TypedArrayBase::new(vm, Self::CLASS, prototype, length, array_buffer, Kind::$class),
},
);
@@ -1724,7 +1724,7 @@ macro_rules! define_typed_arrays {
let prototype = realm.intrinsics().$prototype_accessor(vm);
let typed_array = realm.create_object(
vm,
- $class {
+ |_| $class {
base: TypedArrayBase::new(vm, Self::CLASS, prototype, length, array_buffer, Kind::$class),
},
);
@@ -1748,7 +1748,7 @@ macro_rules! define_typed_arrays {
pub fn create(vm: &Vm, realm: Gc<Realm>, typed_array_prototype: Gc<Object>) -> Gc<$prototype> {
realm.create_object(
vm,
- $prototype {
+ |_| $prototype {
base: Object::new_with_prototype(
vm,
Self::CLASS,
@@ -1790,7 +1790,7 @@ macro_rules! define_typed_arrays {
pub fn create(vm: &Vm, realm: Gc<Realm>, typed_array_constructor: Gc<Object>) -> Gc<$constructor> {
realm.create_object(
vm,
- $constructor {
+ |_| $constructor {
base: NativeFunction::new_with_name(
vm,
Self::CLASS,
diff --git a/Libraries/LibJS/Rust/src/runtime/typed_array_constructor.rs b/Libraries/LibJS/Rust/src/runtime/typed_array_constructor.rs
index 8c29a891239..abe61d0b066 100644
--- a/Libraries/LibJS/Rust/src/runtime/typed_array_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/typed_array_constructor.rs
@@ -42,17 +42,14 @@ define_native_function_class!(
impl TypedArrayConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<TypedArrayConstructor> {
- realm.create_object(
- vm,
- TypedArrayConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.TypedArray.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| TypedArrayConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.TypedArray.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/typed_array_prototype.rs b/Libraries/LibJS/Rust/src/runtime/typed_array_prototype.rs
index cda4d9d577a..880648048f7 100644
--- a/Libraries/LibJS/Rust/src/runtime/typed_array_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/typed_array_prototype.rs
@@ -550,17 +550,14 @@ pub(crate) static LENGTH_GETTER: RawNativeFunctionPointer = raw_native!(TypedArr
impl TypedArrayPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<TypedArrayPrototype> {
- realm.create_object(
- vm,
- TypedArrayPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| TypedArrayPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/value_storage.rs b/Libraries/LibJS/Rust/src/runtime/value_storage.rs
index 5ae58d39832..333721494fb 100644
--- a/Libraries/LibJS/Rust/src/runtime/value_storage.rs
+++ b/Libraries/LibJS/Rust/src/runtime/value_storage.rs
@@ -134,7 +134,7 @@ pub fn allocate(heap: &Heap, capacity: u32, fill: Value) -> *mut Value {
};
let storage = heap.allocate_storage_with_size_class(
size_classes(heap)[index],
- ValueStorage {
+ |_| ValueStorage {
header: CellHeader::for_class(ValueStorage::CLASS),
_padding: [0; 5],
capacity: SIZE_CLASS_CAPACITIES[index],
diff --git a/Libraries/LibJS/Rust/src/runtime/watchpoint_set.rs b/Libraries/LibJS/Rust/src/runtime/watchpoint_set.rs
index 6f930ddec79..a07bec0afe5 100644
--- a/Libraries/LibJS/Rust/src/runtime/watchpoint_set.rs
+++ b/Libraries/LibJS/Rust/src/runtime/watchpoint_set.rs
@@ -67,7 +67,7 @@ unsafe impl Trace for WatchpointSet {
impl WatchpointSet {
pub fn create(vm: &Vm) -> Gc<WatchpointSet> {
- vm.heap().allocate(WatchpointSet {
+ vm.heap().allocate(|_| WatchpointSet {
header: CellHeader::for_class(Self::CLASS),
valid: Cell::new(true),
storage: WatchpointSetStorage::default(),
diff --git a/Libraries/LibJS/Rust/src/runtime/weak_map.rs b/Libraries/LibJS/Rust/src/runtime/weak_map.rs
index 55ca999c6dc..d3dccc67d6c 100644
--- a/Libraries/LibJS/Rust/src/runtime/weak_map.rs
+++ b/Libraries/LibJS/Rust/src/runtime/weak_map.rs
@@ -87,7 +87,7 @@ impl WeakMap {
}
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<WeakMap> {
- realm.create_object(vm, WeakMap::new(vm, realm.intrinsics().weak_map_prototype(vm)))
+ realm.create_object(vm, |_| WeakMap::new(vm, realm.intrinsics().weak_map_prototype(vm)))
}
/// Registers the new WeakMap as a weak container.
diff --git a/Libraries/LibJS/Rust/src/runtime/weak_map_constructor.rs b/Libraries/LibJS/Rust/src/runtime/weak_map_constructor.rs
index 965eeede756..6f1c54dbdfe 100644
--- a/Libraries/LibJS/Rust/src/runtime/weak_map_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/weak_map_constructor.rs
@@ -40,17 +40,14 @@ define_native_function_class!(
impl WeakMapConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<WeakMapConstructor> {
- realm.create_object(
- vm,
- WeakMapConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.WeakMap.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| WeakMapConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.WeakMap.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -83,10 +80,13 @@ impl WeakMapConstructor {
// 2. Let map be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakMap.prototype%", « [[WeakMapData]] »).
// 3. Set map.[[WeakMapData]] to a new empty List.
- let map =
- ordinary_create_from_constructor_of(vm, realm, new_target, Intrinsics::weak_map_prototype, |prototype| {
- WeakMap::new(vm, prototype)
- })?;
+ let map = ordinary_create_from_constructor_of(
+ vm,
+ realm,
+ new_target,
+ Intrinsics::weak_map_prototype,
+ |_, prototype| WeakMap::new(vm, prototype),
+ )?;
// 4. If iterable is either undefined or null, return map.
if iterable.is_nullish() {
diff --git a/Libraries/LibJS/Rust/src/runtime/weak_map_prototype.rs b/Libraries/LibJS/Rust/src/runtime/weak_map_prototype.rs
index 345befce4af..103ce161fb0 100644
--- a/Libraries/LibJS/Rust/src/runtime/weak_map_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/weak_map_prototype.rs
@@ -42,17 +42,14 @@ fn typed_this_weak_map(vm: &Vm) -> ThrowCompletionOr<Gc<WeakMap>> {
impl WeakMapPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<WeakMapPrototype> {
- realm.create_object(
- vm,
- WeakMapPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| WeakMapPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/weak_ref.rs b/Libraries/LibJS/Rust/src/runtime/weak_ref.rs
index ca5732b5a95..005195f4c0a 100644
--- a/Libraries/LibJS/Rust/src/runtime/weak_ref.rs
+++ b/Libraries/LibJS/Rust/src/runtime/weak_ref.rs
@@ -8,8 +8,8 @@ use core::cell::Cell;
use core::ptr::NonNull;
use crate::gc::class::{GcCell, define_cell};
-use crate::gc::visitor::{Trace, Visitor};
use crate::gc::sweep::Sweep;
+use crate::gc::visitor::{Trace, Visitor};
use crate::gc::weak_container::WeakContainer;
use crate::interpreter::vm::Vm;
use crate::layout::cell::Gc;
@@ -61,7 +61,9 @@ impl WeakRef {
}
pub fn create(vm: &Vm, realm: Gc<Realm>, value: Value) -> Gc<WeakRef> {
- realm.create_object(vm, WeakRef::new(vm, value, realm.intrinsics().weak_ref_prototype(vm)))
+ realm.create_object(vm, |_| {
+ WeakRef::new(vm, value, realm.intrinsics().weak_ref_prototype(vm))
+ })
}
/// Registers the new WeakRef as a weak container.
diff --git a/Libraries/LibJS/Rust/src/runtime/weak_ref_constructor.rs b/Libraries/LibJS/Rust/src/runtime/weak_ref_constructor.rs
index 1667dcf6b9d..39ab316f202 100644
--- a/Libraries/LibJS/Rust/src/runtime/weak_ref_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/weak_ref_constructor.rs
@@ -37,17 +37,14 @@ define_native_function_class!(
impl WeakRefConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<WeakRefConstructor> {
- realm.create_object(
- vm,
- WeakRefConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.WeakRef.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| WeakRefConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.WeakRef.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -87,10 +84,13 @@ impl WeakRefConstructor {
// 4. Perform AddToKeptObjects(target).
// 5. Set weakRef.[[WeakRefTarget]] to target.
// 6. Return weakRef.
- let weak_ref =
- ordinary_create_from_constructor_of(vm, realm, new_target, Intrinsics::weak_ref_prototype, |prototype| {
- WeakRef::new(vm, target, prototype)
- })?;
+ let weak_ref = ordinary_create_from_constructor_of(
+ vm,
+ realm,
+ new_target,
+ Intrinsics::weak_ref_prototype,
+ |_, prototype| WeakRef::new(vm, target, prototype),
+ )?;
Ok(weak_ref.upcast())
}
}
diff --git a/Libraries/LibJS/Rust/src/runtime/weak_ref_prototype.rs b/Libraries/LibJS/Rust/src/runtime/weak_ref_prototype.rs
index 434fe8c923b..e262afba0b4 100644
--- a/Libraries/LibJS/Rust/src/runtime/weak_ref_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/weak_ref_prototype.rs
@@ -35,17 +35,14 @@ define_object_class!(WeakRefPrototype, extends: [Object], methods: {
impl WeakRefPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<WeakRefPrototype> {
- realm.create_object(
- vm,
- WeakRefPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| WeakRefPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/weak_set.rs b/Libraries/LibJS/Rust/src/runtime/weak_set.rs
index f1b995c81b3..f85924412b6 100644
--- a/Libraries/LibJS/Rust/src/runtime/weak_set.rs
+++ b/Libraries/LibJS/Rust/src/runtime/weak_set.rs
@@ -82,7 +82,7 @@ impl WeakSet {
}
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<WeakSet> {
- realm.create_object(vm, WeakSet::new(vm, realm.intrinsics().weak_set_prototype(vm)))
+ realm.create_object(vm, |_| WeakSet::new(vm, realm.intrinsics().weak_set_prototype(vm)))
}
/// Registers the new WeakSet as a weak container.
diff --git a/Libraries/LibJS/Rust/src/runtime/weak_set_constructor.rs b/Libraries/LibJS/Rust/src/runtime/weak_set_constructor.rs
index 79d19e09d28..0d37a996cc9 100644
--- a/Libraries/LibJS/Rust/src/runtime/weak_set_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/weak_set_constructor.rs
@@ -38,17 +38,14 @@ define_native_function_class!(
impl WeakSetConstructor {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<WeakSetConstructor> {
- realm.create_object(
- vm,
- WeakSetConstructor {
- base: NativeFunction::new_with_name(
- vm,
- Self::CLASS,
- vm.names.WeakSet.as_string().clone(),
- realm.function_prototype(),
- ),
- },
- )
+ realm.create_object(vm, |_| WeakSetConstructor {
+ base: NativeFunction::new_with_name(
+ vm,
+ Self::CLASS,
+ vm.names.WeakSet.as_string().clone(),
+ realm.function_prototype(),
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -81,10 +78,13 @@ impl WeakSetConstructor {
// 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakSet.prototype%", « [[WeakSetData]] »).
// 3. Set set.[[WeakSetData]] to a new empty List.
- let set =
- ordinary_create_from_constructor_of(vm, realm, new_target, Intrinsics::weak_set_prototype, |prototype| {
- WeakSet::new(vm, prototype)
- })?;
+ let set = ordinary_create_from_constructor_of(
+ vm,
+ realm,
+ new_target,
+ Intrinsics::weak_set_prototype,
+ |_, prototype| WeakSet::new(vm, prototype),
+ )?;
// 4. If iterable is either undefined or null, return set.
if iterable.is_nullish() {
diff --git a/Libraries/LibJS/Rust/src/runtime/weak_set_prototype.rs b/Libraries/LibJS/Rust/src/runtime/weak_set_prototype.rs
index d6dca0c7022..6a5c610ba63 100644
--- a/Libraries/LibJS/Rust/src/runtime/weak_set_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/weak_set_prototype.rs
@@ -42,17 +42,14 @@ fn typed_this_weak_set(vm: &Vm) -> ThrowCompletionOr<Gc<WeakSet>> {
impl WeakSetPrototype {
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<WeakSetPrototype> {
- realm.create_object(
- vm,
- WeakSetPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.object_prototype(),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| WeakSetPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.object_prototype(),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/runtime/wrap_for_valid_iterator_prototype.rs b/Libraries/LibJS/Rust/src/runtime/wrap_for_valid_iterator_prototype.rs
index 53c6b0748b3..9872bd613ea 100644
--- a/Libraries/LibJS/Rust/src/runtime/wrap_for_valid_iterator_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/wrap_for_valid_iterator_prototype.rs
@@ -37,17 +37,14 @@ const DISPLAY_NAME: &str = "Iterator";
impl WrapForValidIteratorPrototype {
// 27.1.3.2.1.1 The %WrapForValidIteratorPrototype% Object, https://tc39.es/ecma262/#sec-%wrapforvaliditeratorprototype%-object
pub fn create(vm: &Vm, realm: Gc<Realm>) -> Gc<WrapForValidIteratorPrototype> {
- realm.create_object(
- vm,
- WrapForValidIteratorPrototype {
- base: Object::new_with_prototype(
- vm,
- Self::CLASS,
- realm.intrinsics().iterator_prototype(vm),
- MayInterfereWithIndexedPropertyAccess::No,
- ),
- },
- )
+ realm.create_object(vm, |_| WrapForValidIteratorPrototype {
+ base: Object::new_with_prototype(
+ vm,
+ Self::CLASS,
+ realm.intrinsics().iterator_prototype(vm),
+ MayInterfereWithIndexedPropertyAccess::No,
+ ),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibJS/Rust/src/script.rs b/Libraries/LibJS/Rust/src/script.rs
index 5f14f8afb55..ace1666f128 100644
--- a/Libraries/LibJS/Rust/src/script.rs
+++ b/Libraries/LibJS/Rust/src/script.rs
@@ -358,7 +358,7 @@ impl Script {
) -> Gc<Script> {
let declared_function_names = parts.function_names.iter().cloned().collect();
- let script = vm.heap().allocate(Script {
+ let script = vm.heap().allocate(|_| Script {
header: CellHeader::for_class(Self::CLASS),
realm,
loaded_modules: GcRefCell::new(Vec::new()),
diff --git a/Libraries/LibJS/Rust/src/utilities/js.rs b/Libraries/LibJS/Rust/src/utilities/js.rs
index c1c97a31e52..ecbfb50c55a 100644
--- a/Libraries/LibJS/Rust/src/utilities/js.rs
+++ b/Libraries/LibJS/Rust/src/utilities/js.rs
@@ -436,12 +436,9 @@ define_object_class!(ReplObject, extends: [GlobalObject, Object], methods: {
impl ReplObject {
pub fn allocate(vm: &Vm, realm: Gc<Realm>) -> Gc<ReplObject> {
- allocate_object(
- vm,
- ReplObject {
- base: GlobalObject::new(vm, Self::CLASS, realm),
- },
- )
+ allocate_object(vm, |_| ReplObject {
+ base: GlobalObject::new(vm, Self::CLASS, realm),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -567,12 +564,9 @@ define_object_class!(ScriptObject, extends: [GlobalObject, Object], methods: {
impl ScriptObject {
pub fn allocate(vm: &Vm, realm: Gc<Realm>) -> Gc<ScriptObject> {
- allocate_object(
- vm,
- ScriptObject {
- base: GlobalObject::new(vm, Self::CLASS, realm),
- },
- )
+ allocate_object(vm, |_| ScriptObject {
+ base: GlobalObject::new(vm, Self::CLASS, realm),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
@@ -1551,7 +1545,7 @@ static REPL_CONSOLE_CLIENT_METHODS: ConsoleClientMethods = ConsoleClientMethods
impl ReplConsoleClient {
pub fn create(vm: &Vm, console: Gc<Console>) -> Gc<ReplConsoleClient> {
- vm.heap().allocate(ReplConsoleClient {
+ vm.heap().allocate(|_| ReplConsoleClient {
base: ConsoleClient::new(Self::CLASS, &REPL_CONSOLE_CLIENT_METHODS, console),
group_stack_depth: Cell::new(0),
})
diff --git a/Libraries/LibJS/Rust/src/utilities/test_js/javascript_test_runner.rs b/Libraries/LibJS/Rust/src/utilities/test_js/javascript_test_runner.rs
index bfebe3af663..fc12a8b4e6f 100644
--- a/Libraries/LibJS/Rust/src/utilities/test_js/javascript_test_runner.rs
+++ b/Libraries/LibJS/Rust/src/utilities/test_js/javascript_test_runner.rs
@@ -70,13 +70,10 @@ impl TestRunnerGlobalObject {
/// realm->create<TestRunnerGlobalObject>(), which already runs initialize() once before InitializeHostDefinedRealm
/// runs it again after SetDefaultGlobalBindings, so the properties it defines come before the default bindings.
pub fn create(vm: &Vm, realm: Gc<Realm>, prints_test_timings: bool) -> Gc<TestRunnerGlobalObject> {
- realm.create_object(
- vm,
- TestRunnerGlobalObject {
- base: GlobalObject::new(vm, Self::CLASS, realm),
- prints_test_timings: Cell::new(prints_test_timings),
- },
- )
+ realm.create_object(vm, |_| TestRunnerGlobalObject {
+ base: GlobalObject::new(vm, Self::CLASS, realm),
+ prints_test_timings: Cell::new(prints_test_timings),
+ })
}
fn initialize(object: &Object, vm: &Vm, realm: Gc<Realm>) {
diff --git a/Libraries/LibWeb/Bindings/Rust/src/bindings/async_iterable.rs b/Libraries/LibWeb/Bindings/Rust/src/bindings/async_iterable.rs
index 0c3eda80524..b122b5de39a 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/bindings/async_iterable.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/bindings/async_iterable.rs
@@ -92,15 +92,12 @@ pub(crate) fn create_default_async_iterator<T: DefaultAsyncIteratorClasses>(
) -> Value {
let vm = cx.vm();
let realm = cx.realm();
- let iterator = T::ASYNC_ITERATOR_CELL_CLASS.allocate(
- vm,
- DefaultAsyncIterator {
- realm,
- state,
- ongoing_promise: Cell::new(None),
- is_finished: Cell::new(false),
- },
- );
+ let iterator = T::ASYNC_ITERATOR_CELL_CLASS.allocate(vm, |_| DefaultAsyncIterator {
+ realm,
+ state,
+ ongoing_promise: Cell::new(None),
+ is_finished: Cell::new(false),
+ });
// SAFETY: The realm is live, and the interface is asynchronously iterable.
let prototype = unsafe { web_bindings_ensure_web_iterator_prototype(realm.as_ptr().cast(), T::INTERFACE_NAME) };
let prototype = NonNull::new(prototype.cast::<Object>()).expect("LibWeb returns the iterator prototype object");
diff --git a/Libraries/LibWeb/Bindings/Rust/src/bindings/interface.rs b/Libraries/LibWeb/Bindings/Rust/src/bindings/interface.rs
index 8bf77590fd5..22e9f8602db 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/bindings/interface.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/bindings/interface.rs
@@ -22,10 +22,10 @@ use core::ptr::NonNull;
use ak::Utf16FlyString;
use libjs_rust::api::{
- Attribute, EmbedderCell, EmbedderClass, EmbedderValue, ErrorKind, ErrorType, ExternalMemorySize, FunctionObject,
- Gc, HostObject, JSHostClass, Object, PrimitiveString, PropertyAttributes, PropertyKey, RawNativeFunction,
- RawNativeFunctionPointer, Realm, Throw, ThrowCompletionOr, Trace, Value, Vm, get_function_realm, host_data_of,
- is_host_instance_of,
+ Attribute, DeferGc, EmbedderCell, EmbedderClass, EmbedderValue, ErrorKind, ErrorType, ExternalMemorySize,
+ FunctionObject, Gc, HostObject, JSHostClass, Object, PrimitiveString, PropertyAttributes, PropertyKey,
+ RawNativeFunction, RawNativeFunctionPointer, Realm, Throw, ThrowCompletionOr, Trace, Value, Vm, get_function_realm,
+ host_data_of, is_host_instance_of,
};
use crate::bindings::CallContext;
@@ -162,15 +162,12 @@ impl<T: Wrappable + Trace + Sized + 'static> Interface for T {
}
}
-/// A new object of the interface, which has no wrapper until something asks for one.
-pub(crate) fn allocate<T: Interface>(vm: &Vm, implementation: T) -> Ref<T> {
- T::CELL_CLASS.allocate(
- vm,
- Wrapped {
- main_world_wrapper: Cell::new(None),
- implementation,
- },
- )
+/// A new object of the interface, built as Heap::allocate() builds a cell.
+pub(crate) fn allocate<T: Interface>(vm: &Vm, build: impl FnOnce(&DeferGc<'_>) -> T) -> Ref<T> {
+ T::CELL_CLASS.allocate(vm, |defer_gc| Wrapped {
+ main_world_wrapper: Cell::new(None),
+ implementation: build(defer_gc),
+ })
}
/// What the constructor steps or the transfer-receiving steps of an interface create: the implementation of the new
@@ -182,7 +179,7 @@ pub(crate) trait ConstructedObject<T: Interface> {
impl<T: Interface> ConstructedObject<T> for T {
fn into_object(self, vm: &Vm) -> Ref<T> {
- allocate(vm, self)
+ allocate(vm, |_| self)
}
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/bindings/iterable.rs b/Libraries/LibWeb/Bindings/Rust/src/bindings/iterable.rs
index 54f7dcf700e..4541f612b4d 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/bindings/iterable.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/bindings/iterable.rs
@@ -99,14 +99,11 @@ pub(crate) fn create_default_iterator<T: DefaultIteratorClasses>(
) -> Value {
let vm = cx.vm();
let realm = cx.realm();
- let iterator = T::ITERATOR_CELL_CLASS.allocate(
- vm,
- DefaultIterator {
- target,
- kind,
- index: Cell::new(0),
- },
- );
+ let iterator = T::ITERATOR_CELL_CLASS.allocate(vm, |_| DefaultIterator {
+ target,
+ kind,
+ index: Cell::new(0),
+ });
// SAFETY: The realm is live, and the interface has a pair iterator.
let prototype = unsafe { web_bindings_ensure_web_iterator_prototype(realm.as_ptr().cast(), T::INTERFACE_NAME) };
let prototype = NonNull::new(prototype.cast::<Object>()).expect("LibWeb returns the iterator prototype object");
diff --git a/Libraries/LibWeb/Bindings/Rust/src/bindings/promise.rs b/Libraries/LibWeb/Bindings/Rust/src/bindings/promise.rs
index 21c609263f3..615d4d845df 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/bindings/promise.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/bindings/promise.rs
@@ -349,17 +349,14 @@ fn wait_for_all(vm: &Vm, realm: Gc<Realm>, promises: &[WebIdlPromise], promise:
// 8. Let result be a list containing total null values.
let total = promises.len();
let result = Array::create_from(vm, realm, &vec![Value::NULL; total]);
- let state = WAIT_FOR_ALL_CLASS.allocate(
- vm,
- WaitForAll {
- promise,
- realm,
- rejected: Cell::new(false),
- result,
- total,
- fulfilled_count: Cell::new(0),
- },
- );
+ let state = WAIT_FOR_ALL_CLASS.allocate(vm, |_| WaitForAll {
+ promise,
+ realm,
+ rejected: Cell::new(false),
+ result,
+ total,
+ fulfilled_count: Cell::new(0),
+ });
// 3. Let rejectionHandlerSteps be the following steps given arg:
let rejection_handler_steps = |vm: &Vm, state: &Gc<EmbedderCell<WaitForAll>>| {
diff --git a/Libraries/LibWeb/Bindings/Rust/src/bindings/realm_data.rs b/Libraries/LibWeb/Bindings/Rust/src/bindings/realm_data.rs
index 97801aa949d..e4623146363 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/bindings/realm_data.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/bindings/realm_data.rs
@@ -51,7 +51,7 @@ pub(crate) fn realm_data(vm: &Vm, realm: Gc<Realm>) -> Gc<EmbedderCell<RealmData
if let Some(data) = realm.embedder_data::<RealmData>() {
return data;
}
- let data = REALM_DATA_CLASS.allocate(vm, RealmData::default());
+ let data = REALM_DATA_CLASS.allocate(vm, |_| RealmData::default());
realm.set_embedder_data(data);
data
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/exports.rs b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/exports.rs
index 0ddc7603cc4..dca64957376 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/exports.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/exports.rs
@@ -93,9 +93,9 @@ pub unsafe extern "C" fn web_canvas_2d_context_create(
},
});
if arguments.canvas_is_offscreen {
- cell_into_abi(allocate(vm, RenderingContext2D::<Offscreen>::new(state)))
+ cell_into_abi(allocate(vm, |_| RenderingContext2D::<Offscreen>::new(state)))
} else {
- cell_into_abi(allocate(vm, RenderingContext2D::<OnScreen>::new(state)))
+ cell_into_abi(allocate(vm, |_| RenderingContext2D::<OnScreen>::new(state)))
}
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/domurl/origin.rs b/Libraries/LibWeb/Bindings/Rust/src/domurl/origin.rs
index 28a4a0fa84c..8395d30d70e 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/domurl/origin.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/domurl/origin.rs
@@ -44,7 +44,7 @@ impl Origin {
// 1. Let origin be the result of executing value's extract an origin operation.
// 2. If origin is not null, then return a new Origin object whose origin is origin.
if let Some(origin) = extract_an_origin(value) {
- return Ok(allocate(cx.vm(), Self { origin }));
+ return Ok(allocate(cx.vm(), |_| Self { origin }));
}
// 2. If value is a string:
@@ -57,7 +57,7 @@ impl Origin {
// origin.
if let Some(parsed_url) = parsed_url {
let origin = parsed_url.origin();
- return Ok(allocate(cx.vm(), Self { origin }));
+ return Ok(allocate(cx.vm(), |_| Self { origin }));
}
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/domurl/url.rs b/Libraries/LibWeb/Bindings/Rust/src/domurl/url.rs
index 72b30719e23..fd8744d98da 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/domurl/url.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/domurl/url.rs
@@ -97,7 +97,7 @@ impl URL {
// 3. Set url's query object to a new URLSearchParams object.
// 4. Initialize url's query object with query.
// 5. Set url's query object's URL object to url.
- let query_object = allocate(vm, URLSearchParams::new(parse_query(query), Some(*this)));
+ let query_object = allocate(vm, |_| URLSearchParams::new(parse_query(query), Some(*this)));
this.query.set(Some(query_object));
query_object
}
@@ -128,7 +128,7 @@ impl URL {
// 3. Let url be a new URL object.
// 4. Initialize url with parsedURL.
// 5. Return url.
- Ok(Some(allocate(cx.vm(), Self::initialize(parsed_url))))
+ Ok(Some(allocate(cx.vm(), |_| Self::initialize(parsed_url))))
}
// https://url.spec.whatwg.org/#dom-url-canparse
diff --git a/Libraries/LibWeb/Bindings/Rust/src/file_api/blob.rs b/Libraries/LibWeb/Bindings/Rust/src/file_api/blob.rs
index e358d546305..9adf989926a 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/file_api/blob.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/file_api/blob.rs
@@ -397,7 +397,9 @@ impl Blob {
// 3. If end is given, set sliceEnd to end.
// 3. If contentType is given, set sliceContentType to contentType.
// 4. Return the result of slice blob given this, sliceStart, sliceEnd, and sliceContentType.
- Ok(allocate(cx.vm(), self.slice_blob(start, end, content_type.as_ref())))
+ Ok(allocate(cx.vm(), |_| {
+ self.slice_blob(start, end, content_type.as_ref())
+ }))
}
// https://w3c.github.io/FileAPI/#slice-blob
diff --git a/Libraries/LibWeb/Bindings/Rust/src/file_api/exports.rs b/Libraries/LibWeb/Bindings/Rust/src/file_api/exports.rs
index 9e22ec5a81b..02c6c9b1095 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/file_api/exports.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/file_api/exports.rs
@@ -63,7 +63,7 @@ pub unsafe extern "C" fn web_blob_create(vm: *mut c_void, bytes: ForeignBytesAbi
let vm = unsafe { vm_from_abi(vm) };
// SAFETY: The caller hands over the bytes and the string.
let blob = unsafe { Blob::with_foreign_bytes(bytes, Utf16String::from_raw_owned(r#type)) };
- cell_into_abi(allocate(vm, blob))
+ cell_into_abi(allocate(vm, |_| blob))
}
/// The byte sequence of the Blob or File, which lives until the object dies or its bytes move to shared memory.
@@ -147,7 +147,7 @@ pub unsafe extern "C" fn web_blob_slice(
has_end.then_some(end),
content_type.as_ref(),
);
- cell_into_abi(allocate(vm, sliced_blob))
+ cell_into_abi(allocate(vm, |_| sliced_blob))
}
/// Whether the cell of a Blob or a File is that of a File.
@@ -193,7 +193,7 @@ pub unsafe extern "C" fn web_file_create(
last_modified: has_last_modified.then_some(last_modified),
};
let file = File::create(bytes.as_slice().to_vec(), file_name, &options);
- cell_into_abi(allocate(vm, file))
+ cell_into_abi(allocate(vm, |_| file))
}
/// The name of the File, a raw AK::Utf16String that the call lends for as long as the File lives.
diff --git a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_matrix.rs b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_matrix.rs
index a9cf3e3aeda..9aae192272d 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_matrix.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_matrix.rs
@@ -48,19 +48,20 @@ impl DOMMatrix {
/// https://drafts.fxtf.org/geometry/#dom-dommatrix-frommatrix
pub(crate) fn from_matrix(cx: &mut CallContext, other: DOMMatrixInit) -> WebIdlResult<Ref<Self>> {
// The fromMatrix(other) static method on DOMMatrix must create a DOMMatrix from the dictionary other.
- Ok(allocate(cx.vm(), Self::from_dictionary(&other)?))
+ let matrix = Self::from_dictionary(&other)?;
+ Ok(allocate(cx.vm(), |_| matrix))
}
/// https://drafts.fxtf.org/geometry/#dom-dommatrix-fromfloat32array
pub(crate) fn from_float32_array(cx: &mut CallContext, array32: Gc<TypedArrayBase>) -> WebIdlResult<Ref<Self>> {
let matrix = DOMMatrixReadOnly::from_typed_array(array32)?;
- Ok(allocate(cx.vm(), Self::from_read_only(matrix)))
+ Ok(allocate(cx.vm(), |_| Self::from_read_only(matrix)))
}
/// https://drafts.fxtf.org/geometry/#dom-dommatrix-fromfloat64array
pub(crate) fn from_float64_array(cx: &mut CallContext, array64: Gc<TypedArrayBase>) -> WebIdlResult<Ref<Self>> {
let matrix = DOMMatrixReadOnly::from_typed_array(array64)?;
- Ok(allocate(cx.vm(), Self::from_read_only(matrix)))
+ Ok(allocate(cx.vm(), |_| Self::from_read_only(matrix)))
}
/// https://drafts.fxtf.org/geometry/#create-a-dommatrix-from-the-dictionary
diff --git a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_matrix_read_only.rs b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_matrix_read_only.rs
index 4dec1b81c7b..e57e2a730e3 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_matrix_read_only.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_matrix_read_only.rs
@@ -184,7 +184,8 @@ impl DOMMatrixReadOnly {
pub(crate) fn from_matrix(cx: &mut CallContext, other: DOMMatrixInit) -> WebIdlResult<Ref<Self>> {
// The fromMatrix(other) static method on DOMMatrixReadOnly must create a DOMMatrixReadOnly from the dictionary
// other.
- Ok(allocate(cx.vm(), Self::from_dictionary(&other)?))
+ let matrix = Self::from_dictionary(&other)?;
+ Ok(allocate(cx.vm(), |_| matrix))
}
/// https://drafts.fxtf.org/geometry/#create-a-dommatrixreadonly-from-the-dictionary
@@ -222,12 +223,14 @@ impl DOMMatrixReadOnly {
/// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-fromfloat32array
pub(crate) fn from_float32_array(cx: &mut CallContext, array32: Gc<TypedArrayBase>) -> WebIdlResult<Ref<Self>> {
- Ok(allocate(cx.vm(), Self::from_typed_array(array32)?))
+ let matrix = Self::from_typed_array(array32)?;
+ Ok(allocate(cx.vm(), |_| matrix))
}
/// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-fromfloat64array
pub(crate) fn from_float64_array(cx: &mut CallContext, array64: Gc<TypedArrayBase>) -> WebIdlResult<Ref<Self>> {
- Ok(allocate(cx.vm(), Self::from_typed_array(array64)?))
+ let matrix = Self::from_typed_array(array64)?;
+ Ok(allocate(cx.vm(), |_| matrix))
}
/// The steps of fromFloat32Array() and fromFloat64Array() on DOMMatrixReadOnly and DOMMatrix, for a Float32Array
@@ -413,7 +416,7 @@ impl DOMMatrixReadOnly {
result.parent().translate_self_steps(tx, ty, tz);
// 3. Return result.
- Ok(allocate(cx.vm(), result))
+ Ok(allocate(cx.vm(), |_| result))
}
/// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-scale
@@ -441,7 +444,7 @@ impl DOMMatrixReadOnly {
.scale_self_steps(scale_x, Some(scale_y), scale_z, origin_x, origin_y, origin_z);
// 4. Return result.
- Ok(allocate(cx.vm(), result))
+ Ok(allocate(cx.vm(), |_| result))
}
/// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-scalenonuniform
@@ -460,7 +463,7 @@ impl DOMMatrixReadOnly {
.scale_self_steps(scale_x, Some(scale_y), 1.0, 0.0, 0.0, 0.0);
// 3. Return result.
- Ok(allocate(cx.vm(), result))
+ Ok(allocate(cx.vm(), |_| result))
}
/// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-scale3d
@@ -479,7 +482,7 @@ impl DOMMatrixReadOnly {
result.parent().scale3d_self_steps(scale, origin_x, origin_y, origin_z);
// 3. Return result.
- Ok(allocate(cx.vm(), result))
+ Ok(allocate(cx.vm(), |_| result))
}
/// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-rotate
@@ -497,7 +500,7 @@ impl DOMMatrixReadOnly {
result.parent().rotate_self_steps(rot_x, rot_y, rot_z);
// 3. Return result.
- Ok(allocate(cx.vm(), result))
+ Ok(allocate(cx.vm(), |_| result))
}
/// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-rotatefromvector
@@ -509,7 +512,7 @@ impl DOMMatrixReadOnly {
result.parent().rotate_from_vector_self_steps(x, y);
// 3. Return result.
- Ok(allocate(cx.vm(), result))
+ Ok(allocate(cx.vm(), |_| result))
}
/// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-rotateaxisangle
@@ -528,7 +531,7 @@ impl DOMMatrixReadOnly {
result.parent().rotate_axis_angle_self_steps(x, y, z, angle);
// 3. Return result.
- Ok(allocate(cx.vm(), result))
+ Ok(allocate(cx.vm(), |_| result))
}
/// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-skewx
@@ -540,7 +543,7 @@ impl DOMMatrixReadOnly {
result.parent().skew_x_self_steps(sx);
// 3. Return result.
- Ok(allocate(cx.vm(), result))
+ Ok(allocate(cx.vm(), |_| result))
}
/// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-skewy
@@ -552,7 +555,7 @@ impl DOMMatrixReadOnly {
result.parent().skew_y_self_steps(sy);
// 3. Return result.
- Ok(allocate(cx.vm(), result))
+ Ok(allocate(cx.vm(), |_| result))
}
/// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-multiply
@@ -565,7 +568,7 @@ impl DOMMatrixReadOnly {
result.parent().multiply_self_steps(other_object.parent());
// 3. Return result.
- Ok(allocate(cx.vm(), result))
+ Ok(allocate(cx.vm(), |_| result))
}
/// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-flipx
@@ -578,7 +581,7 @@ impl DOMMatrixReadOnly {
result.parent().set_matrix(matrix);
// 3. Return result.
- Ok(allocate(cx.vm(), result))
+ Ok(allocate(cx.vm(), |_| result))
}
/// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-flipy
@@ -591,7 +594,7 @@ impl DOMMatrixReadOnly {
result.parent().set_matrix(matrix);
// 3. Return result.
- Ok(allocate(cx.vm(), result))
+ Ok(allocate(cx.vm(), |_| result))
}
/// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-inverse
@@ -604,7 +607,7 @@ impl DOMMatrixReadOnly {
// 3. Return result.
// The current matrix is not modified.
- Ok(allocate(cx.vm(), result))
+ Ok(allocate(cx.vm(), |_| result))
}
/// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-transformpoint
@@ -613,7 +616,7 @@ impl DOMMatrixReadOnly {
// invoking transform a point with a matrix, given pointObject and the current matrix. The passed argument
// does not get modified.
let point_object = DOMPointReadOnly::from_dictionary(&point);
- Ok(allocate(cx.vm(), self.transform_point_steps(&point_object)))
+ Ok(allocate(cx.vm(), |_| self.transform_point_steps(&point_object)))
}
/// https://drafts.fxtf.org/geometry/#transform-a-point-with-a-matrix
diff --git a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_point.rs b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_point.rs
index e81562136b0..4b342588771 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_point.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_point.rs
@@ -44,7 +44,7 @@ impl DOMPoint {
/// https://drafts.fxtf.org/geometry/#dom-dompoint-frompoint
pub(crate) fn from_point(cx: &mut CallContext, other: DOMPointInit) -> WebIdlResult<Ref<Self>> {
// The fromPoint(other) static method on DOMPoint must create a DOMPoint from the dictionary other.
- Ok(allocate(cx.vm(), Self::from_dictionary(&other)))
+ Ok(allocate(cx.vm(), |_| Self::from_dictionary(&other)))
}
/// https://drafts.fxtf.org/geometry/#create-a-dompoint-from-the-dictionary
diff --git a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_point_read_only.rs b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_point_read_only.rs
index e5050a5aca2..e41338bd2a3 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_point_read_only.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_point_read_only.rs
@@ -55,7 +55,7 @@ impl DOMPointReadOnly {
pub(crate) fn from_point(cx: &mut CallContext, other: DOMPointInit) -> WebIdlResult<Ref<Self>> {
// The fromPoint(other) static method on DOMPointReadOnly must create a DOMPointReadOnly from the dictionary
// other.
- Ok(allocate(cx.vm(), Self::from_dictionary(&other)))
+ Ok(allocate(cx.vm(), |_| Self::from_dictionary(&other)))
}
/// https://drafts.fxtf.org/geometry/#create-a-dompointreadonly-from-the-dictionary
@@ -115,7 +115,9 @@ impl DOMPointReadOnly {
// 2. Return the result of invoking transform a point with a matrix, given the current point and matrixObject.
// The current point does not get modified.
- Ok(allocate(cx.vm(), matrix_object.parent().transform_point_steps(self)))
+ Ok(allocate(cx.vm(), |_| {
+ matrix_object.parent().transform_point_steps(self)
+ }))
}
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_quad.rs b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_quad.rs
index f8d89914f8c..e2c14a8aff9 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_quad.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_quad.rs
@@ -31,7 +31,7 @@ impl Wrappable for DOMQuad {}
/// A new DOMPoint object with its attributes set to the values of the namesake dictionary members in the dictionary.
fn new_point(vm: &Vm, init: &DOMPointInit) -> Ref<DOMPoint> {
- allocate(vm, DOMPoint::from_dictionary(init))
+ allocate(vm, |_| DOMPoint::from_dictionary(init))
}
impl DOMQuad {
@@ -75,7 +75,7 @@ impl DOMQuad {
pub(crate) fn from_rect(cx: &mut CallContext, other: DOMRectInit) -> WebIdlResult<Ref<Self>> {
// The fromRect(other) static method on DOMQuad must create a DOMQuad from the DOMRectInit dictionary other.
let quad = Self::from_rect_dictionary(cx.vm(), &other);
- Ok(allocate(cx.vm(), quad))
+ Ok(allocate(cx.vm(), |_| quad))
}
/// https://drafts.fxtf.org/geometry/#create-a-domquad-from-the-domrectinit-dictionary
@@ -86,19 +86,19 @@ impl DOMQuad {
// 2. Let point1 be a new DOMPoint object with x coordinate set to x, y coordinate set to y, z coordinate set
// to 0 and w perspective set to 1.
- let point1 = allocate(vm, DOMPoint::new(x, y, 0.0, 1.0));
+ let point1 = allocate(vm, |_| DOMPoint::new(x, y, 0.0, 1.0));
// 3. Let point2 be a new DOMPoint object with x coordinate set to x + width, y coordinate set to y, z
// coordinate set to 0 and w perspective set to 1.
- let point2 = allocate(vm, DOMPoint::new(x + width, y, 0.0, 1.0));
+ let point2 = allocate(vm, |_| DOMPoint::new(x + width, y, 0.0, 1.0));
// 4. Let point3 be a new DOMPoint object with x coordinate set to x + width, y coordinate set to y + height, z
// coordinate set to 0 and w perspective set to 1.
- let point3 = allocate(vm, DOMPoint::new(x + width, y + height, 0.0, 1.0));
+ let point3 = allocate(vm, |_| DOMPoint::new(x + width, y + height, 0.0, 1.0));
// 5. Let point4 be a new DOMPoint object with x coordinate set to x, y coordinate set to y + height, z
// coordinate set to 0 and w perspective set to 1.
- let point4 = allocate(vm, DOMPoint::new(x, y + height, 0.0, 1.0));
+ let point4 = allocate(vm, |_| DOMPoint::new(x, y + height, 0.0, 1.0));
// 6. Return a new DOMQuad with point 1 set to point1, point 2 set to point2, point 3 set to point3 and point 4
// set to point4.
@@ -134,15 +134,12 @@ impl DOMQuad {
// 5. Return a new DOMQuad with point 1 set to point1, point 2 set to point2, point 3 set to point3 and point 4
// set to point4.
- Ok(allocate(
- vm,
- Self {
- p1: point1,
- p2: point2,
- p3: point3,
- p4: point4,
- },
- ))
+ Ok(allocate(vm, |_| Self {
+ p1: point1,
+ p2: point2,
+ p3: point3,
+ p4: point4,
+ }))
}
/// https://drafts.fxtf.org/geometry/#dom-domquad-p1
@@ -196,7 +193,9 @@ impl DOMQuad {
// 6. Set x coordinate of bounds to left, y coordinate of bounds to top, width dimension of bounds to right -
// left and height dimension of bounds to bottom - top.
// 7. Return bounds.
- Ok(allocate(cx.vm(), DOMRect::new(left, top, right - left, bottom - top)))
+ Ok(allocate(cx.vm(), |_| {
+ DOMRect::new(left, top, right - left, bottom - top)
+ }))
}
}
@@ -229,16 +228,20 @@ impl Serializable for DOMQuad {
/// https://drafts.fxtf.org/geometry/#structured-serialization
fn deserialization_steps(cx: &mut CallContext, serialized: &mut SerializationReader) -> WebIdlResult<Self> {
// 1. Set value’s point 1 to the sub-deserialization of serialized.[[P1]].
- let p1 = allocate(cx.vm(), serialized.read_object_in_place::<DOMPoint>(cx)?);
+ let p1 = serialized.read_object_in_place::<DOMPoint>(cx)?;
+ let p1 = allocate(cx.vm(), |_| p1);
// 2. Set value’s point 2 to the sub-deserialization of serialized.[[P2]].
- let p2 = allocate(cx.vm(), serialized.read_object_in_place::<DOMPoint>(cx)?);
+ let p2 = serialized.read_object_in_place::<DOMPoint>(cx)?;
+ let p2 = allocate(cx.vm(), |_| p2);
// 3. Set value’s point 3 to the sub-deserialization of serialized.[[P3]].
- let p3 = allocate(cx.vm(), serialized.read_object_in_place::<DOMPoint>(cx)?);
+ let p3 = serialized.read_object_in_place::<DOMPoint>(cx)?;
+ let p3 = allocate(cx.vm(), |_| p3);
// 4. Set value’s point 4 to the sub-deserialization of serialized.[[P4]].
- let p4 = allocate(cx.vm(), serialized.read_object_in_place::<DOMPoint>(cx)?);
+ let p4 = serialized.read_object_in_place::<DOMPoint>(cx)?;
+ let p4 = allocate(cx.vm(), |_| p4);
Ok(Self { p1, p2, p3, p4 })
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_rect.rs b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_rect.rs
index 92326235cd4..af84299088d 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_rect.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_rect.rs
@@ -44,12 +44,9 @@ impl DOMRect {
/// https://drafts.fxtf.org/geometry/#dom-domrect-fromrect
pub(crate) fn from_rect(cx: &mut CallContext, other: DOMRectInit) -> WebIdlResult<Ref<Self>> {
// The fromRect(other) static method on DOMRect must create a DOMRect from the dictionary other.
- Ok(allocate(
- cx.vm(),
- Self {
- rect: DOMRectReadOnly::from_dictionary(&other),
- },
- ))
+ Ok(allocate(cx.vm(), |_| Self {
+ rect: DOMRectReadOnly::from_dictionary(&other),
+ }))
}
/// https://drafts.fxtf.org/geometry/#dom-domrect-x
diff --git a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_rect_read_only.rs b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_rect_read_only.rs
index f6e167d3831..a4640f1fd04 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_rect_read_only.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_rect_read_only.rs
@@ -53,7 +53,7 @@ impl DOMRectReadOnly {
/// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-fromrect
pub(crate) fn from_rect(cx: &mut CallContext, other: DOMRectInit) -> WebIdlResult<Ref<Self>> {
// The fromRect(other) static method on DOMRectReadOnly must create a DOMRectReadOnly from the dictionary other.
- Ok(allocate(cx.vm(), Self::from_dictionary(&other)))
+ Ok(allocate(cx.vm(), |_| Self::from_dictionary(&other)))
}
/// https://drafts.fxtf.org/geometry/#create-a-domrectreadonly-from-the-dictionary
diff --git a/Libraries/LibWeb/Bindings/Rust/src/geometry/exports.rs b/Libraries/LibWeb/Bindings/Rust/src/geometry/exports.rs
index b187dd1e0c8..c7b630480f2 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/geometry/exports.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/geometry/exports.rs
@@ -51,7 +51,7 @@ unsafe fn matrix_from_abi<'a>(cell: *mut c_void) -> &'a DOMMatrixReadOnly {
#[unsafe(no_mangle)]
pub extern "C" fn web_dom_point_read_only_create(vm: &Vm, x: f64, y: f64, z: f64, w: f64) -> *mut c_void {
- cell_into_abi(allocate(vm, DOMPointReadOnly::new(x, y, z, w)))
+ cell_into_abi(allocate(vm, |_| DOMPointReadOnly::new(x, y, z, w)))
}
/// Stores the coordinates x, y, z and w of the point, in that order.
@@ -78,17 +78,17 @@ pub unsafe extern "C" fn web_dom_point_set_x_and_y(point: *mut c_void, x: f64, y
#[unsafe(no_mangle)]
pub extern "C" fn web_dom_point_create(vm: &Vm, x: f64, y: f64, z: f64, w: f64) -> *mut c_void {
- cell_into_abi(allocate(vm, DOMPoint::new(x, y, z, w)))
+ cell_into_abi(allocate(vm, |_| DOMPoint::new(x, y, z, w)))
}
#[unsafe(no_mangle)]
pub extern "C" fn web_dom_rect_read_only_create(vm: &Vm, x: f64, y: f64, width: f64, height: f64) -> *mut c_void {
- cell_into_abi(allocate(vm, DOMRectReadOnly::new(x, y, width, height)))
+ cell_into_abi(allocate(vm, |_| DOMRectReadOnly::new(x, y, width, height)))
}
#[unsafe(no_mangle)]
pub extern "C" fn web_dom_rect_create(vm: &Vm, x: f64, y: f64, width: f64, height: f64) -> *mut c_void {
- cell_into_abi(allocate(vm, DOMRect::new(x, y, width, height)))
+ cell_into_abi(allocate(vm, |_| DOMRect::new(x, y, width, height)))
}
/// Sets the x coordinate, y coordinate, width dimension and height dimension of the rectangle.
@@ -113,17 +113,17 @@ pub extern "C" fn web_dom_rect_list_create(vm: &Vm, rects: ak::Span<'_, [f64; 4]
// list holds them.
let created = MarkedVec::with_capacity(vm, rects.as_slice().len());
for &[x, y, width, height] in rects.as_slice() {
- created.push(allocate(vm, DOMRect::new(x, y, width, height)));
+ created.push(allocate(vm, |_| DOMRect::new(x, y, width, height)));
}
let list = DOMRectList::new(&created.values());
- cell_into_abi(allocate(vm, list))
+ cell_into_abi(allocate(vm, |_| list))
}
/// A new DOMMatrix whose elements m11, m12, m13, m14, m21, ..., m44 are the values, in that order.
#[unsafe(no_mangle)]
pub extern "C" fn web_dom_matrix_create(vm: &Vm, elements: &[f64; 16], is_2d: bool) -> *mut c_void {
let matrix = DOMMatrixReadOnly::new(Matrix4::from_column_major(*elements), is_2d);
- cell_into_abi(allocate(vm, DOMMatrix::from_read_only(matrix)))
+ cell_into_abi(allocate(vm, |_| DOMMatrix::from_read_only(matrix)))
}
/// A new DOMMatrix initialized to the values of the matrix.
@@ -136,7 +136,7 @@ pub unsafe extern "C" fn web_dom_matrix_create_from_read_only(vm: &Vm, matrix: *
// SAFETY: The caller passes a live cell.
let matrix = unsafe { matrix_from_abi(matrix) };
let copy = DOMMatrixReadOnly::new(matrix.matrix(), matrix.is_2d());
- cell_into_abi(allocate(vm, DOMMatrix::from_read_only(copy)))
+ cell_into_abi(allocate(vm, |_| DOMMatrix::from_read_only(copy)))
}
/// Stores the elements m11, m12, m13, m14, m21, ..., m44 of the matrix, in that order.
diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/canvas_gradient.rs b/Libraries/LibWeb/Bindings/Rust/src/html/canvas_gradient.rs
index e3f096ae174..773593021ab 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/html/canvas_gradient.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/html/canvas_gradient.rs
@@ -69,13 +69,10 @@ fn point(x: f64, y: f64) -> FloatPoint {
impl CanvasGradient {
fn create(vm: &Vm, geometry: GradientGeometry) -> Ref<Self> {
- allocate(
- vm,
- Self {
- geometry,
- color_stops: RefCell::new(ColorStopList::default()),
- },
- )
+ allocate(vm, |_| Self {
+ geometry,
+ color_stops: RefCell::new(ColorStopList::default()),
+ })
}
/// The gradient of createLinearGradient(), https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createlineargradient
diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/canvas_pattern.rs b/Libraries/LibWeb/Bindings/Rust/src/html/canvas_pattern.rs
index 112df58dd04..a79fea929a7 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/html/canvas_pattern.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/html/canvas_pattern.rs
@@ -104,15 +104,12 @@ impl CanvasPattern {
/// The pattern of createPattern(), whose image and repetition the context has checked,
/// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createpattern
pub(crate) fn create(vm: &Vm, image: Option<ImageFrameHandle>, repetition: Canvas2DPatternRepetition) -> Ref<Self> {
- allocate(
- vm,
- Self {
- image,
- repetition,
- transform: Cell::new(None),
- not_origin_clean: Cell::new(false),
- },
- )
+ allocate(vm, |_| Self {
+ image,
+ repetition,
+ transform: Cell::new(None),
+ not_origin_clean: Cell::new(false),
+ })
}
/// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createpattern
diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/canvas_transform.rs b/Libraries/LibWeb/Bindings/Rust/src/html/canvas_transform.rs
index a1006d9179f..17b9329e5a9 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/html/canvas_transform.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/html/canvas_transform.rs
@@ -144,7 +144,7 @@ impl<K: CanvasKind> RenderingContext2D<K> {
let transform = self.drawing_state().transform;
let elements = transform.values.map(f64::from);
let matrix = DOMMatrix::from_read_only(DOMMatrixReadOnly::create_2d_matrix(elements));
- Ok(allocate(cx.vm(), matrix))
+ Ok(allocate(cx.vm(), |_| matrix))
}
/// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-settransform
diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/image_bitmap.rs b/Libraries/LibWeb/Bindings/Rust/src/html/image_bitmap.rs
index 0d70426ce7b..92a50c300ff 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/html/image_bitmap.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/html/image_bitmap.rs
@@ -113,7 +113,7 @@ impl ImageBitmap {
/// A new ImageBitmap whose bitmap data is the frame, or that has none.
pub(crate) fn create(vm: &Vm, frame: Option<ImageFrameHandle>) -> Ref<Self> {
- allocate(vm, Self::new(frame.map(BitmapData::new)))
+ allocate(vm, |_| Self::new(frame.map(BitmapData::new)))
}
/// The frame of the bitmap data, unless the ImageBitmap has none, as when it is closed or transferred.
@@ -252,9 +252,8 @@ impl Transferable for ImageBitmap {
// SAFETY: The data holder is lent for the steps.
unsafe { web_image_bitmap_receive_bitmap(data_holder.as_raw(), &mut frame) }.into_completion()?;
// SAFETY: C++ hands over the frame it decoded, or null.
- Ok(allocate(
- cx.vm(),
- Self::new(unsafe { BitmapData::from_handed_over_frame(frame) }),
- ))
+ Ok(allocate(cx.vm(), |_| {
+ Self::new(unsafe { BitmapData::from_handed_over_frame(frame) })
+ }))
}
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/image_data.rs b/Libraries/LibWeb/Bindings/Rust/src/html/image_data.rs
index d1f7dc09b58..b4a4437af38 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/html/image_data.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/html/image_data.rs
@@ -152,7 +152,7 @@ impl ImageData {
default_color_space: Option<PredefinedColorSpace>,
) -> WebIdlResult<Ref<Self>> {
let image_data = Self::initialize(cx, height, width, settings, None, default_color_space)?;
- Ok(allocate(cx.vm(), image_data))
+ Ok(allocate(cx.vm(), |_| image_data))
}
/// https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#initialize-an-imagedata-object
diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/text_metrics.rs b/Libraries/LibWeb/Bindings/Rust/src/html/text_metrics.rs
index 0d4130a0009..f52068c4343 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/html/text_metrics.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/html/text_metrics.rs
@@ -42,7 +42,7 @@ impl Wrappable for TextMetrics {}
impl TextMetrics {
pub(crate) fn create(vm: &Vm, measurements: TextMeasurements) -> Ref<Self> {
- allocate(vm, Self { measurements })
+ allocate(vm, |_| Self { measurements })
}
pub(crate) fn width(&self, _: &mut CallContext) -> WebIdlResult<f64> {
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/cross_realm_transform.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/cross_realm_transform.rs
index 4d15b78d72a..18f31f7f852 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/streams/cross_realm_transform.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/cross_realm_transform.rs
@@ -335,9 +335,9 @@ pub(crate) fn set_up_cross_realm_transform_readable(
initialize_readable_stream(stream);
// 2. Let controller be a new ReadableStreamDefaultController.
- let controller = allocate(cx.vm(), ReadableStreamDefaultController::new());
+ let controller = allocate(cx.vm(), |_| ReadableStreamDefaultController::new());
let state = ReadableHandlerState {
- port: PORT_CELL_CLASS.allocate(cx.vm(), PortCell(port.clone())),
+ port: PORT_CELL_CLASS.allocate(cx.vm(), |_| PortCell(port.clone())),
controller,
};
@@ -511,17 +511,14 @@ pub(crate) fn set_up_cross_realm_transform_writable(
initialize_writable_stream(cx.vm(), stream);
// 2. Let controller be a new WritableStreamDefaultController.
- let controller = allocate(cx.vm(), WritableStreamDefaultController::new());
+ let controller = allocate(cx.vm(), |_| WritableStreamDefaultController::new());
// 3. Let backpressurePromise be a new promise.
- let state = CROSS_REALM_WRITABLE_STATE_CLASS.allocate(
- cx.vm(),
- CrossRealmWritableState {
- port: port.clone(),
- controller,
- backpressure_promise: Cell::new(Some(create_promise(cx.vm(), cx.realm()))),
- },
- );
+ let state = CROSS_REALM_WRITABLE_STATE_CLASS.allocate(cx.vm(), |_| CrossRealmWritableState {
+ port: port.clone(),
+ controller,
+ backpressure_promise: Cell::new(Some(create_promise(cx.vm(), cx.realm()))),
+ });
// 4. Add a handler for port’s message event with the following steps:
fn on_message(cx: &CallContext, state: Gc<EmbedderCell<CrossRealmWritableState>>, data: Value) {
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/exports.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/exports.rs
index 9a9914f6940..908ae9c88f0 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/streams/exports.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/exports.rs
@@ -67,7 +67,7 @@ fn promise_into_abi(promise: WebIdlPromise) -> *mut c_void {
pub unsafe extern "C" fn web_rust_readable_stream_create(vm: *mut c_void, realm: *mut c_void) -> *mut c_void {
// SAFETY: The caller passes the VM and a live realm.
let (vm, realm) = unsafe { realm_arguments(vm, realm) };
- cell_into_abi(allocate(vm, ReadableStream::new(realm)))
+ cell_into_abi(allocate(vm, |_| ReadableStream::new(realm)))
}
/// Sets the stream up with byte reading support, https://streams.spec.whatwg.org/#readablestream-set-up-with-byte-reading-support,
@@ -450,7 +450,7 @@ pub unsafe extern "C" fn web_rust_readable_stream_default_reader_closed_promise_
pub unsafe extern "C" fn web_rust_transform_stream_create(vm: *mut c_void, realm: *mut c_void) -> *mut c_void {
// SAFETY: The caller passes the VM and a live realm.
let (vm, realm) = unsafe { realm_arguments(vm, realm) };
- cell_into_abi(allocate(vm, TransformStream::new(realm)))
+ cell_into_abi(allocate(vm, |_| TransformStream::new(realm)))
}
/// Sets the stream up with the algorithms that C++ gives, https://streams.spec.whatwg.org/#transformstream-set-up
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/generic_transform_stream.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/generic_transform_stream.rs
index b44d077285a..59e8a919db6 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/streams/generic_transform_stream.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/generic_transform_stream.rs
@@ -142,8 +142,8 @@ unsafe fn flush_entry<T: TransformSteps>(
/// A new TransformStream, set up with the steps, https://streams.spec.whatwg.org/#transformstream-set-up
pub(crate) fn create_and_set_up<T: TransformSteps>(cx: &CallContext, steps: T) -> Ref<TransformStream> {
- let steps = T::CLASS.allocate(cx.vm(), steps);
- let stream = allocate(cx.vm(), TransformStream::new(cx.realm()));
+ let steps = T::CLASS.allocate(cx.vm(), |_| steps);
+ let stream = allocate(cx.vm(), |_| TransformStream::new(cx.realm()));
let algorithms = RustTransformSteps::new(steps, stream);
TransformStream::set_up(
stream,
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/readable_byte_stream_controller.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/readable_byte_stream_controller.rs
index 370247c8c5e..0dabe846b8f 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/streams/readable_byte_stream_controller.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/readable_byte_stream_controller.rs
@@ -326,20 +326,17 @@ impl ReadableByteStreamController {
// element size 1
// view constructor %Uint8Array%
// reader type "default"
- let pull_into_descriptor = PULL_INTO_DESCRIPTOR_CLASS.allocate(
- vm,
- PullIntoDescriptor {
- buffer: Cell::new(buffer),
- buffer_byte_length: Cell::new(auto_allocate_chunk_size),
- byte_offset: Cell::new(0),
- byte_length: Cell::new(auto_allocate_chunk_size),
- bytes_filled: Cell::new(0),
- minimum_fill: Cell::new(1),
- element_size: Cell::new(1),
- view_constructor: cx.realm().intrinsics().uint8_array_constructor(vm),
- reader_type: Cell::new(ReaderType::Default),
- },
- );
+ let pull_into_descriptor = PULL_INTO_DESCRIPTOR_CLASS.allocate(vm, |_| PullIntoDescriptor {
+ buffer: Cell::new(buffer),
+ buffer_byte_length: Cell::new(auto_allocate_chunk_size),
+ byte_offset: Cell::new(0),
+ byte_length: Cell::new(auto_allocate_chunk_size),
+ bytes_filled: Cell::new(0),
+ minimum_fill: Cell::new(1),
+ element_size: Cell::new(1),
+ view_constructor: cx.realm().intrinsics().uint8_array_constructor(vm),
+ reader_type: Cell::new(ReaderType::Default),
+ });
// 4. Append pullIntoDescriptor to this.[[pendingPullIntos]].
this.pending_pull_intos.borrow_mut(vm).push_back(pull_into_descriptor);
@@ -1140,7 +1137,7 @@ pub(crate) fn readable_byte_stream_controller_get_byob_request(
.expect("a Uint8Array is a typed array");
// 3. Let byobRequest be a new ReadableStreamBYOBRequest.
- let byob_request = allocate(vm, ReadableStreamBYOBRequest::new());
+ let byob_request = allocate(vm, |_| ReadableStreamBYOBRequest::new());
// 4. Set byobRequest.[[controller]] to controller.
byob_request.set_controller(Some(controller));
@@ -1353,20 +1350,17 @@ pub(crate) fn readable_byte_stream_controller_pull_into(
// element size elementSize
// view constructor ctor
// reader type "byob"
- let pull_into_descriptor = PULL_INTO_DESCRIPTOR_CLASS.allocate(
- vm,
- PullIntoDescriptor {
- buffer: Cell::new(buffer),
- buffer_byte_length: Cell::new(buffer.byte_length() as u64),
- byte_offset: Cell::new(byte_offset),
- byte_length: Cell::new(byte_length),
- bytes_filled: Cell::new(0),
- minimum_fill: Cell::new(minimum_fill),
- element_size: Cell::new(element_size),
- view_constructor: ctor,
- reader_type: Cell::new(ReaderType::Byob),
- },
- );
+ let pull_into_descriptor = PULL_INTO_DESCRIPTOR_CLASS.allocate(vm, |_| PullIntoDescriptor {
+ buffer: Cell::new(buffer),
+ buffer_byte_length: Cell::new(buffer.byte_length() as u64),
+ byte_offset: Cell::new(byte_offset),
+ byte_length: Cell::new(byte_length),
+ bytes_filled: Cell::new(0),
+ minimum_fill: Cell::new(minimum_fill),
+ element_size: Cell::new(element_size),
+ view_constructor: ctor,
+ reader_type: Cell::new(ReaderType::Byob),
+ });
// 14. If controller.[[pendingPullIntos]] is not empty,
if !controller.pending_pull_intos_is_empty() {
@@ -1927,7 +1921,7 @@ pub(crate) fn set_up_readable_byte_stream_controller_from_underlying_source(
high_water_mark: f64,
) -> WebIdlResult<()> {
// 1. Let controller be a new ReadableByteStreamController.
- let controller = allocate(cx.vm(), ReadableByteStreamController::new());
+ let controller = allocate(cx.vm(), |_| ReadableByteStreamController::new());
// 2. Let startAlgorithm be an algorithm that returns undefined.
let mut start_algorithm = StartAlgorithm::ReturnsUndefined;
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream.rs
index 68f0581774f..4c77a867815 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream.rs
@@ -227,7 +227,7 @@ impl ReadableStream {
let underlying_source_dict = UnderlyingSource::from_js(cx.vm(), underlying_source)?;
// 3. Perform ! InitializeReadableStream(this).
- let this = allocate(cx.vm(), Self::new(cx.realm()));
+ let this = allocate(cx.vm(), |_| Self::new(cx.realm()));
// 4. If underlyingSourceDict["type"] is "bytes":
if underlying_source_dict.r#type == Some(ReadableStreamType::Bytes) {
@@ -574,7 +574,7 @@ impl Transferable for ReadableStream {
let (port1, port2) = create_entangled_ports(cx);
// 5. Let writable be a new WritableStream in the current Realm.
- let writable = allocate(cx.vm(), WritableStream::new(cx.realm()));
+ let writable = allocate(cx.vm(), |_| WritableStream::new(cx.realm()));
// 6. Perform ! SetUpCrossRealmTransformWritable(writable, port1).
set_up_cross_realm_transform_writable(cx, writable, port1);
@@ -595,7 +595,7 @@ impl Transferable for ReadableStream {
fn transfer_receiving_steps(cx: &mut CallContext, data_holder: &mut TransferDataReader) -> WebIdlResult<Ref<Self>> {
let cx = &*cx;
with_temporary_execution_context_and_callbacks(cx.realm(), || {
- let value = allocate(cx.vm(), Self::new(cx.realm()));
+ let value = allocate(cx.vm(), |_| Self::new(cx.realm()));
// 1. Let deserializedRecord be ! StructuredDeserializeWithTransfer(dataHolder.[[port]], the current Realm).
// 2. Let port be deserializedRecord.[[Deserialized]].
@@ -631,7 +631,7 @@ impl ReadableStream {
// 4. Perform ! InitializeReadableStream(stream).
// 5. Let controller be a new ReadableByteStreamController.
- let controller = allocate(cx.vm(), ReadableByteStreamController::new());
+ let controller = allocate(cx.vm(), |_| ReadableByteStreamController::new());
// 6. Perform ! SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithmWrapper,
// cancelAlgorithmWrapper, highWaterMark, undefined).
@@ -820,7 +820,7 @@ pub(crate) fn acquire_readable_stream_byob_reader(
stream: Ref<ReadableStream>,
) -> WebIdlResult<Ref<ReadableStreamBYOBReader>> {
// 1. Let reader be a new ReadableStreamBYOBReader.
- let reader = allocate(cx.vm(), ReadableStreamBYOBReader::new());
+ let reader = allocate(cx.vm(), |_| ReadableStreamBYOBReader::new());
// 2. Perform ? SetUpReadableStreamBYOBReader(reader, stream).
set_up_readable_stream_byob_reader(cx, reader, stream)?;
@@ -835,7 +835,7 @@ pub(crate) fn acquire_readable_stream_default_reader(
stream: Ref<ReadableStream>,
) -> WebIdlResult<Ref<ReadableStreamDefaultReader>> {
// 1. Let reader be a new ReadableStreamDefaultReader.
- let reader = allocate(cx.vm(), ReadableStreamDefaultReader::new());
+ let reader = allocate(cx.vm(), |_| ReadableStreamDefaultReader::new());
// 2. Perform ? SetUpReadableStreamDefaultReader(reader, stream).
set_up_readable_stream_default_reader(cx, reader, stream)?;
@@ -855,7 +855,7 @@ pub(crate) fn create_readable_stream(
) -> WebIdlResult<Ref<ReadableStream>> {
// 4. Let stream be a new ReadableStream.
// 5. Perform ! InitializeReadableStream(stream).
- let stream = allocate(cx.vm(), ReadableStream::new(cx.realm()));
+ let stream = allocate(cx.vm(), |_| ReadableStream::new(cx.realm()));
create_readable_stream_with_existing_stream(
cx,
stream,
@@ -893,7 +893,7 @@ pub(crate) fn create_readable_stream_with_existing_stream(
initialize_readable_stream(stream);
// 6. Let controller be a new ReadableStreamDefaultController.
- let controller = allocate(cx.vm(), ReadableStreamDefaultController::new());
+ let controller = allocate(cx.vm(), |_| ReadableStreamDefaultController::new());
// 7. Perform ? SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm,
// cancelAlgorithm, highWaterMark, sizeAlgorithm).
@@ -920,10 +920,10 @@ pub(crate) fn create_readable_byte_stream(
) -> WebIdlResult<Ref<ReadableStream>> {
// 1. Let stream be a new ReadableStream.
// 2. Perform ! InitializeReadableStream(stream).
- let stream = allocate(cx.vm(), ReadableStream::new(cx.realm()));
+ let stream = allocate(cx.vm(), |_| ReadableStream::new(cx.realm()));
// 3. Let controller be a new ReadableByteStreamController.
- let controller = allocate(cx.vm(), ReadableByteStreamController::new());
+ let controller = allocate(cx.vm(), |_| ReadableByteStreamController::new());
// 4. Perform ? SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm,
// cancelAlgorithm, 0, undefined).
@@ -969,7 +969,7 @@ pub(crate) fn readable_stream_from_iterable(
) -> WebIdlResult<Ref<ReadableStream>> {
// 1. Let stream be undefined.
// NB: The algorithms below refer to the stream, so it is created here.
- let stream = allocate(cx.vm(), ReadableStream::new(cx.realm()));
+ let stream = allocate(cx.vm(), |_| ReadableStream::new(cx.realm()));
// 2. Let iteratorRecord be ? GetIterator(asyncIterable, async).
let iterator_record = get_iterator(cx.vm(), async_iterable, IteratorHint::Async)?;
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_byob_reader.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_byob_reader.rs
index 54e763fc2f4..36a4fcee49e 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_byob_reader.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_byob_reader.rs
@@ -87,7 +87,7 @@ impl ReadableStreamBYOBReader {
// https://streams.spec.whatwg.org/#byob-reader-constructor
pub(crate) fn construct(cx: &mut CallContext, stream: Ref<ReadableStream>) -> WebIdlResult<Ref<Self>> {
- let reader = allocate(cx.vm(), Self::new());
+ let reader = allocate(cx.vm(), |_| Self::new());
// 1. Perform ? SetUpReadableStreamBYOBReader(this, stream).
set_up_readable_stream_byob_reader(cx, reader, stream)?;
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_default_controller.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_default_controller.rs
index 2353041e61a..07296a5f389 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_default_controller.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_default_controller.rs
@@ -557,7 +557,7 @@ pub(crate) fn set_up_readable_stream_default_controller_from_underlying_source(
size_algorithm: SizeAlgorithm,
) -> WebIdlResult<()> {
// 1. Let controller be a new ReadableStreamDefaultController.
- let controller = allocate(cx.vm(), ReadableStreamDefaultController::new());
+ let controller = allocate(cx.vm(), |_| ReadableStreamDefaultController::new());
// 2. Let startAlgorithm be an algorithm that returns undefined.
let mut start_algorithm = StartAlgorithm::ReturnsUndefined;
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_default_reader.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_default_reader.rs
index 21bb061e20a..ff7fd542853 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_default_reader.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_default_reader.rs
@@ -104,7 +104,7 @@ impl ReadableStreamDefaultReader {
// https://streams.spec.whatwg.org/#default-reader-constructor
pub(crate) fn construct(cx: &mut CallContext, stream: Ref<ReadableStream>) -> WebIdlResult<Ref<Self>> {
- let reader = allocate(cx.vm(), Self::new());
+ let reader = allocate(cx.vm(), |_| Self::new());
// 1. Perform ? SetUpReadableStreamDefaultReader(this, stream).
set_up_readable_stream_default_reader(cx, reader, stream)?;
@@ -187,16 +187,13 @@ impl ReadableStreamDefaultReader {
// https://streams.spec.whatwg.org/#read-loop
// 1. Let readRequest be a new read request with the following items:
// NOTE: The items are the steps of ReadLoop.
- let read_request = READ_LOOP_CLASS.allocate(
- vm,
- ReadLoop {
- realm,
- reader,
- bytes: core::cell::RefCell::new(Vec::new()),
- success_steps,
- failure_steps,
- },
- );
+ let read_request = READ_LOOP_CLASS.allocate(vm, |_| ReadLoop {
+ realm,
+ reader,
+ bytes: core::cell::RefCell::new(Vec::new()),
+ success_steps,
+ failure_steps,
+ });
// 2. Perform ! ReadableStreamDefaultReaderRead(reader, readRequest).
readable_stream_default_reader_read(vm, reader, ReadRequest::ReadLoop(read_request));
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_pipe_to.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_pipe_to.rs
index a5b46520002..a484f256bfb 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_pipe_to.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_pipe_to.rs
@@ -549,24 +549,21 @@ pub(crate) fn readable_stream_pipe_to(
// 13. Let promise be a new promise.
let promise = create_promise(vm, cx.realm());
- let this = PIPE_TO_CLASS.allocate(
- vm,
- PipeTo {
- promise,
- source,
- destination,
- reader,
- writer,
- signal: GcRefCell::new(None),
- signal_algorithm_id: Cell::new(None),
- last_write_promise: Cell::new(None),
- unwritten_chunks: GcRefCell::new(VecDeque::new()),
- prevent_close,
- prevent_abort,
- prevent_cancel,
- shutting_down: Cell::new(false),
- },
- );
+ let this = PIPE_TO_CLASS.allocate(vm, |_| PipeTo {
+ promise,
+ source,
+ destination,
+ reader,
+ writer,
+ signal: GcRefCell::new(None),
+ signal_algorithm_id: Cell::new(None),
+ last_write_promise: Cell::new(None),
+ unwritten_chunks: GcRefCell::new(VecDeque::new()),
+ prevent_close,
+ prevent_abort,
+ prevent_cancel,
+ shutting_down: Cell::new(false),
+ });
reader.set_pipe_to(Some(this));
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_tee.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_tee.rs
index f02b51c57dc..316c13c01d3 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_tee.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/readable_stream_tee.rs
@@ -411,15 +411,15 @@ impl ByteTeeState {
let other_branch = if !for_branch2 { this.branch2() } else { this.branch1() };
// 4. Let readIntoRequest be a read-into request with the following items:
- let read_into_request = ReadIntoRequest::ByteTee(BYTE_TEE_BYOB_READ_REQUEST_CLASS.allocate(
- cx.vm(),
- ByteTeeBYOBReadRequest {
- state: this,
- byob_branch,
- other_branch,
- for_branch2,
- },
- ));
+ let read_into_request =
+ ReadIntoRequest::ByteTee(
+ BYTE_TEE_BYOB_READ_REQUEST_CLASS.allocate(cx.vm(), |_| ByteTeeBYOBReadRequest {
+ state: this,
+ byob_branch,
+ other_branch,
+ for_branch2,
+ }),
+ );
// 5. Perform ! ReadableStreamBYOBReaderRead(reader, view, 1, readIntoRequest).
let ReadableStreamReader::ReadableStreamBYOBReader(reader) = this.reader.get() else {
@@ -933,23 +933,20 @@ pub(crate) fn readable_stream_default_tee(
// 11. Let branch2 be undefined.
// 12. Let cancelPromise be a new promise.
let cancel_promise = create_promise(vm, cx.realm());
- let state = DEFAULT_TEE_STATE_CLASS.allocate(
- vm,
- DefaultTeeState {
- stream,
- reader,
- reading: Cell::new(false),
- read_again: Cell::new(false),
- canceled1: Cell::new(false),
- canceled2: Cell::new(false),
- reason1: Cell::new(Value::UNDEFINED),
- reason2: Cell::new(Value::UNDEFINED),
- branch1: Cell::new(None),
- branch2: Cell::new(None),
- cancel_promise,
- clone_for_branch2,
- },
- );
+ let state = DEFAULT_TEE_STATE_CLASS.allocate(vm, |_| DefaultTeeState {
+ stream,
+ reader,
+ reading: Cell::new(false),
+ read_again: Cell::new(false),
+ canceled1: Cell::new(false),
+ canceled2: Cell::new(false),
+ reason1: Cell::new(Value::UNDEFINED),
+ reason2: Cell::new(Value::UNDEFINED),
+ branch1: Cell::new(None),
+ branch2: Cell::new(None),
+ cancel_promise,
+ clone_for_branch2,
+ });
// 13. Let pullAlgorithm be the following steps:
// 14. Let cancel1Algorithm be the following steps, taking a reason argument:
@@ -1040,23 +1037,20 @@ pub(crate) fn readable_byte_stream_tee(
// 12. Let branch2 be undefined.
// 13. Let cancelPromise be a new promise.
let cancel_promise = create_promise(vm, cx.realm());
- let state = BYTE_TEE_STATE_CLASS.allocate(
- vm,
- ByteTeeState {
- stream,
- reader: Cell::new(ReadableStreamReader::ReadableStreamDefaultReader(reader)),
- reading: Cell::new(false),
- read_again_for_branch1: Cell::new(false),
- read_again_for_branch2: Cell::new(false),
- canceled1: Cell::new(false),
- canceled2: Cell::new(false),
- reason1: Cell::new(Value::UNDEFINED),
- reason2: Cell::new(Value::UNDEFINED),
- branch1: Cell::new(None),
- branch2: Cell::new(None),
- cancel_promise,
- },
- );
+ let state = BYTE_TEE_STATE_CLASS.allocate(vm, |_| ByteTeeState {
+ stream,
+ reader: Cell::new(ReadableStreamReader::ReadableStreamDefaultReader(reader)),
+ reading: Cell::new(false),
+ read_again_for_branch1: Cell::new(false),
+ read_again_for_branch2: Cell::new(false),
+ canceled1: Cell::new(false),
+ canceled2: Cell::new(false),
+ reason1: Cell::new(Value::UNDEFINED),
+ reason2: Cell::new(Value::UNDEFINED),
+ branch1: Cell::new(None),
+ branch2: Cell::new(None),
+ cancel_promise,
+ });
// 14. Let forwardReaderError be the following steps, taking a thisReader argument:
// 15. Let pullWithDefaultReader be the following steps:
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/transform_stream.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/transform_stream.rs
index 335f72bc112..f070cf281ed 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/streams/transform_stream.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/transform_stream.rs
@@ -149,7 +149,7 @@ impl TransformStream {
writable_strategy: QueuingStrategy,
readable_strategy: QueuingStrategy,
) -> WebIdlResult<Ref<Self>> {
- let this = allocate(cx.vm(), Self::new(cx.realm()));
+ let this = allocate(cx.vm(), |_| Self::new(cx.realm()));
// 1. If transformer is missing, set it to null.
let transformer = transformer.map_or(Value::NULL, Value::from_object);
@@ -272,7 +272,7 @@ impl TransformStream {
);
// 10. Let controller be a new TransformStreamDefaultController.
- let controller = allocate(cx.vm(), TransformStreamDefaultController::new());
+ let controller = allocate(cx.vm(), |_| TransformStreamDefaultController::new());
// 11. Perform ! SetUpTransformStreamDefaultController(stream, controller, transformAlgorithmWrapper,
// flushAlgorithmWrapper, cancelAlgorithmWrapper).
@@ -345,7 +345,7 @@ impl Transferable for TransformStream {
// https://streams.spec.whatwg.org/#ref-for-transfer-receiving-steps②
fn transfer_receiving_steps(cx: &mut CallContext, data_holder: &mut TransferDataReader) -> WebIdlResult<Ref<Self>> {
- let value = allocate(cx.vm(), Self::new(cx.realm()));
+ let value = allocate(cx.vm(), |_| Self::new(cx.realm()));
// 1. Let readableRecord be ! StructuredDeserializeWithTransfer(dataHolder.[[readable]], the current Realm).
let readable_record = deserialize_with_transfer(data_holder);
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/transform_stream_default_controller.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/transform_stream_default_controller.rs
index e4d1811acfc..d258eabdcd1 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/streams/transform_stream_default_controller.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/transform_stream_default_controller.rs
@@ -168,7 +168,7 @@ pub(crate) fn set_up_transform_stream_default_controller_from_transformer(
transformer_dict: Transformer,
) {
// 1. Let controller be a new TransformStreamDefaultController.
- let controller = allocate(cx.vm(), TransformStreamDefaultController::new());
+ let controller = allocate(cx.vm(), |_| TransformStreamDefaultController::new());
// 2. Let transformAlgorithm be the following steps, taking a chunk argument:
let mut transform_algorithm = TransformAlgorithm::Enqueue(controller);
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/writable_stream.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/writable_stream.rs
index 3ea61224364..6c433bd12fc 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/streams/writable_stream.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/writable_stream.rs
@@ -180,7 +180,7 @@ impl WritableStream {
}
// 4. Perform ! InitializeWritableStream(this).
- let this = allocate(cx.vm(), Self::new(cx.realm()));
+ let this = allocate(cx.vm(), |_| Self::new(cx.realm()));
// 5. Let sizeAlgorithm be ! ExtractSizeAlgorithm(strategy).
let size_algorithm = extract_size_algorithm(&strategy);
@@ -273,7 +273,7 @@ impl Transferable for WritableStream {
let (port1, port2) = create_entangled_ports(cx);
// 5. Let readable be a new ReadableStream in the current Realm.
- let readable = allocate(cx.vm(), ReadableStream::new(cx.realm()));
+ let readable = allocate(cx.vm(), |_| ReadableStream::new(cx.realm()));
// 6. Perform ! SetUpCrossRealmTransformReadable(readable, port1).
set_up_cross_realm_transform_readable(cx, readable, port1);
@@ -294,7 +294,7 @@ impl Transferable for WritableStream {
fn transfer_receiving_steps(cx: &mut CallContext, data_holder: &mut TransferDataReader) -> WebIdlResult<Ref<Self>> {
let cx: &CallContext = cx;
with_temporary_execution_context_and_callbacks(cx.realm(), || {
- let value = allocate(cx.vm(), Self::new(cx.realm()));
+ let value = allocate(cx.vm(), |_| Self::new(cx.realm()));
// 1. Let deserializedRecord be ! StructuredDeserializeWithTransfer(dataHolder.[[port]], the current
// Realm).
@@ -314,7 +314,7 @@ pub(crate) fn acquire_writable_stream_default_writer(
stream: Ref<WritableStream>,
) -> WebIdlResult<Ref<WritableStreamDefaultWriter>> {
// 1. Let writer be a new WritableStreamDefaultWriter.
- let writer = allocate(cx.vm(), WritableStreamDefaultWriter::new());
+ let writer = allocate(cx.vm(), |_| WritableStreamDefaultWriter::new());
// 2. Perform ? SetUpWritableStreamDefaultWriter(writer, stream).
set_up_writable_stream_default_writer(cx, writer, stream)?;
@@ -338,13 +338,13 @@ pub(crate) fn create_writable_stream(
assert!(is_non_negative_number(Value::from_f64(high_water_mark)));
// 2. Let stream be a new WritableStream.
- let stream = allocate(cx.vm(), WritableStream::new(cx.realm()));
+ let stream = allocate(cx.vm(), |_| WritableStream::new(cx.realm()));
// 3. Perform ! InitializeWritableStream(stream).
initialize_writable_stream(cx.vm(), stream);
// 4. Let controller be a new WritableStreamDefaultController.
- let controller = allocate(cx.vm(), WritableStreamDefaultController::new());
+ let controller = allocate(cx.vm(), |_| WritableStreamDefaultController::new());
// 5. Perform ? SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm,
// closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm).
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/writable_stream_default_controller.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/writable_stream_default_controller.rs
index c1e52ebecd1..39e3b1bfc6d 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/streams/writable_stream_default_controller.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/writable_stream_default_controller.rs
@@ -280,7 +280,7 @@ pub(crate) fn set_up_writable_stream_default_controller_from_underlying_sink(
size_algorithm: SizeAlgorithm,
) -> WebIdlResult<()> {
// 1. Let controller be a new WritableStreamDefaultController.
- let controller = allocate(cx.vm(), WritableStreamDefaultController::new());
+ let controller = allocate(cx.vm(), |_| WritableStreamDefaultController::new());
// 2. Let startAlgorithm be an algorithm that returns undefined.
let mut start_algorithm = StartAlgorithm::ReturnsUndefined;
diff --git a/Libraries/LibWeb/Bindings/Rust/src/streams/writable_stream_default_writer.rs b/Libraries/LibWeb/Bindings/Rust/src/streams/writable_stream_default_writer.rs
index 5615dbd0379..eac2dd4ea55 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/streams/writable_stream_default_writer.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/streams/writable_stream_default_writer.rs
@@ -93,7 +93,7 @@ impl WritableStreamDefaultWriter {
// https://streams.spec.whatwg.org/#default-writer-constructor
pub(crate) fn construct(cx: &mut CallContext, stream: Ref<WritableStream>) -> WebIdlResult<Ref<Self>> {
- let this = allocate(cx.vm(), Self::new());
+ let this = allocate(cx.vm(), |_| Self::new());
// 1. Perform ? SetUpWritableStreamDefaultWriter(this, stream).
set_up_writable_stream_default_writer(cx, this, stream)?;
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_gl/angle_instanced_arrays.rs b/Libraries/LibWeb/Bindings/Rust/src/web_gl/angle_instanced_arrays.rs
index 9450fbdd398..31af4c32d3c 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_gl/angle_instanced_arrays.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_gl/angle_instanced_arrays.rs
@@ -26,12 +26,9 @@ impl Wrappable for ANGLEInstancedArrays {
impl ANGLEInstancedArrays {
pub(crate) fn create(vm: &Vm, context: &ContextState) -> Ref<Self> {
- allocate(
- vm,
- Self {
- context: context.context_ref(),
- },
- )
+ allocate(vm, |_| Self {
+ context: context.context_ref(),
+ })
}
pub(crate) fn draw_arrays_instanced_angle(
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_gl/exports.rs b/Libraries/LibWeb/Bindings/Rust/src/web_gl/exports.rs
index 80a6e5a6b80..34496cc2308 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_gl/exports.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_gl/exports.rs
@@ -160,12 +160,12 @@ pub unsafe extern "C" fn web_webgl_context_create(
});
match version {
WebGLVersion::WebGL1 => {
- let context = allocate(vm, RenderingContext::<WebGL1>::new(state));
+ let context = allocate(vm, |_| RenderingContext::<WebGL1>::new(state));
context.set_context_ref(ContextRef::WebGL1(context));
cell_into_abi(context)
}
WebGLVersion::WebGL2 => {
- let context = allocate(vm, RenderingContext::<WebGL2>::new(state));
+ let context = allocate(vm, |_| RenderingContext::<WebGL2>::new(state));
context.set_context_ref(ContextRef::WebGL2(context));
cell_into_abi(context)
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_gl/extensions.rs b/Libraries/LibWeb/Bindings/Rust/src/web_gl/extensions.rs
index 157fa72bd07..da15f982bd3 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_gl/extensions.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_gl/extensions.rs
@@ -311,7 +311,7 @@ macro_rules! modules_of_extension_interfaces_without_operations {
$($(context.enable_compressed_texture_format($crate::web_gl::constants::$format);)+)?
allocate(
vm,
- Self {
+ |_| Self {
context: context.context_ref(),
},
)
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_gl/oes_vertex_array_object.rs b/Libraries/LibWeb/Bindings/Rust/src/web_gl/oes_vertex_array_object.rs
index ea4b7c8b9fb..ad980e153bf 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_gl/oes_vertex_array_object.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_gl/oes_vertex_array_object.rs
@@ -29,12 +29,9 @@ impl Wrappable for OESVertexArrayObject {
impl OESVertexArrayObject {
pub(crate) fn create(vm: &Vm, context: &ContextState) -> Ref<Self> {
- allocate(
- vm,
- Self {
- context: context.context_ref(),
- },
- )
+ allocate(vm, |_| Self {
+ context: context.context_ref(),
+ })
}
fn is_bound(&self, array_object: Ref<WebGLVertexArrayObjectOES>) -> bool {
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_active_info.rs b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_active_info.rs
index d5314e1737e..1ce53c241dc 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_active_info.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_active_info.rs
@@ -27,7 +27,7 @@ impl Wrappable for WebGLActiveInfo {}
impl WebGLActiveInfo {
pub(crate) fn create(vm: &Vm, name: Utf16String, r#type: u32, size: i32) -> Ref<Self> {
- allocate(vm, Self { name, r#type, size })
+ allocate(vm, |_| Self { name, r#type, size })
}
pub(crate) fn size(&self, _: &mut CallContext) -> WebIdlResult<i32> {
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_buffer.rs b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_buffer.rs
index ae92d7bdb86..b39eae240a6 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_buffer.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_buffer.rs
@@ -35,13 +35,10 @@ impl Inherits<WebGLObject> for WebGLBuffer {
impl WebGLBuffer {
pub(crate) fn create(vm: &Vm, context: &ContextState, handle: u32) -> Ref<Self> {
- allocate(
- vm,
- Self {
- object: WebGLObject::new(context, handle),
- kind: KindOfFirstBinding::default(),
- },
- )
+ allocate(vm, |_| Self {
+ object: WebGLObject::new(context, handle),
+ kind: KindOfFirstBinding::default(),
+ })
}
pub(crate) fn kind_allows_binding_to(&self, target: u32) -> bool {
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_draw_buffers.rs b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_draw_buffers.rs
index bd868b7f505..b4e9e2d2e12 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_draw_buffers.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_draw_buffers.rs
@@ -28,12 +28,9 @@ impl Wrappable for WebGLDrawBuffers {
impl WebGLDrawBuffers {
pub(crate) fn create(vm: &Vm, context: &ContextState) -> Ref<Self> {
- allocate(
- vm,
- Self {
- context: context.context_ref(),
- },
- )
+ allocate(vm, |_| Self {
+ context: context.context_ref(),
+ })
}
pub(crate) fn draw_buffers_webgl(&self, _: &mut CallContext, buffers: Vec<u32>) -> WebIdlResult<()> {
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_framebuffer.rs b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_framebuffer.rs
index 3be45628e5b..7f0e1bf492c 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_framebuffer.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_framebuffer.rs
@@ -48,13 +48,10 @@ impl Inherits<WebGLObject> for WebGLFramebuffer {
impl WebGLFramebuffer {
pub(crate) fn create(vm: &Vm, context: &ContextState, handle: u32) -> Ref<Self> {
- allocate(
- vm,
- Self {
- object: WebGLObject::new(context, handle),
- attachments: GcRefCell::new(Vec::new()),
- },
- )
+ allocate(vm, |_| Self {
+ object: WebGLObject::new(context, handle),
+ attachments: GcRefCell::new(Vec::new()),
+ })
}
pub(crate) fn attachment(&self, attachment: u32) -> Option<Attachment> {
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_object.rs b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_object.rs
index 23d552c1020..bb1039de6b2 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_object.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_object.rs
@@ -128,7 +128,7 @@ macro_rules! modules_of_interfaces_that_only_inherit_from_web_gl_object {
pub(crate) fn create(vm: &Vm, context: &ContextState, handle: u32) -> Ref<Self> {
allocate(
vm,
- Self {
+ |_| Self {
object: WebGLObject::new(context, handle),
},
)
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_program.rs b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_program.rs
index c4bf4f812f5..9fcb42cd709 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_program.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_program.rs
@@ -37,13 +37,10 @@ impl Inherits<WebGLObject> for WebGLProgram {
impl WebGLProgram {
pub(crate) fn create(vm: &Vm, context: &ContextState, handle: u32) -> Ref<Self> {
- allocate(
- vm,
- Self {
- object: WebGLObject::new(context, handle),
- attached_vertex_shader: Cell::new(None),
- attached_fragment_shader: Cell::new(None),
- },
- )
+ allocate(vm, |_| Self {
+ object: WebGLObject::new(context, handle),
+ attached_vertex_shader: Cell::new(None),
+ attached_fragment_shader: Cell::new(None),
+ })
}
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_shader.rs b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_shader.rs
index d52e4693f34..ccef2c3fb7d 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_shader.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_shader.rs
@@ -34,13 +34,10 @@ impl Inherits<WebGLObject> for WebGLShader {
impl WebGLShader {
pub(crate) fn create(vm: &Vm, context: &ContextState, handle: u32, r#type: u32) -> Ref<Self> {
- allocate(
- vm,
- Self {
- object: WebGLObject::new(context, handle),
- r#type,
- },
- )
+ allocate(vm, |_| Self {
+ object: WebGLObject::new(context, handle),
+ r#type,
+ })
}
pub(crate) fn r#type(&self) -> u32 {
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_shader_precision_format.rs b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_shader_precision_format.rs
index 0945895e2fc..d550865855e 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_shader_precision_format.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_shader_precision_format.rs
@@ -26,14 +26,11 @@ impl Wrappable for WebGLShaderPrecisionFormat {}
impl WebGLShaderPrecisionFormat {
pub(crate) fn create(vm: &Vm, range_min: i32, range_max: i32, precision: i32) -> Ref<Self> {
- allocate(
- vm,
- Self {
- range_min,
- range_max,
- precision,
- },
- )
+ allocate(vm, |_| Self {
+ range_min,
+ range_max,
+ precision,
+ })
}
pub(crate) fn range_min(&self, _: &mut CallContext) -> WebIdlResult<i32> {
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_sync.rs b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_sync.rs
index 08663fb7763..cc6c1a504c5 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_sync.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_sync.rs
@@ -35,13 +35,10 @@ impl Inherits<WebGLObject> for WebGLSync {
impl WebGLSync {
pub(crate) fn create(vm: &Vm, context: &ContextState, sync_handle: u32) -> Ref<Self> {
- allocate(
- vm,
- Self {
- object: WebGLObject::new(context, 0),
- sync_handle,
- },
- )
+ allocate(vm, |_| Self {
+ object: WebGLObject::new(context, 0),
+ sync_handle,
+ })
}
pub(crate) fn sync_handle(&self, context: &ContextState) -> Result<u32, InvalidOperation> {
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_uniform_location.rs b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_uniform_location.rs
index d48f8c411d4..2ff751e23c0 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_uniform_location.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl_uniform_location.rs
@@ -28,7 +28,7 @@ impl Wrappable for WebGLUniformLocation {
impl WebGLUniformLocation {
pub(crate) fn create(vm: &Vm, handle: i32, program: Ref<WebGLProgram>) -> Ref<Self> {
- allocate(vm, Self { handle, program })
+ allocate(vm, |_| Self { handle, program })
}
pub(crate) fn handle(&self, current_program: Option<Ref<WebGLProgram>>) -> Result<i32, InvalidOperation> {