-
Notifications
You must be signed in to change notification settings - Fork 189
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
feat(improve): Remove scan through globals #6282
Merged
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
aakoshh
changed the title
Maintain a reverse index from (LocalModuleId, Ident) to GlobalId
feat(improve): Index globals by module and ident for faster lookups
Oct 11, 2024
aakoshh
changed the title
feat(improve): Index globals by module and ident for faster lookups
improve: Index globals by module and ident for faster lookups
Oct 11, 2024
aakoshh
changed the title
improve: Index globals by module and ident for faster lookups
feat(improve): Index globals by module and ident for faster lookups
Oct 11, 2024
Merged
5 tasks
aakoshh
commented
Oct 11, 2024
aakoshh
changed the title
feat(improve): Index globals by module and ident for faster lookups
feat(improve): Remove scan through globals
Oct 11, 2024
aakoshh
added a commit
that referenced
this pull request
Oct 11, 2024
…it from the definition (#6283) # Description ## Problem\* Followup to #6282 ## Summary\* Some methods in the `Elaborator` received a `global_id: Option<GlobalId>` and a `definition: DefinitionKind` parameter. We found that `Elaborator::elaborate_let` actually created `definition` to carry the same global ID as it was given, so `global_id: Some(id)` and `definition: DefinitionKind::Global(id)` always carried the same value. We added an [assertion](1d2bd36) that checked that they are never different. The next logical step is to remove the possibility of confusion by only carrying the ID in the definition. ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [ ] I have tested the changes locally. - [ ] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
…it from the definition (#6283) # Description ## Problem\* Followup to #6282 ## Summary\* Some methods in the `Elaborator` received a `global_id: Option<GlobalId>` and a `definition: DefinitionKind` parameter. We found that `Elaborator::elaborate_let` actually created `definition` to carry the same global ID as it was given, so `global_id: Some(id)` and `definition: DefinitionKind::Global(id)` always carried the same value. We added an [assertion](1d2bd36) that checked that they are never different. The next logical step is to remove the possibility of confusion by only carrying the ID in the definition. ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [ ] I have tested the changes locally. - [ ] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
aakoshh
force-pushed
the
5001-global-index
branch
from
October 11, 2024 16:06
11c7d74
to
d1c3189
Compare
michaeljklein
approved these changes
Oct 11, 2024
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.
LGTM
jfecher
approved these changes
Oct 11, 2024
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.
👍
AztecBot
added a commit
to AztecProtocol/aztec-packages
that referenced
this pull request
Oct 12, 2024
feat(improve): Remove scan through globals (noir-lang/noir#6282) feat: show LSP diagnostic related information (noir-lang/noir#6277) feat: trait inheritance (noir-lang/noir#6252) feat: optimize reading a workspace's files (noir-lang/noir#6281) fix: prevent compiler panic when popping from empty slices (noir-lang/noir#6274) feat(test): Include the PoseidonHasher in the fuzzing (noir-lang/noir#6280) feat: slightly improve "unexpected token" error message (noir-lang/noir#6279) feat(test): Fuzz poseidon hases against an external library (noir-lang/noir#6273) feat: remove byte decomposition in `compute_decomposition` (noir-lang/noir#6159) fix: address inactive public key check in `verify_signature_noir` (noir-lang/noir#6270) feat(test): Fuzz test poseidon2 hash equivalence (noir-lang/noir#6265) fix!: Integer division is not the inverse of integer multiplication (noir-lang/noir#6243) feat(perf): Flamegraphs for test program execution benchmarks (noir-lang/noir#6253) fix: visibility for impl methods (noir-lang/noir#6261) feat: Add `checked_transmute` (noir-lang/noir#6262) feat!: kind size checks (noir-lang/noir#6137) feat: don't crash LSP when there are errors resolving the workspace (noir-lang/noir#6257) fix: don't warn on unuse global if it has an abi annotation (noir-lang/noir#6258) fix: don't warn on unused struct that has an abi annotation (noir-lang/noir#6254) feat: don't suggest private struct fields in LSP (noir-lang/noir#6256) feat: visibility for struct fields (noir-lang/noir#6221) fix: handle dfg databus in SSA normalization (noir-lang/noir#6249) fix: homogeneous input points for EC ADD (noir-lang/noir#6241) chore: add regression test for #5756 (noir-lang/noir#5770) feat: allow `unconstrained` after visibility (noir-lang/noir#6246) feat: optimize `Quoted::as_expr` by parsing just once (noir-lang/noir#6237) fix(frontend): Do not warn when a nested struct is provided as input to main (noir-lang/noir#6239) fix!: Change tag attributes to require a ' prefix (noir-lang/noir#6235) feat: recover from '=' instead of ':' in struct constructor/pattern (noir-lang/noir#6236)
AztecBot
added a commit
to AztecProtocol/aztec-packages
that referenced
this pull request
Oct 12, 2024
feat(improve): Remove scan through globals (noir-lang/noir#6282) feat: show LSP diagnostic related information (noir-lang/noir#6277) feat: trait inheritance (noir-lang/noir#6252) feat: optimize reading a workspace's files (noir-lang/noir#6281) fix: prevent compiler panic when popping from empty slices (noir-lang/noir#6274) feat(test): Include the PoseidonHasher in the fuzzing (noir-lang/noir#6280) feat: slightly improve "unexpected token" error message (noir-lang/noir#6279) feat(test): Fuzz poseidon hases against an external library (noir-lang/noir#6273) feat: remove byte decomposition in `compute_decomposition` (noir-lang/noir#6159) fix: address inactive public key check in `verify_signature_noir` (noir-lang/noir#6270) feat(test): Fuzz test poseidon2 hash equivalence (noir-lang/noir#6265) fix!: Integer division is not the inverse of integer multiplication (noir-lang/noir#6243) feat(perf): Flamegraphs for test program execution benchmarks (noir-lang/noir#6253) fix: visibility for impl methods (noir-lang/noir#6261) feat: Add `checked_transmute` (noir-lang/noir#6262) feat!: kind size checks (noir-lang/noir#6137) feat: don't crash LSP when there are errors resolving the workspace (noir-lang/noir#6257) fix: don't warn on unuse global if it has an abi annotation (noir-lang/noir#6258) fix: don't warn on unused struct that has an abi annotation (noir-lang/noir#6254) feat: don't suggest private struct fields in LSP (noir-lang/noir#6256) feat: visibility for struct fields (noir-lang/noir#6221) fix: handle dfg databus in SSA normalization (noir-lang/noir#6249) fix: homogeneous input points for EC ADD (noir-lang/noir#6241) chore: add regression test for #5756 (noir-lang/noir#5770) feat: allow `unconstrained` after visibility (noir-lang/noir#6246) feat: optimize `Quoted::as_expr` by parsing just once (noir-lang/noir#6237) fix(frontend): Do not warn when a nested struct is provided as input to main (noir-lang/noir#6239) fix!: Change tag attributes to require a ' prefix (noir-lang/noir#6235) feat: recover from '=' instead of ':' in struct constructor/pattern (noir-lang/noir#6236)
AztecBot
added a commit
to AztecProtocol/aztec-packages
that referenced
this pull request
Oct 13, 2024
feat(improve): Remove scan through globals (noir-lang/noir#6282) feat: show LSP diagnostic related information (noir-lang/noir#6277) feat: trait inheritance (noir-lang/noir#6252) feat: optimize reading a workspace's files (noir-lang/noir#6281) fix: prevent compiler panic when popping from empty slices (noir-lang/noir#6274) feat(test): Include the PoseidonHasher in the fuzzing (noir-lang/noir#6280) feat: slightly improve "unexpected token" error message (noir-lang/noir#6279) feat(test): Fuzz poseidon hases against an external library (noir-lang/noir#6273) feat: remove byte decomposition in `compute_decomposition` (noir-lang/noir#6159) fix: address inactive public key check in `verify_signature_noir` (noir-lang/noir#6270) feat(test): Fuzz test poseidon2 hash equivalence (noir-lang/noir#6265) fix!: Integer division is not the inverse of integer multiplication (noir-lang/noir#6243) feat(perf): Flamegraphs for test program execution benchmarks (noir-lang/noir#6253) fix: visibility for impl methods (noir-lang/noir#6261) feat: Add `checked_transmute` (noir-lang/noir#6262) feat!: kind size checks (noir-lang/noir#6137) feat: don't crash LSP when there are errors resolving the workspace (noir-lang/noir#6257) fix: don't warn on unuse global if it has an abi annotation (noir-lang/noir#6258) fix: don't warn on unused struct that has an abi annotation (noir-lang/noir#6254) feat: don't suggest private struct fields in LSP (noir-lang/noir#6256) feat: visibility for struct fields (noir-lang/noir#6221) fix: handle dfg databus in SSA normalization (noir-lang/noir#6249) fix: homogeneous input points for EC ADD (noir-lang/noir#6241) chore: add regression test for #5756 (noir-lang/noir#5770) feat: allow `unconstrained` after visibility (noir-lang/noir#6246) feat: optimize `Quoted::as_expr` by parsing just once (noir-lang/noir#6237) fix(frontend): Do not warn when a nested struct is provided as input to main (noir-lang/noir#6239) fix!: Change tag attributes to require a ' prefix (noir-lang/noir#6235) feat: recover from '=' instead of ':' in struct constructor/pattern (noir-lang/noir#6236)
AztecBot
added a commit
to AztecProtocol/aztec-packages
that referenced
this pull request
Oct 13, 2024
feat(improve): Remove scan through globals (noir-lang/noir#6282) feat: show LSP diagnostic related information (noir-lang/noir#6277) feat: trait inheritance (noir-lang/noir#6252) feat: optimize reading a workspace's files (noir-lang/noir#6281) fix: prevent compiler panic when popping from empty slices (noir-lang/noir#6274) feat(test): Include the PoseidonHasher in the fuzzing (noir-lang/noir#6280) feat: slightly improve "unexpected token" error message (noir-lang/noir#6279) feat(test): Fuzz poseidon hases against an external library (noir-lang/noir#6273) feat: remove byte decomposition in `compute_decomposition` (noir-lang/noir#6159) fix: address inactive public key check in `verify_signature_noir` (noir-lang/noir#6270) feat(test): Fuzz test poseidon2 hash equivalence (noir-lang/noir#6265) fix!: Integer division is not the inverse of integer multiplication (noir-lang/noir#6243) feat(perf): Flamegraphs for test program execution benchmarks (noir-lang/noir#6253) fix: visibility for impl methods (noir-lang/noir#6261) feat: Add `checked_transmute` (noir-lang/noir#6262) feat!: kind size checks (noir-lang/noir#6137) feat: don't crash LSP when there are errors resolving the workspace (noir-lang/noir#6257) fix: don't warn on unuse global if it has an abi annotation (noir-lang/noir#6258) fix: don't warn on unused struct that has an abi annotation (noir-lang/noir#6254) feat: don't suggest private struct fields in LSP (noir-lang/noir#6256) feat: visibility for struct fields (noir-lang/noir#6221) fix: handle dfg databus in SSA normalization (noir-lang/noir#6249) fix: homogeneous input points for EC ADD (noir-lang/noir#6241) chore: add regression test for #5756 (noir-lang/noir#5770) feat: allow `unconstrained` after visibility (noir-lang/noir#6246) feat: optimize `Quoted::as_expr` by parsing just once (noir-lang/noir#6237) fix(frontend): Do not warn when a nested struct is provided as input to main (noir-lang/noir#6239) fix!: Change tag attributes to require a ' prefix (noir-lang/noir#6235) feat: recover from '=' instead of ':' in struct constructor/pattern (noir-lang/noir#6236)
AztecBot
added a commit
to AztecProtocol/aztec-packages
that referenced
this pull request
Oct 14, 2024
feat(improve): Remove scan through globals (noir-lang/noir#6282) feat: show LSP diagnostic related information (noir-lang/noir#6277) feat: trait inheritance (noir-lang/noir#6252) feat: optimize reading a workspace's files (noir-lang/noir#6281) fix: prevent compiler panic when popping from empty slices (noir-lang/noir#6274) feat(test): Include the PoseidonHasher in the fuzzing (noir-lang/noir#6280) feat: slightly improve "unexpected token" error message (noir-lang/noir#6279) feat(test): Fuzz poseidon hases against an external library (noir-lang/noir#6273) feat: remove byte decomposition in `compute_decomposition` (noir-lang/noir#6159) fix: address inactive public key check in `verify_signature_noir` (noir-lang/noir#6270) feat(test): Fuzz test poseidon2 hash equivalence (noir-lang/noir#6265) fix!: Integer division is not the inverse of integer multiplication (noir-lang/noir#6243) feat(perf): Flamegraphs for test program execution benchmarks (noir-lang/noir#6253) fix: visibility for impl methods (noir-lang/noir#6261) feat: Add `checked_transmute` (noir-lang/noir#6262) feat!: kind size checks (noir-lang/noir#6137) feat: don't crash LSP when there are errors resolving the workspace (noir-lang/noir#6257) fix: don't warn on unuse global if it has an abi annotation (noir-lang/noir#6258) fix: don't warn on unused struct that has an abi annotation (noir-lang/noir#6254) feat: don't suggest private struct fields in LSP (noir-lang/noir#6256) feat: visibility for struct fields (noir-lang/noir#6221) fix: handle dfg databus in SSA normalization (noir-lang/noir#6249) fix: homogeneous input points for EC ADD (noir-lang/noir#6241) chore: add regression test for #5756 (noir-lang/noir#5770) feat: allow `unconstrained` after visibility (noir-lang/noir#6246) feat: optimize `Quoted::as_expr` by parsing just once (noir-lang/noir#6237) fix(frontend): Do not warn when a nested struct is provided as input to main (noir-lang/noir#6239) fix!: Change tag attributes to require a ' prefix (noir-lang/noir#6235) feat: recover from '=' instead of ':' in struct constructor/pattern (noir-lang/noir#6236)
AztecBot
added a commit
to AztecProtocol/aztec-packages
that referenced
this pull request
Oct 14, 2024
feat(improve): Remove scan through globals (noir-lang/noir#6282) feat: show LSP diagnostic related information (noir-lang/noir#6277) feat: trait inheritance (noir-lang/noir#6252) feat: optimize reading a workspace's files (noir-lang/noir#6281) fix: prevent compiler panic when popping from empty slices (noir-lang/noir#6274) feat(test): Include the PoseidonHasher in the fuzzing (noir-lang/noir#6280) feat: slightly improve "unexpected token" error message (noir-lang/noir#6279) feat(test): Fuzz poseidon hases against an external library (noir-lang/noir#6273) feat: remove byte decomposition in `compute_decomposition` (noir-lang/noir#6159) fix: address inactive public key check in `verify_signature_noir` (noir-lang/noir#6270) feat(test): Fuzz test poseidon2 hash equivalence (noir-lang/noir#6265) fix!: Integer division is not the inverse of integer multiplication (noir-lang/noir#6243) feat(perf): Flamegraphs for test program execution benchmarks (noir-lang/noir#6253) fix: visibility for impl methods (noir-lang/noir#6261) feat: Add `checked_transmute` (noir-lang/noir#6262) feat!: kind size checks (noir-lang/noir#6137) feat: don't crash LSP when there are errors resolving the workspace (noir-lang/noir#6257) fix: don't warn on unuse global if it has an abi annotation (noir-lang/noir#6258) fix: don't warn on unused struct that has an abi annotation (noir-lang/noir#6254) feat: don't suggest private struct fields in LSP (noir-lang/noir#6256) feat: visibility for struct fields (noir-lang/noir#6221) fix: handle dfg databus in SSA normalization (noir-lang/noir#6249) fix: homogeneous input points for EC ADD (noir-lang/noir#6241) chore: add regression test for #5756 (noir-lang/noir#5770) feat: allow `unconstrained` after visibility (noir-lang/noir#6246) feat: optimize `Quoted::as_expr` by parsing just once (noir-lang/noir#6237) fix(frontend): Do not warn when a nested struct is provided as input to main (noir-lang/noir#6239) fix!: Change tag attributes to require a ' prefix (noir-lang/noir#6235) feat: recover from '=' instead of ':' in struct constructor/pattern (noir-lang/noir#6236)
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.
Description
Problem*
Resolves #5001
Summary*
Removes the search for a global by local module ID and name when elaborating a global variable declaration. Instead simply looks up the global by the ID that we have in the definition we are elaborating. In fact the elaboration starts from a global ID of an unresolved global.
I could be way off the mark on whether this is the right thing to do.
Additional Context
I found a couple of things odd:
NodeInterner::push_global
pushes aDefinitionKind::Global(id)
with the exact ID that theGlobalInfo
will have, ie. it is self-referential (just an observation). This is called during the collection of unresolved globals.Elaborator::add_global_variable_decl
only looks for globals bylocal_id
andname
, but not bydefinition
, even though at this point we know that thedefinition
must contain aGlobalId
, otherwise we would have stayed inElaborator::add_variable_decl
.NodeInterner::push_definition
with thedefinition
in the parameters; since we know it contains aGlobalId
and that the same ID must have been inserted inpush_global
as well, it will now be part of two definitions at different locations - not sure exactly what this means or looks like in codeI added some assertions in the commits to check that during the tests on CI, the
global_id
and thedefinition
, and any results found by the lookup by local+name, are always consistent, which is why in the end I thought that if the only thing we can find is the one we can get by ID, why not get just get it?Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.