JsJs

Remi Forax forax at univ-mlv.fr
Mon Apr 13 07:08:30 UTC 2015


Hi guys,
I've written a simple AOT compiler [1] that takes a javascript file and 
transform it to a .class file that can run with a very small runtime. It 
uses the Nashorn Parser API and also Nashorn to bootstrap itself (the 
AOT is written in JavaScript).

While the runtime is fairly naive, everything is considered as an 
java.lang.Object and JS Objects are hash maps (each field is accessed 
through a double indirection), I've found that Nashorn was really slow 
to run the AOT script (jsjs.js) compared to using jsjs to compile 
itself, given that some Nashorn stacktraces seems to show recompilation 
on top of recompilation on ... etc, I think there is a bug that lies 
somewhere in the runtime of Nashorn.

You can run Nashorn on jsjs.js that way:
jjs -J-Xbootclasspath/p:lib/nashorn.jar -cp 
classes:lib/asm-debug-all-5.0.3.jar jsjs.js -- jsjs.js

and jsjs on jsjs.js that way:
java -Xbootclasspath/p:lib/nashorn.jar -cp 
.:classes:lib/asm-debug-all-5.0.3.jar jsjs jsjs.js

cheers,
Rémi

[1] https://github.com/forax/jsjs


More information about the nashorn-dev mailing list