Skip to main content

Crate jvmrs

Crate jvmrs 

Source
Expand description

JVMRS - JVM implementation in Rust

JVMRS is a high-performance Java Virtual Machine written in Rust, featuring JIT compilation, inline caching, thread-local allocation, and comprehensive polyglot capabilities.

§Performance Features

  • Inline Caching: 3-5x faster virtual method dispatch
  • Thread-Local Allocation (TLAB): 2-3x faster object allocation
  • Tiered JIT Compilation: Adaptive compilation strategy
  • Generational GC: Parallel sweep with reduced pause times

§Unique Capabilities

  • Rust-Based: Memory safety by construction
  • Polyglot: Direct Java/Rust interop without JNI overhead
  • WebAssembly: Native WASM support for browser/edge deployment
  • Embedded: no_std support for resource-constrained environments
  • Interactive REPL: Full-featured REPL for JVM exploration

§Getting Started

§Quick Start

use jvmrs::Interpreter;

// Create interpreter
// Run a Java class

§Interactive REPL

cargo run -- --repl

§Performance Optimization

use jvmrs::jit::TieredCompilationConfig;

§Module Organization

§Core / Runtime

  • class_file - Class file parsing
  • class_loader - Class loading from classpath
  • class_cache - Fast binary cache (.jvmc)
  • memory - Heap, stack frames, values
  • allocator - Arena-based allocation
  • gc - Garbage collection
  • inline_cache - Inline caching for method invocation
  • tlab - Thread-local allocation buffers
  • compressed_oops - 16-bit compressed references for memory-constrained environments

§Execution

  • interpreter - Bytecode execution engine
  • native - Native method dispatch
  • reflection - Runtime introspection
  • repl - Interactive REPL for JVM exploration

§Compilation

  • jit - JIT manager, tiered compilation
  • cranelift_jit - Cranelift bytecode-to-native
  • aot_compiler - AOT to object files
  • wasm_backend - WebAssembly emission (feature: wasm)

§Developer Tools

  • debug - Logging, trace config
  • profiler - Flame graphs, hotspots
  • trace - Time-travel debugging
  • deterministic - Reproducible execution

§Optional Features

  • ffi - C API (feature: ffi)
  • interop - Java/Rust interop (feature: interop)
  • async_io - Async class loading (feature: async)
  • simd - Vectorized arrays (feature: simd)
  • truffle - GraalVM-style language API (feature: truffle)
  • security, aop, cloud, hot_reload - Additional capabilities

§Documentation

§Examples

§Basic Usage

use jvmrs::{Interpreter, Value};

// Call a static method

§Polyglot Programming

use jvmrs::{Interpreter, Value};

// Register Rust function
// Call from Java

§Performance Monitoring

use jvmrs::{Interpreter, Profiler};

// Monitor inline cache
// Monitor TLAB
// Profile performance
// ... run workload ...

§Benchmarks

Run the comprehensive benchmark suite:

cargo bench

§Testing

cargo test                        # Unit tests
cargo test --test property_tests    # Property-based tests

§License

Licensed under either of MIT or Apache-2.0 at your option.

Re-exports§

pub use error::JvmError;
pub use memory::Memory;
pub use memory::Value;
pub use memory::StackFrame;
pub use error::MemoryError;
pub use compressed_oops::CompressedOops;
pub use compressed_oops::OopMode;
pub use interpreter::Interpreter;
pub use jit::JitManager;
pub use jit::TieredCompilationConfig;
pub use jit::CompilationLevel;
pub use profiler::Profiler;

Modules§

allocator
Arena-based allocators for better cache locality and reduced fragmentation.
annotations
Annotation parsing from class file attributes.
aop
Proxy-based AOP (Aspect-Oriented Programming) support at runtime.
aot_compiler
AOT Compiler - Ahead-of-time compilation to native object files.
class_cache
Fast class loading with validated binary cache format (.jvmc).
class_file
class_loader
Class loading implementation for JVMRS
cloud
Cloud and distributed computing extensions.
compressed_oops
Compressed ordinary object pointers (oops) for memory-constrained environments.
cranelift_jit
Cranelift-based JIT: bytecode-to-native code generation.
debug
deterministic
Deterministic execution mode for real-time, safety-critical, and blockchain systems.
error
Custom error types for JVMRS
escape_analysis
Escape analysis for stack allocation optimization.
extensions
Rust crate integration - plugin system for Java extensions.
gc
Garbage collection: generational GC with parallel collection and ownership-based root tracking for low-pause behavior.
hot_reload
Hot code reloading - replace methods at runtime without restart.
inline_cache
Inline caching for optimized method invocation
interpreter
JVM bytecode interpreter.
jit
JIT Compilation Module for jvmrs
jni
Java Native Interface (JNI) implementation.
memory
JVM memory management: heap, stack frames, and values
native
osr
On-Stack Replacement (OSR) for long-running loops.
pgo
Profile-Guided Optimization (PGO) support.
profiler
Integrated profiler with flame graph export and hotspot detection.
reflection
Reflection API for runtime introspection
repl
Interactive REPL for JVM exploration
security
Security instrumentation - runtime vulnerability detection.
serialization
Serialization/deserialization support (java.io.Serializable).
tlab
Thread-Local Allocation Buffers (TLAB) for fast object allocation
trace
Execution trace recorder - foundation for time-travel debugging.
visualization
Visualization tools for JVM internals.

Macros§

convert_result
Convenience macro for converting results with JvmError