-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add InstructionEncoder.Switch
.
#76526
Conversation
The opcode is already stored in a field. And it's no more stored as a byte; it takes the same space as an ILOpCode due to packing.
…rolFlowBuilder. It simplifies the control flow builder and paves the way to support the switch instruction in the future. As a drawback the BranchInfo struct became bigger due to fields that are necessary for error reporting.
…lder. There didn't seem to be any reason to use them; they were not converted to immutable arrays.
And rename instructionStartOffset to ilOffset.
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @dotnet/area-system-reflection-metadata Issue DetailsFixes #40546. This PR refactors I also added two tests.
|
4b68314
to
c44f173
Compare
.../System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/EnumerableExtensions.cs
Outdated
Show resolved
Hide resolved
...em.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/ControlFlowBuilder.cs
Show resolved
Hide resolved
...em.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/InstructionEncoder.cs
Outdated
Show resolved
Hide resolved
...raries/System.Reflection.Metadata/tests/Metadata/Ecma335/Encoding/ControlFlowBuilderTests.cs
Show resolved
Hide resolved
…ile switch branches are being emitted.
c44f173
to
d5c7793
Compare
src/libraries/System.Reflection.Metadata/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
...em.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/ControlFlowBuilder.cs
Outdated
Show resolved
Hide resolved
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.
Thanks @teo-tsirpanis overall LGTM
This reverts commit 92a1f80.
src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs
Show resolved
Hide resolved
...em.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/ControlFlowBuilder.cs
Show resolved
Hide resolved
...em.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/ControlFlowBuilder.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Metadata/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Metadata/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
.../System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/EnumerableExtensions.cs
Outdated
Show resolved
Hide resolved
.../System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/EnumerableExtensions.cs
Outdated
Show resolved
Hide resolved
...em.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/InstructionEncoder.cs
Show resolved
Hide resolved
...lection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/SwitchInstructionEncoder.cs
Outdated
Show resolved
Hide resolved
...raries/System.Reflection.Metadata/tests/Metadata/Ecma335/Encoding/InstructionEncoderTests.cs
Show resolved
Hide resolved
...raries/System.Reflection.Metadata/tests/Metadata/Ecma335/Encoding/InstructionEncoderTests.cs
Show resolved
Hide resolved
Co-authored-by: Stephen Toub <stoub@microsoft.com>
Any more feedback on this? |
LGTM - do you have permission to do the merge? |
No, I am not a team member. 😅 |
Thanks! |
Fixes #40546.
This PR refactors
System.Reflection.Metadata.ControlFlowBuilder
so that instead of tracking branch instructions, it tracks just the label operands. This allows instructions with more than one label operand such asswitch
, which was implemented according to the approved API shape.I also added two tests.