-
Notifications
You must be signed in to change notification settings - Fork 239
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
Better compiler accuracy for functions named differently/the same as the containing script name #1986
Conversation
…the containing script name this is done using the code name, not sure if it should be.
Download the artifacts for this pull request here: GUI:
CLI: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a small note, I think I did this already in the underanalyzer
branch as part of the small compiler upgrades. I think in GM 2024 and above they changed this behavior as well (so it only uses -1), but I can fix the merge conflict for that once this gets merged in.
else | ||
cw.Emit(Opcode.PushI, DataType.Int16).Value = (short)-1; // todo: -6 sometimes? | ||
{ | ||
cw.Emit(Opcode.PushI, DataType.Int16).Value = (short)-6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment explaining tbe -6, similar to above? Probably cleaner to move the comment outside the else if and have it explain both cases.
cw.Emit(Opcode.PushI, DataType.Int16).Value = (short)-16; | ||
} | ||
else if (cw.compileContext.OriginalCode?.Name?.Content == ("gml_GlobalScript_" + funcDefName.Text)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems kinda messy but also dont know any other cleaner way.
I guess linq maybe, but dunno if we have access to the functions here?
oh i didn't know. i think i might just close this pr then? |
Description
This is a port of a very tiny compiler assembly accuracy improvement from UTMTCE.
You know that one pushi.e instruction for function definitions that is -1 sometimes and -6 other times? That instructions's value is -1 if the function's name is the same as the script it's in, and -6 if it isn't.
Not sure what effect this has on the runtime (possibly none), but it does make a difference in the assembly.
Caveats
This is done by comparing to the code entry name, I'm not sure if it should be done like that. (Iterating through all script entries might be cleaner but that would also probably be slower.)