I realized today that with the nodes I have, with each being a meaty operation, I could never truly see what Truffle and Graal are capable of. For this reason, I’m implementing a miniature programming language without a parser. All programs are made through a series of invocations of Java constructors for various node classes. […]Read more "The hextruffle mini language"
The keen reader that has seen previous posts here will easily find a problem, that I overlooked. I will address it at the bottom of this post. I got the Graal JIT compiled as the main JIT in my JVM, and it appears that performance is a bit more reasonable now. 1000 msec per iteration […]Read more "Fooling Truffle’s Intelligence: Part 2"
Today I decided to skip ahead a bit and try to convince Truffle to actually compile my code on Graal (since I wasn’t fully convinced my JVM setup was actually working as expected). I’ll be coming back to basic tutorials as I need, but they have honestly been boring me a bit. I found that […]Read more "Fooling Truffle’s intelligence"
Say that we have a node that may or may not need to be replaced a few times. If it doesn’t get replaced, all is good. If it needs to be replaced once or twice, that’s OK as well. However, if it needs to be replaced hundreds or thousands of times, the performance overhead would […]Read more "Node replacement with a threshold"
This post will cover a powerful feature of Truffle, which allows one to replace a node dynamically with a different node. This is extremely useful if you have a node that will start in one state and rarely change. That node’s state should be a static field to allow the JIT to aggressively optimize it […]Read more "Replacing nodes"
Often, it is necessary for a dynamic number of children to be present in a node (e.g. a block of code with multiple operations, or an array initializer in the guest language). This can be done with arrays, for which the code is fairly straightforward: package com.wordpress.hextruffle.tests; import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.TruffleRuntime; import com.oracle.truffle.api.frame.VirtualFrame; […]Read more "Child nodes in arrays"
Of course, any language would be practically useless if all that was available to you was a single hardwired root node. For this reason, Truffle allows for child nodes. Their uses include: Multiple statements in a program or block Evaluation of arguments Operators (e.g. 2+2) Here, I’ll create a root node that has two child […]Read more "Child nodes"