You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can appropriately use a dynamic slice intrinsic on a nested slice whose element types are primitive types, but we should be able to also use dynamic slice intrinsics on a nested slice whose element types are also complex types such as another nested slice.
Happy Case
If I have this nested slice:
struct FooParent {
parent_arr: [Field; 3],
foos: [Foo],
}
struct Bar {
inner: [Field; 3],
}
struct Foo {
a: Field,
b: [Field],
bar: Bar,
}
let q = x.push_back(foo_four);
let foo_parent_one = FooParent { parent_arr: [0, 1, 2], foos: x };
let foo_parent_two = FooParent { parent_arr: [3, 4, 5], foos: q };
let mut foo_parents = [foo_parent_one];
foo_parents = foo_parents.push_back(foo_parent_two);
where the nested slice simply has primitive element types.
Alternatives Considered
N/A
Additional Context
Nested dynamic slices were made possible by this pass (#3258). There is a chance that something is simply off in this pass rather than the ACIR gen.
After some investigation it does look like the fill internal slices pass is working as expected but this is still important to note in case I missed something.
Would you like to submit a PR for this Issue?
No
Support Needs
No response
The text was updated successfully, but these errors were encountered:
# Description
## Problem\*
Resolves#3364
## Summary\*
This PR heavily changes the way slice intrinsics are implemented in ACIR
gen. Following the `fill_internal_slices` pass nested slices now have
dummy data automatically attached to them to enable known sizes to be
used when fetching from an array with nested slices. Most of the slice
intrinsics were written for non-complex inputs and also did not account
for the addition of already included dummy data. With dummy data already
included we cannot simply push back or push front elements for example,
we need to make sure we do not alter the size of the internal slice we
are using.
The slice intrinsic implementations essentially treat the input already
as a dynamic array and perform the appropriate memory operations upon
them. I considered alternatives and went with what I think is the most
efficient way to implement these intrinsics, however, there is
definitely room for cleanup and in the name of getting a first iteration
working, we can consider how to optimize these intrinsics in another PR.
I have added comments in the ACIR gen itself to help with some of the
logic for the implementation, but do let me know if something is not
clear and I can document it further.
The `fill_internal_slices` pass now also accounts for slice constants
passed as inputs to slice intrinsics as these must also be filled with
dummy data when they are being attached to a nested slice.
## Additional Context
A bug was found in the `fill_internal_slices` pass that was necessary to
resolve this issue. Essentially the children fetched from a slice were
not being accurately tracked when an `array_get` occurs. This fix is
included in this PR as it did not come up until more complex operations
with nested slices were attempted.
SliceInsert and SliceRemove now use a dynamic index. I only tested using
a constant index in this PR and will have a followup PR that shows this
tested out as this PR is already large enough.
## Documentation\*
Check one:
- [ ] No documentation needed.
- [X] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.
# PR Checklist\*
- [X] I have tested the changes locally.
- [X] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
---------
Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
Co-authored-by: Tom French <tom@tomfren.ch>
Co-authored-by: jfecher <jake@aztecprotocol.com>
Problem
We can appropriately use a dynamic slice intrinsic on a nested slice whose element types are primitive types, but we should be able to also use dynamic slice intrinsics on a nested slice whose element types are also complex types such as another nested slice.
Happy Case
If I have this nested slice:
I should be able to do:
the same way I can do:
where the nested slice simply has primitive element types.
Alternatives Considered
N/A
Additional Context
Nested dynamic slices were made possible by this pass (#3258). There is a chance that something is simply off in this pass rather than the ACIR gen.
After some investigation it does look like the fill internal slices pass is working as expected but this is still important to note in case I missed something.
Would you like to submit a PR for this Issue?
No
Support Needs
No response
The text was updated successfully, but these errors were encountered: