Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: Make TCG create Webassembly instead of using TCI #16

Open
petersalomonsen opened this issue Aug 16, 2019 · 2 comments
Open

Comments

@petersalomonsen
Copy link

As @atrosinenko has achieved with https://github.com/atrosinenko/qemujs, it would be great to have just in time compilation to webassembly instead of using the TCI interpreter.

@petersalomonsen petersalomonsen changed the title feature request: Compile to Webassembly instead of using TCI feature request: Make TCG create Webassembly instead of using TCI Aug 16, 2019
@AlexAltea
Copy link
Owner

AlexAltea commented Aug 16, 2019

As of today, WebAssembly is not designed to do JIT compilation [1]. Every recompiled Translation Block (TB) of TCG, needs results in a new WebAssembly module.

This has quite a significant performance overhead on most browsers, with Firefox being the most reliable of them all. Chrome's engine reserves 4 GiB of virtual address space for every WebAssembly module so theoretically it can only handle 4096 WebAssembly modules before crashing which is certainly not enough for us.

That said, we already have the code, and TCG-WASM translation is slightly faster (on benchmarks), and the code is slightly simpler, but the bottleneck is still the WASM engines in browsers. It seems, @atrosinenko solved this issue by interpreting TBs (at Binaryen level!) that are not frequently used. We haven't written anything like that yet, but if JIT keeps being delayed from the WASM specification, then we will (though relying on TCI rather than interpreting WASM bytecode).

We will probably release the code soon so stay tuned! I'll update this thread when we're ready.

[1] https://webassembly.org/docs/jit-library/

@petersalomonsen
Copy link
Author

That sounds good! Looking very much forward to the new release.

My use case is a very simple one. I've tested unicorn.js for running 4klang in the browser. It works fine, and your api is great, but interpretation is too slow for generating audio in real time. However this code is so small that I don't think it should generate lot's of TBs and maybe what you have already is sufficient for running this.

Thank you for the great work in porting unicorn to the browser!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants