ProcDecoder Refactor Redux#2651
Open
ike709 wants to merge 12 commits into
Open
Conversation
added 12 commits
June 29, 2026 03:51
ike709
commented
Jun 29, 2026
|
|
||
| /// <summary> | ||
| /// A typed bytecode operand. Array operands are used only by compact variable-argument opcodes | ||
| /// TODO: When .NET 11 is out, revisit this with C# 15 unions and OneOrMany |
Collaborator
Author
There was a problem hiding this comment.
This is a really important TODO that will be very useful for these changes, but I'm not going to delay the PR by several months to wait for it.
I will open an issue for this when the PR gets merged.
| } | ||
| case ProcOperandShape.RepeatedString: { | ||
| string[] values = operand0.Strings!; | ||
| for (int i = 0; i < values.Length; i++) { |
| } | ||
| case ProcOperandShape.RepeatedResource: { | ||
| string[] values = operand0.Strings!; | ||
| for (int i = 0; i < values.Length; i++) { |
| } | ||
| case ProcOperandShape.RepeatedReference: { | ||
| DMReference[] values = operand0.References!; | ||
| for (int i = 0; i < values.Length; i++) { |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR has a few main changes:
ProcDecoderwas moved from the runtime to the compiler.DMDisassemblernow depends on the compiler instead of the runtime.ITupleis now aProcInstructioncomprised ofProcOperands that store the argument values.Format()andDecodeInstruction()now utilize opcode metadata to figure out how to handle each opcode rather than using user-definedswitch()cases for each opcode.Most of that handling diverges depending on whether the opcode has a fixed-length argument count or a variable-length argument count (
N-variant opcodes). There's also a fair bit of code repetition for the tradeoff of not having to do a ton of typechecking on what types the arguments actually are.Tested with DM disassembly of /tg/station before and after this PR. Didn't see any non-whitespace diffs.
See my first comment below as well.