hey guys, my software takes math expressions from ...
# announcements
g
hey guys, my software takes math expressions from users and evaluates them (eg
x1 + x2 - max(thirdVar, fourthVar) * cos(y6)
). Thus I got to write a little compiler and I did it on top of antlr. I recently converted it to generate a little stack assembly language (implemented with a sealed class, eg (
sealed class ASM()
,
data class PushI(val int: Int): ASM()
,
object Multiply: ASM()
,
data class InvokeBinary(val name: String)
), expecting that to be fast as hell. its not. Its actually slower than when I just did a tree evaluation. I'm going to stripe the sealed classes such that they use enums, in hopes that makes things run faster. I want to be able to evaluate these expressions at the rate of ~100,000 per sec. Any idea how i might get there? this is https://github.com/EmpowerOperations/babel\
has anybody got experience emitting raw JBC from kotlin? my ASM matches JBC reasonably closely, so it should be a pretty straight port. If i change my code generation to use byte-buddy and emit a kind of expression, would i see a significatn performance increase? Can i get Javas ASM validator to make sure I dont ruin the JVM?
n
for this kind of thing, have you considered implementing in truffle using graalvm ?
g
I ended up using ByteBuddy and its dependency ASM. Interestingly ASM is shadowed by the JVM itself in "jdk.internal.asm", which, as you might imagine, is protected by the SymbolExport flag in jdk8 and not exported as a module in jdk9+. The end result is about 2x to 3x faster than my emulator. The majority of CPU time is now spent in some precondition and postcondition checks. Im pretty happy, though im not done