Skip to content
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

Refactored const-folding. #6070

Merged
merged 1 commit into from
Jul 29, 2024
Merged

Conversation

orizi
Copy link
Collaborator

@orizi orizi commented Jul 25, 2024

Copy link
Contributor

@gilbens-starkware gilbens-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @orizi)


crates/cairo-lang-lowering/src/optimizations/const_folding.rs line 179 at r1 (raw file):

    nz_fns: UnorderedHashSet<FunctionId>,
    /// The storage access module.
    storage_access_module: ModuleHelper<'a>,

Consider making these a sub-struct.

Code quote:

    // The required ids for optimizations.
    /// The `felt252_sub` libfunc.
    felt_sub: FunctionId,
    /// The `into_box` libfunc.
    into_box: ExternFunctionId,
    /// The `upcast` libfunc.
    upcast: ExternFunctionId,
    /// The `storage_base_address_from_felt252` libfunc.
    storage_base_address_from_felt252: FunctionId,
    /// The set of functions that check if a number is zero.
    nz_fns: UnorderedHashSet<FunctionId>,
    /// The storage access module.
    storage_access_module: ModuleHelper<'a>,

@orizi orizi force-pushed the pr/orizi/const-folding/605c1c38 branch from e939cef to d9ffee0 Compare July 28, 2024 09:39
Copy link
Contributor

@gilbens-starkware gilbens-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all commit messages.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @orizi)


crates/cairo-lang-lowering/src/optimizations/const_folding.rs line 337 at r2 (raw file):

    /// The storage access module.
    storage_access_module: ModuleHelper<'a>,
}

Maybe it should really be static with once_cell::Lazy?

Code quote:

/// Holds static information about libfuncs required for the optimization.
struct LibfuncInfo<'a> {
    /// The `felt252_sub` libfunc.
    felt_sub: FunctionId,
    /// The `into_box` libfunc.
    into_box: ExternFunctionId,
    /// The `upcast` libfunc.
    upcast: ExternFunctionId,
    /// The `storage_base_address_from_felt252` libfunc.
    storage_base_address_from_felt252: FunctionId,
    /// The set of functions that check if a number is zero.
    nz_fns: UnorderedHashSet<FunctionId>,
    /// The storage access module.
    storage_access_module: ModuleHelper<'a>,
}

@orizi orizi force-pushed the pr/orizi/const-folding/605c1c38 branch from d9ffee0 to 20bba5d Compare July 28, 2024 16:54
Copy link
Collaborator Author

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @gilbens-starkware)


crates/cairo-lang-lowering/src/optimizations/const_folding.rs line 337 at r2 (raw file):

Previously, gilbens-starkware (Gil Ben-Shachar) wrote…

Maybe it should really be static with once_cell::Lazy?

cannot be - but can become a db query - but will get to it when actually required.

commit-id:605c1c38
@orizi orizi force-pushed the pr/orizi/const-folding/605c1c38 branch from 20bba5d to 29c2728 Compare July 28, 2024 19:26
Copy link
Contributor

@gilbens-starkware gilbens-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @orizi)

@orizi orizi added this pull request to the merge queue Jul 29, 2024
Merged via the queue into dev-v2.7.0 with commit cc0a321 Jul 29, 2024
87 checks passed
@orizi orizi deleted the pr/orizi/const-folding/605c1c38 branch July 31, 2024 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants