All Projects → i-net-software → Jwebassembly

i-net-software / Jwebassembly

Licence: apache-2.0
Java bytecode to WebAssembly compiler

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Jwebassembly

Wasm Forth
A Forth implementation compiling to WebAssembly.
Stars: ✭ 92 (-78.4%)
Mutual labels:  compiler, webassembly, wasm
Webassemblyjs
Toolchain for WebAssembly
Stars: ✭ 566 (+32.86%)
Mutual labels:  compiler, webassembly, wasm
Wag
WebAssembly compiler implemented in Go
Stars: ✭ 177 (-58.45%)
Mutual labels:  compiler, webassembly, wasm
Viper
[WIP] A Pythonesque language with a design that focuses on efficiency and expressiveness. Compiles to WebAssembly
Stars: ✭ 23 (-94.6%)
Mutual labels:  compiler, webassembly, wasm
Grain
The Grain compiler toolchain and CLI. Home of the modern web staple. 🌾
Stars: ✭ 2,199 (+416.2%)
Mutual labels:  compiler, webassembly, wasm
Assemblyscript
A TypeScript-like language for WebAssembly.
Stars: ✭ 13,152 (+2987.32%)
Mutual labels:  compiler, webassembly, wasm
Prototype
(deprecated) The journey continues at ASNEXT: https://github.com/AssemblyScript/assemblyscript
Stars: ✭ 2,114 (+396.24%)
Mutual labels:  compiler, webassembly, wasm
Pigo
Fast face detection, pupil/eyes localization and facial landmark points detection library in pure Go.
Stars: ✭ 3,542 (+731.46%)
Mutual labels:  webassembly, wasm
Parity Wasm
WebAssembly serialization/deserialization in rust
Stars: ✭ 314 (-26.29%)
Mutual labels:  webassembly, wasm
Awesome Wasi
😎 Curated list of awesome things regarding WebAssembly WASI ecosystem.
Stars: ✭ 319 (-25.12%)
Mutual labels:  webassembly, wasm
Unrust
unrust - A pure rust based (webgl 2.0 / native) game engine
Stars: ✭ 341 (-19.95%)
Mutual labels:  webassembly, wasm
Ant Design Blazor
🌈A set of enterprise-class UI components based on Ant Design and Blazor WebAssembly.
Stars: ✭ 3,890 (+813.15%)
Mutual labels:  webassembly, wasm
Speedy.js
Accelerate JavaScript Applications by Compiling to WebAssembly
Stars: ✭ 300 (-29.58%)
Mutual labels:  compiler, webassembly
Rustynes
👾 An NES emulator by Rust and WebAssembly
Stars: ✭ 399 (-6.34%)
Mutual labels:  webassembly, wasm
Wasmer Ruby
💎🕸 WebAssembly runtime for Ruby
Stars: ✭ 286 (-32.86%)
Mutual labels:  webassembly, wasm
Wasm3
🚀 The fastest WebAssembly interpreter, and the most universal runtime
Stars: ✭ 4,375 (+927%)
Mutual labels:  webassembly, wasm
Wasabi
A dynamic analysis framework for WebAssembly programs.
Stars: ✭ 279 (-34.51%)
Mutual labels:  webassembly, wasm
Webml
A Standard ML Compiler for the Web
Stars: ✭ 326 (-23.47%)
Mutual labels:  compiler, webassembly
React Wasm
Declarative WebAssembly instantiation for React
Stars: ✭ 349 (-18.08%)
Mutual labels:  webassembly, wasm
Lucet
Lucet, the Sandboxing WebAssembly Compiler.
Stars: ✭ 4,006 (+840.38%)
Mutual labels:  webassembly, wasm

JWebAssembly

Build Status License Coverage Status Download

JWebAssembly is a Java bytecode to WebAssembly compiler. It uses Java class files as input. That it can compile any language that compile to Java bytecode like Clojure, Groovy, JRuby, Jython, Kotlin and Scala. As output it generates the binary format (.wasm file) or the text format (.wat file). The target is to run Java natively in the browser with WebAssembly.

The difference to similar projects is that not a complete VM with GC and memory management should be ported. It's more like a 1: 1 conversion. The generated WebAssembly code is similar in size to the original Java class files.

Documentation

The documentation can be found in the wiki.

Roadmap

The project is currently not production ready but you can run already some tests.

Version 1.0 (Milestone 1)

Desired Features

  • [x] Java byte code parser
  • [x] test framework
  • [x] Public API of the Compiler see class JWebAssembly
  • [x] Gradle Plugin
  • [x] Emulator
  • [x] Binary format file writer and Text format file writer
  • [x] Support for native methods #2
  • [x] Memory Management - currently with a polyfill on JavaScript side
  • [x] invoke static method calls
  • [x] invoke instance method calls
  • [x] invoke interface method calls
  • [ ] invoke dynamic method calls (lambdas)
  • [x] invoke default method calls
  • [x] String support
  • [x] Simple Class object support
  • [x] static constructors
  • [x] Optimizer - Optimize the WASM output of a single method after transpiling before writing to output
  • [x] Hello World sample (live), (source code)

Status of Required WebAssembly Features

The following table shows the status of future WebAssembly features required by JWebAssembly in nightly builds in various implementations. These features are already used by the trunk version of JWebAssembly. If you want know the status of your current browser then look for your browser support.

Feature Importance V8/Chrome SpiderMonkey/FF WABT
Mutable Globals high yes yes yes
float-to-int high yes yes yes
Sign-extension high yes yes yes
Reference Types high yes yes yes
JavaScript BigInt medium yes yes yes
Multi-value medium yes - yes

To use it also some flags and switches are currently needed.

Importance: All with high marked features are required for a hello word sample. For a first version that can be used for production.

Version 2.0 (Milestone 2)

Desired Features

Version 3.0 (Milestone 3)

Desired Features

  • [ ] Exception handling - required the next version of WebAssembly
  • [ ] Multiple threads - required the next version of WebAssembly
  • [ ] Memory Management with build in GC without JavaScript polyfill
  • [ ] More Optimize like Tail Calls

Status of Required WebAssembly Features

Feature Importance V8/Chrome SpiderMonkey/FF WABT
Garbage collection medium - partly -
Exceptions low partly - partly
Threads low yes ? yes
Tail call very low yes ? yes

Required Java Version

The JWebAssembly compiler requires Java SE 8 or higher. It is tested with Java SE 8 on travis-ci.org.

Usage

Exporting functions

To export a Java function to make it accessible from JavaScript, you must add the annotation de.inetsoftware.jwebassembly.api.annotation.Export.

import de.inetsoftware.jwebassembly.api.annotation.Export;

@Export
public static int add( int a, int b ) {
    return a + b;
}

importing functions

To import a JavaScript function to make it accessible from Java, you must add the annotation de.inetsoftware.jwebassembly.api.annotation.Import. The method can be declared native or can have a Java implementation which will be ignored on compiling.

import de.inetsoftware.jwebassembly.api.annotation.Import;

@Import( module = "global.Math", name = "max" )
static int max( int a, int b) {
    return Math.max( a, b );
}

Java Limits

In version 1 of WebAssembly you can only compile:

  • static methods
  • use the data types int, long float and double

This is state of JWebAssembly 0.1. With version 0.2 you can use Objects via JavaScript polyfill.

Alternatives

For Tool Developer

If you want to develop some tools like plugins for a build system or an IDE, then you need

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].