ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject supporting graal.js
Date Wed, 27 May 2020 16:36:15 GMT
Hi all

I've changed master to also download the things required to use GraalVM
JavaScript as language and changed JavaxScriptRunner to make it work a
bit better.

This uses
which is not the preferred way of using GraalVM, but the least intrusive
one for us. An alternative could be to add another ScriptRunner that
explicitly uses the GraalVM Context[1], but I'm not sure it is worth the
effort. Should we?

The change to JavaxScriptRunner is to disable Graal's security
restrictions as without that the <script>s would be more restricted than
before. Without allowHostAccess the scripts wouldn't even be allowed to
call public methods on Java objects unless they had a specific
annotation. I think this is required for what we want to allow <script>
to do. We might be able to make this configurable, but I don't see a
convenient way to do it. It would probably be easier to provide GraalVM
specific variants of the script family of tasks and types if we want to
do something like this.

I have not enabled full Nashorn compatibility[2]. This means some
JavaScript code will need to be changed. For example our own "squares"
example fails as it invokes setMessage(Number) on the Echo task -
Nashorn seems to wrap this in a String in order to match the method's
signature. Should we enable full Nashorn compatibility?

Finally, the unit test we've disabled for Java15 fails with GraalVM on
any version of Java as it is (a) really really fast and (b) the compiler
is rather slow (i.e. takes about as long as the Nashorn compiler).

The test runs the same script 20 times and expects a pre-compiled
version to be faster than the non-compiled one. In my personal
non-scientific benchmarks when comparing the non-compiled versions
GraalVM is about four times faster than Nashorn for a single
execution. It also seems to become faster if the script is executed

Compilation takes more than twenty times the time it takes to run the
non-compiled script (and running the compiled script isn't really much
faster than the non-compiled version) so we'd need to run a lot more
scripts to make the test pass. I'd probably disable the timing
comparison when we detect we are running GraalVM.




To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message