Rerumu / Wasynth

WebAssembly to Lua translation library and tool
https://discord.gg/sgm5YcmgyD
GNU General Public License v3.0
130 stars 18 forks source link

Lacking `BrTable` optimization #8

Closed Rerumu closed 2 years ago

Rerumu commented 2 years ago

The BrTable AST node is currently not emitted with any form of optimization, as it used to be. The reason being that this causes problems consolidating the stack as different branches have different alignments that must be emitted before doing the jump.

Nonetheless, it should still be possible to at least generate a binary search instead of a linear search for the branch or otherwise optimize the lookup.

https://github.com/Rerumu/Wasynth/blob/master/codegen-luajit/src/backend/statement.rs#L31 https://github.com/Rerumu/Wasynth/blob/master/codegen-luau/src/backend/statement.rs#L42