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

[REQUEST] Web Assembly JIT compiler #1871

Open
aschrein opened this issue Mar 3, 2020 · 3 comments
Open

[REQUEST] Web Assembly JIT compiler #1871

aschrein opened this issue Mar 3, 2020 · 3 comments
Labels

Comments

@aschrein
Copy link

aschrein commented Mar 3, 2020

It is possible to get native jitted code for web assembly(wasm) out of javascript engines like SpiderMonkey and V8. Here is an example.

I think it makes sense to add wat(wasm text)-to-x86 explorer in the future to study optimization opportunities. One could use CE to generate wat and then copy-paste that wat in the second window and get native assembly.

One way to get native assembly is to run v8 with --print-wasm-code option. There's also a way using v8's internals to get custom output.

Adding that would involve installing wasm tools for (wat -> wasm) conversion and one of the javasctipt engines. I personally tried using v8 and it wasn't difficult in terms of installing/compiling from source compared to llvm/clang. Although that would also involve pulling some google internal tools like depot_tools.

Thanks,
Anton

@aschrein aschrein added the request Request for something label Mar 3, 2020
@gautam1168
Copy link
Contributor

Please look at the issue #264
and this discussion #4700

Im adding a webassembly thing to it right now. I am adding a way to do it through c++ -> clang -> wasm -> d8

Although I could also use wabt to do it from .wat files directly. But I have had wabt fail me before this, so Ill do that later. I could do spydermonkey but I haven't ever compiled it before, unlike d8. But I would like to compare spydermonkey and d8 too.

@gautam1168
Copy link
Contributor

I have this working right now where I have added the bytes of the compiled add function directly to the javascript file. You can see both the webassembly code generated by the baseline compiler and then the optimized code here:
image

@gautam1168
Copy link
Contributor

I got webassembly working using clang and c in my local env. You can make a tree view and have a js file with a special string. The javascript compiler class will then compile the c file to wasm and put the bytes in the javascript file before giving it to d8.

image

mattgodbolt pushed a commit that referenced this issue Jun 11, 2024
👋 Hey,

This PR adds support for the Webassembly Text Language (#1871).
Currently it only supports the
[wasmtime](https://github.com/bytecodealliance/wasmtime) compiler, but
it should be possible to add others (i.e. v8 / wasmer / etc...).

It looks like the monaco does not support the WAT language, so I've
added a simple mode for it, that is mostly copied from the clojure mode
with some changes. From what I've tested it seems to work reasonably
well.


![image](https://github.com/compiler-explorer/compiler-explorer/assets/1357143/9e38b28e-235c-47e5-a71e-50217e5d2056)

---------

Co-authored-by: Patrick Quist <partouf@gmail.com>
mattgodbolt pushed a commit that referenced this issue Jun 11, 2024
👋 Hey,

This PR adds support for the Webassembly Text Language (#1871).
Currently it only supports the
[wasmtime](https://github.com/bytecodealliance/wasmtime) compiler, but
it should be possible to add others (i.e. v8 / wasmer / etc...).

It looks like the monaco does not support the WAT language, so I've
added a simple mode for it, that is mostly copied from the clojure mode
with some changes. From what I've tested it seems to work reasonably
well.


![image](https://github.com/compiler-explorer/compiler-explorer/assets/1357143/9e38b28e-235c-47e5-a71e-50217e5d2056)

---------

Co-authored-by: Patrick Quist <partouf@gmail.com>
OfekShilon pushed a commit to OfekShilon/compiler-explorer that referenced this issue Jul 13, 2024
👋 Hey,

This PR adds support for the Webassembly Text Language (compiler-explorer#1871).
Currently it only supports the
[wasmtime](https://github.com/bytecodealliance/wasmtime) compiler, but
it should be possible to add others (i.e. v8 / wasmer / etc...).

It looks like the monaco does not support the WAT language, so I've
added a simple mode for it, that is mostly copied from the clojure mode
with some changes. From what I've tested it seems to work reasonably
well.


![image](https://github.com/compiler-explorer/compiler-explorer/assets/1357143/9e38b28e-235c-47e5-a71e-50217e5d2056)

---------

Co-authored-by: Patrick Quist <partouf@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants