f426fa44e32e461f0610bfec0b15f95475c181c6 made Struct.new and the rest of the C API create an anonymous struct, give it its members and only then set it as a constant. rb_struct_define_under() was left defining the class with rb_define_cl...shia (Sangyong Sim)
I wrote a patch in the direction of #note-8 to #note-10, keeping the struct info on the class instead of in hidden ivars. It is two draft PRs. ## 1. https://github.com/ruby/ruby/pull/19906 A follow-up to https://github.com/ruby/rub...shia (Sangyong Sim)
This is an interim report about iseq approach experiment. ## Background * For now, I only look at Struct. I am trying to build the `initialize` of classes made by `Struct.new(...)` (`keyword_init` nil/true/false) directly as ISEQs....shia (Sangyong Sim)
Data#initialize copied the member list on every call to find the missing keywords, then cleared the given ones. A byte per member is enough to track what was given, and the member list is only needed to build the error message, so look i...shia (Sangyong Sim)
struct_ivar_get caches a member list found on a superclass into the subclass with rb_ivar_set. The ID has no "@", so it skips the Ractor ownership check, and a Ractor that does not own the class ends up writing class fields concurrently ...shia (Sangyong Sim)
3rd PR is here. [Track the given members of Data#initialize without copying them](https://github.com/ruby/ruby/pull/19581) Before digging into where to store the members, I'm going to look into the ISEQ approach first.shia (Sangyong Sim)
Data.new turned positional arguments into a keyword Hash and called initialize with it. When initialize is the default Data#initialize and every member is given, that call can only store the members and freeze the instance, so do that di...shia (Sangyong Sim)
Eregon, Thanks for your comments. I would like to go that way too if possible. But as you said, generating ISEQs needs a careful look at whether the code stays maintainable, and at other side effects. So for now, I will keep working on t...shia (Sangyong Sim)
struct_alloc() sizes an instance by the member count of its class, so the instance's own length can be used instead of looking the hidden __members__ ivar up on the class again. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anth...shia (Sangyong Sim)