diff options
author | Ayke van Laethem <[email protected]> | 2018-11-09 17:16:36 +0100 |
---|---|---|
committer | Ayke van Laethem <[email protected]> | 2018-12-01 13:26:06 +0100 |
commit | b4c90f36776fcd2f8a2ab30b50928442c973afc5 (patch) | |
tree | 9aaa2556aa805cba7aa8f2f0e372c639df2616e1 /docs | |
parent | e45c4ac182aae5ad7fab876660cec531287199b8 (diff) | |
download | tinygo-b4c90f36776fcd2f8a2ab30b50928442c973afc5.tar.gz tinygo-b4c90f36776fcd2f8a2ab30b50928442c973afc5.zip |
compiler: lower interfaces in a separate pass
This commit changes many things:
* Most interface-related operations are moved into an optimization
pass for more modularity. IR construction creates pseudo-calls which
are lowered in this pass.
* Type codes are assigned in this interface lowering pass, after DCE.
* Type codes are sorted by usage: types more often used in type
asserts are assigned lower numbers to ease jump table construction
during machine code generation.
* Interface assertions are optimized: they are replaced by constant
false, comparison against a constant, or a typeswitch with only
concrete types in the general case.
* Interface calls are replaced with unreachable, direct calls, or a
concrete type switch with direct calls depending on the number of
implementing types. This hopefully makes some interface patterns
zero-cost.
These changes lead to a ~0.5K reduction in code size on Cortex-M for
testdata/interface.go. It appears that a major cause for this is the
replacement of function pointers with direct calls, which are far more
susceptible to optimization. Also, not having a fixed global array of
function pointers greatly helps dead code elimination.
This change also makes future optimizations easier, like optimizations
on interface value comparisons.
Diffstat (limited to 'docs')
0 files changed, 0 insertions, 0 deletions