From 09ae2a78ab136e5f72abdd4edcf4d69144524ada Mon Sep 17 00:00:00 2001 From: Zheyuan Chen Date: Mon, 15 May 2023 23:11:48 -0700 Subject: [PATCH 1/4] mmtk/ChangeLog: * rust-toolchain: Update rust-toolchain to nightly version for RPITIT. * src/lib: Update crate attribute. * vm/active_plan.rs: Remove SynchronizedMutatorIterator and related trait function. Change the return type of mutators function. Signed-off-by: Zheyuan Chen --- rust-toolchain | 3 ++- src/lib.rs | 2 ++ src/vm/active_plan.rs | 36 +----------------------------------- 3 files changed, 5 insertions(+), 36 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 0403bed10c..2419c4c13b 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1,2 @@ -1.66.1 +[toolchain] +channel = "nightly-2023-01-10" \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 9a1b7fd751..a0f1a21602 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,6 +10,8 @@ // to me - considering it will break our API and all the efforts for all the developers to make the change, it may // not worth it. #![allow(clippy::upper_case_acronyms)] +#![feature(return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] //! Memory Management ToolKit (MMTk) is a portable and high performance memory manager //! that includes various garbage collection algorithms and provides clean and efficient diff --git a/src/vm/active_plan.rs b/src/vm/active_plan.rs index bcd22c48dc..087ed1af11 100644 --- a/src/vm/active_plan.rs +++ b/src/vm/active_plan.rs @@ -5,26 +5,6 @@ use crate::util::opaque_pointer::*; use crate::util::ObjectReference; use crate::vm::VMBinding; use crate::ObjectQueue; -use std::marker::PhantomData; -use std::sync::MutexGuard; - -pub struct SynchronizedMutatorIterator<'a, VM: VMBinding> { - _guard: MutexGuard<'a, ()>, - start: bool, - phantom: PhantomData, -} - -impl<'a, VM: VMBinding> Iterator for SynchronizedMutatorIterator<'a, VM> { - type Item = &'static mut Mutator; - - fn next(&mut self) -> Option { - if self.start { - self.start = false; - VM::VMActivePlan::reset_mutator_iterator(); - } - VM::VMActivePlan::get_next_mutator() - } -} /// VM-specific methods for the current plan. pub trait ActivePlan { @@ -52,22 +32,8 @@ pub trait ActivePlan { /// The caller needs to make sure that the thread is a mutator thread. fn mutator(tls: VMMutatorThread) -> &'static mut Mutator; - /// Reset the mutator iterator so that `get_next_mutator()` returns the first mutator. - fn reset_mutator_iterator(); - - /// Return the next mutator if there is any. This method assumes that the VM implements stateful type - /// to remember which mutator is returned and guarantees to return the next when called again. This does - /// not need to be thread safe. - fn get_next_mutator() -> Option<&'static mut Mutator>; - /// A utility method to provide a thread-safe mutator iterator from `reset_mutator_iterator()` and `get_next_mutator()`. - fn mutators<'a>() -> SynchronizedMutatorIterator<'a, VM> { - SynchronizedMutatorIterator { - _guard: Self::global().base().mutator_iterator_lock.lock().unwrap(), - start: true, - phantom: PhantomData, - } - } + fn mutators<'a>() -> impl Iterator>; /// Return the total count of mutators. fn number_of_mutators() -> usize; From b5ff6fbaf2436ee0b27752f438bb67c617af9d0b Mon Sep 17 00:00:00 2001 From: Zheyuan Chen Date: Mon, 15 May 2023 23:35:00 -0700 Subject: [PATCH 2/4] mmtk-core/src/vm/ChangeLog: * active_plan.rs: update correct lifetime for mutators function. Signed-off-by: Zheyuan Chen --- src/vm/active_plan.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vm/active_plan.rs b/src/vm/active_plan.rs index 087ed1af11..a05bfa4f01 100644 --- a/src/vm/active_plan.rs +++ b/src/vm/active_plan.rs @@ -33,7 +33,7 @@ pub trait ActivePlan { fn mutator(tls: VMMutatorThread) -> &'static mut Mutator; /// A utility method to provide a thread-safe mutator iterator from `reset_mutator_iterator()` and `get_next_mutator()`. - fn mutators<'a>() -> impl Iterator>; + fn mutators<'a>() -> impl Iterator>; /// Return the total count of mutators. fn number_of_mutators() -> usize; From 0e9764b5c27ba52608c86b98baf2faf53b7f51a0 Mon Sep 17 00:00:00 2001 From: Zheyuan Chen Date: Tue, 16 May 2023 00:06:30 -0700 Subject: [PATCH 3/4] mmmtk-core/ChangeLog: * rust-toolchain: Change back to stable version. * src/lib.rs: Remove unused crate attribute. * src/vm/active_plan.rs: Boxes the return of mutuators function to avoid using unstable feature. Signed-off-by: Zheyuan Chen --- rust-toolchain | 3 +-- src/lib.rs | 2 -- src/vm/active_plan.rs | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 2419c4c13b..0403bed10c 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,2 +1 @@ -[toolchain] -channel = "nightly-2023-01-10" \ No newline at end of file +1.66.1 diff --git a/src/lib.rs b/src/lib.rs index a0f1a21602..9a1b7fd751 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,8 +10,6 @@ // to me - considering it will break our API and all the efforts for all the developers to make the change, it may // not worth it. #![allow(clippy::upper_case_acronyms)] -#![feature(return_position_impl_trait_in_trait)] -#![allow(incomplete_features)] //! Memory Management ToolKit (MMTk) is a portable and high performance memory manager //! that includes various garbage collection algorithms and provides clean and efficient diff --git a/src/vm/active_plan.rs b/src/vm/active_plan.rs index a05bfa4f01..957e9470e0 100644 --- a/src/vm/active_plan.rs +++ b/src/vm/active_plan.rs @@ -33,7 +33,7 @@ pub trait ActivePlan { fn mutator(tls: VMMutatorThread) -> &'static mut Mutator; /// A utility method to provide a thread-safe mutator iterator from `reset_mutator_iterator()` and `get_next_mutator()`. - fn mutators<'a>() -> impl Iterator>; + fn mutators<'a>() -> Box> + 'a>; /// Return the total count of mutators. fn number_of_mutators() -> usize; From 1bd9b39053f5596204c196746f50a2dd51128c7c Mon Sep 17 00:00:00 2001 From: Yi Lin Date: Tue, 16 May 2023 23:57:30 +0000 Subject: [PATCH 4/4] Fix DummyVM --- src/vm/active_plan.rs | 2 +- vmbindings/dummyvm/src/active_plan.rs | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/vm/active_plan.rs b/src/vm/active_plan.rs index 957e9470e0..bf07141aae 100644 --- a/src/vm/active_plan.rs +++ b/src/vm/active_plan.rs @@ -32,7 +32,7 @@ pub trait ActivePlan { /// The caller needs to make sure that the thread is a mutator thread. fn mutator(tls: VMMutatorThread) -> &'static mut Mutator; - /// A utility method to provide a thread-safe mutator iterator from `reset_mutator_iterator()` and `get_next_mutator()`. + /// Return an iterator that includes all the mutators at the point of invocation. fn mutators<'a>() -> Box> + 'a>; /// Return the total count of mutators. diff --git a/vmbindings/dummyvm/src/active_plan.rs b/vmbindings/dummyvm/src/active_plan.rs index 1d59e925bc..1985def213 100644 --- a/vmbindings/dummyvm/src/active_plan.rs +++ b/vmbindings/dummyvm/src/active_plan.rs @@ -25,11 +25,7 @@ impl ActivePlan for VMActivePlan { unimplemented!() } - fn reset_mutator_iterator() { - unimplemented!() - } - - fn get_next_mutator() -> Option<&'static mut Mutator> { + fn mutators<'a>() -> Box> + 'a> { unimplemented!() } }