Correctly initialize Data field accessors#9253
Open
headius wants to merge 2 commits intojruby:masterfrom
Open
Conversation
Data types are initialized with a set of accessors for the requested fields, which allows caching those accessors and avoiding costly hash lookups for future accesses. Due to a bug in how these accessors are initialized, parent and subclasses may have a different view of how those fields are stored in the object. Here, the cached accessors are iterated, but then not used to read the field. This results in a second field being created for the subclass, in a different order from definition time. Using the original accessor here accesses the correct field. Fixes jruby#9241. Note that there's other problems with the data layout inside a Data type and other fixes will be needed to clean up how these accessors are allocated and shared with subclasses.
9e80f69 to
824a359
Compare
There's a few changes here to support Data types and their subclasses: * Always copy the variable table manager from parent to child, unless the parent is Object. This ensures that Data type subclasses still see the same accessors and likely makes sense for most other classes that inherit instance variables. * Fix the definition sequence for Data fields to specialize and properly use the field-based accessors rather than the growable varTable accessors. This maintains a compact store for Data fields where previously the object was specialized but variables still were stored in varTable. This relates to and partially fixes some root causes of the Data type subclass issues reported in jruby#9241. There are other concerns with this structure of Data, however, since it may use accessors from the parent in the child (rather than the cloned versions for the child). We need a larger overhaul of both Data and how the variable table manager is propagated from parents to children (previously no propagation happened and all child classes re-discovered their own instance variables).
824a359 to
73b2a99
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the root cause of #9241 was the improper initialization of variable accessors during
Datatype setup. The changes here attempt to address that and make sure that:Data, which could again lead to child classes forming their own picture of the object's shape.The changes here extend #9252 and may be too experimental for a 10.0 maintenance release, but without them all
Dataobjects are being allocated much larger than they should be and not using native fields.