Skip to content

Write swap in assembly instead of C++ #548

Closed

Description

@eholk

Right now, C++ compilers like to make set_registers into a tail call, which causes problems when get_registers returns the second time. To get around this, we should write the swap context function in assembly instead of disabling compiler optimizations.

Activity

  1. ghost assigned on Jun 22, 2011
  2. marijnh commented on Jun 23, 2011

    @marijnh
    Contributor

    Could you write it in LLVM bitcode instead? I think we're hoping to use as little assembly as possible, in order to make supporting different processor types easy.

  3. eholk commented on Jun 23, 2011

    @eholk
    ContributorAuthor

    My first thought was no, because swapping contexts needs direct access to the machine's registers. However, we already have set_registers and get_registers written in assembly, so we could probably write the swap function in LLVM.

    If we do this, can we guarantee that LLVM won't turn the call to set_registers into a tail call like is happening in the C version?

  4. removed their assignment
    on Jun 16, 2014
  5. added a commit that references this issue on Dec 12, 2017
    edbc1f1
  6. added a commit that references this issue on Mar 7, 2023
  7. added a commit that references this issue on Sep 27, 2024
  8. added a commit that references this issue on Jun 3, 2025
  9. added a commit that references this issue on Sep 8, 2025
  10. added a commit that references this issue on Aug 21, 2026
  11. added a commit that references this issue on Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions