Repository navigation
Add PowerPC 64-bit coroutine context switching - #327
Conversation
Add powerpc64/powerpc64le support for coroutine context switching using inline assembly. Uses bcl 20,31 to capture the resume address without polluting the link stack predictor. Saves sp (r1), fp (r31), and pc in the context struct, with all other registers marked as clobbered. Stack trace test is skipped on ppc64 for now due to integer overflow in Zig 0.15's stack trace dumping.
📝 WalkthroughWalkthroughAdds PowerPC 64-bit (powerpc64 / powerpc64le) support to the coroutine subsystem: new Context variants, PPC64-specific context init/switch/entry assembly paths, minor docs updates, and CI matrix entry for powerpc64le. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/coro/coroutines.zig (2)
1360-1361: Skip is unconditional — consider gating on Zig version.The skip applies to all Zig versions, but the PR description says the overflow is in Zig 0.15's stack trace dumping. Other version-specific branches in this file already check
builtin.zig_version.minor < 16. If Zig 0.16 fixes this, you'd silently skip the test forever.Not blocking — ppc64 is brand new and you can revisit when 0.16 lands.
Possible version-gated skip
- if (builtin.cpu.arch == .powerpc64 or builtin.cpu.arch == .powerpc64le) return error.SkipZigTest; + if ((builtin.cpu.arch == .powerpc64 or builtin.cpu.arch == .powerpc64le) and + builtin.zig_version.major == 0 and builtin.zig_version.minor < 16) return error.SkipZigTest;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/coro/coroutines.zig` around lines 1360 - 1361, The unconditional skip for PowerPC in coroutines.zig should be gated by Zig version; change the condition that currently returns error.SkipZigTest when builtin.cpu.arch == .powerpc64 or .powerpc64le to only do so when the Zig minor version is less than 16 (check builtin.zig_version.minor < 16) so the test is not permanently skipped; update the condition around the return error.SkipZigTest to combine the CPU check with the Zig version check.
805-878: FYI:f0–f31andv0–v31overlap withvs0–vs63— listing all three is redundant but safe.On PPC64,
vs0–vs31aliasf0–f31, andvs32–vs63aliasv0–v31. Declaring all three sets as clobbered is conservative but harmless — same approach as x86 listing bothzmmandmm. Not asking you to change it, just noting it for future reference.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/coro/coroutines.zig` around lines 805 - 878, The clobber list redundantly lists overlapping registers (f0–f31 and v0–v31 overlap with vs0–vs63 on PPC64); simplify by removing the explicit .f0–.f31 and .v0–.v31 entries and keep the .vs0–.vs63 range plus the unique entries (.acc0–.acc7, .acc, .spefsc) so the clobber set is accurate and non-redundant (look for the block that currently enumerates .f0.. .f31, .v0.. .v31, .vs0.. .vs63 and update it to only include .vs0.. .vs63 and the non-aliased symbols).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/coro/coroutines.zig`:
- Around line 1360-1361: The unconditional skip for PowerPC in coroutines.zig
should be gated by Zig version; change the condition that currently returns
error.SkipZigTest when builtin.cpu.arch == .powerpc64 or .powerpc64le to only do
so when the Zig minor version is less than 16 (check builtin.zig_version.minor <
16) so the test is not permanently skipped; update the condition around the
return error.SkipZigTest to combine the CPU check with the Zig version check.
- Around line 805-878: The clobber list redundantly lists overlapping registers
(f0–f31 and v0–v31 overlap with vs0–vs63 on PPC64); simplify by removing the
explicit .f0–.f31 and .v0–.v31 entries and keep the .vs0–.vs63 range plus the
unique entries (.acc0–.acc7, .acc, .spefsc) so the clobber set is accurate and
non-redundant (look for the block that currently enumerates .f0.. .f31, .v0..
.v31, .vs0.. .vs63 and update it to only include .vs0.. .vs63 and the
non-aliased symbols).
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/test.yml (1)
74-74: LGTM — consistent with the existing QEMU matrix pattern.The new entry follows the exact same shape as the other QEMU cross-compile targets:
ubuntu-latest,qemu: true,backends: 'epoll poll'(noio_uring, which is correct for QEMU user-mode). Thepowerpc64le-linuxtarget triple is the right form for Zig.One thing worth flagging: the AI summary notes that
src/coro/coroutines.zigadds both.powerpc64(big-endian) and.powerpc64leContext variants. If big-endian PPC64 support is code-complete, a correspondingpowerpc64-linuxQEMU entry would give it actual CI coverage. If it's intentionally deferred (e.g., no reliable BE QEMU image or untested), that's fine — just worth documenting.➕ Optional: add big-endian coverage if the BE path is ready
- { os: ubuntu-latest, target: powerpc64le-linux, qemu: true, backends: 'epoll poll' } + - { os: ubuntu-latest, target: powerpc64-linux, qemu: true, backends: 'epoll poll' }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/test.yml at line 74, The workflow adds a QEMU matrix entry for powerpc64le but the repo also added .powerpc64 (big-endian) and .powerpc64le Context variants in src/coro/coroutines.zig; either add a corresponding QEMU CI matrix entry for the big-endian target (target: powerpc64-linux, os: ubuntu-latest, qemu: true, backends: 'epoll poll') so BE code gets tested, or explicitly document in the workflow or README why powerpc64 (big-endian) is not included in CI (e.g., no BE QEMU image or untested) so the disparity between .powerpc64 and CI coverage is clear.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/test.yml:
- Line 74: The workflow adds a QEMU matrix entry for powerpc64le but the repo
also added .powerpc64 (big-endian) and .powerpc64le Context variants in
src/coro/coroutines.zig; either add a corresponding QEMU CI matrix entry for the
big-endian target (target: powerpc64-linux, os: ubuntu-latest, qemu: true,
backends: 'epoll poll') so BE code gets tested, or explicitly document in the
workflow or README why powerpc64 (big-endian) is not included in CI (e.g., no BE
QEMU image or untested) so the disparity between .powerpc64 and CI coverage is
clear.
Summary
bcl 20,31idiom to capture resume address without polluting the link stack predictorTest plan
./check.sh --target powerpc64le-linux --qemu -Dbackend=epoll