-
Notifications
You must be signed in to change notification settings - Fork 732
(opt): Libfunc for matching on a boxed enum for boxed variants results #9378
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
base: eytan_graphite/_refactor_build_jump_and_jump_table_to_support_prepended_instructions
Are you sure you want to change the base?
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
c5d3e57 to
27ca24b
Compare
TomerStarkware
left a comment
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.
@TomerStarkware reviewed 9 files and all commit messages, and made 1 comment.
Reviewable status: 9 of 10 files reviewed, all discussions resolved (waiting on @ilyalesokhin-starkware and @orizi).
orizi
left a comment
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.
@orizi reviewed all commit messages and made 1 comment.
Reviewable status: 9 of 10 files reviewed, 1 unresolved discussion (waiting on @eytan-starkware and @ilyalesokhin-starkware).
crates/cairo-lang-sierra-ap-change/src/core_libfunc_ap_change.rs line 301 at r1 (raw file):
signature, .. }) | EnumConcreteLibfunc::BoxedMatch(EnumBoxedMatchConcreteLibfunc {
this sounds incorrect - as box match should include a deref before the match.
orizi
left a comment
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.
@orizi made 1 comment.
Reviewable status: 9 of 10 files reviewed, 2 unresolved discussions (waiting on @eytan-starkware and @ilyalesokhin-starkware).
tests/e2e_test_data/libfuncs/enum line 527 at r1 (raw file):
//! > casm jmp rel 7 if [fp + -3] != 0;
[fp + -3] is a pointer
Suggestion:
[ap + 0] = [[fp + -3]], ap++;
jmp rel 7 if [fp + -3] != 0;
ead4620 to
082b6c3
Compare
eytan-starkware
left a comment
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.
@eytan-starkware made 2 comments.
Reviewable status: 5 of 10 files reviewed, 2 unresolved discussions (waiting on @ilyalesokhin-starkware, @orizi, and @TomerStarkware).
crates/cairo-lang-sierra-ap-change/src/core_libfunc_ap_change.rs line 301 at r1 (raw file):
Previously, orizi wrote…
this sounds incorrect - as box match should include a deref before the match.
Done
tests/e2e_test_data/libfuncs/enum line 527 at r1 (raw file):
Previously, orizi wrote…
[fp + -3] is a pointer
Done.
orizi
left a comment
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.
@orizi reviewed all commit messages and made 2 comments.
Reviewable status: 5 of 10 files reviewed, 4 unresolved discussions (waiting on @eytan-starkware, @ilyalesokhin-starkware, and @TomerStarkware).
tests/e2e_test_data/libfuncs/enum line 524 at r2 (raw file):
BoxedOption::None(_) => BoxTrait::new(0), } }
and so on.
Suggestion:
fn foo(e: Box<Option>) -> BoxedOption {
enum_boxed_match(e)
}
tests/e2e_test_data/libfuncs/enum line 676 at r2 (raw file):
}, } }
Suggestion:
fn foo(e: Box<Data>) -> BoxedData {
enum_boxed_match(e)
}
082b6c3 to
1c24515
Compare
eytan-starkware
left a comment
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.
@eytan-starkware made 2 comments.
Reviewable status: 5 of 10 files reviewed, 4 unresolved discussions (waiting on @ilyalesokhin-starkware, @orizi, and @TomerStarkware).
tests/e2e_test_data/libfuncs/enum line 524 at r2 (raw file):
Previously, orizi wrote…
and so on.
Done.
tests/e2e_test_data/libfuncs/enum line 676 at r2 (raw file):
}, } }
Done.
1c24515 to
2875ad7
Compare
TomerStarkware
left a comment
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.
@TomerStarkware partially reviewed 4 files and made 1 comment.
Reviewable status: 8 of 10 files reviewed, 4 unresolved discussions (waiting on @ilyalesokhin-starkware and @orizi).
2875ad7 to
b8ec7a5
Compare
orizi
left a comment
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.
@orizi reviewed all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: 5 of 10 files reviewed, 4 unresolved discussions (waiting on @eytan-starkware, @ilyalesokhin-starkware, and @TomerStarkware).
a discussion (no related file):
this PR now requires an actual audit - as it already touches too much existing code.
requires major simplification or splitting.
b8ec7a5 to
09abae4
Compare
254407f to
7de9b91
Compare
c9f6067 to
38c5207
Compare
7de9b91 to
2f62226
Compare
38c5207 to
8581230
Compare
68b0a7d to
c4c9d0f
Compare
8581230 to
3b5d56b
Compare
3b5d56b to
0298e08
Compare
c4c9d0f to
7638bf8
Compare
56b2dd5 to
a5e79e9
Compare
7638bf8 to
902d2d9
Compare
SIERRA_UPDATE_MINOR_CHANGE_TAG=Added enum_boxed_match libfunc for matching boxed enums
eytan-starkware
left a comment
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.
@eytan-starkware made 1 comment.
Reviewable status: 3 of 10 files reviewed, 4 unresolved discussions (waiting on @ilyalesokhin-starkware, @orizi, and @TomerStarkware).
a discussion (no related file):
Previously, orizi wrote…
this PR now requires an actual audit - as it already touches too much existing code.
requires major simplification or splitting.
Now?
a5e79e9 to
45aef2e
Compare

Summary
Added support for
enum_boxed_matchlibfunc that allows matching on boxed enums, returning boxes of the variant types. This complements the existingstruct_boxed_deconstructfunctionality and enables more efficient handling of boxed enum types.Type of change
Please check one:
Why is this change needed?
When working with boxed enums, there was no direct way to match on the enum and get boxed variants without unboxing and reboxing. This implementation allows for more efficient handling of boxed enum types by providing a direct way to match on a boxed enum and get boxes of the variant types.
What was the behavior or documentation before?
Previously, to match on a boxed enum and work with its variants as boxes, you would need to unbox the enum, match on it, and then box each variant again. This was inefficient and required more code.
What is the behavior or documentation after?
Now, the
enum_boxed_matchlibfunc allows directly matching on a boxed enum and getting boxes of the variant types. This is similar to howstruct_boxed_deconstructworks for structs. The implementation handles different variant sizes correctly, including padding for right-aligned variants.Additional context
The implementation includes refactoring of the box unpacking functionality to reduce code duplication between struct and enum implementations. The
BoxUnpackLibfunctrait was introduced to share common logic betweenstruct_boxed_deconstructandenum_boxed_match.