1
1
mirror of https://github.com/kanaka/mal.git synced 2024-10-26 14:22:25 +03:00

[java-truffle] mention native images in README

This commit is contained in:
mmcgill 2021-06-06 18:08:58 -04:00 committed by Joel Martin
parent 20b6677551
commit 13bb041072
2 changed files with 28 additions and 0 deletions

View File

@ -677,3 +677,23 @@ It's also worth observing that the Truffle/GraalVM provide _other_ interesting b
that are not performance-related. I won't cover them here. I think the most interesting
non-performance benefit is the promise of interoperability with other Truffle languages.
## Bonus: AOT-compiled Mal
GraalVM can ahead-of-time compile Java into a stand-alone executable (with some caveats)
called a _native image_.
This works even for Truffle interpreters! With AOT-compiled Mal, we get all the JIT compilation
goodness of Truffle, _and_ we ditch the need for a Java runtime, **and** we skip the long JVM
start-up time! A GraalVM native image of our Mal interpreter is well suited for scripts and
command line applications.
The `make-native.sh` script can be used to compile a native image of any Mal step.
To run it, though, you'll need some additional
[prerequisites](https://www.graalvm.org/reference-manual/native-image/#prerequisites).
The `make-native.sh` script
* assumes you've already run `gradle build` to compile all Java classes
* takes as its only argument a step name, e.g. `step3_env`
** when no argument is supplied, `stepE_macros` is selected by default
* produces a `build/${STEP}` native image

View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
STEP=${1:-stepE_macros}
CP=$(gradle -q --console plain printClasspath)
native-image --macro:truffle --no-fallback --initialize-at-build-time \
-H:+TruffleCheckBlackListedMethods \
-cp "$CP" truffle.mal.$STEP build/$STEP