-
Notifications
You must be signed in to change notification settings - Fork 738
performance(sierra-to-casm): Removed CellExpression unrequired clone.
#9526
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
performance(sierra-to-casm): Removed CellExpression unrequired clone.
#9526
Conversation
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 1 file and all commit messages, and made 1 comment.
Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @eytan-starkware and @orizi).
crates/cairo-lang-casm/src/builder.rs line 280 at r1 (raw file):
pub fn assert_vars_eq(&mut self, dst: Var, res: Var, kind: AssertEqKind) { let a = self.as_adjasted_cell_ref(dst); let b = self.get_adjusted(res);
shouldn't this be unadjusted?
8573a25 to
cb68427
Compare
7f15bec to
ecc7d3c
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 made 1 comment.
Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @eytan-starkware and @TomerStarkware).
crates/cairo-lang-casm/src/builder.rs line 280 at r1 (raw file):
Previously, TomerStarkware wrote…
shouldn't this be unadjusted?
if i do - we require to 'readjust' as well. attepted.
cb68427 to
5681777
Compare
ecc7d3c to
73878a2
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 1 file, made 1 comment, and resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @eytan-starkware).
5681777 to
aa81a46
Compare
73878a2 to
377f341
Compare
aad259a to
6c9ba5c
Compare
6c9ba5c to
cbffbe8
Compare
Done by refactoring the basic callbacks. SIERRA_UPDATE_PATCH_CHANGE_TAG=No interface changes.
cbffbe8 to
0cc98d1
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 1 file and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @eytan-starkware).

Summary
Refactored the
CasmBuilderto improve handling of cell expressions by:get_unadjustedandget_adjustedmethodsadjust_apboolean parameter in favor of explicit method namesto_i16()andchecked_addType of change
Please check one:
Why is this change needed?
The current implementation of
CasmBuilderhas inconsistent handling of AP adjustments and cell references. The booleanadjust_apparameter creates confusion about when adjustments should be applied. Additionally, the offset calculations for cell references could potentially overflow without proper checking.What was the behavior or documentation before?
The code used a boolean parameter
adjust_apto determine whether to apply AP changes, leading to potential inconsistencies. Cell reference handling was also less efficient, with redundant cloning operations and unsafe offset calculations.What is the behavior or documentation after?
The code now has explicit methods for adjusted and unadjusted values, making the intent clearer. Offset calculations use proper checked arithmetic to prevent overflows, and AP changes are applied more consistently throughout the codebase.
Additional context
This refactoring improves code maintainability by making the API more explicit about when AP adjustments are applied. It also reduces unnecessary cloning of cell expressions and adds proper bounds checking for offsets.