compiler: implement method-set based AssignableTo and Implements#5304
compiler: implement method-set based AssignableTo and Implements#5304deadprogram merged 15 commits intotinygo-org:devfrom
Conversation
Based on the design from tinygo-org#4376 by aykevl. Fixes tinygo-org#4277, fixes tinygo-org#3580. Co-authored-by: Ayke van Laethem <aykevanlaethem@gmail.com>
|
From one of my more intensive programs in the upcoming release: Current With this PR: So code size 976848 vs 955276 and ram usage 427954 vs 401654 That is a considerable increase for an embedded device! |
|
Hm, that is about the 2% I was quoting (2.26%). @dgryski had suggested a mode that disables some of this information. But in my testing, the method lists are only half the cost, the other half being borne by adding the method pointers to the types. I'm not sure what the right tradeoff is here. This number seems pretty worth it to me given what it unbreaks? I can brainstorm reintroducing sort of DCE or something, not emitting this if reflect is not imported, maybe? Or if certain methods are unused? I don't have an example where these criteria would be met, so having a test case would be helpful. |
|
I have a more complicated optimization on top of this PR which eliminates For these examples: "minimal"package main
type Stringer interface {
String() string
}
type MyType struct{ Name string }
func (m MyType) String() string { return m.Name }
func main() {
var x interface{} = MyType{Name: "hello"}
if s, ok := x.(Stringer); ok {
println("yes:", s.String())
} else {
println("no")
}
}"fmt.Println"package main
import "fmt"
type Stringer interface {
String() string
}
type MyType struct {
Name string
}
func (m MyType) String() string {
return m.Name
}
func main() {
var x interface{} = MyType{Name: "hello"}
if s, ok := x.(Stringer); ok {
fmt.Println("implements Stringer:", s.String())
} else {
fmt.Println("does not implement Stringer")
}
var y interface{} = 42
if _, ok := y.(Stringer); ok {
fmt.Println("int implements Stringer")
} else {
fmt.Println("int does not implement Stringer")
}
}"encoding/json"package main
import (
"encoding/json"
"fmt"
)
type Person struct {
Name string `json:"name"`
Age int `json:"age"`
}
func main() {
data := []byte(`{"name":"Alice","age":30}`)
var p Person
err := json.Unmarshal(data, &p)
if err != nil {
fmt.Println("error:", err)
return
}
fmt.Println(p.Name, p.Age)
}With Wasm, measuring bytes:
So, I end up actually getting smaller. I'll push this up, but I still need some sort of test case to look at if this is not helping your case. |
|
Pulled the latest commit in this PR: So it got a bit bigger. |
|
That... doesn't make any sense 😄 Do you have some code I can test? |
|
This is the code I am building: Using Using this branch: |
…dSet and method info to be dropped when reflect is not present
33b58a0 to
1b13c9f
Compare
|
on your example, I think it's now at: |
|
Interestingly, if I include the needed vars it increases the RAM size which is the number I am thinking about overall, not specific to this PR. The optimizer eliminated a bunch of code that is needed for the device to function. I added them back into the build command:
Current PR branch: On this example, an increase of |
|
I have another very tricky change I that omits this info entirely from types without methods; I'll have numbers on that once I finish testing 😄 |
|
My trick shaves off about 3.8K in flash, 3.6K in RAM (so far), though it's a bit sketchy given it means these type objects differ in their actual size depending on whether or not they have methods (using the high bit on numMethods to indicate whether I'm not sure what bar you have for this. |
|
I was able to shave a bit more off. I have other ideas to go further but it's getting increasingly complex. |
|
Current size: That is down to a I do not want to dissuade you from seeking further optimizations, of course. 😸 |
|
@jakebailey this is a legit fail in the last push: |
|
Yeah, I keep forgetting to fix these committed ll files; will fix that in the morning (and see what else is left) |
|
I'll review this tomorrow. |
|
Couldn't help myself, so, got it passing now before I fall asleep 😅 |
|
Going through the rest of my ideas, they are all pretty invasive or have other bad effects. I think what's here is probably enough. I of course had to slap a lot of stuff on top of my original change to make this acceptable, so hopefully those changes are alright. |
|
@aykevl Unless you have some objections, I think we should merge this. |
|
Last call for feedback before squash/merge! |
|
I'll try to take a look soon! |
|
I ran the
Three more packages in the stdlib are now passing tests! 🥳 |
|
Ah, I will add errors to the list! |
| value = llvm.AddGlobal(c.mod, c.ctx.Int8Type(), globalName) | ||
| value.SetInitializer(llvm.ConstNull(c.ctx.Int8Type())) | ||
| value.SetGlobalConstant(true) | ||
| value.SetLinkage(llvm.LinkOnceODRLinkage) | ||
| value.SetAlignment(1) |
There was a problem hiding this comment.
There might be ways to optimize this, since all it really needs is unique IDs.
Also, might be worth adding debug info for this (can be done in the future) so that -size=full correctly attributes the data used for this.
Anyway, just ideas for the future it looks good enough for now.
There was a problem hiding this comment.
Yeah, so I did think about using IDs, but there were some challenges that made me not do that. Namely that I wasn't sure that it would be easy to DCE because with the pointers, at least I think the LLVM stack knows when something is unused, but with the IDs, not so much?
For the debug info, I think I could try and do that quick, but if you don't mind it later I'm happy to wait (not sure if there's any rebasing or something needed for this PR or if it's going to just get squashed).
There was a problem hiding this comment.
Oh, adding the debug info is acutally very easy, it's effectively just copy-paste from getTypeCode
|
Since the sizediff CI test couldn't make a comment here, I've copied over the text myself. See below. Binary size is either the same as before, or about 0.3-0.5% increase which I consider entirely acceptable. The overall difference over all tests is 0.22% which is not bad at all! Thanks for working on these optimizations! This is indeed roughly what I had in mind, but it's a bit tricky to implement correctly. Size differenceflash ram before after diff before after diff 8764 8764 0 0.00% 5088 5088 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adxl345/main.go 13636 13636 0 0.00% 7136 7136 0 0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/amg88xx 8924 8924 0 0.00% 5088 5088 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/main.go 11372 11372 0 0.00% 6928 6928 0 0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/apds9960/proximity/main.go 9828 9828 0 0.00% 5108 5108 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/itsybitsy-m0/main.go 7356 7356 0 0.00% 2296 2296 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/at24cx/main.go 8008 8008 0 0.00% 5080 5080 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bh1750/main.go 7368 7368 0 0.00% 5080 5080 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/blinkm/main.go 27664 27664 0 0.00% 5120 5120 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp180/main.go 11816 11816 0 0.00% 5152 5152 0 0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bmp388/main.go 7712 7712 0 0.00% 3336 3336 0 0.00% tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/sram/main.go 4400 4400 0 0.00% 2256 2256 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/easystepper/main.go 7068 7068 0 0.00% 2260 2260 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/gc9a01/main.go 8420 8420 0 0.00% 5080 5080 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/hcsr04/main.go 5528 5528 0 0.00% 2256 2256 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/customchar/main.go 5568 5568 0 0.00% 2256 2256 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/text/main.go 10376 10376 0 0.00% 5088 5088 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/hd44780i2c/main.go 14248 14248 0 0.00% 6928 6928 0 0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/hts221/main.go 15980 15980 0 0.00% 2340 2340 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hub75/main.go 10156 10156 0 0.00% 7264 7264 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/basic 11144 11144 0 0.00% 5224 5224 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/basic 29436 29436 0 0.00% 38424 38424 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/pyportal_boing 10188 10188 0 0.00% 7256 7256 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/scroll 11224 11224 0 0.00% 5216 5216 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/scroll 10472 10472 0 0.00% 5120 5120 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis3dh/main.go 13632 13632 0 0.00% 6928 6928 0 0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/lps22hb/main.go 26188 26188 0 0.00% 2304 2304 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/lsm303agr/main.go 27860 27860 0 0.00% 7168 7168 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/lsm303dlhc/main.go 12312 12312 0 0.00% 5128 5128 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/lsm6ds3/main.go 10020 10020 0 0.00% 5080 5080 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mag3110/main.go 8984 8984 0 0.00% 5120 5120 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017/main.go 9416 9416 0 0.00% 5128 5128 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017-multiple/main.go 9440 9440 0 0.00% 5088 5088 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp3008/main.go 7464 7464 0 0.00% 5088 5088 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mma8653/main.go 7368 7368 0 0.00% 5080 5080 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mpu6050/main.go 12312 12312 0 0.00% 5756 5756 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/pca9685/main.go 6244 6244 0 0.00% 3268 3268 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setbuffer/main.go 4628 4628 0 0.00% 2260 2260 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setpixel/main.go 10604 10604 0 0.00% 5732 5732 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/seesaw/soil-sensor 11916 11916 0 0.00% 5740 5740 0 0.00% tinygo build -size short -o ./build/test.hex -target=qtpy-rp2040 ./examples/seesaw/rotary-encoder 3113 3113 0 0.00% 560 560 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino ./examples/servo 13896 13896 0 0.00% 5804 5804 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/sgp30 7988 7988 0 0.00% 7128 7128 0 0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/shifter/main.go 5896 5896 0 0.00% 2260 2260 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ssd1331/main.go 6808 6808 0 0.00% 2260 2260 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7735/main.go 6488 6488 0 0.00% 2260 2260 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7789/main.go 16784 16784 0 0.00% 5080 5080 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/thermistor/main.go 9640 9640 0 0.00% 4880 4880 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-bluefruit ./examples/tone 10136 10136 0 0.00% 5080 5080 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/tm1637/main.go 10924 10924 0 0.00% 5744 5744 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/touch/capacitive 8816 8816 0 0.00% 7128 7128 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/fourwire/main.go 12348 12348 0 0.00% 7324 7324 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/pyportal_touchpaint/main.go 15772 15772 0 0.00% 5088 5088 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl53l1x/main.go 14328 14328 0 0.00% 5088 5088 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl6180x/main.go 6356 6356 0 0.00% 2300 2300 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13/main.go 5944 5944 0 0.00% 2292 2292 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13x/main.go 6248 6248 0 0.00% 2300 2300 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd4in2/main.go 7096 7096 0 0.00% 5120 5120 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/ws2812 5506 5506 0 0.00% 8918 8918 0 0.00% '-xesppie' is not a recognized feature for this target (ignoring feature) 1997 1997 0 0.00% 600 600 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino ./examples/ws2812 1488 1488 0 0.00% 182 182 0 0.00% tinygo build -size short -o ./build/test.hex -target=digispark ./examples/ws2812 32068 32068 0 0.00% 5120 5120 0 0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bme280/main.go 16392 16392 0 0.00% 5080 5080 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/microphone/main.go 11740 11740 0 0.00% 5080 5080 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/buzzer/main.go 12268 12268 0 0.00% 5120 5120 0 0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/veml6070/main.go 6796 6796 0 0.00% 5080 5080 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l293x/simple/main.go 8716 8716 0 0.00% 5080 5080 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l293x/speed/main.go 6772 6772 0 0.00% 5080 5080 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l9110x/simple/main.go 9120 9120 0 0.00% 5080 5080 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l9110x/speed/main.go 7272 7272 0 0.00% 3308 3308 0 0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-f103rb ./examples/shiftregister/main.go 7032 7032 0 0.00% 2256 2256 0 0.00% '-xesppie' is not a recognized feature for this target (ignoring feature) 13280 13280 0 0.00% 5080 5080 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis2mdl/main.go 11248 11248 0 0.00% 5104 5104 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/max72xx/main.go 7176 7176 0 0.00% 5080 5080 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/clkout/ 12196 12196 0 0.00% 5708 5708 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/qmi8658c/main.go 10876 10876 0 0.00% 5692 5692 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/pcf8591/ 8732 8732 0 0.00% 5088 5088 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/ina260/main.go 12176 12176 0 0.00% 5120 5120 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/ina219/main.go 9300 9300 0 0.00% 5232 5232 0 0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-l432kc ./examples/aht20/main.go 10160 10160 0 0.00% 7128 7128 0 0.00% tinygo build -size short -o ./build/test.elf -target=wioterminal ./examples/axp192/m5stack-core2-blinky/ 9020 9020 0 0.00% 5680 5680 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/xpt2046/main.go 13128 13128 0 0.00% 4924 4924 0 0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-wl55jc ./examples/sx126x/lora_rxtx/ 11300 11300 0 0.00% 6656 6656 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/irremote/main.go 12292 12292 0 0.00% 5756 5756 0 0.00% tinygo build -size short -o ./build/test.hex -target=badger2040 ./examples/uc8151/main.go 12296 12296 0 0.00% 6200 6200 0 0.00% tinygo build -size short -o ./build/test.hex -target=badger2040 ./examples/waveshare-epd/epd2in9v2/main.go 10516 10516 0 0.00% 5752 5752 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/scd4x/main.go 7984 7984 0 0.00% 5088 5088 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=circuitplay-express ./examples/makeybutton/main.go 9448 9448 0 0.00% 5104 5104 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ds18b20/main.go 16100 16100 0 0.00% 7348 7348 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/as560x/main.go 9912 9912 0 0.00% 5700 5700 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mpu6886/main.go 7764 7764 0 0.00% 5080 5080 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ttp229/main.go 9364 9364 0 0.00% 5692 5692 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mpu9150/main.go 8508 8508 0 0.00% 6156 6156 0 0.00% tinygo build -size short -o ./build/test.hex -target=macropad-rp2040 ./examples/encoders/quadrature-interrupt 13220 13220 0 0.00% 5688 5688 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/tmc5160/main.go 12004 12004 0 0.00% 4900 4900 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=nicenano ./examples/sharpmem/main.go 12856 12856 0 0.00% 5748 5748 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/ens160/main.go 16108 16108 0 0.00% 5764 5764 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/si5351/main.go 42964 42980 16 0.04% 5316 5316 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/ds3231/basic/main.go 27420 27436 16 0.06% 3808 3808 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/microbitmatrix/main.go 29088 29108 20 0.07% 5316 5316 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/ds3231/alarms/main.go 36232 36252 20 0.06% 6388 6388 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/pcf8523/ 21592 21616 24 0.11% 3532 3532 0 0.00% tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/time/main.go 27300 27324 24 0.09% 5852 5852 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit-v2 ./examples/microbitmatrix/main.go 12320 12344 24 0.19% 8712 8712 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao-ble ./examples/ssd1306/ 42172 42196 24 0.06% 8964 8964 0 0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/sx127x/lora_rxtx/ 23312 23340 28 0.12% 5744 5744 0 0.00% tinygo build -size short -o ./build/test.hex -target=metro-rp2350 ./examples/bno08x/i2c/main.go 11692 11728 36 0.31% 5684 5684 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao-rp2040 ./examples/ssd1306/ 11780 11816 36 0.31% 5684 5684 0 0.00% tinygo build -size short -o ./build/test.hex -target=thumby ./examples/ssd1306/ 11572 11612 40 0.35% 5728 5728 0 0.00% tinygo build -size short -o ./build/test.hex -target=macropad-rp2040 ./examples/sh1106/macropad_spi 57568 57612 44 0.08% 3672 3672 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht3x/main.go 57560 57604 44 0.08% 3680 3680 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht4x/main.go 57568 57612 44 0.08% 3672 3672 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/shtc3/main.go 31788 31848 60 0.19% 7200 7200 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/ssd1289/main.go 24568 24636 68 0.28% 14076 14076 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840-sense ./examples/waveshare-epd/epd1in54/main.go 17016 17112 96 0.56% 6576 6576 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/adafruit4650 62852 62948 96 0.15% 6296 6296 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840 ./examples/is31fl3731/main.go 67560 67660 100 0.15% 6704 6704 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/i2c/main.go 68260 68360 100 0.15% 6852 6852 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/uart/main.go 26380 26484 104 0.39% 18816 18816 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/waveshare-epd/epd2in66b/main.go 62124 62228 104 0.17% 3768 3768 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ndir/main_ndir.go 65468 65572 104 0.16% 6600 6600 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ndir/main_ndir.go 67344 67464 120 0.18% 7212 7212 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/ndir/main_ndir.go 71412 71676 264 0.37% 3640 3640 0 0.00% tinygo build -size short -o ./build/test.hex -target=pinetime ./examples/bma42x/main.go 61996 62264 268 0.43% 8576 8576 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/i2csoft/adt7410/ 62424 62696 272 0.44% 6332 6332 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840 ./examples/max6675/main.go 61744 62024 280 0.45% 6528 6528 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adt7410/main.go 65628 65908 280 0.43% 6544 6544 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmi160/main.go 64300 64580 280 0.44% 6568 6568 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp280/main.go 66712 67004 292 0.44% 9356 9356 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/flash/console/qspi 76256 76548 292 0.38% 7788 7788 0 0.00% tinygo build -size short -o ./build/test.hex -target=p1am-100 ./examples/p1am/main.go 42144 42436 292 0.69% 7536 7536 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/tmc2209/main.go 71812 72108 296 0.41% 6544 6544 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp2515/main.go 71312 71608 296 0.42% 6688 6688 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/alarm/ 70748 71044 296 0.42% 6688 6688 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/time/ 71144 71440 296 0.42% 6688 6688 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/timer/ 73760 74056 296 0.40% 11092 11092 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/sdcard/console/ 66840 67136 296 0.44% 7180 7180 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mcp9808/main.go 70312 70612 300 0.43% 7316 7316 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/flash/console/spi 76924 77244 320 0.42% 6680 6680 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/dht/main.go 122140 122768 628 0.51% 8112 8112 0 0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-wl55jc ./examples/lora/lorawan/atcmd/ 263644 264552 908 0.34% 47108 47108 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/slideshow 3532508 3540352 7844 0.00% 850212 850212 0 0.00% |
|
Pushed the debug info plus removed an unreferenced function I missed; shouldn't affect the size comparison (which I am very excited to see, that's a lot better than I thought it was going to be). |
|
Great work everyone! Thanks for getting it done, now squash/merging. |
|
Awesome! I realized just now that I had not added to the test suite |
Fixes #4277
Fixes #3580
Fixes #4873
Closes #4375
Closes #4376
Updates #4894
Based on the design from #4375/#4376 by @aykevl; I've
Co-authored-byit since it's obviously based on those changes. There were just a couple of bugs in it that I found, e.g. offsetting instructTypeas its length is actually dynamic.In my testing, this
increases binary sizes by about 2%; I did not see the 4% as in the other PR, but perhaps its down to which binary is being used?More like 1-1.5%ish (it depends).Even less! See #5304 (comment)But it does enable full
AssignableTo/Implementsand eliminatesOptimizeReflectImplements.This allows
typescript-goto work withgo-json-experiment.I believe that this can also be used to implement #3862.