-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
InstructionEncoder.Switch
. (#76526)
* Avoid passing a redundant parameter in BranchInfo.GetBranchDistance. 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. * Track only the label operand instead of the whole instruction in ControlFlowBuilder. 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. * Replace immutable array builders with regular lists in ControlFlowBuilder. There didn't seem to be any reason to use them; they were not converted to immutable arrays. * Clean-up EnumerableExtensions; remove an unused method and forward another one. * Fix the tests. And rename instructionStartOffset to ilOffset. * Add InstructionEncoder.Switch. * Add tests. * Remove a potentially unclear comment. * Validate that an `InstructionEncoder` is not used in any other way while switch branches are being emitted. * Use named parameters instead of just `default`. * Remove an automatically generated comment in the resx. * Revert "Remove a potentially unclear comment." This reverts commit 92a1f80. * Apply suggestions from code review Co-authored-by: Stephen Toub <[email protected]> * Remove `EnumerableExtensions.FirstOrDefault`. * Rename `AssertNotInSwitch` to `ValidateNotInSwitch` and call it on `DefineLabel`. Co-authored-by: Stephen Toub <[email protected]>
- Loading branch information
1 parent
c6e0b06
commit 6e0c046
Showing
12 changed files
with
287 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.