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

Peephole optimize proc returns #1843

Merged
merged 5 commits into from
Jun 19, 2024
Merged

Conversation

ike709
Copy link
Collaborator

@ike709 ike709 commented Jun 16, 2024

(PushReferenceValue, Return) -> ReturnReferenceValue

Per my frequency analysis this pattern occurs ~16k times in Paradise and ~25k times in goon and TG. It is a top-ten offender on all codebases tested.

However, this optimization is heavily kneecapped by #1842 which causes it to only be applied 664 times in Paradise bytecode. Once that issue is fixed this will become much more significant, as a large number of procs will no longer modify their stack when they return.

@boring-cyborg boring-cyborg bot added Compiler Involves the OpenDream compiler Runtime Involves the OpenDream server/runtime labels Jun 16, 2024
@ike709 ike709 requested a review from wixoaGit June 16, 2024 20:29
input.RemoveRange(index, 2);
input.Insert(index,
new AnnotatedBytecodeInstruction(DreamProcOpcode.ReturnReferenceValue,
new List<IAnnotatedBytecode> { pushVal }));

Check warning

Code scanning / InspectCode

Possible null reference argument for a parameter. Warning

Possible null reference argument for parameter 'item' in 'System.Collections.Generic.List.Add'
input.RemoveRange(index, 2);
input.Insert(index,
new AnnotatedBytecodeInstruction(DreamProcOpcode.ReturnReferenceValue,
new List<IAnnotatedBytecode> { pushVal }));

Check notice

Code scanning / InspectCode

Use collection expression syntax Note

Use collection expression
@ike709 ike709 requested a review from wixoaGit June 19, 2024 18:20
@wixoaGit wixoaGit enabled auto-merge (squash) June 19, 2024 18:26
@wixoaGit wixoaGit merged commit 31d973d into OpenDreamProject:master Jun 19, 2024
9 checks passed
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/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants