Congratulations on Nashorn - Question about Bytecode Generation

Tobias Downer toby at mckoi.com
Sat Dec 22 18:07:42 PST 2012


Hello Nashorn Developers. Congratulations on the first public release!
I'm really interested to see the performance you'll get out of your
JavaScript engine.

My question; will (does?) Nashorn support customization of the
bytecode generator so that we can get it to inject callbacks to our
own code? I need a feature like this because I need a way to interrupt
scripts that have been running for too long (gone into an infinite
loop). To do this, I'd need the bytecode generator to inject a
callback to my Java code on every JavaScript loop and function call.
My Java code then might check 'Thread.isInterrupted()' and throw a
runtime exception.

Rhino supports this with an 'observeInstructionCount' flag/callback on
the context. Groovy has a more sophisticated parse tree transformation
API for this sort of thing. I'm wondering if Nashorn has something
similar.

Regards,
Toby.


More information about the nashorn-dev mailing list