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

Fix several issues with CreateSpan support #65919

Merged
merged 3 commits into from
Dec 12, 2022

Conversation

stephentoub
Copy link
Member

@stephentoub stephentoub commented Dec 10, 2022

  1. It turns out we can't use the system types (short, int, long) for data fields when there's an alignment requirement, as those types have .pack 1 and thus a rewriter (e.g. illink) might not align fields using those types appropriately.

  2. We weren't incorporating the alignment into the name of the ExplicitSizeStruct created, so we could end up with two types both for the same size but for different alignments and with the same name.

  3. In looking at the code again, I realized we could simplify it so that EmitArrayBlockInitializer doesn't take an alignment at all, since for array purposes, we always want to use alignment 1. Because it took an alignment, we were unnecessarily specifying one even for the no-CreateSpan fallback. This was functionally correct but unnecessary and resulting in a bit more complicated IL, especially once (1) above was fixed.

The telltale sign of the problem is "System.ArgumentException : Value does not fall within the expected range." in CreateSpan call.

cc: @jcouv
Contributes to dotnet/runtime#79477
Follow-up on #61414

1. It turns out we can't use the system types (short, int, long) for data fields when there's an alignment requirement, as those types have .pack 1 and thus a rewriter (e.g. illink) might not align fields using those types appropriately.

2. We weren't incorporating the alignment into the name of the ExplicitSizeStruct created, so we could end up with two types both for the same size but for different alignments and with the same name.

3. In looking at the code again, I realized we could simplify it so that EmitArrayBlockInitializer doesn't take an alignment at all, since for array purposes, we always want to use alignment 1.  Because it took an alignment, we were unnecessarily specifying one even for the no-CreateSpan fallback.  This was functionally correct but unnecessary and resulting in a bit more complicated IL, especially once (1) above was fixed.
@AlekseyTs
Copy link
Contributor

Done with review pass (commit 1)

@stephentoub
Copy link
Member Author

Thanks. Feedback addressed.

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks (iteration 2)

@AlekseyTs
Copy link
Contributor

@stephentoub It looks like there are legitimate test failures

@AlekseyTs
Copy link
Contributor

Done with review pass (commit 2)

@stephentoub
Copy link
Member Author

stephentoub commented Dec 10, 2022

looks like there are legitimate test failures

It's some Windows vs Unix difference.

@stephentoub
Copy link
Member Author

stephentoub commented Dec 10, 2022

Apparently we expect different output / blob addresses based on OS, e. g.

string blobId = ExecutionConditionUtil.IsWindows ?
"I_000026F8" :
"I_00002738";

Why is that? I'll work around it, but doesn't that go against deterministic builds?

@stephentoub
Copy link
Member Author

I found @jaredpar's comment in #51437 (comment) about no guarantees of determinism across OS.

@stephentoub
Copy link
Member Author

Tests passed now.

@jcouv jcouv requested a review from AlekseyTs December 11, 2022 19:24
Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (commit 3)

@AlekseyTs AlekseyTs merged commit 40c0aa5 into dotnet:main Dec 12, 2022
@ghost ghost added this to the Next milestone Dec 12, 2022
@AlekseyTs
Copy link
Contributor

Thank you, @stephentoub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants