mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
compiler: add alloc attributes to runtime.alloc
This gives a small improvement now, and is needed to be able to use the
Heap2Stack transform that's available in the Attributor pass. This
Heap2Stack transform could replace our custom OptimizeAllocs pass.
Most of the changes are just IR that changed, the actual change is
relatively small.
To give an example of why this is useful, here is the code size before
this change:
$ tinygo build -o test -size=short ./testdata/stdlib.go
code data bss | flash ram
95620 1812 968 | 97432 2780
$ tinygo build -o test -size=short ./testdata/stdlib.go
code data bss | flash ram
95380 1812 968 | 97192 2780
That's a 0.25% reduction. Not a whole lot, but nice for such a small
patch.
This commit is contained in:
committed by
Ron Evans
parent
5ed0cecf0d
commit
f180339d6b
Vendored
+3
-1
@@ -18,7 +18,7 @@ func main() {
|
||||
s3 := make([]int, 3) // OUT: object allocated on the heap: escapes at line 19
|
||||
returnIntSlice(s3)
|
||||
|
||||
_ = make([]int, getUnknownNumber()) // OUT: object allocated on the heap: size is not constant
|
||||
useSlice(make([]int, getUnknownNumber())) // OUT: object allocated on the heap: size is not constant
|
||||
|
||||
s4 := make([]byte, 300) // OUT: object allocated on the heap: object size 300 exceeds maximum stack allocation size 256
|
||||
readByteSlice(s4)
|
||||
@@ -82,3 +82,5 @@ func getComplex128() complex128
|
||||
func useInterface(interface{})
|
||||
|
||||
func callVariadic(...int)
|
||||
|
||||
func useSlice([]int)
|
||||
|
||||
Reference in New Issue
Block a user