Commit graph

18 commits

Author SHA1 Message Date
Evgeniy Stratonikov
ed43b75631 compiler: do not traverse defer function literals twice
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-02-02 16:52:15 +03:00
Evgeniy Stratonikov
1d6d7206e9 compiler: inline expressions with type conversions, fix #1879
Don't count `string(data)` or `[]byte(data)` as function calls.
2021-06-04 11:08:00 +03:00
Evgeniy Stratonikov
6b3afe9131 compiler: inline all expression with no side-effects, fix #1881
This has the drawback of traversing expression each time the argument is
used. However this is not the case in our syscall/native wrappers.
The old behaviour can be restored by explicit local assignment.
2021-06-04 11:07:59 +03:00
Evgeniy Stratonikov
3749f38720 compiler/test: add more tests for inline behaviour 2021-06-04 11:06:09 +03:00
Evgeniy Stratonikov
c538512e60 compiler/test: check Main locals in inline tests 2021-06-04 11:06:09 +03:00
Evgeniy Stratonikov
87a69b13f1 compiler/test: add test for inlining with local alias
INITSLOT count should be 1 more than for the same test with global.
2021-05-19 11:50:07 +03:00
Evgeniy Stratonikov
b693d54282 compiler: count local variables on the go
Create local variables as they are needed and remove `INITSLOT`
if there were no locals. This helps to eliminate a whole class
of bugs when calculated and real amount mismatched.
2021-05-19 11:50:07 +03:00
Roman Khimov
7e9f8e03c2 compiler: add a test for inlined selector statements
Selector here is either a struct field access or global package
variable/constant. While technically none of these require an additional
local, inlining actually uses one, so add a test for it.
2021-04-06 10:54:37 +03:00
Roman Khimov
21a7f3d760 compiler: keep traversing after c.countLocalsCall()
Some arguments can be inlined functions themselves thus requiring additional
attention. Otherwise we can get less local variables than really used by
STLOCs (and subsequent program crash).
2021-04-05 22:58:07 +03:00
Anna Shaleva
f65485b735 core: remove System.Binary.Itoa and System.Binary.Atoi syscalls
And move their tests to native StdLib.
2021-03-10 19:24:19 +03:00
Evgeniy Stratonikov
7577bbef22 compiler: copy locals slice during inline
Consider function call `f(1, g(2, 3))` when
both `f` and `g` are inlined. If `f` contains some locals,
inlining `g` will replace them with it's another locals map,
because slices in Go reuse storage on `append`.
Thus scope needs to be copied.
2021-03-01 11:48:42 +03:00
Evgeniy Stratonikov
b66b853285 compiler: drop stack after inline
Some control-flow statements drop stack items, for example
`return` when it is used inside of `range` loop.
For inlined calls this `return` should drop only portion of stack
which belongs to inlined call.
2021-03-01 11:48:42 +03:00
Evgeniy Stratonikov
0a4ff9d3e4 compiler: allow to use inlined functions to init globals 2021-02-25 15:12:16 +03:00
Evgeniy Stratonikov
cf459002f7 compiler: allow to inline global variables 2021-02-15 18:48:33 +03:00
Evgeniy Stratonikov
6e560c6c9f compiler: allow to inline var arg functions 2021-02-15 18:48:33 +03:00
Evgeniy Stratonikov
3484025065 compiler: load constants directly on inline 2021-02-15 18:48:33 +03:00
Evgeniy Stratonikov
27e60455c7 compiler: do not introduce excessive locals on inline
When function call-site parameter is an identifier,
we may load it directly. Currently it can be also modified,
this will be fixed in a separate commit.
2021-02-15 18:48:33 +03:00
Evgeniy Stratonikov
1ae0d022dd compiler: support basic inlining 2021-02-15 18:48:33 +03:00