davidar / lljvm

Low Level Java Virtual Machine
https://davidar.io
MIT License
475 stars 62 forks source link

Dynamic link and concurrent execution #10

Open the-felis-leo opened 7 years ago

the-felis-leo commented 7 years ago

In order to allow concurrent execution of a C program into a unique JVM, Instead of using static fields and methods, use instance.

Said actual generated code look like :

class MyModule {
    public static void myMethod() {
        ExternModule.externMethod();
    }
}

Change it into:

class MyModule {
    ExternModule externModule;
    public MyModule(ProcessContext ctx) {
        externModule = ctx.get(ExternModule.class);
    }
    public void myMethod() {
        externModule.externMethod();
    }
}

With ProcessContext.get() which lazy instantiate module.