Hi Walid,
We don't have plans for an instruction count/callback feature.
One idea behind Nashorn is that it should be part of the Java platform
instead just sitting on top of it. That also means it should make use of
existing infrastructure and tools instead of providing a half-hearted
version of everything.
For the purpose of instruction count callbacks, one thing you could look
at is the JVM Tool Interface:
https://docs.oracle.com/javase/8/docs/technotes/guides/jvmti/
One obvious difference is that TI agents are written in C/C++. On the
other hand, you get a generic, stable and well-supported interface.
Hannes
Am 2016-01-28 um 18:35 schrieb walid:
Hello,
Are there any plans to include the type of code suggested in the last few mails
in the following
conversation?http://mail.openjdk.java.net/pipermail/nashorn-dev/2014-March/002861.html
Aside from sandboxing and using classloader shutters, it would be really useful
(and in my case, mandatory) to get a callback every x instruction, allowing me
to check for execution time and other resource limitation.
This would be the equivalent of the Rhino feature which has an instruction
count callback. The callback isn't (as mentioned in some conversation i found
online) only available in interpreted mode: the generated code is also
instrumented to add frequent calls back, allowing this callback to be triggered
even in compiled mode.
Any reason why this isn't implemented in nashorn? Are there any major reasons
why it wouldn't be? if it is only a matter of priority, i would appreciate some
notes on where you suggest i could start so that i implement it myself for my
own project.
thank you,
-walid