Understanding how Truffle supports interoperability
Truffle provides a very well-designed interoperability framework to allow guest languages to read and store data. In this section, we will cover some of the key features that the Truffle interoperability framework provides. Let's have a rundown of each of them.
Frame management and local variables
Truffle provides a standard interface to handle the local variables and data between host and guest language implementations. The frame provides the interface to read and store the data in the current namespace. When a function is called, the local variables' data is passed as an instance of com.oracle.truffle.api.frame.Frame
. There are two implementations of the frame:
- VirtualFrame: This is most commonly used, and is passed as a parameter to the
execute()
method. This is lightweight, and preferable, as Graal optimizes this better. This frame lives in the scope of the function. It is the optimum and recommended way...