Skip to content

Conversation

tlively
Copy link
Member

@tlively tlively commented Sep 29, 2025

With the upcoming stricter validation rules for descriptor types, we can
no longer use the placeholder describee trick in GlobalTypeOptimization,
so its ability to optimize out unneeded descriptors will be
significantly restricted. Because of the increasing coupling between the
validation for subtyping and descriptor relationships, it makes most
sense to optimize both at the same time in Unsubtyping.

Update Unsubtyping to start the analysis assuming no descriptors are
necessary, then add them in as it discovers that they are indeed
necessary either to preserve behavior or validitiy. Discovering new
required descriptors can imply that new subtypings are necessary and
vice versa.

With the upcoming stricter validation rules for descriptor types, we can
no longer use the placeholder describee trick in GlobalTypeOptimization,
so its ability to optimize out unneeded descriptors will be
significantly restricted. Because of the increasing coupling between the
validation for subtyping and descriptor relationships, it makes most
sense to optimize both at the same time in Unsubtyping.

Update Unsubtyping to start the analysis assuming no descriptors are
necessary, then add them in as it discovers that they are indeed
necessary either to preserve behavior or validitiy. Discovering new
required descriptors can imply that new subtypings are necessary and
vice versa.
@tlively tlively requested a review from kripken September 29, 2025 22:25
@tlively
Copy link
Member Author

tlively commented Sep 30, 2025

All comments addressed except the one about the side effects of null descriptors in allocations.

@tlively
Copy link
Member Author

tlively commented Sep 30, 2025

Ok, now the traps are properly preserved. Will fuzz overnight.

)
)

;; No fixup is necessary if the descriptor cannot be null in the first place.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add a test for a non-nullable descriptor in a global?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is tested toward the bottom with the comment ;; When we optimize out descriptors, we may need to update allocations..

;; Test the case where a newly discovered descriptor has a supertype that now
;; needs to be a descriptor as well. Set this up:
;;
;; top top.desc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there intentionally no arrow from top to top.desc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the arrows in this diagram are only the initial edges required by the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe that can be clarified? I was reading all these diagrams assuming they describe the situation in the wasm, and the wasm itself does contain a descriptor relationship there. I think that is what you've done elsewhere?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a good way to do this is to graph the initial wasm, and then put this second graph after it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "described by" arrows in the other diagrams are inherited from before this change, when we never removed descriptors, so they were irrelevant to the test cases. I'll update them to include only the initially required descriptor edges, just like they include only the initially required subtype edges.

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm otherwise

@tlively tlively enabled auto-merge (squash) October 1, 2025 23:58
@tlively tlively merged commit 899bac4 into main Oct 2, 2025
16 checks passed
@tlively tlively deleted the unsubtyping-optimize-descs branch October 2, 2025 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants