oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀

Home Page:https://www.graalvm.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WebAssembly on GraalVM

linux-china opened this issue · comments

Add WebAssembly runtime on GraalVM with CLI and embed support, just like LLVM on GraalVM.

Cli as following:

gwasm polyglot.wasm 

Embed as following:

 Context polyglot = Context.newBuilder().allowAllAccess(true).build();
        File file = new File("polyglot.wasm");
        Source source = Source.newBuilder("wasm", file).build();
        Value cpart = polyglot.eval(source);
        cpart.execute();  

Now no Java Runtime for WebAssembly. https://github.com/appcypher/awesome-wasm-runtimes

Now lots of guys did the work to make WebAssembly run from web and with huge future for FaaS, Serverless and WASM MicroVM. If GraalVM has this feature, and Java developers can develop a real Polyglot runtime platform to accept WebAssembly module from Rust, TypeScript etc. Please consider WebIDL and WASI support.

Happy to see TruffleWASM :)

Towards a WebAssembly standalone runtime on GraalVM https://dl.acm.org/citation.cfm?id=3362780

FYI I wrote a blog post about my experience trying to run WASM on the JVM, if anyone is interested (yes, it's possible now, but far from "complete")!.

Basically, you can use asmble to create class files from wasm and wat files... and I wrote a Gradle plugin that uses asmble to make using WASM in a Gradle project as easy as using any JVM language.

Get in touch if that would be of interest to you.

I wonder if it can be possible to translate wasm into llvm and run that llvm bitcode upon graal.

commented

I wonder if it can be possible to translate wasm into llvm and run that llvm bitcode upon graal.

Check out the post referred to by @renatoathaydes above.

I have already read it.

The wabt toolkit includes a wasm2c tool (i.e. compiles WASM to C). You can use that, then compile C to LLVM with clang, and you're done.

There are converters that convert wasm to llvm bitcode directly. Thank you for getting me known about wasm2c though.

Looks like this is now being worked on here https://github.com/oracle/graal/tree/master/wasm

Tweet on the announcement about the effort is now available here: https://twitter.com/graalvm/status/1201544880364937216?s=20
Medium post: https://medium.com/graalvm/announcing-graalwasm-a-webassembly-engine-in-graalvm-25cd0400a7f2

I think the issue can be closed for now :). For follow-up suggestions and bug reports feel encouraged to open separate issues.

Great @thomaswue ! It's funny we met in San Francisco at a cafe, hope you remember me... now here :) will play with GraalVM's WASM as soon as I can!!