Skip to content

winch: Improve frame handling#9708

Merged
saulecabrera merged 1 commit intobytecodealliance:mainfrom
saulecabrera:improve-local-management
Dec 4, 2024
Merged

winch: Improve frame handling#9708
saulecabrera merged 1 commit intobytecodealliance:mainfrom
saulecabrera:improve-local-management

Conversation

@saulecabrera
Copy link
Copy Markdown
Member

This commit addresses issues identified while working on issue #8091. It improves the frame handling in Winch to prevent subtle bugs and enhance the robustness of the code generation process.

Previously, there was no clear mechanism to verify when the frame was fully set up and safe to access the local slots allocated for register arguments, including the special slots used for the VMContext. As a result, it was possible to inadvertently read from uninitialized memory if calls were made before the frame was properly set up and sealed.

This commit introduces two main changes with the objective to help reduce the risk of introducing bugs related to the above:

  • A CodeGenPhase trait, used via the type state pattern to clearly gate the operations allowed during each phase of the code generation process.

  • Improve the semantics of locals, by clearly separating the notion of Wasm locals and special locals used by the compiler. This specialization allows a more accurate representation of the semantics of Wasm locals and their index space.

@saulecabrera saulecabrera requested a review from a team as a code owner December 2, 2024 20:18
@saulecabrera saulecabrera requested review from abrown and removed request for a team December 2, 2024 20:18
@github-actions github-actions bot added the winch Winch issues or pull requests label Dec 2, 2024
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 2, 2024

Subscribe to Label Action

cc @saulecabrera

Details This issue or pull request has been labeled: "winch"

Thus the following users have been cc'd because of the following labels:

  • saulecabrera: winch

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Copy link
Copy Markdown
Member

@abrown abrown left a comment

Choose a reason for hiding this comment

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

Makes sense; sorry for missing this review earlier.

This commit addresses issues identified while working on issue bytecodealliance#8091. It
improves the frame handling in Winch to prevent subtle bugs and enhance
the robustness of the code generation process.

Previously, there was no clear mechanism to verify when the frame was
fully set up and safe to access the local slots allocated for register
arguments, including the special slots used for the `VMContext`. As
a result, it was possible to inadvertently read from uninitialized
memory if calls were made before the frame was properly set up and
sealed.

This commit introduces two main changes with the objective to help
reduce the risk of introducing bugs related to the above:

* A `CodeGenPhase` trait, used via the type state pattern to clearly
  gate the operations allowed during each phase of the code generation
  process.

* Improve the semantics of locals, by clearly separating the notion of
  Wasm locals and special locals used by the compiler. This
  specialization allows a more accurate representation of the semantics
  of Wasm locals and their index space.
@saulecabrera saulecabrera force-pushed the improve-local-management branch from e8c88df to 9d90033 Compare December 4, 2024 19:00
@saulecabrera
Copy link
Copy Markdown
Member Author

Thanks for the review @abrown -- and no worries!

@saulecabrera saulecabrera added this pull request to the merge queue Dec 4, 2024
Merged via the queue into bytecodealliance:main with commit 7ef8f2e Dec 4, 2024
@saulecabrera saulecabrera deleted the improve-local-management branch December 4, 2024 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

winch Winch issues or pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants