Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Pre-compiled methods do not have AST available for re-compilation #1395
Upcoming runtimes/backends for JRuby like IR and Truffle will often be able to do a better job of optimizing pre-compiled code. However, they both need the original AST to be able to generate their intermediate format.
When precompiling Ruby code, the best we can do is to emit straightforward JVM bytecode from the original AST. The resulting class does not have any references to the AST since the AST is not serializable. Therefore, if we want to access the original AST, we need to make it serializable and pack it into the precompiled class.
See Helpers.def/defs and InvocationMethodCompiler.getCompiledMethod for a few places where we would like to be able to save off the AST.
Note that this may be moot if the current compiler goes completely away in favor of the other options. However, there will always be a desire to precompile, so the AST-saving aspect may remain valid.
I've worked around this for the most common case where the class is both generated and used in the same VM in 4d6d1e8.
This solves my immediate need for method nodes from jitted methods so that I can
It also is potentially a space leak, as it keeps the method nodes around forever. I've marked with a named TODO and will re-visit before the next major.