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

Add InstructionEncoder.Switch. #76526

Merged
merged 15 commits into from
Dec 6, 2022
Merged

Conversation

teo-tsirpanis
Copy link
Contributor

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 as switch, which was implemented according to the approved API shape.

I also added two tests.

teo-tsirpanis and others added 6 commits October 2, 2022 13:15
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.
@dotnet-issue-labeler
Copy link

Note regarding the new-api-needs-documentation label:

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.

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Oct 3, 2022
@ghost
Copy link

ghost commented Oct 3, 2022

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

Issue Details

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 as switch, which was implemented according to the approved API shape.

I also added two tests.

Author: teo-tsirpanis
Assignees: -
Labels:

area-System.Reflection.Metadata, new-api-needs-documentation, community-contribution

Milestone: -

Copy link
Member

@buyaa-n buyaa-n left a 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

@teo-tsirpanis
Copy link
Contributor Author

Any more feedback on this?

@steveharter
Copy link
Member

Any more feedback on this?

LGTM - do you have permission to do the merge?

@teo-tsirpanis
Copy link
Contributor Author

No, I am not a team member. 😅

@stephentoub
Copy link
Member

Thanks!

@stephentoub stephentoub merged commit 6e0c046 into dotnet:main Dec 6, 2022
@teo-tsirpanis teo-tsirpanis deleted the srm-switch branch December 6, 2022 08:18
@ghost ghost locked as resolved and limited conversation to collaborators Jan 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add InstructionEncoder.Switch to enable emitting switch instructions with LabelHandles
6 participants