diff --git a/gc/mmtk/src/weak_proc.rs b/gc/mmtk/src/weak_proc.rs index 2592490..addb137 100644 --- a/gc/mmtk/src/weak_proc.rs +++ b/gc/mmtk/src/weak_proc.rs @@ -133,21 +133,17 @@ impl WeakProcessor { } fn process_obj_free_candidates(obj_free_candidates: &mut Vec) { - // Process obj_free - let mut new_candidates = Vec::new(); - - for object in obj_free_candidates.iter().copied() { + obj_free_candidates.retain_mut(|object| { if object.is_reachable() { - // Forward and add back to the candidate list. let new_object = object.forward(); trace!("Forwarding obj_free candidate: {object} -> {new_object}"); - new_candidates.push(new_object); + *object = new_object; + true } else { - upcalls::call_obj_free(object); + upcalls::call_obj_free(*object); + false } - } - - *obj_free_candidates = new_candidates; + }); } struct ProcessParallelObjFreeCandidates {