diff --git a/nova_vm/src/engine/bytecode/executable.rs b/nova_vm/src/engine/bytecode/executable.rs index 704878010..3ed6fa03f 100644 --- a/nova_vm/src/engine/bytecode/executable.rs +++ b/nova_vm/src/engine/bytecode/executable.rs @@ -81,6 +81,26 @@ pub(crate) struct FunctionExpression<'a> { bindable_handle!(FunctionExpression); +impl HeapMarkAndSweep for FunctionExpression<'static> { + fn mark_values(&self, queues: &mut WorkQueues) { + let Self { + expression: _, + identifier: _, + compiled_bytecode, + } = self; + compiled_bytecode.mark_values(queues); + } + + fn sweep_values(&mut self, compactions: &CompactionLists) { + let Self { + expression: _, + identifier: _, + compiled_bytecode, + } = self; + compiled_bytecode.sweep_values(compactions); + } +} + #[derive(Debug, Clone)] pub(crate) struct ArrowFunctionExpression { pub(crate) expression: SendableRef>, @@ -504,16 +524,15 @@ impl HeapMarkAndSweep for ExecutableHeapData<'static> { caches, constants, shapes, - function_expressions: _, + function_expressions, arrow_function_expressions: _, class_initializer_bytecodes, } = self; constants.mark_values(queues); caches.mark_values(queues); shapes.mark_values(queues); - for ele in class_initializer_bytecodes { - ele.0.mark_values(queues); - } + function_expressions.mark_values(queues); + class_initializer_bytecodes.mark_values(queues); } fn sweep_values(&mut self, compactions: &CompactionLists) { @@ -522,16 +541,15 @@ impl HeapMarkAndSweep for ExecutableHeapData<'static> { caches, constants, shapes, - function_expressions: _, + function_expressions, arrow_function_expressions: _, class_initializer_bytecodes, } = self; constants.sweep_values(compactions); caches.sweep_values(compactions); shapes.sweep_values(compactions); - for ele in class_initializer_bytecodes { - ele.0.sweep_values(compactions); - } + function_expressions.sweep_values(compactions); + class_initializer_bytecodes.sweep_values(compactions); } } diff --git a/nova_vm/src/heap/heap_bits.rs b/nova_vm/src/heap/heap_bits.rs index 73b16843c..c4ade13dd 100644 --- a/nova_vm/src/heap/heap_bits.rs +++ b/nova_vm/src/heap/heap_bits.rs @@ -1320,6 +1320,36 @@ where } } +macro_rules! trivially_sweepable { + ($self:ty) => { + impl crate::heap::heap_bits::HeapMarkAndSweep for $self { + #[inline] + fn mark_values(&self, _: &mut crate::heap::heap_bits::WorkQueues) {} + + #[inline] + fn sweep_values(&mut self, _: &crate::heap::heap_bits::CompactionLists) {} + } + }; +} +pub(crate) use trivially_sweepable; + +trivially_sweepable!(()); +trivially_sweepable!(bool); +trivially_sweepable!(i8); +trivially_sweepable!(u8); +trivially_sweepable!(i16); +trivially_sweepable!(u16); +trivially_sweepable!(i32); +trivially_sweepable!(u32); +trivially_sweepable!(i64); +trivially_sweepable!(u64); +trivially_sweepable!(isize); +trivially_sweepable!(usize); +#[cfg(feature = "proposal-float16array")] +trivially_sweepable!(f16); +trivially_sweepable!(f32); +trivially_sweepable!(f64); + impl HeapMarkAndSweep for (T,) where T: HeapMarkAndSweep,