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

winch: Add support for br_table #6951

Merged
merged 4 commits into from
Sep 2, 2023

Commits on Sep 1, 2023

  1. winch: Add support for br_table

    This change adds support for the `br_table` instruction, including
    several modifications to the existing control flow implementation:
    
    * Improved handling of jumps to loops: Previously, the compiler erroneously
    treated the result of loop blocks as the definitive result of the jump. This
    change fixes this bug.
    
    * Streamlined result handling and stack pointer balancing: In the past, these
    operations were executed in two distinct steps, complicating the process of
    ensuring the correct invariants when emitting unconditional jumps. To simplify
    this, `CodeGenContext::unconditional_jump` is introduced . This function
    guarantees all necessary invariants are met, encapsulating the entire operation
    within a single function for easier understanding and maintenance.
    
    * Handling of unreachable state at the end of a function: when reaching the end
    of a function in an unreachable state, clear the stack and ensure that the
    machine stack pointer is correctly placed according to the expectations of the
    outermost block.
    
    In addition to the above refactoring, the main implementation of the
    `br_table` instruction involves emitting labels for each target. Within each
    label, an unconditional jump is emitted to the frame's label, ensuring correct
    stack pointer balancing  when the jump is emitted.
    
    While it is possible to optimize this process by avoiding intermediate labels
    when balancing isn't required, I've opted to maintain the current
    implementation until such optimization becomes necessary.
    saulecabrera committed Sep 1, 2023
    Configuration menu
    Copy the full SHA
    ae4c431 View commit details
    Browse the repository at this point in the history
  2. chore: Rust fmt

    saulecabrera committed Sep 1, 2023
    Configuration menu
    Copy the full SHA
    406120b View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a60a3d5 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e865967 View commit details
    Browse the repository at this point in the history