I'm trying to understand performance of my JavaScript running within a Java application but I can't find a way to pass Truffle options through the Java interfaces like Bindings (when in Nashorn compat mode) and Context.
Specifically, I'm trying to turn on compilation info --engine.TraceCompilation mentioned in: https://www.graalvm.org/22.1/graalvm-as-a-platform/language-implementation-framework/Options/
but all I find are examples like this:
ScriptEngine js = scriptEngineManager.getEngineByName("graal.js");
Bindings bindings = js.getBindings(ScriptContext.ENGINE_SCOPE);
bindings.put("polyglot.js.allowHostAccess", true);
bindings.put("polyglot.js.nashorn-compat", true);
// ------- I want to do something like this: -----------
bindings.put("polyglot.js.engine.TraceCompilation", true); // <-- does not work
//--------------------------------------------------------
This guide mentions the list of options that can be passed this way and none of the Truffle options are listed: https://www.graalvm.org/22.1/reference-manual/js/ScriptEngine/
Note that for legacy reasons I need to use Nashorn compatibility mode to run the JavaScript code.
as the documentation states, those are language launcher options. You would typically provide them to a launcher like js, node or similar.
As you seem to start from Java, you can also provide them to the Java process with system properties (by preprending polyglot and explicitly providing true for boolean options):
I don't believe you can provide those options as late as in the bindings of the language, because they should not affect the language but the overall GraalVM system. (this is also why your polyglot.js.engine.TraceCompilation is off; the option has nothing to do with js)
HTH, Christian