diff --git a/boa_gc/src/internals/gc_box.rs b/boa_gc/src/internals/gc_box.rs index 9c5ac998d9b..8ce48182ecf 100644 --- a/boa_gc/src/internals/gc_box.rs +++ b/boa_gc/src/internals/gc_box.rs @@ -157,13 +157,16 @@ impl GcBox { } } - /// Trace inner data + /// Trace inner data and search for ephemerons to add to the ephemeron queue. #[inline] pub(crate) fn weak_trace_inner(&self) { - // SAFETY: if a `GcBox` has `weak_trace_inner` called, then the inner. - // value must have been deemed as reachable. - unsafe { - self.value.weak_trace(); + if !self.header.is_marked() && !self.header.is_ephemeron() { + self.header.mark(); + // SAFETY: if a `GcBox` has `weak_trace_inner` called, then the inner. + // value must have been deemed as reachable. + unsafe { + self.value.weak_trace(); + } } }