Skip to content

Commit

Permalink
swiper: remove forward_full method in swiper.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
dinfuehr committed Jan 5, 2024
1 parent 150cd31 commit 4bbcc21
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 28 deletions.
4 changes: 2 additions & 2 deletions dora-runtime/src/gc/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ where
lazy_compilation_stub::iterate_roots(vm, frame.fp, &params, is_variadic, return_type, callback)
}

pub fn iterate_weak_roots<F>(vm: &VM, object_updater: F)
pub fn iterate_weak_roots<F>(vm: &VM, mut object_updater: F)
where
F: Fn(Address) -> Option<Address>,
F: FnMut(Address) -> Option<Address>,
{
let mut finalizers = vm.gc.finalizers.lock();
let mut deleted = false;
Expand Down
21 changes: 0 additions & 21 deletions dora-runtime/src/gc/swiper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,27 +622,6 @@ pub trait CommonOldGen {
fn committed_size(&self) -> usize;
}

fn forward_full(object: Address, heap: Region, perm: Region) -> Option<Address> {
if heap.contains(object) {
let obj = object.to_obj();

if obj.header().is_marked() {
let vtblptr = obj.header().vtblptr();

if let VtblptrWordKind::Fwdptr(new_address) = vtblptr {
Some(new_address)
} else {
Some(object)
}
} else {
None
}
} else {
debug_assert!(perm.contains(object));
Some(object)
}
}

fn forward_minor(object: Address, young: Region) -> Option<Address> {
if young.contains(object) {
let obj = object.to_obj();
Expand Down
18 changes: 13 additions & 5 deletions dora-runtime/src/gc/swiper/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::gc::swiper::crossing::CrossingMap;
use crate::gc::swiper::large::LargeSpace;
use crate::gc::swiper::old::{OldGen, OldGenProtected, Page};
use crate::gc::swiper::young::YoungGen;
use crate::gc::swiper::{forward_full, walk_region, INITIAL_METADATA_OLD};
use crate::gc::swiper::{walk_region, INITIAL_METADATA_OLD};
use crate::gc::{fill_region_with, iterate_strong_roots, iterate_weak_roots, marking, Slot};
use crate::gc::{Address, GcReason, Region};
use crate::object::{Obj, VtblptrWordKind};
Expand Down Expand Up @@ -228,7 +228,7 @@ impl<'a> FullCollector<'a> {
});

iterate_weak_roots(self.vm, |object_address| {
forward_full(object_address, self.heap, self.readonly_space.total())
self.forward_object(object_address).or(Some(object_address))
});

self.large_space.remove_objects(|object_start| {
Expand Down Expand Up @@ -384,16 +384,24 @@ impl<'a> FullCollector<'a> {
return;
}

if let Some(forwarded) = self.forward_object(object_address) {
debug_assert!(self.heap.contains(forwarded));
slot.set(forwarded);
}
}

fn forward_object(&mut self, object_address: Address) -> Option<Address> {
if self.heap.contains(object_address) {
let object = object_address.to_obj();
let vtblptr = object.header().vtblptr();

if let VtblptrWordKind::Fwdptr(address) = vtblptr {
debug_assert!(self.heap.contains(address));
slot.set(address);
Some(address)
} else {
None
}
} else {
debug_assert!(self.readonly_space.contains(object_address));
None
}
}

Expand Down

0 comments on commit 4bbcc21

Please sign in to comment.