Skip to content

Conversation

@giladchase
Copy link
Contributor

Currently is always mapped to into_box during sierra-gen, but soon in sierra-gen it can also be
mapped into local_into_box when applicable.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@giladchase giladchase marked this pull request as ready for review December 8, 2025 12:44
@giladchase giladchase force-pushed the gilad/12-08-add_intobox_instead_of_into_box_in_lowering branch 3 times, most recently from b055ea0 to 8dd2bd5 Compare December 8, 2025 12:52
Copy link
Collaborator

@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.

@orizi reviewed 1 of 14 files at r1.
Reviewable status: 0 of 14 files reviewed, 1 unresolved discussion (waiting on @eytan-starkware and @giladchase)


crates/cairo-lang-lowering/src/lower/mod.rs line 1396 at r1 (raw file):

    // Handle into_box specially - emit IntoBox instead of a call.
    let into_box_fn = ModuleHelper::core(ctx.db).submodule("box").extern_function_id("into_box");

add to CoreInfo instead of calling every time.

@giladchase giladchase force-pushed the gilad/12-08-add_intobox_instead_of_into_box_in_lowering branch from 8dd2bd5 to 6510a18 Compare December 8, 2025 13:22
Copy link
Contributor Author

@giladchase giladchase 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 15 files reviewed, 1 unresolved discussion (waiting on @eytan-starkware and @orizi)


crates/cairo-lang-lowering/src/lower/mod.rs line 1396 at r1 (raw file):

Previously, orizi wrote…

add to CoreInfo instead of calling every time.

Done.
I'm assuming Is it OK to add ExternFunctionId there, rather than just adding box submodule and call extern_function_id (context: this is the first time ExternFunctionIds are added to CoreInfo)

Copy link
Collaborator

@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.

@orizi reviewed 9 of 14 files at r1, 1 of 1 files at r2, 1 of 2 files at r3, all commit messages.
Reviewable status: 11 of 15 files reviewed, 1 unresolved discussion (waiting on @eytan-starkware and @giladchase)


crates/cairo-lang-semantic/src/corelib.rs line 1147 at r3 (raw file):

            upcast_fn: bounded_int.generic_function_id("upcast"),
            downcast_fn: bounded_int.generic_function_id("downcast"),
            into_box: core.submodule("box").extern_function_id("into_box"),

Suggestion:

            into_box: box_module.extern_function_id("into_box"),

Copy link
Collaborator

@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.

@orizi reviewed 3 of 14 files at r1.
Reviewable status: 14 of 15 files reviewed, 1 unresolved discussion (waiting on @eytan-starkware and @giladchase)

Currently is always mapped to into_box during sierra-gen, but soon in sierra-gen it can also be
mapped into local_into_box when applicable.
@giladchase giladchase force-pushed the gilad/12-08-add_intobox_instead_of_into_box_in_lowering branch from 6510a18 to b7672df Compare December 8, 2025 14:23
Copy link
Contributor Author

@giladchase giladchase 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: 14 of 15 files reviewed, 1 unresolved discussion (waiting on @eytan-starkware and @orizi)


crates/cairo-lang-semantic/src/corelib.rs line 1147 at r3 (raw file):

            upcast_fn: bounded_int.generic_function_id("upcast"),
            downcast_fn: bounded_int.generic_function_id("downcast"),
            into_box: core.submodule("box").extern_function_id("into_box"),

Done.

Copy link
Contributor Author

@giladchase giladchase 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: 14 of 15 files reviewed, 2 unresolved discussions (waiting on @eytan-starkware and @orizi)


-- commits line 1 at r4:
Blocking merge: until we finish the stack.

Copy link
Collaborator

@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.

:lgtm:

@orizi reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @eytan-starkware and @giladchase)

Copy link
Contributor

@eytan-starkware eytan-starkware 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: all files reviewed, 1 unresolved discussion (waiting on @giladchase and @orizi)


-- commits line 1 at r4:

Previously, giladchase wrote…

Blocking merge: until we finish the stack.

I am not sure what the full stack holds, but I think if we have IntoBox we should also have Unbox treated the same. We also have different analysis not sure if you dealt with all of them. I saw const folding, what about the statement reordering?

Copy link
Collaborator

@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: all files reviewed, 1 unresolved discussion (waiting on @giladchase)


-- commits line 1 at r4:

Previously, eytan-starkware wrote…

I am not sure what the full stack holds, but I think if we have IntoBox we should also have Unbox treated the same. We also have different analysis not sure if you dealt with all of them. I saw const folding, what about the statement reordering?

Yeah, unboxing as well makes sense to me.
Regarding the other algorithm, I think all non-function calls are movable anyway, but we need to validate.

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.

5 participants