Posted August 03, 2022 by YellowAfterlife
path_set_live
)file_set_live
)delete
keyword is now supporteddelete
keyword actually does anything special in GML)self
no longer being a constant value.This release brings a number of optimizations for common operations.
GMLive represents compiled code as an array of instructions. So, for example,
var x1 = mesh[# 0, i] - x;
would be represented as something like
0 push self
1 get field mesh
2 push constant 0
3 push local var i
4 call ds_grid_get with 3 arguments, push result
5 push self
6 get field x
7 subtract values, push result
8 set local x1
A lot of time here is spent on putting something on the stack and removing it in the next instruction.
As an improvement, I started introducing special-purpose instructions, so that instead of “push self” + “get field” you have “get field from self”, for example. Similarly, setting a local variable, incrementing a local variable, comparing a local variable to a constant, etc. are all reduced to a single instructions.
Later I noticed that function/script arguments commonly feature chains of constants, local variables, or self-variables, so I added a special instruction type that can acquire multiple such values at once and place them on stack together - so for a line like
draw_surface_ext(_surf,_x,_y,2,2,0,c_white,1);
instead of 9 instructions there are now just 2.
Most “normal” code sees a performance boost of 1.5 .. 2.5x from this while specific bits become a lot faster.
Thanks to method(), current versions of GameMaker also offer an opportunity to represent the program as a tree instead of an instruction list (so a + b
becomes a function() { return a() + b() }
where a
and b
themselves are also functions), but this is both riskier and a huge effort to support entirety of GML syntax for.
self.array[index]
)