The goal here is to start splitting off the method reification, which many (most) people don't need, so we can still get the benefit of generating a real class for every custom Ruby class without the hassle of binding a bunch of methods. See #4643.
This is a first step toward unifying all forms of reification. In this commit, all the hand-implemented RubyObjectVar* and ObjectAllocator* are instead generated as needed and then reused statically. Since this will be a bounded number of classes (based on the max size of inspected instance vars in user classes) it should not use too much memory. This now allows us to support reified instance variable fields up to an arbitrary size. Note that although the allocators are generated on a per-class basis (necessary without using MethodHandle for allocation) the variable accessors are still hand-written and only call the appropriate getVariable# or setVariable# up to 9 as before. It is an open TODO to generate these accessors on a per-class basis so they inline all the way through. The alternative would be moving toward more MethodHandle-based factories, but that limits cross-JVM support and may result in startup impact. For #4643 among others.
I've just retried with this branch with the following testcase (from #4643)
class BrokenReify def to_s super end end puts BrokenReify.new.to_s
And it still causes a stack overflow. I believe the reason why it fails is still similar: it's because unlike other reification options (e.g. reify variables) we define the instance methods from the ruby class in the reified class, which is what breaks code which tries to call
I'm not sure what the is best choice here: