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

Cleaning up write barrier code #68124

Merged
merged 3 commits into from
Apr 22, 2022

Conversation

SingleAccretion
Copy link
Contributor

I was investigating some diffs from deleting the last of CLS_VAR (on ARM), and the majority had to do with how we select write barriers for stores. I found the relevant code that does that somewhat confusing, so, two changes:

Write barrier code cleanup

1) Delete leftovers from legacy codegen, including the "tgt" naming.
2) Do not second-guess the write barrier form when selecting a helper,
   always return "known" WBF from "gcIsWriteBarrierCandidate" instead.
Delete GTF_IND_TGT_ANYWHERE

And create GTF_IND_TGT_HEAP instead, its logical opposite.

For reference, the situation before this change was as follows:

// Type of the ("simplified"/"base") address:
//
//  - TYP_I_IMPL: checked write barrier
//  - TYP_REF:    unchecked write barrier
//  - TYP_BYREF:
//    1) No flags:     unchecked write barrier
//    2) TGT_ANYWHERE: checked write barrier

The TYP_BYREF case will now look like this:
//
//    1) No flags: checked write barrier
//    2) TGT_HEAP: unchecked write barrier

The main benefit is that we get the default state (no flags) to
be the conservatively correct one.

No diffs are expected.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Apr 17, 2022
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Apr 17, 2022
@ghost
Copy link

ghost commented Apr 17, 2022

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

Issue Details

I was investigating some diffs from deleting the last of CLS_VAR (on ARM), and the majority had to do with how we select write barriers for stores. I found the relevant code that does that somewhat confusing, so, two changes:

Write barrier code cleanup

1) Delete leftovers from legacy codegen, including the "tgt" naming.
2) Do not second-guess the write barrier form when selecting a helper,
   always return "known" WBF from "gcIsWriteBarrierCandidate" instead.
Delete GTF_IND_TGT_ANYWHERE

And create GTF_IND_TGT_HEAP instead, its logical opposite.

For reference, the situation before this change was as follows:

// Type of the ("simplified"/"base") address:
//
//  - TYP_I_IMPL: checked write barrier
//  - TYP_REF:    unchecked write barrier
//  - TYP_BYREF:
//    1) No flags:     unchecked write barrier
//    2) TGT_ANYWHERE: checked write barrier

The TYP_BYREF case will now look like this:
//
//    1) No flags: checked write barrier
//    2) TGT_HEAP: unchecked write barrier

The main benefit is that we get the default state (no flags) to
be the conservatively correct one.

No diffs are expected.

Author: SingleAccretion
Assignees: -
Labels:

area-CodeGen-coreclr, community-contribution

Milestone: -

{
CorInfoHelpFunc helper = genWriteBarrierHelperForWriteBarrierForm(tgt, wbf);
CorInfoHelpFunc helper = genWriteBarrierHelperForWriteBarrierForm(store, wbf);

#ifdef FEATURE_COUNT_GC_WRITE_BARRIERS
Copy link
Contributor Author

@SingleAccretion SingleAccretion Apr 17, 2022

Choose a reason for hiding this comment

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

The new FEATURE_COUNT_GC_WRITE_BARRIERS code is a best-effort construction based on what I thought was "reasonable", I did not test it.

1) Delete leftovers from legacy codegen, including the "tgt" naming.
2) Do not second-guess the write barrier form when selecting a helper,
   always return "known" WBF from "gcIsWriteBarrierCandidate" instead.
@SingleAccretion SingleAccretion force-pushed the Write-Barriers branch 2 times, most recently from beae5fc to 4e16737 Compare April 17, 2022 14:42
And create GTF_IND_TGT_HEAP instead, its logical opposite.

For reference, the situation before this change was as follows:

// Type of the ("simplified"/"base") address:
//
//  - TYP_I_IMPL: checked write barrier
//  - TYP_REF:    unchecked write barrier
//  - TYP_BYREF:
//    1) No flags:     unchecked write barrier
//    2) TGT_ANYWHERE: checked write barrier

The TYP_BYREF case will now look like this:
//
//    1) No flags: checked write barrier
//    2) TGT_HEAP: unchecked write barrier

The main benefit is that we get the default state (no flags) to
be the conservatively correct one.
@SingleAccretion
Copy link
Contributor Author

No diffs, but there is one seemingly pre-existing related SPMI failure:

[14:39:00] ERROR: Exception thrown: SuperPMI assertion 'srcBuffer != nullptr' failed

[14:39:00] ERROR: Exception thrown: SuperPMI assertion 'srcBuffer != nullptr' failed

[14:39:00] ERROR: Method 39626 of size 41 failed to load and compile correctly by JIT2.

[14:39:00] ERROR: main method 39626 of size 41 failed to load and compile correctly.

@SingleAccretion SingleAccretion marked this pull request as ready for review April 19, 2022 16:24
@SingleAccretion
Copy link
Contributor Author

@dotnet/jit-contrib

@BruceForstall BruceForstall merged commit 10012c4 into dotnet:main Apr 22, 2022
@SingleAccretion SingleAccretion deleted the Write-Barriers branch April 23, 2022 11:09
@ghost ghost locked as resolved and limited conversation to collaborators May 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants