Closed SoniEx2 closed 1 year ago
I would propose considering it required. It appears to contain 25340 entries, which is large, but not unreasonably large in contexts like binary decoding or lookup tables. Large jump tables can be split up into small jump tables by using eg. binary search with comparisons and branches to split the range into ranges small enough to be encoded.
25340 entries requires 101360 bytes in JVM bytecode.
we only have 65535 bytes to work with.
What would be the max number of entries that you can handle without splitting up the function?
less than 16380 (tho at 16380 there wouldn't be space for anything else)
Personally, I'd be fine reducing the example to a number like that, if there is a concrete implementation to justify it with and test against. Does that actually exist or is the question just hypothetical?
wasm2kotlin (targets JVM) exists, yes. tho we're unsure what exact size it needs to be in order to fit.
Well, thus my question earlier. Can you find out?
looks like we need to optimize wasm2kotlin codegen. it's currently having an overhead of 4 extra bytes per branch - so it only fits about 8190 entries instead of the theoretical 16380. it should be able to do at least 16370 (there's still gonna be a bit of overhead) once we fix this.
will check back in once we have that done.
At some point, we discussed a base conformance plus a small number of features, e.g. "2.0 + FwSimd + TailCall". Would it be useful to consumers to have a sense of the size of the jump table they could expect an implementation to handle? (Also, would it be nice to have a tool that read a .wasm and estimate the features required to execute it?
we have managed to compile it with 16149 cases
(kotlinc 1.8 appears to have a bug, where it unnecessarily generates some extra branches, so it does eat at the max a little. kotlin 2.0 (experimental) gets us to at least 16353.)
(yes, these are in 34-case chunks.)
Is the br_table "large" test required? Some platforms (e.g. JVM bytecode) simply do not support jump tables that large.