Summary: | Support WebAssembly (wasm) Target Platform (browser/web) | ||
---|---|---|---|
Product: | [JogAmp] General | Reporter: | Sven Gothel <sgothel> |
Component: | generic | Assignee: | Sven Gothel <sgothel> |
Status: | UNCONFIRMED --- | ||
Severity: | normal | CC: | gouessej, mfery |
Priority: | P4 | ||
Version: | tbd | ||
Hardware: | All | ||
OS: | all | ||
Type: | FEATURE | SCM Refs: | |
Workaround: | --- |
Description
Sven Gothel
2024-04-02 10:03:54 CEST
As far as I know, GraalVM is able to run WebAssembly but it's unable to convert JVM bytecode into WebAssembly. This helps a lot to parse the bytecode: https://openjdk.org/jeps/457 This project is worth interest too and it targets OpenCL (bonus): https://mirkosertic.github.io/Bytecoder/ I don't know yet if the project Babylon could help: https://openjdk.org/projects/babylon/articles/linq I'll see what I can do. It's a major research field for me. (In reply to Julien Gouesse from comment #1) Correct. GraalVM hosts wasm, but is not producing a wasm target for the wasm (browser) runtime. Sorry .. didn't take enough time. Bottom line, either one brings back the JVM to the browser allowing Java bytecode execution using existing tech - or the wasm target compiler path. Alternatively, drop Java and use C++ etc. (In reply to Sven Gothel from comment #2) https://jogamp.org/wiki/index.php?title=SW_Tracking_Report_Feature_Objectives_Overview#WebAssembly_%28wasm%29_Target_Platform updated wiki text (In reply to Sven Gothel from comment #2) In my humble opinion, the wasm target compiler path is more viable, especially now that there are garbage collectors for WebAssembly in many major web browsers. There is a request for enhancement about wasm target in GraalVM: https://github.com/oracle/graal/issues/3391 Google J2wasm within J2CL can be a source of inspiration too, it emits very naïve Wasm using the text format and it relies on Binaryen toolchain to assemble, link, and optimize: https://github.com/google/j2cl/blob/master/docs/getting-started-j2wasm.md https://www.wingolog.org/pub/epfl-wasm-gc-feb-2024-slides.pdf I have to be more accurate. Mozilla Firefox >= 120, Chrome and Chromium-based web browsers >= 119 support the WASM garbage collector by default. Importing host functions to manipulate the DOM tree and to call the web APIs seems to be still necessary, am I missing something obvious? (In reply to Julien Gouesse from comment #4) Whether re-animating the JVM within the browser or having a webassembly compilation target, not sure what would be best on a technical basis. In general I prefer less layers of complexity, which also often cause (a) bugs and (b) reduce performance. However, if working well, both would allow using Java on the web. TeaVM also seems to be close, if willing to drop certain features. A long road ahead :) +++ Extracted the big section to its own wiki (w/ back/forth link to features) https://jogamp.org/wiki/index.php?title=WebAssembly_(wasm)_Target_Platform (added your infos, please feel free to edit this page as well as you seem fit) I started using the class-file API a few weeks ago to evaluate it, I'll post an example soon just to show what I mean. Just for the follow-up, I've succeeded in using Java 22 with preview features enabled in a Gradle 8.10 project, I use TestNG too, the class-file API works like a charm. I'm able to find the enum constants within an enum class, it's a first step. I'll publish the source code somewhere when it can emit a simple WAT file. |