Skip to content

ProcDecoder Refactor Redux#2651

Open
ike709 wants to merge 12 commits into
OpenDreamProject:masterfrom
ike709:cfg_part1_redux_procdecoder_refactor
Open

ProcDecoder Refactor Redux#2651
ike709 wants to merge 12 commits into
OpenDreamProject:masterfrom
ike709:cfg_part1_redux_procdecoder_refactor

Conversation

@ike709

@ike709 ike709 commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

This PR has a few main changes:

  • ProcDecoder was moved from the runtime to the compiler.
  • As a side effect of that, DMDisassembler now depends on the compiler instead of the runtime.
  • The ITuple is now a ProcInstruction comprised of ProcOperands that store the argument values.
  • Format() and DecodeInstruction() now utilize opcode metadata to figure out how to handle each opcode rather than using user-defined switch() 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.

@boring-cyborg boring-cyborg Bot added Compiler Involves the OpenDream compiler Runtime Involves the OpenDream server/runtime labels 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

@ike709 ike709 Jun 29, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

@ike709 ike709 requested a review from wixoaGit June 29, 2026 11:24
}
case ProcOperandShape.RepeatedString: {
string[] values = operand0.Strings!;
for (int i = 0; i < values.Length; i++) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Do we care?

}
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++) {
@ike709 ike709 changed the title CFG Part 1: ProcDecoder Refactor Redux ProcDecoder Refactor Redux Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Compiler Involves the OpenDream compiler Runtime Involves the OpenDream server/runtime size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants