tsoding / bm

Simple compiler ecosystem
MIT License
169 stars 16 forks source link

arm64 : Remove awkward jump table #392

Closed herrhotzenplotz closed 3 years ago

herrhotzenplotz commented 3 years ago

As noted in the commit message of 07eef8b .

I removed the jump table because it seemed like a hack anyways. Now we use the proper call/return mechanisms of arm slightly modified to use the bm stack instead of the "C stack" (which doesn't really exist since we don't depend on libc).

Maybe this can be done to the amd64 assembly generator as well.

Spoiler: Performance slightly increased:

Before

[nico@henricus ~/src/bm]$ build/toolchain/basm -t gas-freebsd-arm64 -I lib test/cases/pi.basm
[nico@henricus ~/src/bm]$ cc -c -g -o pi.o pi.S
[nico@henricus ~/src/bm]$ ld -o pi pi.o
[nico@henricus ~/src/bm]$ time ./pi
3.1415933203

real   0.273605
user   0.273777
sys    0.000000
[nico@henricus ~/src/bm]$ time ./pi
3.1415933203

real   0.273515
user   0.273590
sys    0.000243
[nico@henricus ~/src/bm]$

After

[nico@henricus ~/src/bm]$ build/toolchain/basm -t gas-freebsd-arm64 -I lib test/cases/pi.basm
[nico@henricus ~/src/bm]$ cc -c -g -o pi.o pi.S
[nico@henricus ~/src/bm]$ ld -o pi pi.o
[nico@henricus ~/src/bm]$ time ./pi
3.1415933203

real   0.269791
user   0.269187
sys    0.000537
[nico@henricus ~/src/bm]$ time ./pi
3.1415933203

real   0.269755
user   0.262562
sys    0.007125
[nico@henricus ~/src/bm]$
rexim commented 3 years ago

@herrhotzenplotz looks good to me! :+1: Thank you for your contribution!