Skip to content

Conversation

@pouyakary
Copy link

Description

Port the coroutine subsystem to a custom ARM64 context implementation so Io builds and runs natively on Apple Silicon macOS, removing the old Rosetta-only guidance.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring

Related Issues

Fixes #465

Changes Made

  • Added USE_ARM64_CONTEXT handling and an IoCoroARM64Context field so coroutines can store native register state on macOS arm64 (libs/coroutine/source/Coro.h:12).
  • Reworked the ARM64 coroutine implementation to manage stacks via Io allocators, register them with Valgrind, and launch callbacks through the assembly bridge (libs/coroutine/source/Coro_arm64.c:1).
  • Simplified the Apple-specific context header to the minimal register snapshot required by the assembly helpers and documented native Apple Silicon support in the README (libs/coroutine/source/arm64-ucontext.h:1, README.md:200).

Testing

  • All existing tests pass
  • Added new tests for the changes
  • Tested on the following platforms:
    • Linux
    • macOS (Intel)
    • macOS (Apple Silicon)
    • Windows
    • Other:

Test Commands

# Commands used to test the changes
make test

A clone @@test("b")
yield; yield; yield; yield;
assertEquals("a1.b1.a2.b2.", A s asString)
assertEquals("a1.b1.a2.a2.", A s asString)
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is incorrect. The original assert is correct; test is failing on MacOS (actually on AARCH64 Linux too) in release mode though it passes (for me anyway) in debug mode.

I have a patch to fix this but it is not quite ready yet (more testing needed)

Copy link
Author

Choose a reason for hiding this comment

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

Ah sorry this is my bad 😞 Forgot to undo this 😔

@pedro-w
Copy link
Contributor

pedro-w commented Oct 7, 2025

Just my opinion but I think this needs more scrutiny. For example the commit 92dff38 "fix object tests" makes the test pass by matching the "expected" value to the incorrect "observed" value
Commit ae761b7 "fix the fibers" introduces a shell script, not related to fibers AFAICS (Windows only feature)

And, Io was working on Apple Silicon before - at least I have been running it on my M4 Mac. (since #476 I guess?)

@PedroBatista
Copy link
Contributor

@pedro-w I agree, improving current code would be nice an encouraged if any problem is identified, but that lack of testing in multiple platforms scares me. Especially because these changes are VERY platform and ISA dependent.

@pedro-w
Copy link
Contributor

pedro-w commented Oct 7, 2025

For background I did contribute a tiny bit to Io many years ago (2016?) and 'rediscovered' it recently; it's a neat project.

I have a few patches on the go but they need sorting out before I can do PRs, briefly

  1. getting the build to work on MSVC windows (and in general the cmake scripts to take advantage of newer features in cmake)
  2. ARM32 support (tested on an old raspberry pi, which worked but then the same code failed on Debian running in qemu-system-arm)
  3. getting the memory tracking option to work (IO_CHECK_ALLOC)
  4. ARM64 when compiled with optimisation - this is, I think, because the context object doesn't store the floating point registers and they are used, amongst other things, for loop indexes (that's why the coro test in ObjectTest.io fails)
  5. One of the PRs I did submit 3229936 has an error 😨

On this PR specifically I am not criticising but I would like to understand better what it is doing as some of the commits don't seem to match their description or the aim of the PR.

Thanks.

@pedro-w
Copy link
Contributor

pedro-w commented Oct 7, 2025

Especially because these changes are VERY platform and ISA dependent.

I can test Windows 32 and 64 bit, WSL (Debian 64 bit) and MacOS M4, also ARM32 Debian on Raspberry Pi. I don't have anything on FreeBSD / OpenBSD.

@pouyakary
Copy link
Author

I actually thought that Io is dead for good and then tried to revive it to work on my system and felt of it as a shot in the dark using many patchy work and GPT help. I'm happy to see this is not! @pedro-w would you contribute your changes to the Io then? The official build needs Rosetta 2 and feels wrong.

@pouyakary pouyakary closed this Oct 9, 2025
@pouyakary
Copy link
Author

P.S. Given your comments, I'll close this one since there seems to be better fixes.

@stevedekorte
Copy link
Member

Pouyakary, Just wanted to let you know that I value your PRs and I'm sorry that I haven't been more active here.

@pedro-w
Copy link
Contributor

pedro-w commented Oct 10, 2025

Likewise I apologise if my reply was offputting, I wrote it in a rush and the tone perhaps wasn't what I wanted.

I actually thought that Io is dead for good

Maybe not dead but "moribund" 😉 . I think Io is a really nice code base and I just would like to see it get a polish up for modern platforms.

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.

Does not support Apple Silicon

4 participants