-
Notifications
You must be signed in to change notification settings - Fork 81
Mark compact #494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Mark compact #494
Changes from 33 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
e6afb63
init commit
tianleq 91a26a8
implement single-threaded lisp2 mark-compact
tianleq 0f88032
fix missing TLAB bump allocator reset
tianleq 6916306
fix missing reset cursor
tianleq 8df62b6
initial clean up
tianleq 9daceae
remove dependency on global alloc bit feature
tianleq da9ff70
fix 1. infinite gc loop due to incorrect page accounting
tianleq 8e49469
fix extra header calculation
tianleq ecad445
get upstream changes
tianleq 0d3ed9a
bring upstream changes and fixes
tianleq 5d67c70
bring upstream changes and fixes
tianleq 7e3b029
implement fast path allocation
tianleq f1e2784
fix object alignment
tianleq 7fc9162
bring upstream changes
tianleq f46449c
fix duplicate edges in the second round of tracing
tianleq 45cc071
add new allocator semantics(bump pointer with global alloc bit enabled)
tianleq 0c7960c
clean up
tianleq eb4110c
clean up
tianleq 10b134d
add missing implementation in dummyvm
tianleq 92dd28c
fix failed tests
tianleq c88f8fc
fix style issue
tianleq 963d02d
rollback changes
tianleq 0b462ff
clean up
tianleq 4c0e8cb
backup
tianleq e181e7b
implement the markcompact allocator
tianleq 07bd00f
clean up
tianleq 139a47a
use copy_to api
tianleq c188a2a
fix crash on mutator iteration
tianleq 2785837
remove object_alignment()
tianleq 62b44b6
clean up
tianleq c6e57a2
clean up
tianleq 27c18dd
add finalization to markcompact
tianleq e0c9ba9
remove BumpPointerAllocBit
tianleq 46c1cd2
clean up
tianleq d30bce0
remove unused code
tianleq 28f13ed
clean up
tianleq bc3babb
Merge branch 'master' into mark-compact
tianleq fdfb88d
merge upstream changes
tianleq 60c5c68
merge upstream updates of scanned stack
tianleq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,189 @@ | ||
| use super::global::MarkCompact; | ||
| use crate::plan::global::NoCopy; | ||
| use crate::policy::markcompactspace::MarkCompactSpace; | ||
| use crate::policy::space::Space; | ||
| use crate::scheduler::gc_work::*; | ||
| use crate::scheduler::GCWork; | ||
| use crate::scheduler::GCWorker; | ||
| use crate::scheduler::WorkBucketStage; | ||
| use crate::util::{Address, ObjectReference}; | ||
| use crate::vm::ActivePlan; | ||
| use crate::vm::Scanning; | ||
| use crate::vm::VMBinding; | ||
| use crate::MMTK; | ||
| use std::marker::PhantomData; | ||
| use std::ops::{Deref, DerefMut}; | ||
|
|
||
| // iterate through the heap and calculate the new location of live objects | ||
qinsoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pub struct CalculateForwardingAddress<VM: VMBinding> { | ||
| mc_space: &'static MarkCompactSpace<VM>, | ||
| } | ||
|
|
||
| impl<VM: VMBinding> GCWork<VM> for CalculateForwardingAddress<VM> { | ||
| #[inline] | ||
| fn do_work(&mut self, _worker: &mut GCWorker<VM>, _mmtk: &'static MMTK<VM>) { | ||
| self.mc_space.calculate_forwarding_pointer(); | ||
| } | ||
| } | ||
|
|
||
| impl<VM: VMBinding> CalculateForwardingAddress<VM> { | ||
| pub fn new(mc_space: &'static MarkCompactSpace<VM>) -> Self { | ||
| Self { mc_space } | ||
| } | ||
| } | ||
|
|
||
| // create another round of root scanning work packets | ||
| // to update object references | ||
| pub struct UpdateReferences<VM: VMBinding> { | ||
| p: PhantomData<VM>, | ||
| } | ||
|
|
||
| impl<VM: VMBinding> GCWork<VM> for UpdateReferences<VM> { | ||
| #[inline] | ||
| fn do_work(&mut self, _worker: &mut GCWorker<VM>, mmtk: &'static MMTK<VM>) { | ||
| // The following needs to be done right before the second round of root scanning | ||
| VM::VMScanning::prepare_for_roots_re_scanning(); | ||
|
|
||
| #[cfg(feature = "extreme_assertions")] | ||
| crate::util::edge_logger::reset(); | ||
|
|
||
| // TODO investigate why the following will create duplicate edges | ||
| // scheduler.work_buckets[WorkBucketStage::RefForwarding] | ||
| // .add(ScanStackRoots::<ForwardingProcessEdges<VM>>::new()); | ||
| for mutator in VM::VMActivePlan::mutators() { | ||
| mmtk.scheduler.work_buckets[WorkBucketStage::RefForwarding] | ||
| .add(ScanStackRoot::<ForwardingProcessEdges<VM>>(mutator)); | ||
| } | ||
|
|
||
| mmtk.scheduler.work_buckets[WorkBucketStage::RefForwarding] | ||
| .add(ScanVMSpecificRoots::<ForwardingProcessEdges<VM>>::new()); | ||
| } | ||
| } | ||
|
|
||
| impl<VM: VMBinding> UpdateReferences<VM> { | ||
| pub fn new() -> Self { | ||
| Self { p: PhantomData } | ||
| } | ||
| } | ||
|
|
||
| // compact live objects based on forwarding pointers calculated before | ||
| pub struct Compact<VM: VMBinding> { | ||
| mc_space: &'static MarkCompactSpace<VM>, | ||
| } | ||
|
|
||
| impl<VM: VMBinding> GCWork<VM> for Compact<VM> { | ||
| #[inline] | ||
| fn do_work(&mut self, _worker: &mut GCWorker<VM>, _mmtk: &'static MMTK<VM>) { | ||
| self.mc_space.compact(); | ||
| } | ||
| } | ||
|
|
||
| impl<VM: VMBinding> Compact<VM> { | ||
| pub fn new(mc_space: &'static MarkCompactSpace<VM>) -> Self { | ||
| Self { mc_space } | ||
| } | ||
| } | ||
|
|
||
| // Transitive closure to mark live objects | ||
| pub struct MarkingProcessEdges<VM: VMBinding> { | ||
| plan: &'static MarkCompact<VM>, | ||
| base: ProcessEdgesBase<MarkingProcessEdges<VM>>, | ||
| } | ||
|
|
||
| impl<VM: VMBinding> MarkingProcessEdges<VM> { | ||
| fn markcompact(&self) -> &'static MarkCompact<VM> { | ||
| self.plan | ||
| } | ||
| } | ||
|
|
||
| impl<VM: VMBinding> ProcessEdgesWork for MarkingProcessEdges<VM> { | ||
| type VM = VM; | ||
| fn new(edges: Vec<Address>, roots: bool, mmtk: &'static MMTK<VM>) -> Self { | ||
| let base = ProcessEdgesBase::new(edges, roots, mmtk); | ||
| let plan = base.plan().downcast_ref::<MarkCompact<VM>>().unwrap(); | ||
| Self { base, plan } | ||
| } | ||
|
|
||
| #[inline] | ||
| fn trace_object(&mut self, object: ObjectReference) -> ObjectReference { | ||
| if object.is_null() { | ||
| return object; | ||
| } | ||
| if self.markcompact().mc_space().in_space(object) { | ||
| self.markcompact() | ||
| .mc_space() | ||
| .trace_mark_object::<Self>(self, object) | ||
| } else { | ||
| self.markcompact() | ||
| .common | ||
| .trace_object::<Self, NoCopy<VM>>(self, object) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl<VM: VMBinding> Deref for MarkingProcessEdges<VM> { | ||
| type Target = ProcessEdgesBase<Self>; | ||
| #[inline] | ||
| fn deref(&self) -> &Self::Target { | ||
| &self.base | ||
| } | ||
| } | ||
|
|
||
| impl<VM: VMBinding> DerefMut for MarkingProcessEdges<VM> { | ||
| #[inline] | ||
| fn deref_mut(&mut self) -> &mut Self::Target { | ||
| &mut self.base | ||
| } | ||
| } | ||
|
|
||
| // Transitive closure to update object references | ||
| pub struct ForwardingProcessEdges<VM: VMBinding> { | ||
| plan: &'static MarkCompact<VM>, | ||
| base: ProcessEdgesBase<ForwardingProcessEdges<VM>>, | ||
| } | ||
|
|
||
| impl<VM: VMBinding> ForwardingProcessEdges<VM> { | ||
| fn markcompact(&self) -> &'static MarkCompact<VM> { | ||
| self.plan | ||
| } | ||
| } | ||
|
|
||
| impl<VM: VMBinding> ProcessEdgesWork for ForwardingProcessEdges<VM> { | ||
| type VM = VM; | ||
| fn new(edges: Vec<Address>, roots: bool, mmtk: &'static MMTK<VM>) -> Self { | ||
| let base = ProcessEdgesBase::new(edges, roots, mmtk); | ||
| let plan = base.plan().downcast_ref::<MarkCompact<VM>>().unwrap(); | ||
| Self { base, plan } | ||
| } | ||
|
|
||
| #[inline] | ||
| fn trace_object(&mut self, object: ObjectReference) -> ObjectReference { | ||
| if object.is_null() { | ||
| return object; | ||
| } | ||
| if self.markcompact().mc_space().in_space(object) { | ||
| self.markcompact() | ||
| .mc_space() | ||
| .trace_forward_object::<Self>(self, object) | ||
| } else { | ||
| self.markcompact() | ||
| .common | ||
| .trace_object::<Self, NoCopy<VM>>(self, object) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl<VM: VMBinding> Deref for ForwardingProcessEdges<VM> { | ||
| type Target = ProcessEdgesBase<Self>; | ||
| #[inline] | ||
| fn deref(&self) -> &Self::Target { | ||
| &self.base | ||
| } | ||
| } | ||
|
|
||
| impl<VM: VMBinding> DerefMut for ForwardingProcessEdges<VM> { | ||
| #[inline] | ||
| fn deref_mut(&mut self) -> &mut Self::Target { | ||
| &mut self.base | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.