-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lazy field index #4514
lazy field index #4514
Conversation
7bda9ba
to
9ce4e22
Compare
Ended up deciding maybe we could use this review as the central point for the design discussion - since the other two patches are a bit more drafty, so I'll leave them in draft mode, but linked from here for context - but maybe keeping the design discussion here in this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Direction here looks good, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
This way if the type_id of the FieldDecl is anything other than Error or UnboundElementType, this should check-fail at the `GetAs<UnboundElementType>`. We could add a more explicit check, but I tend to err towards relying on implicit checks to avoid making the code too noisy
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
…irtual declaration in base
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
…d_decls_stack instead
04a9706
to
c6f65fb
Compare
We considered a couple of other options for this: * carbon-language#4515 Keep the `ElementIndex` numbering vptr-ignorant, and do +1 offsets as needed - seems subtle/easy to miss * carbon-language#4517 Always have a zeroth element in the object representation, make it zero-size in the case of no-vptr - @zygoloid was concerned this would add overhead especially to stateless objects used in type-trait-like things. But currently moving forward with this direction - of initializing field indexes with an invalid value until the end of the class definition, then assigning field indexes during construction of the class's object representation struct type. This direction might reinforce/help avoid premature access to the object representation before the class is complete, and give a single place where class layout is done (at class completion) if we want to add more options there, such as class layout optimizations, etc. This patch still has problems with object initialization (that carbon-language#4515 does not have/does address) but does address normal `obj.member` access correctly. --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
We considered a couple of other options for this:
ElementIndex
numbering vptr-ignorant, and do +1 offsets as needed - seems subtle/easy to missBut currently moving forward with this direction - of initializing field indexes with an invalid value until the end of the class definition, then assigning field indexes during construction of the class's object representation struct type. This direction might reinforce/help avoid premature access to the object representation before the class is complete, and give a single place where class layout is done (at class completion) if we want to add more options there, such as class layout optimizations, etc.
This patch still has problems with object initialization (that #4515 does not have/does address) but does address normal
obj.member
access correctly.