Skip to content

fix: correct loadOffset handling in generated overrides - #2487

Merged
maximilien-noal merged 1 commit into
masterfrom
fix/generated-load-offset
Nov 8, 2026
Merged

maximilien-noal merged 1 commit into
masterfrom
fix/generated-load-offset

Conversation

@kevinferrare

Copy link
Copy Markdown
Contributor

Fix generated method signatures and cyclic jumps by counting unique entry points and checking the current method’s loadOffset requirement. Extend an existing ASM fixture to reproduce compilation failures and incorrect entry resumption.

Copilot AI balanced review requested due to automatic review settings November 8, 2026 21:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the loadOffset and entry-dispatch changes.

No open issues 🎉

What changed in this PR

This PR corrects loadOffset handling in Spice86’s C# override generator so duplicate entry records do not produce mismatched signatures and cyclic jumps resume at the correct entry.

Changes:

  • Use unique entry points when selecting generated calls, delegates, interrupt handlers, and fault handlers.
  • Reload loadOffset during cyclic jumps only when the current method requires entry dispatch.
  • Extend the existing ASM regression scenario and behavioral assertions; refresh goldens and raise readability limits for the expanded fixture.
File Description
tests/​Spice86.Tests/​Resources/​GeneratedCodeReadability/​partition_multi_entry_irreducible_shared.spec.json Updates the source hash and metric limits for the expanded fixture.
tests/​Spice86.Tests/​Resources/​cpuTests/​res/​GeneratedCode/​partition_multi_entry_irreducible_shared.spec.cs.txt Refreshes generated overrides, cyclic dispatch, and DS memory accessors.
tests/​Spice86.Tests/​Resources/​cpuTests/​res/​DumpedListing/​partition_multi_entry_irreducible_shared.txt Updates the expected instruction listing.
tests/​Spice86.Tests/​Resources/​cpuTests/​res/​DumpedCfgPartitions/​partition_multi_entry_irreducible_shared.json Records expanded partitions, duplicate entry evidence, and cyclic transfers.
tests/​Spice86.Tests/​Resources/​cpuTests/​res/​DumpedCfgBlocks/​partition_multi_entry_irreducible_shared.json Updates expected control-flow blocks and edges.
tests/​Spice86.Tests/​Resources/​cpuTests/​asmsrc/​partition_multi_entry_irreducible_shared.asm Adds cyclic resumption and shared-handler transfer scenarios.
tests/​Spice86.Tests/​AsmFixtures/​AsmFixtureCatalog.cs Checks cycle completion, secondary-entry resumption, and four handler executions.
src/​Spice86.Core/​Emulator/​ReverseEngineer/​CfgCodeGeneration/​TransferEmitter.cs Uses unique entry counts for transfers, function references, and fault handlers.
src/​Spice86.Core/​Emulator/​ReverseEngineer/​CfgCodeGeneration/​InstructionLowerer.cs Uses unique entry counts for interrupt-handler references.
src/​Spice86.Core/​Emulator/​ReverseEngineer/​CfgCodeGeneration/​CSharpStatementPrinter.cs Bases cyclic offset reloads on the current method’s dispatch requirement.
src/​Spice86.Core/​Emulator/​ReverseEngineer/​CfgCodeGeneration/​CSharpExpressionPrinter.cs Exposes the current method’s entry-dispatch requirement.
src/​Spice86.Core/​Emulator/​ReverseEngineer/​CfgCodeGeneration/​Ast/​CyclicJumpNode.cs Clarifies source-versus-target entry semantics in documentation only.

Review effort: Balanced

@maximilien-noal maximilien-noal added Dune Related to Dune code generation Related to generation of low level C# overrides of ASM code bugfix fixes a bug CFGCPU Related to the future Control Flow CPU labels Nov 8, 2026
@maximilien-noal
maximilien-noal merged commit cf8df59 into master Nov 8, 2026
6 checks passed
@kevinferrare
kevinferrare deleted the fix/generated-load-offset branch November 8, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix fixes a bug CFGCPU Related to the future Control Flow CPU code generation Related to generation of low level C# overrides of ASM code Dune Related to Dune

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants