A JVM for the web. Bring back the applet!
Message me on Discord if you are interested in collaborating: forevermilk#0001
Always use int64_t
instead of long
because Emscripten has sizeof(long) == 4
. int
can be assumed to be 32 bits.
Place all native functions in the corresponding folder in src/natives
, and use the DECLARE_NATIVE
macro to link them.
Common abbreviations:
cf
– classfilecp
– constant poolbc
– bytecodevm
– virtual machine
See GitHub issues
- General method signature:
bjvm_interpreter_result_t (*compiled)(bjvm_thread *thread, bjvm_cp_method *method, bjvm_stack_value *result, ... args)
- Generated on the fly for each argument type combination
- Longs are split into two ints to avoid overhead of creating
bigint
s - Method is responsible for setting up its own stack frame and in the case of de-opt or interruption, generating all interpreter stack frames
- Methods which are not compiled will have a generated implementation that delegates appropriately to the interpreter
- Full implementation of the JVM spec (including esoteric things like classfile verification)
- Java 17 support (starting with Java 8)
- Reasonably fast (geomean within factor of 10 of HotSpot in memory and CPU usage across benchmarks)
- JIT compilation to WebAssembly
- Interruptable execution
- Dynamic class loading
- Mild JNI compatibility
- Desktop JVM -- only useful for testing/debugging
- Swing, AWT, etc. compatibility
- Beautiful, elegant code (see QuickJS for that)
clang-format -i test/*.cc src/**/*.c src/**/*.h