Graal VM components required for a Node calling Java polyglot application

345 Views Asked by At

I planning to GraalVM to merge two (services one using Node and other based on Java) with Node as the main entry point language which calls classes/constructs in Java. I was reading about GraalVM but was not able to find below information in clarty. It will be great if someone can help me with this (or point out if I am missing/overlooking something)

  1. What are the bare minimum GraalVM components required for above use case ? I know that Graal VM has core and optional components. Do we require entire GraalVM including the hotspot VM for this use case or just below components are sufficient ?(please add/correct I am missing some components). I perfer to use OpenJDK8 as my JVM

    • GraalJS
    • GraalSDK
    • Truffle

    Correct me If I am wrong - My understanding for coming up with above components are that - GraalJS contains node/js run time implemented over truffle and supporting polyglot and has node modules which contains polyglot api. GraalSDK - contains polyglot api for Java. Truffle has the logic to convert JS to bytecode which runs on JVM

  2. Is there any clear documentation on how each of this module work together ? I am looking for a small/abstract diagram/flow-diagaram which tells how GraalJS , GraalSDK & Truffle and underlying JVM work together to achieve polyglotness. This helps further understand and pinpoint which components are required for my usecase

Thank you

1

There are 1 best solutions below

0
On

regarding the first question: your assumption would be correct if you only used "pure" JavaScript (ECMAScript 2020). Then, only the GraalVM Compiler is missing from your list. If you omit that, you can technically execute the JavaScript interpreter, but it will be very slow. To allow the Truffle component to do its magic of speeding up the application, you will need the GraalVM Compiler. See our blogpost https://medium.com/graalvm/graalvms-javascript-engine-on-jdk11-with-high-performance-3e79f968a819 how to set that up on a stock JDK (like OpenJDK) using Maven.

In your case, you want to use Node.js though. For that you need a full Node.js distribution including Graal.js - only a full GraalVM will provide that.

For your second question: I don't know of a good graphic that describes the GraalVM SDK. For Truffle and language implementation in general, https://docs.oracle.com/en/graalvm/enterprise/19/guide/overview/jvm-runtime-model.html might be a good starting point. There are also several good tutorials on YouTube on GraalVM+Truffle.

Best, Christian