Skip to content

[NFC] Simplify Array2Struct type replacement#7539

Merged
tlively merged 8 commits intomainfrom
array2struct-simplify
Apr 23, 2025
Merged

[NFC] Simplify Array2Struct type replacement#7539
tlively merged 8 commits intomainfrom
array2struct-simplify

Conversation

@tlively
Copy link
Copy Markdown
Member

@tlively tlively commented Apr 22, 2025

Array2Struct has to update the types of every expression that interacts
with and produces a reference to the optimized array type. It previously
did this by separately checking whether a nullable or non-nullable
reference to the array was a subtype of the expression's type. Simplify
this logic by doing only a single check that considers only the heap
types of the references.

Also remove some unnecessary variables in which various reference types
were cached since it is extremely cheap to materialize a reference type
now.

These simplifications will also make it easier to update the pass to
handle exact reference types once array.new instructions are typed as
exact.

tlively added 3 commits April 21, 2025 17:16
The logic for joining nullability into a PossibleContents cone value did
not previously preserve the exactness of the type in the cone value,
causing assertion failures.
Exact references are known to point to exactly their heap type and not
one of its subtypes. GUFA already analyzed exactness via the more
general "cone" types that include an allowed subtyping depth. Exact
types are equivalent to cone types of depth zero. Let GUFA take
advantage of exactness information by normalizing cone depths to 0
whenever the cone type is exact.
Array2Struct has to update the types of every expression that interacts
with and produces a reference to the optimized array type. It previously
did this by separately checking whether a nullable or non-nullable
reference to the array was a subtype of the expression's type. Simplify
this logic by doing only a single check that considers only the heap
types of the references.

Also remove some unnecessary variables in which various reference types
were cached since it is extremely cheap to materialize a reference type
now.

These simplifications will also make it easier to update the pass to
handle exact reference types once `array.new` instructions are typed as
exact.
@tlively tlively requested a review from kripken April 22, 2025 03:12
@tlively tlively changed the base branch from gufa-exact-cone to main April 23, 2025 04:03
@tlively tlively merged commit e2b41f2 into main Apr 23, 2025
14 checks passed
@tlively tlively deleted the array2struct-simplify branch April 23, 2025 04:04
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