Developer, gamer, cat lover, tea addict ๐ฎ๐น๐ช๐บ
Currently Sr Staff Engineer @ ServiceNow, working on the JavaScript scripting engine
A tiny JVM written in Rust. Learning project
License: Apache License 2.0
Developer, gamer, cat lover, tea addict ๐ฎ๐น๐ช๐บ
Currently Sr Staff Engineer @ ServiceNow, working on the JavaScript scripting engine
The opcode invokeinterface
is not implemented, but it is an important one!
We do not have a real implementation of class loaders at the moment.
Downloading vm/rt.jar (60 MB) Error downloading object: vm/rt.jar (bbdd2f5): Smudge error: Error downloading vm/rt.jar (bbdd2f5909ea77fa115f03a2b030f231cc4bf720528b0436f83459a2be429349): batch response: This repository is over its data quota. Account responsible for LFS bandwidth should purchase more data packs to restore access.
Need to expose the various attributes of the objects in a class
file. At the moment, only some of them are parsed.
We need to deallocate objects eventually ๐
We need to parse generics correctly and to suppor them in the VM.
Need to support a concept of "classpath" in the vm.
Also, class loaders should be a hierarchy - not sure if this should be done at the same time as the classpath or not.
We need to support multiple threads.
The vm does not support arrays currently. We need to implement:
We only support int and float. Long/double are complex because they take two slots in the local variables, but we need to handle them.
Test for Java Code:
package rjvm.test;
import java.io.PrintStream;
public class Test {
public static void main(String[] args) {
final PrintStream p = System.out;
}
}
#[test_log::test]
fn invoke_test() {
let mut vm = Vm::new(DEFAULT_MAX_MEMORY);
let src_dir = env!("CARGO_MANIFEST_DIR");
vm.append_class_path(&format!("{src_dir}/rt.jar;{src_dir}/tests/resources"))
.expect("should be able to add entries to the classpath");
let _ = invoke(
&mut vm,
"rjvm/test/Test",
"main",
"([Ljava/lang/String;)V",
);
}
run result (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)
The VM does not support exceptions currently.
there is a java method named "xxx" which calls a native function from native lib,
how to invoke xxx from rust side?
VM
has a lifetime 'a
. This lifetime is arbitrary โ it is chosen by the caller with no restrictions. This means it can outlive the VM
, but other structs assume the VM
is life for 'a
. This is unsound.
Segfaulting example:
let mut vm = create_base_vm(DEFAULT_MAX_MEMORY);
let call_stack = vm.allocate_call_stack();
let main_method = vm
.resolve_class_method(
call_stack,
"rjvm/SimpleMain",
"main",
"([Ljava/lang/String;)V",
)
.expect("should find main method");
drop(vm);
println!("{main_method:?}");
Possible solutions:
VM
. All methods that produce lifetimed objects take their lifetime from the reference to the VM
.VM
. Keep VM in an Arc
. Erase lifetimes internally. Don't hand out structs referencing VM memory directly, instead hand out a wrapper object that also contains a copy of the Arc
(this can be transparent to the user).Aastore cannot store nulls (trying to do so generates a ValidationException
).
The API allows data (CallStack
, AbstractObject
, ClassRef
m โฆ) managed by one VM
to be used with another VM
. This allows e.g. storing a pointer to an object on the heap of vm1 in a static field in the heap of vm2. If a garbage collection then triggers on vm1, the static field on vm2 now points to cleared/invalid data.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.