Control Flow Graph#2558
Closed
ike709 wants to merge 14 commits intoOpenDreamProject:masterfrom
Closed
Conversation
added 14 commits
October 23, 2025 12:10
|
|
||
|
|
||
|
|
||
| private AnnotatedBytecodeInstruction? GetLastInstruction(BasicBlock block) |
|
|
||
| // TODO: It would be nice to print the arguments properly for all opcodes; need to pass CFG info to DMDisassembler somehow | ||
| public void Dump() { | ||
| var sb = new System.Text.StringBuilder(); |
| List<int> BlockLeaderIndices = new(){0}; // start of instructions (idx 0) is a leader | ||
| Dictionary<IAnnotatedBytecode, BasicBlock> StartBytecodeToBlock = new(); // The first instruction/label of the block | ||
| List<BasicBlock> Blocks = new(); | ||
| private DMProc Proc = proc; |
| // The first AnnotatedBytecodeLabel or AnnotatedBytecodeInstruction in each block; blocks are separated by labels and terminators | ||
| List<int> BlockLeaderIndices = new(){0}; // start of instructions (idx 0) is a leader | ||
| Dictionary<IAnnotatedBytecode, BasicBlock> StartBytecodeToBlock = new(); // The first instruction/label of the block | ||
| List<BasicBlock> Blocks = new(); |
| internal class ControlFlowGraph(DMCompiler compiler, DMProc proc) { | ||
| // The first AnnotatedBytecodeLabel or AnnotatedBytecodeInstruction in each block; blocks are separated by labels and terminators | ||
| List<int> BlockLeaderIndices = new(){0}; // start of instructions (idx 0) is a leader | ||
| Dictionary<IAnnotatedBytecode, BasicBlock> StartBytecodeToBlock = new(); // The first instruction/label of the block |
| // The first AnnotatedBytecodeLabel or AnnotatedBytecodeInstruction in each block; blocks are separated by labels and terminators | ||
| List<int> BlockLeaderIndices = new(){0}; // start of instructions (idx 0) is a leader | ||
| Dictionary<IAnnotatedBytecode, BasicBlock> StartBytecodeToBlock = new(); // The first instruction/label of the block | ||
| List<BasicBlock> Blocks = new(); |
| List<int> BlockLeaderIndices = new(){0}; // start of instructions (idx 0) is a leader | ||
| Dictionary<IAnnotatedBytecode, BasicBlock> StartBytecodeToBlock = new(); // The first instruction/label of the block | ||
| List<BasicBlock> Blocks = new(); | ||
| private DMProc Proc = proc; |
| List<int> BlockLeaderIndices = new(){0}; // start of instructions (idx 0) is a leader | ||
| Dictionary<IAnnotatedBytecode, BasicBlock> StartBytecodeToBlock = new(); // The first instruction/label of the block | ||
| List<BasicBlock> Blocks = new(); | ||
| private DMProc Proc = proc; |
| // TODO: Validate switch() behavior | ||
| // TODO: Proper try/catch exception handler shenanigans | ||
|
|
||
| if(Proc.Name == "push" && Proc.Location.Line == 102) |
| // is physically in the same BasicBlock already, so it's inherently marked | ||
| // reachable as part of this block | ||
| foreach (var instr in block.Instructions) { | ||
| if (instr is AnnotatedBytecodeInstruction abi && |
Collaborator
Author
might as well start now |
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 is extremely not ready yet to the point this PR will likely go stale and be closed. But I was tired of losing track of the branch and also it gives other people a chance to prod at and point out the (likely stupid) things I am doing.
I haven't even properly looked over this code in months.