Commit graph

249 commits

Author SHA1 Message Date
Elizaveta Chichindaeva
28908aa3cf [#2442] English Check
Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
2022-05-04 19:48:27 +03:00
Evgeniy Stratonikov
a2cef15932 compiler: emit bindings configuration
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-02-28 15:36:14 +03:00
Evgeniy Stratonikov
b5afe24090 compiler: properly process defer in conditional statements
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-02-04 11:04:03 +03:00
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
970769e5b2 compiler: allow to use _ in constants
When `_` is unused it can be omitted from constant values mapping.
Catched when compiling `netmap` contract from nspcc-dev/neofs-contract.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-01-20 13:52:58 +03:00
Evgeniy Stratonikov
9871dc8f5a compiler: update x/tools package
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-01-20 13:21:26 +03:00
Roman Khimov
299a7ea614 compiler: use CALLT for native contract calls, fix #2257 2021-12-10 11:58:50 +03:00
Roman Khimov
dbe184a335
Merge pull request #2280 from nspcc-dev/compiler-struct-cast
compiler: allow to slice struct field
2021-11-30 18:14:56 +03:00
Roman Khimov
cddd5e1f6d compiler: add a panic on internal lambda inconsistency
It's a bit better than behavior observer in #2281 (which is very cryptic).
2021-11-30 18:02:38 +03:00
Evgeniy Stratonikov
66a4245bef compiler: allow to slice struct field
It makes no sense to restrict to identifiers.
2021-11-30 15:48:46 +03:00
Roman Khimov
7fa58a4dc8
Merge pull request #2255 from nspcc-dev/compiler-noreturn-defers
compiler: correctly handle defer in functions without return values
2021-11-15 10:43:00 +03:00
Roman Khimov
db99368e96 compiler: optimize GAS cost of type conversion
CONVERT call base price is 8192. DUP, ISTYPE and JMPIF all cost 2. So we add
0.07% overhead in the worst case and save 99.93% otherwise.

At the same time, old code was just two bytes and new one is seven, but I
think it's tolerable considering how much GAS it can potentially save.

Fix #2250.
2021-11-12 19:58:21 +03:00
Roman Khimov
a91581fa16 compiler: correctly handle defer in functions without return values
Fix #2253.
2021-11-12 19:36:59 +03:00
Roman Khimov
410aabe7a1 compiler: drop some useless NOPs
They're all obsolete and not needed.
2021-11-12 17:19:59 +03:00
Roman Khimov
0d50730382 compiler: optimize map initialization with PACKMAP 2021-11-12 17:19:59 +03:00
Roman Khimov
a8befeea33 compiler: optimize new empty struct creation with PACKSTRUCT 2021-11-12 17:19:59 +03:00
Roman Khimov
909ea477f4 compiler: create arrays/structs more effectively
Use PACK/PACKSTRUCT.
2021-11-12 17:19:59 +03:00
Evgeniy Stratonikov
4fe188a60d compiler: check correctness of emitted bytecode
The error here indicates a bug in compiler implementation.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-25 13:55:55 +03:00
Evgeniy Stratonikov
a885f84cad compiler: fail if some functions are missing
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-25 13:55:55 +03:00
Evgeniy Stratonikov
a92bf281c1 compiler: remove custom logic for util builtins
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-23 16:12:47 +03:00
Roman Khimov
36295357d8 interop: add Abort() function to ABORT things
Related to #2227.
2021-10-22 14:50:51 +03:00
Evgeniy Stratonikov
dc9287bf5c compiler: use parameter directly in writeJumps
`Next` doesn't longer copy parameter.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-08-13 11:59:04 +03:00
Roman Khimov
4d1e952be6 go.mod: update go-datastructures to 1.0.53
We're only using queue library and it didn't change in any way, but 1.0.53 has
proper go.mod, so it's still an improvement.

It at the same time pulls some new packages also like x/tools.
2021-07-21 23:28:00 +03:00
Evgeniy Stratonikov
4249674ddc compiler: check for contract permissions
On many occassions we can determine at compile-time if contract config lacks
some properties it needs. This includes all native contract invocations
through stdlib, as both hashes and methods are known at compile-time
there.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-06-28 11:49:29 +03:00
Roman Khimov
efb814a97e
Merge pull request #1995 from nspcc-dev/compiler-verify-notify
compiler: disallow `runtime.Notify` in `Verify` function
2021-06-06 11:34:42 +03:00
Evgeniy Stratonikov
1578904da2 compiler: disallow runtime.Notify in Verify function
Only direct invocations are considered. The check can be disabled
with '--no-events' compiler option.
2021-06-06 09:34:24 +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
1a5e656d38 compiler: restore event check warnings
It was broken after changes for inlining. Add tests.
2021-06-03 10:32:56 +03:00
Evgeniy Stratonikov
60a3e0d778 compiler: count auxiliary locals introduced by inlining
During initialization of globals no function scope is present thus
locals number is not saved anywere. Save it in `codegen` directly.
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
Evgeniy Stratonikov
2aaaf30db7 compiler: remove finallyProcessIndex from funcScope 2021-05-19 09:54:10 +03:00
Roman Khimov
834743ec88
Merge pull request #1958 from nspcc-dev/linter
Linter improvements
2021-05-13 10:52:58 +03:00
Roman Khimov
9d2712573f *: enable godot linter and fix all its warnings
It's important for NeoGo to have clean documentation. No functional changes.
2021-05-12 23:17:03 +03:00
Roman Khimov
c4e084b0d8 *: fix whitespace errors
leading/trailing newlines
2021-05-12 22:51:41 +03:00
Roman Khimov
92dbb3c4b9 *: fix all unused warnings
From golangci-lint.
2021-05-12 18:53:12 +03:00
Evgeniy Stratonikov
7b638d5489 compiler: emit debug variable info for _deploy() 2021-05-12 16:04:11 +03:00
Evgeniy Stratonikov
b72f6be9e9 compiler: emit debug variable info for init() 2021-05-12 16:04:06 +03:00
Evgeniy Stratonikov
7afca7f8e5 compiler: add support for static-variables in debug info 2021-05-12 15:05:39 +03:00
Evgeniy Stratonikov
dc393642a2 opcode: fix GTE, LTE string representations 2021-04-29 16:08:48 +03:00
Roman Khimov
924de3e090
Merge pull request #1796 from nspcc-dev/compiler/pow
Add syscalls for POW and SQRT opcodes
2021-03-04 16:56:15 +03:00
Evgeniy Stratonikov
8f8c7d2839 compiler: fix import alias handling 2021-03-04 14:41:20 +03:00
Evgeniy Stratonikov
56fe6574c9 compiler: simplify convert.To* processing
With inlining there is no need for special logic in compiler.
2021-03-04 13:05:33 +03:00
Evgeniy Stratonikov
e754ca62db compiler: do not emit CONVERT for syscall results
When we encounter type assertion CONVERT is emitted.
This isn't needed for SYSCALL (or opcode) results
because value already has needed type.
Problems can arise when result is converted to invalid type
but `neogointernal` package shouldn't be used directly anyway.
2021-03-04 13:05:33 +03:00
Evgeniy Stratonikov
578bbabd1d compiler: allow to emit opcodes directly 2021-03-04 13:03:05 +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
df5314f286 compiler: refactor syscall handling
Close #941.
2021-02-24 12:51:15 +03:00
Evgeniy Stratonikov
d16ef53653 compiler: support ellipsis for append of non-byte slices
NeoVM lacks opcode for array append, thus some
kind of loop is needed for this.
2021-02-17 17:14:32 +03:00
Evgeniy Stratonikov
fc3b840335 compiler: append bytes >0x80 properly
NeoVM encoding for int(0x80) is []byte{0x80, 0x00} and
byte constant can be used both as integer and as an element
of byte-slice. Thus special case needs to be taken in
`append`.
2021-02-17 16:34:34 +03:00
Evgeniy Stratonikov
6e560c6c9f compiler: allow to inline var arg functions 2021-02-15 18:48:33 +03:00