-
Notifications
You must be signed in to change notification settings - Fork 8
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
Building Projects: Optimise various make_colour...(), string...(), and maths functions which have constant arguments during the compiler phase #5688
Comments
Here is a test project for the current functions that were added... |
Added in more functions - only works for constant arguments
|
How would the compiler handle live executions of |
The only math operation that is affected by |
Here is an updated project with better layout and tests all the functions mentioned above - |
Feature added in 2024.6 The test GML code in the above project is
and this now generates the VM code
The only function calls that remain are the |
I would imagine this recursive? For instance |
yes it is and does collapse down... above the functions are optimised and become constant and because of that all the NOTE: Currently this only works for functions where every argument is a constant.. I am going to take a look at doing it for partially constant arguments for certain functions like |
It may be worth considering also optimizing single assigned local variables. as a local variable, there is no way to go about var foo = "bar"
show_debug_message(foo) Its obvious that there is only ever one assignment operation, and given it's a constant, it would be safe to replace all uses of It would honestly be more beneficial for config variables in an objects create event, but reasonably so that's not viable, short of making something like a local macro system, but that might just overcomplicate things. |
I have also added some more optimisation so partial constant strings passed to some of the string functions will be further optimised like so stringwhen being used with formatting any constant arguments are inlined into the main string and then the parameters are reordered i.e.
becomes
string_concatConstant strings are concatenated by the compiler so
becomes
string_joinConstant string arguments are joined by the compiler so
becomes
|
…etc.) YoYoGames/GameMaker-Bugs#5688 * Added a new page "Compiler Optimisations" under "Runner Details" * Linked to the page from the "Compiling" page * Updated old links to Help Center on YoYo Compiler page
Documented all compiler optimisations on a new manual page "Compiler Optimisations" under the "Runner Details" section. |
…etc.) YoYoGames/GameMaker-Bugs#5688 * Removed the note on the buffer_sizeof page, since it's now listed under Compiling Optimisations
YoYoGames/GameMaker-Bugs#5688 * Referred to the rule for deterministic functions in the sentence preceding the function list
@YYBartT Is that available publicly yet? I'd love to peek at the changes the runner makes. |
@tinkerer-red It's in the beta manual here: Compiler Optimisations. (not everything's been documented in the beta manual yet though, this is) |
verified in window, html5 and operagx as of IDE v2024.6.0.156 Runtime v2024.6.0.205 |
and on mac |
Description
Currently the GM compiler will optimise certain functions that have constant parameters i.e.
ord
,chr
,int64
,real
,string
,is_method
,variable_get_hash
,os_get_config
,buffer_sizeof
.We should expand this list to include common maths and colour functions
Compiler would optimise out functions that can be evaluated at compile time, because all the params are constant and the function itself is deterministic, candidates would include
make_colour_rgb
,make_color_rgb
string_lower
string_upper
sin
,cos
,tan
,arcsin
,arccos
,arctan
,arctan2
ceil
floor
round
degtorad
radtodeg
They should be evaluated at compile time and be replaced by a constant that can be used at runtime.
Expected Change
See above
Steps To Reproduce
No functionality would be changed it would work as it should
How reliably can you recreate this issue using your steps above?
Always
Which version of GameMaker are you reporting this issue for?
2024.2.0 (Monthly)
Which platform(s) are you seeing the problem on?
Windows
Contact Us Package Attached?
Sample Project Added?
The text was updated successfully, but these errors were encountered: