Skip to content
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

Refactor derive macros and add HasSpaces trait #934

Merged
merged 14 commits into from
Sep 4, 2023

Conversation

wks
Copy link
Collaborator

@wks wks commented Sep 1, 2023

The main part of this PR is adding a HasSpaces trait that enumerates spaces in a plan. This trait can be automatically generated using derive macro and attributes, saving the effort to enumerate spaces by hand.

  • This PR adds a HasSpaces trait that enumerates spaces of a plan. Plans (including NoGC) are now required to implement this trait.
  • This PR implements derived macro for HasSpaces
  • The #[trace] and #[fallback_trace] attributes are replaced by the #[space] and #[parent] attributes for generality. A dedicated #[copy_semantics(xxxxx)] attribute is added to specify copy semantics for trace_object.
  • The manually written Plan::get_spaces() method is removed in favor for the automatically generated HasSpace::for_each_space method.
  • Added a Plan::verify_side_metadata_sanity that calls Space::verify_side_metadata_sanity for all spaces in the plan. This replaces the manual invocations of Space::verify_side_metadata_sanity in the constructors of plans.

This PR also slightly refactors the mmtk-macros crate.

  • The syn dependency is one major version behind the latest. This PR bumps the version and refactors the code to adapt to this change.
  • mmtk-core/macros/src/lib.rs is cleaned up so that it only contains functions with minimum function bodies. Those functions for derive macros are required to be in the root module of the crate. Their function bodies are off-loaded to other modules.

This PR is a stepping stone for #925. This PR makes it possible to enumerate spaces of a plan without resorting to unsafe global maps.

@wks wks force-pushed the feature/improve-macros branch from 0621d99 to a9fa818 Compare September 1, 2023 02:56
wks added 6 commits September 1, 2023 20:42
The Plan trait also requires the HasSpaces trait.
Remove the manually written `get_spaces` method in favor for the
auto-generated `for_each_space` method.
Replace the hand-written implementations of
`verify_side_metadata_sanity` with a generic implementation using
`Plan::for_each_space` to visit all spaces.
@wks wks requested a review from qinsoon September 1, 2023 16:53
@wks wks marked this pull request as ready for review September 1, 2023 16:53
Copy link
Member

@qinsoon qinsoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@qinsoon qinsoon added the PR-testing Run binding tests for the pull request (deprecated: use PR-extended-testing instead) label Sep 4, 2023
@wks wks added this pull request to the merge queue Sep 4, 2023
@wks wks removed this pull request from the merge queue due to a manual request Sep 4, 2023
wks added 2 commits September 4, 2023 14:14
Added the missing `#[parent]` attribute to the `PageProtect::common`
field.  It didn't have the `#[fallback_trace]` attribute, but it worked
because the PageProtect plan only ever allocates into
`PageProtect::space` which is an LOS.  Now that the `#[parent]`
attribute is also used for enumerating spaces and verifying space
metadata, it can no longer be omitted.  Omitting `#[parent]` will cause
failure when the "extreme_assertions" feature is enabled.
@wks wks enabled auto-merge September 4, 2023 06:25
@wks wks added this pull request to the merge queue Sep 4, 2023
Merged via the queue into mmtk:master with commit 2e29b97 Sep 4, 2023
@wks wks deleted the feature/improve-macros branch September 4, 2023 10:10
wks added a commit to wks/mmtk-core that referenced this pull request May 6, 2024
`ScanObjectsWork::make_another` is unused.  It was used when
`ScanObjectsWork` was used for scanning node roots.  Now that node roots
are scanned by the dedicated `ProcessRootNode` work packet, we can
remove it.

`WorkCounter::get_base_mut` is never used.  All derived counters use
`merge_val` to update all fields at the same time.

We use `Box::as_ref()` to get the reference to its underlying element.
It fixes a compilation error related to CommonFreeListPageResource.  But
we should eventually remove CommonFreeListPageResource completely as it
is a workaround for mimicking the legacy design from JikesRVM that allow
VMMap to enumerate and patch existing FreeListPageResource instances by
registering them in a global list, which is not idiomatic in Rust.  See
mmtk#934 and
mmtk#953
github-merge-queue bot pushed a commit that referenced this pull request May 6, 2024
`ScanObjectsWork::make_another` is unused. It was used when
`ScanObjectsWork` was used for scanning node roots. Now that node roots
are scanned by the dedicated `ProcessRootNode` work packet, we can
remove it.

`WorkCounter::get_base_mut` is never used. All derived counters use
`merge_val` to update all fields at the same time.

We use `Box::as_ref()` to get the reference to its underlying element.
It fixes a compilation error related to CommonFreeListPageResource. But
we should eventually remove CommonFreeListPageResource completely as it
is a workaround for mimicking the legacy design from JikesRVM that allow
VMMap to enumerate and patch existing FreeListPageResource instances by
registering them in a global list, which is not idiomatic in Rust. See
#934 and
#953.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-testing Run binding tests for the pull request (deprecated: use PR-extended-testing instead)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants