-
Notifications
You must be signed in to change notification settings - Fork 649
(feature): A new libfunc for calculating the pointer to temporary storage using a double call #8667
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: main
Are you sure you want to change the base?
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
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 2 of 14 files at r1, all commit messages.
Reviewable status: 2 of 14 files reviewed, 2 unresolved discussions (waiting on @giladchase and @ilyalesokhin-starkware)
crates/cairo-lang-sierra/src/extensions/core.rs line 132 at r1 (raw file):
Gas(GasLibfunc), GasReserve(GasReserveLibfunc), GetTempPtr(GetTempPtrLibfunc),
move to under Box.
Code quote:
GetTempPtr(GetTempPtrLibfunc),crates/cairo-lang-sierra/src/extensions/modules/get_temp_ptr.rs line 1 at r1 (raw file):
//! Libfunc for computing the address of a variable based on type size.
box_from_temp_store
all around probably.
f0f324a to
c65e1d8
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.
Reviewable status: 1 of 16 files reviewed, 2 unresolved discussions (waiting on @giladchase, @ilyalesokhin-starkware, and @orizi)
crates/cairo-lang-sierra/src/extensions/core.rs line 132 at r1 (raw file):
Previously, orizi wrote…
move to under
Box.
Done.
crates/cairo-lang-sierra/src/extensions/modules/get_temp_ptr.rs line 1 at r1 (raw file):
Previously, orizi wrote…
box_from_temp_store
all around probably.
Done.
c65e1d8 to
aa0c9dc
Compare
… storage using a double call SIERRA_UPDATE_MINOR_CHANGE_TAG=adding a libfunc for optimizing creating boxes from temp storage
aa0c9dc to
c4e803d
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 6 of 14 files at r2.
Reviewable status: 7 of 16 files reviewed, 2 unresolved discussions (waiting on @giladchase and @ilyalesokhin-starkware)
crates/cairo-lang-sierra/src/extensions/modules/boxing.rs line 142 at r2 (raw file):
// The actual offset is computed in CASM based on type size Ok(LibfuncSignature::new_non_branch( vec![],
you should have the value as an input.
Code quote:
vec![],
giladchase
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.
Reviewable status: 7 of 16 files reviewed, 2 unresolved discussions (waiting on @eytan-starkware, @ilyalesokhin-starkware, and @orizi)
crates/cairo-lang-sierra-to-casm/src/compiler.rs line 376 at r2 (raw file):
let segment = UtilitySegment { instructions, offset: total_segments_size }; total_segments_size += segment.instructions.iter().map(|i| i.body.op_size()).sum::<usize>();
Nonblocking: perhaps this should be a for, side-effects inside map (modifying the external var total_segments_size) can be surprising
Code quote:
.map(|(id, instructions)| {
let segment = UtilitySegment { instructions, offset: total_segments_size };
total_segments_size +=
segment.instructions.iter().map(|i| i.body.op_size()).sum::<usize>();
giladchase
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.
Reviewable status: 7 of 16 files reviewed, 2 unresolved discussions (waiting on @eytan-starkware, @ilyalesokhin-starkware, and @orizi)
crates/cairo-lang-sierra-to-casm/src/compiler.rs line 351 at r2 (raw file):
Ok(CoreConcreteLibfunc::Box(BoxConcreteLibfunc::FromTempStore(_))) ) });
Might be time to iterate only once on libfunc_ids and match on program_info.registry.get_libfunc(id).unwrap()
Code quote:
let has_box_from_temp_store = libfunc_ids.into_iter().any(|id| {
matches!(
program_info.registry.get_libfunc(id),
Ok(CoreConcreteLibfunc::Box(BoxConcreteLibfunc::FromTempStore(_)))
)
});
TL;DR
Added a new
get_temp_ptrlibfunc to compute addresses for variables based on type size, with utility segment support for code reuse.What changed?
get_temp_ptr<T>that computes the address where a value of type T would be locatedConstsInfotoSegmentsInfoand extended it to support utility segments for code reuseget_temp_ptrusing a shared utility segment