Skip to content

refactoring(sierra-to-casm): Removed specific instruction-to-offset map.#9446

Merged
orizi merged 1 commit intomainfrom
orizi/01-11-refactoring_sierra-to-casm_removed_specific_instruction-to-offset_map
Jan 13, 2026
Merged

refactoring(sierra-to-casm): Removed specific instruction-to-offset map.#9446
orizi merged 1 commit intomainfrom
orizi/01-11-refactoring_sierra-to-casm_removed_specific_instruction-to-offset_map

Conversation

@orizi
Copy link
Collaborator

@orizi orizi commented Jan 11, 2026

Summary

Refactored the relocation logic in the Sierra-to-CASM compiler to improve code clarity and efficiency. The changes include:

  1. Simplified relocation entry handling by modifying entries in-place rather than creating new ones
  2. Restructured the apply method in the Relocation enum to use helper closures for calculating offsets
  3. Removed redundant statement offsets collection and directly used the sierra_statement_info for relocations
  4. Improved error messages and assertions for better debugging

Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

The relocation logic in the Sierra-to-CASM compiler was unnecessarily complex and inefficient. This refactoring simplifies the code by eliminating redundant data structures and calculations, making the code more maintainable and slightly more efficient.


What was the behavior or documentation before?

The compiler was creating a separate collection of statement offsets and using more verbose code patterns for handling relocations. It was also creating new relocation entries instead of modifying existing ones in-place.


What is the behavior or documentation after?

The compiler now directly uses the sierra_statement_info for relocations, eliminating the redundant statement_offsets collection. The relocation logic is more concise with helper closures, and relocation entries are modified in-place rather than creating new ones.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator Author

orizi commented Jan 11, 2026

Copy link
Collaborator

@TomerStarkware TomerStarkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

@TomerStarkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ilyalesokhin-starkware).

Using the info that generated it directly.

SIERRA_UPDATE_MINOR_CHANGE_TAG=No behaviour change.
@orizi orizi force-pushed the orizi/01-11-refactoring_sierra-to-casm_removed_specific_instruction-to-offset_map branch from 63d2f2c to 344a942 Compare January 13, 2026 14:53
@orizi orizi enabled auto-merge January 13, 2026 14:55
@orizi orizi added this pull request to the merge queue Jan 13, 2026
Merged via the queue into main with commit d7e77ed Jan 13, 2026
55 checks passed
@orizi orizi deleted the orizi/01-11-refactoring_sierra-to-casm_removed_specific_instruction-to-offset_map branch January 13, 2026 17:19
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.

3 participants