dyn.js - invokedynamic-based js implementation

Rémi Forax forax at univ-mlv.fr
Tue Oct 11 01:00:13 PDT 2011


On 10/11/2011 12:22 AM, John Rose wrote:
> On Oct 10, 2011, at 7:12 AM, Douglas Campos wrote:
>
>> Hello mlvm friends, just a heads up that dyn.js is released at https://github.com/dynjs/dyn.js
>>
>> feedback is more than welcome :)
> Congratulations on getting this working...
>
> Nice, crunchy uses of invokedynamic, ASM, ANTLR, and dynalang.  Remarkable leverage!
>
> -- John

If John plays the good guy, I will play the bad one :)

You should get rid of all the scope stuff for local variables.
One var in Javascript should be one local variable on the Java stack.
(if you only implement the strict mode of JavaScript 5, there is no 
problem).

For property, you should try to map them to Java field, you can use 
John's hidden class
or Nashorn double tables trick and avoid hashmaps.

You should also don't use you own hierarchy of classes but try to reuse 
j.l.Object,
j.l.String, etc and boolean, double, void where you can, by example
the condition of a if should be a boolean,  in x + 2, 2 should be a double.

I've some trouble to understand why your DynPrimitiveNumber is not a 
DynNumber
and the difference between a DynAtom and a DynObject.

DynObject.eq and DynObject.toBoolean should be implemented using 
invokedynamic
to adapt the sequence of if/instanceof to the callsite.

And at the end, all predefined Javascript objects should be re-written 
in Javascript,
with some native calls to Java but it will be easier for providing the 
core API.
By example, for javascript Number, it should be a j.l.Double but with 
it's own vtable
to add all Javascript predefined methods.
The idea is that j.l.Double and Javascript Number are the same object at 
runtime but
are seen differently in Java and in Javascript.

cheers,
Rémi



More information about the mlvm-dev mailing list