Skip to content

psyqo: align TexInfo and PageInfo to 32 bits - #2067

Open
nicolasnoble wants to merge 1 commit into
grumpycoders:mainfrom
nicolasnoble:psyqo-texinfo-packed
Open

psyqo: align TexInfo and PageInfo to 32 bits#2067
nicolasnoble wants to merge 1 commit into
grumpycoders:mainfrom
nicolasnoble:psyqo-texinfo-packed

Conversation

@nicolasnoble

Copy link
Copy Markdown
Member

Both are four bytes wide but only two-byte aligned - their sizeof assert never checked that. So copying one splits into lhu/lhu/sh/sh instead of lw/sw, four memory accesses per glyph in FontBase instead of two.

alignas(uint32_t) fixes it: 71 halfword loads down to 65 in libpsyqo.a, all six in the glyph path, no new lwl/lwr, .text 88 bytes smaller. Neither type moves - both already sat at word-aligned offsets in every primitive that embeds them.

Both are four bytes but only two-byte aligned, since their members are two
uint8_t followed by a 16-bit type. The size static_assert never caught it.
Copying one is a whole-word move on paper, but the compiler cannot prove the
alignment, so it splits into two lhu and two sh - four memory accesses where
two would do, in the per-glyph path of every innerprint variant.

Aligning them to uint32_t restores the single lw/sw. No layout change: both
already sat at word-aligned offsets inside every primitive that carries them,
and sizeof is unchanged. Adds the matching alignof assertions so this cannot
regress silently.

Signed-off-by: Nicolas 'Pixel' Noble <nicolas@nobis-crew.org>
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 30b9310a-3b30-44f3-8280-86c8bb2f965a

📥 Commits

Reviewing files that changed from the base of the PR and between 3e10093 and c6a201f.

📒 Files selected for processing (1)
  • src/mips/psyqo/primitives/common.hh

📝 Walkthrough

Walkthrough

The change explicitly aligns TexInfo and PageInfo to uint32_t. Static assertions verify both structures retain 32-bit size and use the required alignment.

Changes

Primitive structure alignment

Layer / File(s) Summary
Structure layout contracts
src/mips/psyqo/primitives/common.hh
TexInfo and PageInfo now use explicit uint32_t alignment. Static assertions verify their alignment and 32-bit size.

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: 32-bit alignment for TexInfo and PageInfo.
Description check ✅ Passed The description explains the alignment change, its performance impact, and its effect on generated code and binary size.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant