-
Notifications
You must be signed in to change notification settings - Fork 792
[DRAFT] Do not rewrite supertypes in AbstractTypeRefining #7720
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
base: main
Are you sure you want to change the base?
Conversation
The interpreter was returning the wrong value when evaluating a branching descriptor operand to a descriptor cast. Adding tests for this fix also exposed a bug where the validator did not allow for unreachable descriptor operands without also having unreachable ref operands.
Update the cast optimizations in OptimizeInstructions to correctly optimize ref.cast_desc. The optimizations differ from the optimizations of normal casts because they have to be careful not to skip any side effects in the descriptor operand and because type information alone is not sufficient to prove that a cast will succeed.
We previously hit an assertion failure when accessing the GCData of the ref literal because i31 literals do not have GCData.
Keeping descriptor chains valid while rewriting subtyping is complicated. Make it simpler to optimize descriptor and described types by not rewriting supertypes at all in AbstractTypeRefining. Landing this is blocked on making Unsubtyping more efficient so we can use it by default as a follow-up to AbstractTypeRefining to avoid regressions.
// supertype, which is not allowed. We could fix this by walking up the | ||
// supertype chain to find a supertype that is not being rewritten, but | ||
// changing subtype relationships and keep descriptor chains valid is | ||
// nontrivial. Instead, avoid changing subtype relationships entirely. |
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.
// nontrivial. Instead, avoid changing subtype relationships entirely. | |
// nontrivial. Instead, avoid changing subtype relationships entirely: | |
// leave that for Unsubtyping. |
// C. But if we rewrote C's supertype, C would declare itself to be its own | ||
// supertype, which is not allowed. We could fix this by walking up the | ||
// supertype chain to find a supertype that is not being rewritten, but | ||
// changing subtype relationships and keep descriptor chains valid is |
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.
// changing subtype relationships and keep descriptor chains valid is | |
// changing subtype relationships and keeping descriptor chains valid is |
} | ||
return super; | ||
// We do not want to update subtype relationships. | ||
return oldType.getDeclaredSuperType(); |
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.
This is identical to the function being overridden, so it can be removed. We do not need to declare AbstractTypeRefiningTypeMapper at all, I think.
Keeping descriptor chains valid while rewriting subtyping is
complicated. Make it simpler to optimize descriptor and described types
by not rewriting supertypes at all in AbstractTypeRefining.
Landing this is blocked on making Unsubtyping more efficient so we can
use it by default as a follow-up to AbstractTypeRefining to avoid
regressions.