-
Notifications
You must be signed in to change notification settings - Fork 69
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
Remove cast ref to mut everywhere #893
Conversation
Note: it still requires |
Thanks for the PR. I will look at it tomorrow. |
Again thanks for the PR. This is a good cleanup for identifying and removing As a summary, the changes in this PR are:
Generally, undefined behavior < unsafe code < safe code. However, this PR adds a large number of unsafe code (see the following table) to remove the undefined behavior code (which is also counted as unsafe in the table). As reducing unsafe code is one of our goals for the project (#97), this makes it hard to argue that this PR is an improvement for the code base.
(The data is from The urgency for this PR is that from Rust 1.72, I think the PR is good on its own, no change is needed. But it is a temporary solution for
My current preference is 2, considering that we will still have some time before Rust 1.72 and the next MMTk release. |
I am OK with either merging this PR in this release or the next release. I am OK with doing some refactoring before merging this PR, too, because that will mean this PR will need to change fewer places. But as a reminder, some of the unsafe code introduced in this PR can be very hard to refactor fully. For example, fully fixing #852 requires refactoring the work packet scheduler, which should be part of the research topic of a PhD. However, a shallow refactoring may be possible. We can use Others should be easy to fix. #853 I think the |
We do not plan to change the scheduler (the design or the algorithm) for now (which is a research goal for @wenyuzhao), but we intend to allow mutable access to
Not necessarily so. The reason for the issue is that most of the related code is a direct port of Java MMTk which has no concept about mutable vs immutable. The unsafe code was just used to work around the issues Rust raised. What we want is to figure out mutability, and allow Rust to reason and check for us. Another example is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, too.
Plan
insideUnsafeCell
to allow safe mutable access when necessarymut_self()
method now are separated intoType
andTypeInner
, second one is stored insideType
behindUnsafeCell
which allows to obtain mutable access when necessary without involving UB.&'static
references that were previously stored in some types are now converted intoNonNull<>