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

Make initialization more consistent in gc.cpp #75908

Merged
merged 2 commits into from
Sep 21, 2022

Conversation

AaronRobinsonMSFT
Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT commented Sep 20, 2022

Use = default; for class Volatile ctor since it permits the compiler to optimize when used in a static context. This also makes the previously troublesome UB issue fixed in #74363 no longer exist - calling memset on a non-trivial type. Reverting some of the changes in gc.cpp.

Fixes #75893

/cc @Maoni0 @dotnet/gc

@ghost
Copy link

ghost commented Sep 20, 2022

Tagging subscribers to this area: @dotnet/gc
See info in area-owners.md if you want to be subscribed.

Issue Details

Use = default; for class Volatile ctor since it permits the compiler to optimize when used in a static context.

Remove explicit static member initialization and instead rely on default initialization.

Explicit array sizes were removed from the initialization path since they are only needed at declaration. I can put them back if preferred.

Fixes #75893

/cc @Maoni0 @dotnet/gc

Author: AaronRobinsonMSFT
Assignees: -
Labels:

area-GC-coreclr

Milestone: 8.0.0

src/coreclr/gc/gc.cpp Outdated Show resolved Hide resolved
@AaronRobinsonMSFT
Copy link
Member Author

@Maoni0 and I spoke offline. Since this PR is also making class Volatile have a compiler generated default ctor so we can now use memset on instances. I reverted changes to GC code from #74363.

Copy link
Member

@Maoni0 Maoni0 left a comment

Choose a reason for hiding this comment

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

thanks so much @AaronRobinsonMSFT. this looks great!

@AaronRobinsonMSFT
Copy link
Member Author

AaronRobinsonMSFT commented Sep 21, 2022

Shoot. It seems I missed something when creating a small repro outside of dotnet/runtime and my "fix" wasn't complete. The class Volatile also has a user defined copy-constructor - ugh. There is only one use of it in gc.cpp on 20140:

gc_mechanisms temp_settings = settings;

I'll see what I can do tomorrow.

@Maoni0
Copy link
Member

Maoni0 commented Sep 21, 2022

new changes look good to me. thanks @AaronRobinsonMSFT!

@AaronRobinsonMSFT AaronRobinsonMSFT merged commit 2545487 into dotnet:main Sep 21, 2022
@AaronRobinsonMSFT AaronRobinsonMSFT deleted the runtime_75893 branch September 21, 2022 21:54
@ghost ghost locked as resolved and limited conversation to collaborators Oct 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove redundant initialization to keep consistent style
3 participants