-
Notifications
You must be signed in to change notification settings - Fork 194
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
Ensure that each distinct type occurs only once in Module::types
#1419
Merged
Conversation
This file contains 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
jimblandy
force-pushed
the
unique-arena
branch
from
September 24, 2021 09:00
24ecfe6
to
9da14b6
Compare
Closed
kvark
reviewed
Sep 27, 2021
That's wonderful, I was looking forward to this change! And well executed, too 👍 🎖️ . Just one note to address. |
Replace `Module::apply_common_default_interpolation` with a simpler function that handles a single `Binding` at a time. In exchange for the simplicity, the function must be called at each point function arguments, function results, and struct members are prepared. (Any missed spots will be caught by the verifier.) This approach no longer requires mutating types in the arena, a prerequisite for properly handling type identity. Applying defaults to struct members when the struct declaration is parsed does have a disadvantage, compared to the old whole-module pass: at struct parse time, we don't yet know which pipeline stages the struct will be used in. The best we can do is apply defaults to anything with a `Location` binding. This causes needless qualifiers to appear in some output. However, it seems that our back end languages all tolerate such qualifiers.
jimblandy
force-pushed
the
unique-arena
branch
from
September 27, 2021 16:34
9da14b6
to
8f97688
Compare
Ensure that each distinct type occurs only once in `Module::types`, so that we can use `Eq` on `Type` or `TypeInner` for type equivalence, without being confused by differing `Handle<Type>` values that point to identical types. This removes a number of duplicate types from the ir snapshots. Fixes gfx-rs#1385.
`UniqueArena::fetch_or_append` becomes `insert`. `UniqueArena::try_get` becomes `get_handle`, by analogy with `get`, that takes a type as a key.
jimblandy
force-pushed
the
unique-arena
branch
from
September 27, 2021 17:22
8f97688
to
d8b18a2
Compare
That last forced push just adds a "fixes #1385" note to the commit message. No code change. |
kvark
approved these changes
Sep 27, 2021
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.
Each commit should be CI-safe. I recommend reviewing commits separately.
Use
UniqueArena
for types.Ensure that each distinct type occurs only once in
Module::types
, so that wecan use
Eq
onType
orTypeInner
for type equivalence, without beingconfused by differing
Handle<Type>
values that point to identical types.This removes a number of duplicate types from the ir snapshots.
Simplify interpolation defaulting.
Replace
Module::apply_common_default_interpolation
with a simpler functionthat handles a single
Binding
at a time. In exchange for the simplicity, thefunction must be called at each point function arguments, function results, and
struct members are prepared. (Any missed spots will be caught by the verifier.)
This approach no longer requires mutating types in the arena, a prerequisite for
properly handling type identity.
Applying defaults to struct members when the struct declaration is parsed does
have a disadvantage, compared to the old whole-module pass: at struct parse
time, we don't yet know which pipeline stages the struct will be used in. The
best we can do is apply defaults to anything with a
Location
binding. Thiscauses needless qualifiers to appear in some output. However, it seems that our
back end languages all tolerate such qualifiers.
Consolidate Handle construction code.
[glsl-in]: Register new types as necessary during constant solving.
Rename
UniqueArena
methods to more closely resembleHashSet
.UniqueArena::fetch_or_append
becomesinsert
.UniqueArena::try_get
becomesget_handle
, by analogy withget
, that takes atype as a key.